private void 强制toolStripButton_Click(object sender, EventArgs e) { if (MessageDialog.ShowEnquiryMessage("无论关联单是否已经批准,都强制性的处理为当前的真实考勤类别?") == DialogResult.Yes) { if (cmbRealExceptionType.Text == "") { MessageDialog.ShowPromptMessage("请选择真实的异常类型!"); return; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["选"].Value)) { HR_TimeException exception = new HR_TimeException(); exception.ID = Convert.ToInt32(dataGridView1.Rows[i].Cells["序号"].Value); exception.Date = Convert.ToDateTime(dataGridView1.Rows[i].Cells["异常日期"].Value).Date; exception.HR_Signature = BasicInfo.LoginID; exception.HR_SignatureDate = ServerTime.Time.ToString(); exception.WorkID = dataGridView1.Rows[i].Cells["员工编号"].Value.ToString(); exception.ExceptionDescription = BasicInfo.LoginName + " 强制处理 " + txtDescription.Text; exception.RealExceptionType = m_attendanceMachineServer.GetExceptionTypeID(cmbRealExceptionType.Text); if (!m_timeExServer.UpdateTimeException(exception, out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } } } RefreshDataGridView(); } }
///// <summary> ///// 通过员工编号和时间获得出差信息 ///// </summary> ///// <param name="workID">员工编号</param> ///// <param name="starTime">起始时间</param> ///// <param name="endTime">截止时间</param> ///// <returns>返回数据集</returns> //public DataTable GetOnBusinessBillByWorkIDAndTime(string workID,DateTime starTime,DateTime endTime) //{ // string sql = @"select 单据号,View_HR_OnBusinessPersonnel.员工编号,预定出发时间,预定返程时间 "+ // " from dbo.View_HR_OnBusinessPersonnel inner join "+ // " dbo.View_HR_OnBusinessBill on View_HR_OnBusinessBill.编号=View_HR_OnBusinessPersonnel.单据号"+ // " where View_HR_OnBusinessPersonnel.员工编号='" + workID + "' and ("+ // " (实际出发时间 between '" + starTime + "' and '" + endTime + "'" + // " or (实际返程时间 >= '" + starTime + "' and '" + endTime + "')) and 是否批准 = '"+ bool.TrueString +"'"; // DataTable dt = GlobalObject.DatabaseServer.QueryInfo(sql); // return dt; //} /// <summary> /// 考勤异常处理_判断是否出差 /// </summary> /// <param name="timeException">考勤异常对象</param> /// <returns>返回Table</returns> public DataTable GetOnBusinessInfo_TimeExceptionJudge(HR_TimeException timeException) { string strSql = " select 单据号,a.员工编号,预定出发时间,预定返程时间 ,c.* " + " from dbo.View_HR_OnBusinessPersonnel as a " + " inner join dbo.View_HR_OnBusinessBill as b on b.编号= a.单据号 " + " inner join HR_TimeException as c on a.员工编号 = c.WorkID and c.ID = " + timeException.ID + " where a.员工编号='" + timeException.WorkID + "' and 是否批准 = '" + bool.TrueString + "' " + " and CAST( CONVERT(varchar(100), b.实际出发时间, 23) as dateTime) <= c.Date " + " and CAST( CONVERT(varchar(100), b.实际返程时间, 23) as dateTime) >= c.Date"; return(GlobalObject.DatabaseServer.QueryInfo(strSql)); }
private void 审核toolStripButton_Click(object sender, EventArgs e) { bool flag = false; if (cmbRealExceptionType.Text == "") { MessageDialog.ShowPromptMessage("请选择真实的异常类型!"); return; } if (txtHRAuthorize.Text.Trim() != "") { MessageDialog.ShowPromptMessage("人力资源已经审核,您不能再审核!"); return; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["选"].Value)) { flag = true; HR_TimeException exception = new HR_TimeException(); exception.ID = Convert.ToInt32(dataGridView1.Rows[i].Cells["序号"].Value); exception.Date = Convert.ToDateTime(dataGridView1.Rows[i].Cells["异常日期"].Value); exception.ExceptionDescription = txtDescription.Text; exception.RealExceptionType = m_attendanceMachineServer.GetExceptionTypeID(cmbRealExceptionType.Text); exception.DeptAuditor = BasicInfo.LoginID; exception.DeptAuditorSignatureDate = ServerTime.Time; exception.WorkID = dataGridView1.Rows[i].Cells["员工编号"].Value.ToString(); if (!m_timeExServer.UpdateTimeException(exception, "部门审核", out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } } } if (!flag) { MessageDialog.ShowPromptMessage("请勾选需要修改的数据行"); return; } MessageDialog.ShowPromptMessage("部门审核成功!"); RefreshDataGridView(); }
private void 提交toolStripButton1_Click(object sender, EventArgs e) { bool flag = false; if (cmbRealExceptionType.Text == "") { MessageDialog.ShowPromptMessage("请选择真实的异常类型!"); return; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["选"].Value)) { flag = true; HR_TimeException exception = new HR_TimeException(); exception.ID = Convert.ToInt32(dataGridView1.Rows[i].Cells["序号"].Value); exception.Date = Convert.ToDateTime(dataGridView1.Rows[i].Cells["异常日期"].Value); exception.ExceptionDescription = txtDescription.Text; exception.RealExceptionType = m_attendanceMachineServer.GetExceptionTypeID(cmbRealExceptionType.Text); if (!m_timeExServer.UpdateTimeException(exception, "员工自己", out m_error)) { MessageDialog.ShowPromptMessage(m_error); return; } } } if (!flag) { MessageDialog.ShowPromptMessage("请勾选需要修改的数据行"); return; } RefreshDataGridView(); }
/// <summary> /// 修改考勤异常登记信息(强制处理) /// </summary> /// <param name="timeException">考勤异常登记信息数据集</param> /// <param name="error">错误信息</param> /// <returns>成功返回true失败返回False</returns> public bool UpdateTimeException(HR_TimeException timeException, out string error) { error = ""; DateTime starTime = Convert.ToDateTime(timeException.Date.Date); DateTime endTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "23:59:59"); string[] leaveType = new LeaveServer().GetLeaveTypeByWorkID(timeException.WorkID, starTime, endTime).Split(';'); string onbusinessBill = new OnBusinessBillServer().IsExistOnBusinessBillByWorkIDAndTime( timeException.WorkID, starTime, Convert.ToDateTime(endTime.AddDays(1).ToShortDateString())); DataTable dtOverTime = new OverTimeBillServer().IsExistOverTimeByWorkID(timeException.WorkID, starTime.Date, starTime.AddDays(1).Date); try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_TimeException where a.ID == timeException.ID select a; if (result.Count() > 0) { HR_TimeException exceptionList = result.Single(); exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.HR_Signature = timeException.HR_Signature; exceptionList.HR_SignatureDate = timeException.HR_SignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; var resultList = from a in dataContxt.HR_AttendanceDaybookList where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID select a; if (resultList.Count() > 0) { HR_AttendanceDaybookList dayBookList = resultList.Single(); if (timeException.RealExceptionType == 4 && leaveType != null && leaveType[0] != "") { dayBookList.ResultType = "4"; dayBookList.BillNo = leaveType[0]; if (dayBookList.BillNo != "") { dayBookList.ResultSubclass = leaveType[1]; dayBookList.Remark = timeException.ExceptionDescription; } else { dayBookList.ResultSubclass = ""; } } else if (timeException.RealExceptionType == 7 && onbusinessBill != null) { dayBookList.ResultType = "7"; dayBookList.BillNo = onbusinessBill; } else if (timeException.RealExceptionType == 9 || timeException.RealExceptionType == 8 || timeException.RealExceptionType == 10 || timeException.RealExceptionType == 1 || timeException.RealExceptionType == 2 || timeException.RealExceptionType == 3 || timeException.RealExceptionType == 11 || timeException.RealExceptionType == 12) { dayBookList.ResultType = timeException.RealExceptionType.ToString(); dayBookList.BillNo = ""; dayBookList.ResultSubclass = ""; } else if (timeException.RealExceptionType == 5 && dtOverTime != null && dtOverTime.Rows.Count > 0) { dayBookList.ResultType = "5"; if (dayBookList.BillNo == null || dayBookList.BillNo.Trim().Length == 0 || dayBookList.Hours == 0) { dayBookList.BillNo = dtOverTime.Rows[0]["单据号"].ToString(); dayBookList.ResultSubclass = dtOverTime.Rows[0]["补偿方式"].ToString(); dayBookList.Hours = Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()); } } else { timeException.RealExceptionType = timeException.RealExceptionType; timeException.ExceptionDescription += " 没有检测到关联单;已被" + BasicInfo.LoginName + "强制处理"; } dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType); } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 修改考勤异常登记信息 /// </summary> /// <param name="timeException">考勤异常登记信息数据集</param> /// <param name="role">角色(部门审核、人力资源审核)</param> /// <param name="error">错误信息</param> /// <returns>成功返回true失败返回False</returns> public bool UpdateTimeException(HR_TimeException timeException, string role, out string error) { error = ""; DateTime starTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "08:30:00"); DateTime endTime = Convert.ToDateTime(timeException.Date.ToShortDateString() + " " + "17:30:00"); //string[] leaveType = new LeaveServer().GetLeaveTypeByWorkID(timeException.WorkID, endTime, starTime).Split(';'); //DataTable onbusinessDt = new OnBusinessBillServer().GetOnBusinessInfo_TimeExceptionJudge(timeException); //DataTable dtOverTime = new OverTimeBillServer().GetOverTimeByWorkID(timeException.WorkID,starTime.Date,starTime.AddDays(1).Date); try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.HR_TimeException where a.ID == timeException.ID select a; if (result.Count() > 0) { HR_TimeException exceptionList = result.Single(); switch (role) { case "部门审核": exceptionList.DeptAuditor = timeException.DeptAuditor; exceptionList.DeptAuditorSignatureDate = timeException.DeptAuditorSignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; exceptionList.RealExceptionType = timeException.RealExceptionType; if (timeException.RealExceptionType == 8) { //DateTime starDate = new DateTime(timeException.Date.Year, timeException.Date.Month, 1); //int Days = DateTime.DaysInMonth(timeException.Date.Year, timeException.Date.Month); //DateTime endDate = new DateTime(timeException.Date.Year, timeException.Date.Month, Days); //if (!IsTimeExceptionCount(timeException.WorkID, starDate, endDate, // timeException.RealExceptionType.ToString(), out error))//漏打卡次数大于3 //{ // error = "每人每个月漏打卡次数不能超过3次!" + // UniversalFunction.GetPersonnelName(timeException.WorkID) + "已有三次"; // return false; //} exceptionList.RealExceptionType = timeException.RealExceptionType; } #region 文员只能处理已登记与漏打卡 //if (timeException.RealExceptionType == 7) //{ // if (onbusinessDt.Rows.Count > 0 && onbusinessDt.Rows[0]["单据号"].ToString() != "") // { // exceptionList.RealExceptionType = timeException.RealExceptionType; // } // else // { // error = m_personnerServer.GetPersonnelInfo(timeException.WorkID).Name + timeException.Date + "没有出差单或单据没有完成"; // return false; // } //} //else if (timeException.RealExceptionType == 4) //{ // if (leaveType != null && leaveType[0] != "") // { // exceptionList.RealExceptionType = timeException.RealExceptionType; // } // else // { // error = m_personnerServer.GetPersonnelInfo(timeException.WorkID).Name + timeException.Date + "没有请假单或单据没有完成"; // return false; // } //} //else if (timeException.RealExceptionType == 8) //{ // DateTime starDate = new DateTime(timeException.Date.Year, timeException.Date.Month, 1); // int Days = DateTime.DaysInMonth(timeException.Date.Year, timeException.Date.Month); // DateTime endDate = new DateTime(timeException.Date.Year, timeException.Date.Month, Days); // if (!IsTimeExceptionCount(timeException.WorkID, starDate, endDate, // timeException.RealExceptionType.ToString(), out error))//漏打卡次数大于3 // { // error = "每人每个月漏打卡次数不能超过3次!" + // UniversalFunction.GetPersonnelName(timeException.WorkID) + "已有三次"; // return false; // } // exceptionList.RealExceptionType = timeException.RealExceptionType; //} #endregion break; case "人力资源审核": exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.HR_Signature = timeException.HR_Signature; exceptionList.HR_SignatureDate = timeException.HR_SignatureDate; exceptionList.ExceptionDescription = timeException.ExceptionDescription; var varData = from a in dataContxt.HR_AttendanceDaybookList where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID select a; if (varData.Count() == 1) { HR_AttendanceDaybookList dayBookList = varData.Single(); dayBookList.ResultType = timeException.RealExceptionType.ToString(); dayBookList.BillNo = ""; dayBookList.ResultSubclass = ""; if (result.Single().ExceptionType != timeException.RealExceptionType) { if (exceptionList.DeptAuditor != null && exceptionList.DeptAuditor != "") { dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + ";更改人:" + new PersonnelArchiveServer().GetPersonnelInfo(exceptionList.DeptAuditor).Name; } else { dayBookList.Remark = timeException.ExceptionDescription + " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + ";更改人:" + BasicInfo.LoginName; } } } #region 文员只能处理已登记与漏打卡 //var varData = from a in dataContxt.HR_AttendanceDaybookList // where a.TimeExceptionRelevanceID == exceptionList.DayBookUniqueID // select a; //if (varData.Count() == 1) //{ // HR_AttendanceDaybookList dayBookList = varData.Single(); // //请假 // if (timeException.RealExceptionType == 4 && leaveType != null && leaveType[0] != "") // { // dayBookList.ResultType = "4"; // dayBookList.BillNo = leaveType[0]; // dayBookList.ResultSubclass = leaveType[1]; // }//加班 // else if (timeException.RealExceptionType == 5 && dtOverTime != null && dtOverTime.Rows.Count > 0) // { // dayBookList.ResultType = "5"; // if (dayBookList.BillNo == null || dayBookList.BillNo.Trim().Length == 0 || dayBookList.Hours == 0) // { // dayBookList.BillNo = dtOverTime.Rows[0]["单据号"].ToString(); // dayBookList.ResultSubclass = dtOverTime.Rows[0]["补偿方式"].ToString(); // double alreadyHours = GetAlreadyHours(dataContxt, dayBookList, timeException.WorkID); // dayBookList.Hours = Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()) < alreadyHours ? // dayBookList.Hours : Convert.ToDouble(dtOverTime.Rows[0]["实际小时数"].ToString()) - alreadyHours; // } // } // else if (timeException.RealExceptionType == 7 && (onbusinessDt != null && onbusinessDt.Rows.Count > 0 // && onbusinessDt.Rows[0]["单据号"].ToString() != "")) // { // dayBookList.ResultType = "7"; // dayBookList.BillNo = onbusinessDt.Rows[0]["单据号"].ToString(); // } // else if (timeException.RealExceptionType == 9 || timeException.RealExceptionType == 8 // || timeException.RealExceptionType == 10 || timeException.RealExceptionType == 1 // || timeException.RealExceptionType == 2 || timeException.RealExceptionType == 3 // || timeException.RealExceptionType == 11 || timeException.RealExceptionType == 12 // || timeException.RealExceptionType == 13) // { // dayBookList.ResultType = timeException.RealExceptionType.ToString(); // dayBookList.BillNo = ""; // dayBookList.ResultSubclass = ""; // } // else // { // error = "没有检测到关联单"; // error += "【工号】:" + exceptionList.WorkID + "【时间】:" + exceptionList.Date.ToShortDateString(); // timeException.ExceptionDescription += ";没有检测到关联单;"; // timeException.ExceptionDescription += "【工号】:" + exceptionList.WorkID + "【时间】:" + exceptionList.Date.ToShortDateString(); // return false; // } // if (result.Single().ExceptionType != timeException.RealExceptionType) // { // if (exceptionList.DeptAuditor != null && exceptionList.DeptAuditor != "") // { // dayBookList.Remark = timeException.ExceptionDescription + // " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + // "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + // ";更改人:" + new PersonnelArchiveServer().GetPersonnelInfo(exceptionList.DeptAuditor).Name; // } // else // { // dayBookList.Remark = timeException.ExceptionDescription + // " 异常类型由之前的" + new AttendanceMachineServer().GetExceptionTypeName(result.Single().ExceptionType) + // "更改为" + new AttendanceMachineServer().GetExceptionTypeName(timeException.RealExceptionType) + // ";更改人:" + BasicInfo.LoginName; // } // } // break; //} #endregion break; default: exceptionList.RealExceptionType = timeException.RealExceptionType; exceptionList.ExceptionDescription = timeException.ExceptionDescription; break; } } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }