public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rpt_DutyReport rpt = new rpt_DutyReport(); rpt.Site = this.Site; return(rpt); }
private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { idtype = Request.QueryString["idtype"].ToString(); ids = Request.QueryString["ids"].ToString(); begintime = Request.QueryString["begintime"].ToString(); endtime = Request.QueryString["endtime"].ToString(); ViewState["idtype"] = idtype; ViewState["ids"] = ids; ViewState["begintime"] = begintime; ViewState["endtime"] = endtime; } else { idtype = ViewState["idtype"].ToString(); ids = ViewState["ids"].ToString(); begintime = ViewState["begintime"].ToString(); endtime = ViewState["endtime"].ToString(); } ds_Duty = (DataSet)Cache["WA_Duty"]; //��TotalDuty.xsd��üܹ� ds_Report = new DataSet(); ds_Report.ReadXmlSchema(Request.MapPath(".")+"\\TotalDuty.xsd"); #region ������������� if(ds_Duty==null) { //���»�ȡds_Duty SqlDataReader dr,dr1,dr2; SqlParameter[] prams = new SqlParameter[4]; UDS.Components.Database db = new UDS.Components.Database(); DataSet ds = new DataSet(); //�õ��������� prams[0] = db.MakeInParam("@begintime",SqlDbType.DateTime,8,begintime); prams[1] = db.MakeInParam("@endtime",SqlDbType.DateTime,8,endtime); prams[2] = db.MakeInParam("@ids",SqlDbType.VarChar,1000,ids); prams[3] = db.MakeInParam("@idtype",SqlDbType.VarChar,50,idtype); db.RunProc("sp_WA_GetAttendanceData",prams,out dr); DataTable datatable = Tools.ConvertDataReaderToDataTable(dr); ds.Tables.Add(datatable); db.Dispose(); dr.Close(); //�õ���Ա���� if(idtype=="staff") { SqlParameter[] prams1 = {db.MakeInParam("@ids",SqlDbType.VarChar,1000,ids)}; db.RunProc("sp_WA_GetSelectedStaffFromID",prams1,out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } else if(idtype=="Position") { SqlParameter[] prams1 = { db.MakeInParam("@Position_id",SqlDbType.Int,4,Int32.Parse(ids)), db.MakeInParam("@Dimission",SqlDbType.Bit,1,0) }; db.RunProc("sp_GetStaffInPosition",prams1,out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } else if(idtype=="company") { SqlParameter[] prams1 = { db.MakeInParam("@StaffType",SqlDbType.Int,4,0) }; db.RunProc("sp_GetAllStaff",prams1,out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } SqlParameter[] prams2 = { db.MakeInParam("@begintime",SqlDbType.DateTime,8,begintime), db.MakeInParam("@endtime",SqlDbType.DateTime,8,endtime) }; db.RunProc("sp_WA_GetDutyDay",prams2,out dr2); DataTable datatable2 = Tools.ConvertDataReaderToDataTable(dr2); ds.Tables.Add(datatable2); db.Dispose(); dr2.Close(); //�������� Cache["WA_Duty"] = ds; ds_Duty = (DataSet)Cache["WA_Duty"]; } #endregion //����ds_Report�Կ���rpt //ds_Duty.Tables[0] �������� //ds_Duty.Tables[1] ��Ա���� //ds_Duty.Tables[2] ������������ //������Ա���ݱ��������µ�ds_Report for(int i=0;i<ds_Duty.Tables[1].Rows.Count;i++) { DataRow row = ds_Report.Tables[0].NewRow(); row[0] = ds_Duty.Tables[1].Rows[i]["RealName"]; row[1] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView,ds_Duty.Tables[2].DefaultView,ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(),0); row[2] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView,ds_Duty.Tables[2].DefaultView,ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(),1); row[3] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView,ds_Duty.Tables[2].DefaultView,ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(),2); row[4] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView,ds_Duty.Tables[2].DefaultView,ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(),3); row[5] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView,ds_Duty.Tables[2].DefaultView,ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(),4); ds_Report.Tables[0].Rows.Add(row); } myreport = new rpt_DutyReport(); myreport.SetDataSource(ds_Report); cv_Duty.ReportSource = myreport; cv_Duty.DataBind(); }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rpt_DutyReport rpt = new rpt_DutyReport(); rpt.Site = this.Site; return rpt; }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { idtype = Request.QueryString["idtype"].ToString(); ids = Request.QueryString["ids"].ToString(); begintime = Request.QueryString["begintime"].ToString(); endtime = Request.QueryString["endtime"].ToString(); ViewState["idtype"] = idtype; ViewState["ids"] = ids; ViewState["begintime"] = begintime; ViewState["endtime"] = endtime; } else { idtype = ViewState["idtype"].ToString(); ids = ViewState["ids"].ToString(); begintime = ViewState["begintime"].ToString(); endtime = ViewState["endtime"].ToString(); } ds_Duty = (DataSet)Cache["WA_Duty"]; //从TotalDuty.xsd获得架构 ds_Report = new DataSet(); ds_Report.ReadXmlSchema(Request.MapPath(".") + "\\TotalDuty.xsd"); #region 缓存如果不存在 if (ds_Duty == null) { //重新获取ds_Duty SqlDataReader dr, dr1, dr2; SqlParameter[] prams = new SqlParameter[4]; UDS.Components.Database db = new UDS.Components.Database(); DataSet ds = new DataSet(); //得到考勤数据 prams[0] = db.MakeInParam("@begintime", SqlDbType.DateTime, 8, begintime); prams[1] = db.MakeInParam("@endtime", SqlDbType.DateTime, 8, endtime); prams[2] = db.MakeInParam("@ids", SqlDbType.VarChar, 1000, ids); prams[3] = db.MakeInParam("@idtype", SqlDbType.VarChar, 50, idtype); db.RunProc("sp_WA_GetAttendanceData", prams, out dr); DataTable datatable = Tools.ConvertDataReaderToDataTable(dr); ds.Tables.Add(datatable); db.Dispose(); dr.Close(); //得到人员名单 if (idtype == "staff") { SqlParameter[] prams1 = { db.MakeInParam("@ids", SqlDbType.VarChar, 1000, ids) }; db.RunProc("sp_WA_GetSelectedStaffFromID", prams1, out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } else if (idtype == "Position") { SqlParameter[] prams1 = { db.MakeInParam("@Position_id", SqlDbType.Int, 4, Int32.Parse(ids)), db.MakeInParam("@Dimission", SqlDbType.Bit, 1, 0) }; db.RunProc("sp_GetStaffInPosition", prams1, out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } else if (idtype == "company") { SqlParameter[] prams1 = { db.MakeInParam("@StaffType", SqlDbType.Int, 4, 0) }; db.RunProc("sp_GetAllStaff", prams1, out dr1); DataTable datatable1 = Tools.ConvertDataReaderToDataTable(dr1); ds.Tables.Add(datatable1); db.Dispose(); dr1.Close(); } SqlParameter[] prams2 = { db.MakeInParam("@begintime", SqlDbType.DateTime, 8, begintime), db.MakeInParam("@endtime", SqlDbType.DateTime, 8, endtime) }; db.RunProc("sp_WA_GetDutyDay", prams2, out dr2); DataTable datatable2 = Tools.ConvertDataReaderToDataTable(dr2); ds.Tables.Add(datatable2); db.Dispose(); dr2.Close(); //缓存数据 Cache["WA_Duty"] = ds; ds_Duty = (DataSet)Cache["WA_Duty"]; } #endregion //生成ds_Report以可以绑定到rpt //ds_Duty.Tables[0] 考勤数据 //ds_Duty.Tables[1] 人员数据 //ds_Duty.Tables[2] 考勤日期数据 //遍历人员数据表以生成新的ds_Report for (int i = 0; i < ds_Duty.Tables[1].Rows.Count; i++) { DataRow row = ds_Report.Tables[0].NewRow(); row[0] = ds_Duty.Tables[1].Rows[i]["RealName"]; row[1] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView, ds_Duty.Tables[2].DefaultView, ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(), 0); row[2] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView, ds_Duty.Tables[2].DefaultView, ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(), 1); row[3] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView, ds_Duty.Tables[2].DefaultView, ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(), 2); row[4] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView, ds_Duty.Tables[2].DefaultView, ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(), 3); row[5] = GetDutyDateCount(ds_Duty.Tables[0].DefaultView, ds_Duty.Tables[2].DefaultView, ds_Duty.Tables[1].Rows[i]["Staff_ID"].ToString(), 4); ds_Report.Tables[0].Rows.Add(row); } myreport = new rpt_DutyReport(); myreport.SetDataSource(ds_Report); cv_Duty.ReportSource = myreport; cv_Duty.DataBind(); }