[C#] 纯文本查看 复制代码 using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace HRMS_REPORT
{
public partial class _Default : System.Web.UI.Page
{
DB conn = new DB();
protected void Page_Load(object sender, EventArgs e)
{
for (DateTime dt = new DateTime(2014, 07, 26); dt < new DateTime(2014, 08, 26); dt = dt.AddDays(1))
{
Check_Emp(Check_Emp_InOrOut(dt.ToShortDateString()));
}
}
public DataSet Check_Emp_InOrOut(string strDate)
{
string strSql = "SELECT emp_no,emp_name,visa_date,visa_time,visa_type FROM hrms_visa where visa_date=CONVERT(varchar(100),'" + strDate.Replace("/","") + "',112) group by emp_no,emp_name,visa_date,visa_time,visa_type";
DataSet _ds = conn.ExecuteSql(strSql);
if (_ds == null)
{
return null;
}
return _ds;
}
public void Check_Emp(DataSet _ds)
{
if (_ds != null)
{
DataTable dt = new DataTable();
dt.Columns.Add("emp_no");
dt.Columns.Add("emp_name");
dt.Columns.Add("visa_date");
dt.Columns.Add("visa_time");
dt.Columns.Add("visa_type");
string temp =_ds.Tables[0].Rows[0]["emp_no"].ToString();
for(int i=0;i<_ds.Tables[0].Rows.Count;i++)
{
if (temp == _ds.Tables[0].Rows[i]["emp_no"].ToString())
{
DataRow dr = dt.NewRow();
dr["emp_no"] = _ds.Tables[0].Rows[i]["emp_no"].ToString();
dr["emp_name"] = _ds.Tables[0].Rows[i]["emp_name"].ToString();
dr["visa_date"] = _ds.Tables[0].Rows[i]["visa_date"].ToString();
dr["visa_time"] = _ds.Tables[0].Rows[i]["visa_time"].ToString();
dr["visa_type"] = _ds.Tables[0].Rows[i]["visa_type"].ToString();
dt.Rows.Add(dr);
dt.AcceptChanges();
if (i == (_ds.Tables[0].Rows.Count - 1))
{
Check_Double(dt);
}
}
else
{
Check_Double(dt);
temp = _ds.Tables[0].Rows[i]["emp_no"].ToString();
dt.Clear();
DataRow dr = dt.NewRow();
dr["emp_no"] = _ds.Tables[0].Rows[i]["emp_no"].ToString();
dr["emp_name"] = _ds.Tables[0].Rows[i]["emp_name"].ToString();
dr["visa_date"] = _ds.Tables[0].Rows[i]["visa_date"].ToString();
dr["visa_time"] = _ds.Tables[0].Rows[i]["visa_time"].ToString();
dr["visa_type"] = _ds.Tables[0].Rows[i]["visa_type"].ToString();
dt.Rows.Add(dr);
dt.AcceptChanges();
}
}
}
}
public void Check_Double(DataTable _dt)
{
if (_dt.Rows.Count % 2 != 0)
{
for (int i = 0; i < _dt.Rows.Count; i++)
{
Response.Write(_dt.Rows[i]["emp_no"] + "||" + _dt.Rows[i]["emp_name"] + "||" + _dt.Rows[i]["visa_date"] + "||" + _dt.Rows[i]["visa_type"] + "<BR />");
}
Response.Write("<BR />");
}
else
{
}
}
}
}
|