protected void btQuery_Click(object sender, System.EventArgs e) { Session.Remove("QUERY"); Session.Remove("toExcel"); strBeginDate = Request.Form["txtBegin"].ToString(); strEndDate = Request.Form["txtEnd"].ToString(); if (strBeginDate == "" || strEndDate == "" || strBeginDate == null || strEndDate == null) { this.SetErrorMsgPageBydir("时间不能为空,请重新选择时间!"); return; } string[] SchDatelistBegin = strBeginDate.Split('-'); if (SchDatelistBegin.Length != 3) { this.SetErrorMsgPageBydir("时间格式不正确!"); return; } string strSchIDBegin = SchDatelistBegin[0]; if (int.Parse(SchDatelistBegin[1]) < 10) { strSchIDBegin += "0" + SchDatelistBegin[1]; } else { strSchIDBegin += SchDatelistBegin[1]; } if (int.Parse(SchDatelistBegin[2]) < 10) { strSchIDBegin += "0" + SchDatelistBegin[2]; } else { strSchIDBegin += SchDatelistBegin[2]; } string[] SchDatelistEnd = strEndDate.Split('-'); if (SchDatelistEnd.Length != 3) { this.SetErrorMsgPageBydir("时间格式不正确!"); return; } string strSchIDEnd = SchDatelistEnd[0]; if (int.Parse(SchDatelistEnd[1]) < 10) { strSchIDEnd += "0" + SchDatelistEnd[1]; } else { strSchIDEnd += SchDatelistEnd[1]; } if (int.Parse(SchDatelistEnd[2]) < 10) { strSchIDEnd += "0" + SchDatelistEnd[2]; } else { strSchIDEnd += SchDatelistEnd[2]; } Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; empb = new BusiComm.EmpBusi(strcons); Hashtable htPara = new Hashtable(); string strDeptName = ddlDept.SelectedItem.Text; if (strDeptName == "全部") { strDeptName = ""; } htPara.Add("strDeptName", strDeptName); string strType = ddlType.SelectedValue; htPara.Add("strType", strType); htPara.Add("strBegin", strSchIDBegin); htPara.Add("strEnd", strSchIDEnd); try { DataTable dtout = new DataTable(); switch (strType) { case "0": if (int.Parse(strSchIDBegin) > int.Parse(strSchIDEnd)) { this.SetErrorMsgPageBydir("开始时间不能大于结束时间!"); return; } dtout = empb.GetSignSumQuery(htPara); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); return; } else { dtout.TableName = "总体考勤情况"; DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } break; case "1": dtout = empb.GetSignDetailQuery(htPara); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); return; } else { dtout.TableName = "考勤明细列表"; DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; for (int i = 0; i < dtexcel.Rows.Count; i++) { dtexcel.Rows[i][1] = "'" + dtexcel.Rows[i][1].ToString(); if (dtexcel.Rows[i][5].ToString() != "") { dtexcel.Rows[i][5] = "'" + dtexcel.Rows[i][5].ToString(); } if (dtexcel.Rows[i][6].ToString() != "") { dtexcel.Rows[i][6] = "'" + dtexcel.Rows[i][6].ToString(); } } Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } break; } UcPageView1.MyDataGrid.PageSize = 30; DataView dvOut = new DataView(dtout); this.UcPageView1.MyDataSource = dvOut; this.UcPageView1.BindGrid(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } }
protected void btQuery_Click(object sender, System.EventArgs e) { Session.Remove("QUERY"); Session.Remove("toExcel"); string strmonth = txtMonth.Text.Trim(); if (strmonth == "" || strmonth.Length != 6) { this.SetErrorMsgPageBydir("查询月份为6位数,如:200801!"); return; } string strCardID = txtCardID.Text.Trim(); string strEmpName = txtEmpName.Text.Trim(); if (strCardID == "" && strEmpName == "") { this.SetErrorMsgPageBydir("员工卡号和员工姓名请至少填写一个!"); return; } Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; empb = new BusiComm.EmpBusi(strcons); Hashtable htPara = new Hashtable(); string strType = ddlType.SelectedValue; htPara.Add("strmonth", strmonth); htPara.Add("strType", strType); htPara.Add("strCardID", strCardID); htPara.Add("strEmpName", strEmpName); try { DataTable dtout = new DataTable(); dtout = empb.GetSignUnitQuery(htPara); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); return; } else { DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; for (int i = 0; i < dtexcel.Rows.Count; i++) { dtexcel.Rows[i][1] = "'" + dtexcel.Rows[i][1].ToString(); } if (strType == "0") { dtout.TableName = "个人考勤详情"; } else { dtout.TableName = "个人考勤日志"; this.TableConvert(dtout, "考勤标志", "tbCommCode", "vcCommSign='SFlag'"); } Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } UcPageView1.MyDataGrid.PageSize = 30; DataView dvOut = new DataView(dtout); this.UcPageView1.MyDataSource = dvOut; this.UcPageView1.BindGrid(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } }
private void QueryRefresh(string strDept, string strDate) { int daycount = DateTime.DaysInMonth(int.Parse(strDate.Substring(0, 4)), int.Parse(strDate.Substring(4, 2))); for (int i = 1; i <= 31; i++) { switch (i) { #region 初始化设置天数颜色为红色 case 1: lbl1.ForeColor = Color.Red; break; case 2: lbl2.ForeColor = Color.Red; break; case 3: lbl3.ForeColor = Color.Red; break; case 4: lbl4.ForeColor = Color.Red; break; case 5: lbl5.ForeColor = Color.Red; break; case 6: lbl6.ForeColor = Color.Red; break; case 7: lbl7.ForeColor = Color.Red; break; case 8: lbl8.ForeColor = Color.Red; break; case 9: lbl9.ForeColor = Color.Red; break; case 10: lbl10.ForeColor = Color.Red; break; case 11: lbl11.ForeColor = Color.Red; break; case 12: lbl12.ForeColor = Color.Red; break; case 13: lbl13.ForeColor = Color.Red; break; case 14: lbl14.ForeColor = Color.Red; break; case 15: lbl15.ForeColor = Color.Red; break; case 16: lbl16.ForeColor = Color.Red; break; case 17: lbl17.ForeColor = Color.Red; break; case 18: lbl18.ForeColor = Color.Red; break; case 19: lbl19.ForeColor = Color.Red; break; case 20: lbl20.ForeColor = Color.Red; break; case 21: lbl21.ForeColor = Color.Red; break; case 22: lbl22.ForeColor = Color.Red; break; case 23: lbl23.ForeColor = Color.Red; break; case 24: lbl24.ForeColor = Color.Red; break; case 25: lbl25.ForeColor = Color.Red; break; case 26: lbl26.ForeColor = Color.Red; break; case 27: lbl27.ForeColor = Color.Red; break; case 28: lbl28.ForeColor = Color.Red; break; case 29: lbl29.ForeColor = Color.Red; break; case 30: lbl30.ForeColor = Color.Red; break; case 31: lbl31.ForeColor = Color.Red; break; #endregion } } for (int j = 31; j > daycount; j--) { switch (j) { case 31: lbl31.Visible = false; break; case 30: lbl30.Visible = false; break; case 29: lbl29.Visible = false; break; } } Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; empb = new BusiComm.EmpBusi(strcons); ArrayList alDay = empb.GetSignCalcResultQuery(strDept, strDate); this.lblQueryTitle.Text = strDept + " " + strDate.Substring(0, 4) + "年" + strDate.Substring(4, 2) + "月的考勤计算情况如下:"; if (alDay.Count > 0) { for (int i = 0; i < alDay.Count; i++) { switch (int.Parse(alDay[i].ToString())) { #region 根据天数据设置颜色 case 1: lbl1.ForeColor = Color.Blue; break; case 2: lbl2.ForeColor = Color.Blue; break; case 3: lbl3.ForeColor = Color.Blue; break; case 4: lbl4.ForeColor = Color.Blue; break; case 5: lbl5.ForeColor = Color.Blue; break; case 6: lbl6.ForeColor = Color.Blue; break; case 7: lbl7.ForeColor = Color.Blue; break; case 8: lbl8.ForeColor = Color.Blue; break; case 9: lbl9.ForeColor = Color.Blue; break; case 10: lbl10.ForeColor = Color.Blue; break; case 11: lbl11.ForeColor = Color.Blue; break; case 12: lbl12.ForeColor = Color.Blue; break; case 13: lbl13.ForeColor = Color.Blue; break; case 14: lbl14.ForeColor = Color.Blue; break; case 15: lbl15.ForeColor = Color.Blue; break; case 16: lbl16.ForeColor = Color.Blue; break; case 17: lbl17.ForeColor = Color.Blue; break; case 18: lbl18.ForeColor = Color.Blue; break; case 19: lbl19.ForeColor = Color.Blue; break; case 20: lbl20.ForeColor = Color.Blue; break; case 21: lbl21.ForeColor = Color.Blue; break; case 22: lbl22.ForeColor = Color.Blue; break; case 23: lbl23.ForeColor = Color.Blue; break; case 24: lbl24.ForeColor = Color.Blue; break; case 25: lbl25.ForeColor = Color.Blue; break; case 26: lbl26.ForeColor = Color.Blue; break; case 27: lbl27.ForeColor = Color.Blue; break; case 28: lbl28.ForeColor = Color.Blue; break; case 29: lbl29.ForeColor = Color.Blue; break; case 30: lbl30.ForeColor = Color.Blue; break; case 31: lbl31.ForeColor = Color.Blue; break; #endregion } } } }
protected void btCalc_Click(object sender, System.EventArgs e) { strBeginDate = Request.Form["txtBegin"].ToString(); strEndDate = Request.Form["txtEnd"].ToString(); if (strBeginDate == "" || strEndDate == "" || strBeginDate == null || strEndDate == null) { this.SetErrorMsgPageBydir("时间不能为空,请重新选择时间!"); return; } string[] SchDatelistBegin = strBeginDate.Split('-'); if (SchDatelistBegin.Length != 3) { this.SetErrorMsgPageBydir("时间格式不正确!"); return; } string strSchIDBegin = SchDatelistBegin[0]; if (int.Parse(SchDatelistBegin[1]) < 10) { strSchIDBegin += "0" + SchDatelistBegin[1]; } else { strSchIDBegin += SchDatelistBegin[1]; } if (int.Parse(SchDatelistBegin[2]) < 10) { strSchIDBegin += "0" + SchDatelistBegin[2]; } else { strSchIDBegin += SchDatelistBegin[2]; } string[] SchDatelistEnd = strEndDate.Split('-'); if (SchDatelistEnd.Length != 3) { this.SetErrorMsgPageBydir("时间格式不正确!"); return; } string strSchIDEnd = SchDatelistEnd[0]; if (int.Parse(SchDatelistEnd[1]) < 10) { strSchIDEnd += "0" + SchDatelistEnd[1]; } else { strSchIDEnd += SchDatelistEnd[1]; } if (int.Parse(SchDatelistEnd[2]) < 10) { strSchIDEnd += "0" + SchDatelistEnd[2]; } else { strSchIDEnd += SchDatelistEnd[2]; } if (int.Parse(strSchIDBegin) > int.Parse(strSchIDEnd)) { this.SetErrorMsgPageBydir("开始时间不能大于结束时间!"); return; } string strDeptID = ddlDept.SelectedValue; string strDeptName = ddlDept.SelectedItem.Text; Hashtable htpara = new Hashtable(); htpara.Add("strDeptID", strDeptID); htpara.Add("strDeptName", strDeptName); htpara.Add("strSchIDBegin", strSchIDBegin); htpara.Add("strSchIDEnd", strSchIDEnd); try { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; empb = new BusiComm.EmpBusi(strcons); string strerr = ""; if (empb.SignCalc(htpara, out strerr)) { this.lblCalcResult.Text = strDeptName + " 计算考勤成功,请进入考勤查询统计中进行查询!"; this.QueryRefresh(strDeptName, strSchIDBegin.Substring(0, 6)); return; } else { this.lblCalcResult.Text = strDeptName + " 计算考勤失败!" + strerr; this.QueryRefresh(strDeptName, strSchIDBegin.Substring(0, 6)); return; } } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("计算考勤出错!<br>" + er.ToString()); return; } }
protected void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 this.btnExcel.Attributes.Add("onclick", "javascript:window.open('../DataGridToExcel.aspx', 'Sample', 'toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=no,resizable=yes,copyhistory=yes,width=790,height=520,left=0,top=0')"); if (Session["Login"] != null) { if (!IsPostBack) { if (Request.QueryString.HasKeys()) { this.txtBegin.Text = Request.QueryString["begin"]; this.txtEnd.Text = Request.QueryString["end"]; string strDeptName = Request.QueryString["dept"]; string stremp = Request.QueryString["emp"]; Session.Remove("QUERY"); Session.Remove("toExcel"); Session.Remove("page_view"); string strBeginDate = this.txtBegin.Text.Trim(); string strEndDate = this.txtEnd.Text.Trim(); if (strBeginDate == "" || strEndDate == "" || strBeginDate == null || strEndDate == null) { this.SetErrorMsgPageBydirHistory("时间不能为空!"); return; } Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; BusiComm.EmpBusi empb = new BusiComm.EmpBusi(strcons); Hashtable htPara = new Hashtable(); htPara.Add("strDeptName", strDeptName); htPara.Add("strBegin", strBeginDate); htPara.Add("strEnd", strEndDate); htPara.Add("empname", stremp); try { DataTable dtout = new DataTable(); dtout = empb.GetSignDetailQuery(htPara); if (dtout == null) { this.SetErrorMsgPageBydir("查询出错,请重试!"); return; } else { dtout.TableName = "考勤明细列表"; DataTable dtexcel = dtout.Copy(); Session["QUERY"] = dtout; for (int i = 0; i < dtexcel.Rows.Count; i++) { dtexcel.Rows[i][1] = "'" + dtexcel.Rows[i][1].ToString(); if (dtexcel.Rows[i][5].ToString() != "") { dtexcel.Rows[i][5] = "'" + dtexcel.Rows[i][5].ToString(); } if (dtexcel.Rows[i][6].ToString() != "") { dtexcel.Rows[i][6] = "'" + dtexcel.Rows[i][6].ToString(); } } Session["toExcel"] = dtexcel; if (dtout.Rows.Count <= 0) { btnExcel.Enabled = false; } else { btnExcel.Enabled = true; } } UcPageView1.MyDataGrid.PageSize = 30; DataView dvOut = new DataView(dtout); this.UcPageView1.MyDataSource = dvOut; this.UcPageView1.BindGrid(); } catch (Exception er) { this.clog.WriteLine(er); this.SetErrorMsgPageBydir("查询错误,请重试!"); return; } } } } else { Response.Redirect("../Exit.aspx"); } }