public bool IsErrorTimespanWithTwoClass(CMSMStruct.EmpSchLogStruct empschlog) { if (Ea.IsErrorTimespanWithTwoClass(empschlog) == 0) { return(false); } else { return(true); } }
public bool SchedEmpDailyEvery(CMSMStruct.EmpSchLogStruct empsl) { int recount = Ea.SchedEmpDailyEvery(empsl); if (recount < 1) { return(false); } else { return(true); } }
public int SchedEmpDailyEvery(CMSMStruct.EmpSchLogStruct empsl) { con.Open(); int rerow = 0; using (SqlTransaction tran = con.BeginTransaction()) { try { string sql1 = "select count(*) from tbEmpSchLog where vcSchID='" + empsl.strSchID + "' and vcEmpName='" + empsl.strEmpName + "' and vcClass='" + empsl.strClass + "'"; drr = SqlHelper.ExecuteReader(con, tran, CommandType.Text, sql1); drr.Read(); string strissch = drr[0].ToString(); drr.Close(); if (strissch == "0") { string sql2 = "insert into tbEmpSchLog values('" + empsl.strSchID + "','" + empsl.strDeptName + "','" + empsl.strManager + "','" + empsl.strCardID + "','" + empsl.strEmpName + "','" + empsl.strEmpOF + "','" + empsl.strClass + "','" + empsl.strCheckIn + "','" + empsl.strCheckOut + "')"; rerow = SqlHelper.ExecuteNonQuery(con, tran, CommandType.Text, sql2); } else { rerow = 0; } tran.Commit(); } catch (Exception e) { tran.Rollback(); clog.WriteLine(e); return(rerow); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } return(rerow); } }
private 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) { if (this.ddlClass.SelectedValue != "5") { 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) <= 2.5) { this.SetErrorMsgPageBydirHistory("每班次的上班时间不能小于等于2.5小时!"); return; } } } else { if (this.ddlClass.SelectedValue != "5") { 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) <= 2.5) { this.SetErrorMsgPageBydirHistory("每班次的上班时间不能小于等于2.5小时!"); 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; CMSMStruct.EmployeeStruct emp1 = ebu.GetEmpInfoByName(empschlog.strEmpName); if (emp1.strCardID == "" || emp1.strCardID == null) { alfail.Add(empschlog.strEmpName + " 失败原因:获取卡号出错,请检查员工姓名是否正确!"); continue; } else { empschlog.strCardID = emp1.strCardID; empschlog.strEmpOF = emp1.strOfficer; } if (ebu.IsEmpSchAllDayWork(empschlog.strSchID, empschlog.strCardID, empschlog.strClass)) { alfail.Add(empschlog.strEmpName + " 失败原因:排班表中不可即有全日班或休息,又有其它班次!"); continue; } if (ebu.IsEmpSchDupClass(empschlog.strSchID, empschlog.strCardID, empschlog.strClass)) { alfail.Add(empschlog.strEmpName + " 失败原因:排班表中已经存在" + empschlog.strClass + "信息!"); continue; } empschlog.strSchID = this.txtSchDate.Text.Trim(); if (empschlog.strClass != "休息") { 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 (empschlog.strClass != "休息" && empschlog.strClass != "全日班") { if (ebu.IsErrorTimespanWithTwoClass(empschlog)) { alfail.Add(empschlog.strEmpName + " 失败原因:两相邻班次之间的时间间隔不得小于2.5小时!"); continue; } } 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"); }