private DataSet CheckEmpSch(DataSet ds) { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; emb = new EmpBusi(strcons); DataTable dtEmp = emb.GetEmployInfo(); Hashtable htEmpCardID = new Hashtable(); foreach (DataRow dr in dtEmp.Rows) { CMSMStruct.EmployeeStruct emp1 = new CommCenter.CMSMStruct.EmployeeStruct(); emp1.strCardID = dr["vcCardID"].ToString(); emp1.strEmpName = dr["vcEmpName"].ToString(); emp1.strOfficer = dr["vcOfficer"].ToString(); emp1.strDeptID = dr["vcDeptName"].ToString(); htEmpCardID.Add(emp1.strCardID, emp1); } DataTable dtDeptManager = emb.GetDeptManagerList(); Hashtable htManager = new Hashtable(); string strManaDeptID = ""; string strManager = ""; if (dtDeptManager != null && dtDeptManager.Rows.Count > 0) { strManaDeptID = dtDeptManager.Rows[0]["vcDeptID"].ToString(); } for (int i = 0; i < dtDeptManager.Rows.Count; i++) { if (strManaDeptID == dtDeptManager.Rows[i]["vcDeptID"].ToString()) { strManager += dtDeptManager.Rows[i]["vcEmpName"].ToString() + ","; } else { if (strManager != "") { strManager = strManager.Substring(0, strManager.Length - 1); } htManager.Add(strManaDeptID, strManager); strManaDeptID = dtDeptManager.Rows[i]["vcDeptID"].ToString(); strManager = dtDeptManager.Rows[i]["vcEmpName"].ToString() + ","; } if (i == dtDeptManager.Rows.Count - 1) { if (strManager != "") { strManager = strManager.Substring(0, strManager.Length - 1); } htManager.Add(strManaDeptID, strManager); } } int iError = 0; DataTable dt = ds.Tables[0]; dt.Columns.Add("校验错误"); dt.Columns.Add("vcSchID"); dt.Columns.Add("vcDeptName"); dt.Columns.Add("vcManager"); dt.Columns.Add("vcCardID"); dt.Columns.Add("vcEmpName"); dt.Columns.Add("vcEmpOF"); dt.Columns.Add("vcClass"); dt.Columns.Add("dtCheckIn"); dt.Columns.Add("dtCheckOut"); foreach (DataRow dr in dt.Rows) { string strSchID = dr["排班日期"].ToString().Trim(); if (strSchID.Length != 8) { dr["校验错误"] += strSchID + ":排班日期应为8位日期;"; iError += 1; } else { DateTime dtsch = new DateTime(int.Parse(strSchID.Substring(0, 4)), int.Parse(strSchID.Substring(4, 2)), int.Parse(strSchID.Substring(6, 2))); if (dtsch.CompareTo(DateTime.Today) < 0) { dr["校验错误"] += strSchID + ":不能排今天以前的班;"; iError += 1; } else { dr["vcSchID"] = strSchID; } } string strDeptName = dr["门店"].ToString().Trim(); string strDeptOldID = ""; bool isdeptexist = false; DataTable dtDept = (DataTable)Application["AllMD"]; foreach (DataRow dr1 in dtDept.Rows) { if (dr1["vcCommName"].ToString() == strDeptName) { isdeptexist = true; strDeptOldID = dr1["vcCommCode"].ToString(); break; } } if (!isdeptexist) { dr["校验错误"] += strDeptName + ":门店不存在;"; iError += 1; } else { dr["vcDeptName"] = strDeptName; } if (dr["vcDeptName"].ToString() != "" && strDeptOldID != "") { if (htManager.ContainsKey(strDeptOldID)) { dr["vcManager"] = htManager[strDeptOldID].ToString(); } } string strCardID = dr["员工卡号"].ToString(); string strEmpName = dr["员工姓名"].ToString(); string strOfficer = dr["职务"].ToString(); if (!htEmpCardID.ContainsKey(strCardID)) { dr["校验错误"] += strCardID + ":卡号不正确,员工不存在;"; iError += 1; } else { dr["vcCardID"] = strCardID; CMSMStruct.EmployeeStruct emptmp2 = (CMSMStruct.EmployeeStruct)htEmpCardID[strCardID]; if (emptmp2.strEmpName != strEmpName) { dr["校验错误"] += strEmpName + ":员工姓名不正确;"; iError += 1; } else { dr["vcEmpName"] = strEmpName; } if (emptmp2.strOfficer != strOfficer) { dr["校验错误"] += strOfficer + ":职务不正确;"; iError += 1; } else { dr["vcEmpOF"] = strOfficer; } if (emptmp2.strDeptID != strDeptName) { dr["校验错误"] += strDeptName + ":员工所属部门不正确;"; iError += 1; } } string strClass = dr["班次"].ToString(); if (emb.IsEmpSchExist(strSchID, strDeptName, strCardID, strClass)) { dr["校验错误"] += "系统中已有该员工的本条排班信息;"; iError += 1; } else { dr["vcClass"] = strClass; } string InHour = dr["上班-小时"].ToString().Trim(); string InMin = dr["上班-分钟"].ToString().Trim(); string OutHour = dr["下班-小时"].ToString().Trim(); string OutMin = dr["下班-分钟"].ToString().Trim(); string nextoutflag = dr["次日下班"].ToString().Trim(); if (!(this.JudgeIsNum(InHour) && this.JudgeIsNum(InMin) && this.JudgeIsNum(OutHour) && this.JudgeIsNum(OutMin))) { dr["校验错误"] += "上下班的小时数或分钟数中有非数字字符;"; iError += 1; } else { if (!(this.JudgeIs24Hour(InHour) && this.JudgeIs60Minute(InMin) && this.JudgeIs24Hour(OutHour) && this.JudgeIs60Minute(OutMin))) { dr["校验错误"] += "上下班的小时数或分钟数有误;"; iError += 1; } else { if (dr["vcSchID"].ToString() != "") { DateTime dtIn = new DateTime(int.Parse(dr["vcSchID"].ToString().Substring(0, 4)), int.Parse(dr["vcSchID"].ToString().Substring(4, 2)), int.Parse(dr["vcSchID"].ToString().Substring(6, 2)), int.Parse(InHour), int.Parse(InMin), 0); DateTime dtOut = DateTime.Now; if (nextoutflag == "是") { dtOut = new DateTime(dtIn.AddDays(1).Year, dtIn.AddDays(1).Month, dtIn.AddDays(1).Day, int.Parse(OutHour), int.Parse(OutMin), 0); } else { dtOut = new DateTime(int.Parse(dr["vcSchID"].ToString().Substring(0, 4)), int.Parse(dr["vcSchID"].ToString().Substring(4, 2)), int.Parse(dr["vcSchID"].ToString().Substring(6, 2)), int.Parse(OutHour), int.Parse(OutMin), 0); } if (dtIn.CompareTo(dtOut) > 0) { dr["校验错误"] += "上班时间不能大于下班时间;"; iError += 1; } TimeSpan tsIn = new TimeSpan(dtIn.Ticks); TimeSpan tsOut = new TimeSpan(dtOut.Ticks); TimeSpan ts = tsIn.Subtract(tsOut).Duration(); double diffdate = Math.Round(double.Parse(ts.Hours.ToString()) + double.Parse(ts.Minutes.ToString()) / 60, 2); if (diffdate < 8.5) { dr["校验错误"] += "每班次的上班时间应大于8小时30分钟;"; iError += 1; } dr["dtCheckIn"] = dtIn; dr["dtCheckOut"] = dtOut; } } } } this.txtError.Text = iError.ToString(); return(ds); }
protected void btadd_Click(object sender, System.EventArgs e) { Hashtable htapp = (Hashtable)Application["appconf"]; string strcons = (string)htapp["cons"]; ebu = new EmpBusi(strcons); string strManager = ""; if (this.lblDeptID.Text.Trim() != "") { DataTable dtMana = ebu.GetEmpManager(this.lblDeptID.Text.Trim()); for (int i = 0; i < dtMana.Rows.Count; i++) { strManager += dtMana.Rows[i]["vcEmpName"].ToString() + ","; } if (strManager != "") { strManager = strManager.Substring(0, strManager.Length - 1); } } else { this.SetErrorMsgPageBydirHistory("门店信息错误!"); return; } double strInHour = double.Parse(ddlInHour.SelectedItem.Text); double strInMinute = double.Parse(ddlInMinute.SelectedItem.Text); double strOutHour = double.Parse(ddlOutHour.SelectedItem.Text); double strOutMinute = double.Parse(ddlOutMinute.SelectedItem.Text); double dateHourLong = 0; double dateMinuteLong = 0; if (chcSecDay.Checked) { dateHourLong = (24 - strInHour) + strOutHour; if (strInMinute == strOutMinute) { dateMinuteLong = 0; } else if (strInMinute < strOutMinute) { dateMinuteLong = Math.Round(((strOutMinute - strInMinute) / 60), 2); } else { dateMinuteLong = Math.Round((strInMinute - strOutMinute) / 60, 2); } if ((dateHourLong + dateMinuteLong) < 8.5) { this.SetErrorMsgPageBydirHistory("每班次的上班时间应大于8小时30分钟!"); return; } } else { if (strInHour > strOutHour) { this.SetErrorMsgPageBydirHistory("上班时间不能大于下班时间!"); return; } dateHourLong = strOutHour - strInHour; if (strInMinute == strOutMinute) { dateMinuteLong = 0; } else if (strInMinute < strOutMinute) { dateMinuteLong = Math.Round((strOutMinute - strInMinute) / 60, 2); } else { dateMinuteLong = Math.Round((strInMinute - strOutMinute) / 60, 2); } if ((dateHourLong + dateMinuteLong) < 8.5) { this.SetErrorMsgPageBydirHistory("每班次的上班时间应大于8小时30分钟!"); return; } } ArrayList alsuc = new ArrayList(); ArrayList alfail = new ArrayList(); for (int k = 0; k < this.ltbSelect.Items.Count; k++) { CMSMStruct.EmpSchLogStruct empschlog = new CMSMStruct.EmpSchLogStruct(); empschlog.strManager = strManager; empschlog.strSchID = this.txtSchDate.Text.Trim(); empschlog.strEmpName = this.ltbSelect.Items[k].Text.Trim(); empschlog.strDeptName = this.txtDept.Text.Trim(); empschlog.strClass = this.ddlClass.SelectedItem.Text; if (ebu.IsEmpSchAllDayWork(empschlog.strSchID, empschlog.strEmpName, empschlog.strClass)) { // this.SetErrorMsgPageBydirHistory("排班表不可即有全日班,又有其它班次!"); // return; alfail.Add(empschlog.strEmpName + " 失败原因:排班表不可即有全日班,又有其它班次!"); continue; } CMSMStruct.EmployeeStruct emp1 = ebu.GetEmpInfoByName(empschlog.strEmpName); if (emp1.strCardID == "" || emp1.strCardID == null) { // this.SetErrorMsgPageBydir("获取卡号出错,请检查员工姓名是否正确!"); // return; alfail.Add(empschlog.strEmpName + " 失败原因:获取卡号出错,请检查员工姓名是否正确!"); continue; } else { empschlog.strCardID = emp1.strCardID; empschlog.strEmpOF = emp1.strOfficer; } empschlog.strSchID = this.txtSchDate.Text.Trim(); string strDate = empschlog.strSchID.Substring(0, 4) + "-" + empschlog.strSchID.Substring(4, 2) + "-" + empschlog.strSchID.Substring(6, 2); empschlog.strCheckIn = strDate + " " + strInHour.ToString() + ":" + strInMinute.ToString() + ":00"; if (chcSecDay.Checked) { DateTime dtdate = new DateTime(int.Parse(empschlog.strSchID.Substring(0, 4)), int.Parse(empschlog.strSchID.Substring(4, 2)), int.Parse(empschlog.strSchID.Substring(6, 2))); DateTime dtnewdate = dtdate.AddDays(1); empschlog.strCheckOut = dtnewdate.ToShortDateString() + " " + strOutHour.ToString() + ":" + strOutMinute.ToString() + ":00"; } else { empschlog.strCheckOut = strDate + " " + strOutHour.ToString() + ":" + strOutMinute.ToString() + ":00"; } if (ebu.SchedEmpDailyEvery(empschlog)) { alsuc.Add(empschlog.strEmpName); } } string strinfo = "--------成功员工列表--------<br>"; for (int m = 0; m < alsuc.Count; m++) { strinfo += alsuc[m].ToString() + "<br>"; } strinfo += "--------失败员工列表--------<br>"; for (int n = 0; n < alfail.Count; n++) { strinfo += alfail[n].ToString() + "<br>"; } this.SetSuccMsgPageBydir("添加员工排班表完成,如果有失败请检查是否该员工已经有该班次的排班信息了!<br>" + strinfo, "Employ/wfmWorkDailyEvery.aspx"); }
public int ModEmployee(CMSMStruct.EmployeeStruct esold, CMSMStruct.EmployeeStruct esnew) { string strCondition = ""; if (esold.strEmpName != esnew.strEmpName) { strCondition = " vcEmpName='" + esnew.strEmpName + "'"; } if (esold.strSex != esnew.strSex) { if (strCondition != "") { strCondition += ",vcSex='" + esnew.strSex + "'"; } else { strCondition += " vcSex='" + esnew.strSex + "'"; } } if (esold.strEmpNbr != esnew.strEmpNbr) { if (strCondition != "") { strCondition += ",vcEmpNbr='" + esnew.strEmpNbr + "'"; } else { strCondition += " vcEmpNbr='" + esnew.strEmpNbr + "'"; } } if (esold.strDegree != esnew.strDegree) { if (strCondition != "") { strCondition += ",vcDegree='" + esnew.strDegree + "'"; } else { strCondition += " vcDegree='" + esnew.strDegree + "'"; } } if (esold.strLinkPhone != esnew.strLinkPhone) { if (strCondition != "") { strCondition += ",vcLinkPhone='" + esnew.strLinkPhone + "'"; } else { strCondition += " vcLinkPhone='" + esnew.strLinkPhone + "'"; } } if (esold.strAddress != esnew.strAddress) { if (strCondition != "") { strCondition += ",vcAddress='" + esnew.strAddress + "'"; } else { strCondition += " vcAddress='" + esnew.strAddress + "'"; } } if (esold.strDeptID != esnew.strDeptID) { if (strCondition != "") { strCondition += ",vcDeptID='" + esnew.strDeptID + "'"; } else { strCondition += " vcDeptID='" + esnew.strDeptID + "'"; } } if (esold.strFlag != esnew.strFlag) { if (strCondition != "") { strCondition += ",vcFlag='" + esnew.strFlag + "'"; } else { strCondition += " vcFlag='" + esnew.strFlag + "'"; } } if (esold.strOfficer != esnew.strOfficer) { if (strCondition != "") { strCondition += ",vcOfficer='" + esnew.strOfficer + "'"; } else { strCondition += " vcOfficer='" + esnew.strOfficer + "'"; } } if (esold.strComments != esnew.strComments) { if (strCondition != "") { strCondition += ",vcComments='" + esnew.strComments + "'"; } else { strCondition += " vcComments='" + esnew.strComments + "'"; } } int recount = 0; if (strCondition != "") { string sql1 = "update tbEmployee set " + strCondition + " where vcCardID='" + esold.strCardID + "'"; recount = SqlHelper.ExecuteNonQuery(con, CommandType.Text, sql1); if (con.State == ConnectionState.Open) { con.Close(); } } return(recount); }