/// <summary> /// 获得人员档案数据集 /// </summary> /// <returns>返回人员档案集合</returns> HR_PersonnelArchive GetPersonnelArchiveData() { HR_PersonnelArchive personnel = m_personnerServer.GetPersonnelInfo(dataGridView1.CurrentRow.Cells["员工编号"].Value.ToString()); if (dataGridView1.CurrentRow.Cells["离职时间"].Value.ToString() != "") { if (Convert.ToDateTime(dataGridView1.CurrentRow.Cells["离职时间"].Value).Year > 2000) { allowDate = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["离职时间"].Value).ToString(); } } else { allowDate = ""; } //if (dataGridView1.CurrentRow.Cells["合同起始时间"].Value.ToString() != "") //{ // if (Convert.ToDateTime(dataGridView1.CurrentRow.Cells["合同起始时间"].Value).Year > 2000) // { // starTime = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["合同起始时间"].Value).ToString(); // } //} //else //{ //starTime = ""; //} if (dataGridView1.CurrentRow.Cells["合同到期日"].Value.ToString() != "") { if (Convert.ToDateTime(dataGridView1.CurrentRow.Cells["合同到期日"].Value).Year > 2000) { endTime = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["合同到期日"].Value).ToString(); } } else { endTime = ""; } return(personnel); }
private void 修改toolStripButton_Click(object sender, EventArgs e) { if (txtStatus.Text.Trim() == "已完成" || txtStatus.Text.Trim() == "等待下次排班") { MessageDialog.ShowPromptMessage("单据已经完成,不能修改"); return; } if (!CheckControl()) { return; } List <HR_WorkSchedulingDetail> lstPersonnel = new List <HR_WorkSchedulingDetail>(); int day1 = GlobalObject.Year.GetDays(dtpBegin.Value); int days = 0; for (int i = dtpBegin.Value.Day; i <= day1; i++) { days++; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { DataGridViewCellCollection cells = dataGridView1.Rows[i].Cells; for (int j = 0; j < dataGridView1.Columns.Count; j++) { HR_WorkSchedulingDetail personnel = new HR_WorkSchedulingDetail(); DataGridViewComboBoxColumn dgvComboBoxColumn = dataGridView1.Columns[j] as DataGridViewComboBoxColumn; if (dataGridView1.Columns[j].CellType.Name == "DataGridViewComboBoxCell" && cells[j].Value != null) { personnel.WorkID = dataGridView1.Rows[i].Cells["工号"].Value.ToString(); personnel.Code = cells[j].Value.ToString(); if (dtpBegin.Value.Month == dtpEnd.Value.Month) { if (j - 1 <= days) { personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpBegin.Value.Month + "-" + dataGridView1.Columns[j].HeaderText); } else { break; } } else { if (j - 1 <= days) { personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpBegin.Value.Month + "-" + dataGridView1.Columns[j].HeaderText); } else { personnel.Date = Convert.ToDateTime(numYear.Value + "-" + dtpEnd.Value.Month + "-" + dataGridView1.Columns[j].HeaderText); } } lstPersonnel.Add(personnel); } } } HR_WorkScheduling workSchedule = new HR_WorkScheduling(); bool isDeptDirector = false; IQueryable <View_HR_PersonnelArchive> directorGroup = m_personnerServer.GetDeptDirector(m_personnerServer.GetPersonnelInfo(txtCreaterWorkID.Tag.ToString()).Dept, "0"); bool flag = false; if (directorGroup != null && directorGroup.Count() > 0) { isDeptDirector = true; foreach (var item in directorGroup) { if (BasicInfo.LoginID == item.员工编号) { flag = true; break; } } } IQueryable <View_HR_PersonnelArchive> directorGroup1 = m_personnerServer.GetDeptDirector(m_personnerServer.GetPersonnelInfo(txtCreaterWorkID.Tag.ToString()).Dept, "1"); bool flagPri = false; if (directorGroup1 != null && directorGroup1.Count() > 0) { foreach (var item in directorGroup1) { if (BasicInfo.LoginID == item.员工编号) { flagPri = true; break; } } } if (!flag && !flagPri) { if (isDeptDirector) { workSchedule.BillStatus = OverTimeBillStatus.等待主管审核.ToString(); } else { workSchedule.BillStatus = OverTimeBillStatus.等待部门负责人审核.ToString(); } } else if (flag && !flagPri) { workSchedule.BillStatus = OverTimeBillStatus.等待部门负责人审核.ToString(); } else { workSchedule.BillStatus = OverTimeBillStatus.已完成.ToString(); } workSchedule.ScheduleName = txtScheduleName.Text; workSchedule.CreateDate = dtpCreateDate.Value; workSchedule.CreaterWorkID = txtCreaterWorkID.Tag.ToString(); workSchedule.BeginDate = dtpBegin.Value; workSchedule.EndDate = dtpEnd.Value; workSchedule.Remark = txtRemark.Text; workSchedule.Year = Convert.ToInt32(numYear.Value); workSchedule.Month = Convert.ToInt32(numMonth.Value); workSchedule.PendingDate = Convert.ToDateTime(dateTimePendingDate.Value.ToShortDateString()); if (!m_workSchedulingServer.UpdateWorkScheduling(workSchedule, lstPersonnel, Convert.ToInt32(txtBillNo.Text), out error)) { MessageDialog.ShowPromptMessage(error); return; } else { MessageDialog.ShowPromptMessage("修改成功!"); } this.Close(); }
/// <summary> /// 刷新 /// </summary> void RefreshControl() { ClearControl(); IQueryable <View_HR_Dept> m_findDepartment; if (m_departmentServer.GetAllDeptInfo(out m_findDepartment, out error)) { foreach (var item in m_findDepartment) { cmbDept.Items.Add(item.部门名称); } } DataTable dt = new DataTable(); if (BasicInfo.DeptCode != "ZB03") { if (!BasicInfo.ListRoles.Contains(CE_RoleEnum.业务系统管理员.ToString())) { dt = m_PostServer.GetOperatingPost(m_personnerServer.GetPersonnelInfo(BasicInfo.LoginID).WorkPost); } else { dt = m_PostServer.GetOperatingPost(null); } } else { dt = m_PostServer.GetOperatingPost(null); } dataGridView1.DataSource = dt; dataGridView1.Columns["岗位编号"].Visible = false; dataGridView1.Refresh(); for (int i = 0; i < m_PostServer.GetPostType().Rows.Count; i++) { cmbPostType.Items.Add(m_PostServer.GetPostType().Rows[i]["职位类别"].ToString()); } this.dataGridView1.ColumnWidthChanged -= new System.Windows.Forms.DataGridViewColumnEventHandler( this.dataGridView1_ColumnWidthChanged); ColumnWidthControl.SetDataGridView(labelTitle.Text, dataGridView1); this.dataGridView1.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler( this.dataGridView1_ColumnWidthChanged); if (m_findField == null) { List <string> lstColumnName = new List <string>(); for (int i = 0; i < dataGridView1.Columns.Count; i++) { if (dataGridView1.Columns[i].Visible) { lstColumnName.Add(dataGridView1.Columns[i].Name); } } m_findField = lstColumnName.ToArray(); } userControlDataLocalizer1.Init(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); }
/// <summary> /// 修改销售清单 /// </summary> /// <param name="marketPartBill">销售清单主表信息</param> /// <param name="marketPritList">销售清单子表信息</param> /// <param name="role">操作角色</param> /// <param name="error">错误信息</param> /// <returns>修改成功返回True否则返回False</returns> public bool UpdateData(S_MarketingPartBill marketPartBill, List <View_S_MarketintPartList> marketPritList, string role, out string error) { error = ""; try { DataTable dt = m_findSellIn.GetBill(marketPartBill.AssociatedBillNo, 0); DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from a in dataContxt.S_MarketingPartBill where a.BillNo == marketPartBill.BillNo && a.AssociatedBillNo == marketPartBill.AssociatedBillNo select a; error = "判断角色"; if (result.Count() > 0) { S_MarketingPartBill bill = result.Single(); switch (role) { case "销售主管": bill.YX_Auditor = marketPartBill.YX_Auditor; bill.YX_AuditTime = marketPartBill.YX_AuditTime; bill.Status = marketPartBill.Status; SystemLog_MarketPart YXAuditorlog = new SystemLog_MarketPart(); YXAuditorlog.BillNo = marketPartBill.BillNo; YXAuditorlog.Content = marketPartBill.YX_AuditTime + "销售主管【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.YX_Auditor).Name + "】审核"; YXAuditorlog.Recorder = marketPartBill.YX_Auditor; YXAuditorlog.RecordTime = Convert.ToDateTime(marketPartBill.YX_AuditTime); dataContxt.SystemLog_MarketPart.InsertOnSubmit(YXAuditorlog); if (dt != null && dt.Rows.Count > 0) { if (m_findSellIn.AuditingBill(Convert.ToInt32(dt.Rows[0]["ID"].ToString()), marketPartBill.Remark, out error)) { string storage = dt.Rows[0]["storageID"].ToString(); m_billMessageServer.BillType = "营销出库单"; m_billMessageServer.PassFlowMessage(marketPartBill.AssociatedBillNo, string.Format("{0} 号营销出库单,请财务审核", marketPartBill.AssociatedBillNo), BillFlowMessage_ReceivedUserType.角色, CE_RoleEnum.会计.ToString()); error = error + "/n" + "主管审核成功"; } else { return(false); } } else { error = "找不到营销出库单【" + marketPartBill.AssociatedBillNo + "】"; return(false); } break; case "销售": bill.Recorder = marketPartBill.Recorder; bill.RecordTime = marketPartBill.RecordTime; bill.Status = marketPartBill.Status; bill.CiteTerminalClient = marketPartBill.CiteTerminalClient; bill.IsCarLoad = marketPartBill.IsCarLoad; if (bill.ClientID != marketPartBill.ClientID) { bill.Remark = marketPartBill.Remark; SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.RecordTime + "销售人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.Recorder).Name + "】修改客户,将" + m_clientServer.GetClientName(result.Single().ClientID) + "修改为:" + m_clientServer.GetClientName(bill.ClientID) + "】"; log.Recorder = marketPartBill.Recorder; log.RecordTime = marketPartBill.RecordTime; dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); } else { bill.Remark = marketPartBill.Remark; SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.RecordTime + "销售人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.Recorder).Name + "】确认"; log.Recorder = marketPartBill.Recorder; log.RecordTime = marketPartBill.RecordTime; dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); } bill.ClientID = marketPartBill.ClientID; dataContxt.SubmitChanges(); foreach (View_S_MarketintPartList item in marketPritList) { var resultList = from c in dataContxt.S_MarketintPartList where c.BillNo == item.单据号 && c.GoodsID == item.GoodsID && c.BatchNo == item.批次号 select c; if (resultList.Count() > 0) { S_MarketintPartList list = resultList.Single(); if (list.SellUnitPrice != item.销售单价) { SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.RecordTime + "销售人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.Recorder).Name + "】修改销售单价,将" + item.物品名称 + "销售单价" + resultList.Single().SellUnitPrice + "修改为:" + item.销售单价 + "】"; log.Recorder = marketPartBill.Recorder; log.RecordTime = marketPartBill.RecordTime; dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); dataContxt.SubmitChanges(); } list.Reamrk = item.备注; list.SellUnitPrice = item.销售单价; list.UnitPrice = item.最低定价; list.AssemblyCarCode = item.主机厂代码; list.AssemblyCarName = item.主机厂物品名称; dataContxt.SubmitChanges(); } } var resultMarketing = from c in dataContxt.S_MarketingBill where c.DJH == marketPartBill.AssociatedBillNo select c; if (resultMarketing.Count() > 0) { S_MarketingBill marketing = resultMarketing.Single(); marketing.DJZT_FLAG = "已保存"; m_billMessageServer.BillType = "营销出库单"; m_billMessageServer.PassFlowMessage(marketPartBill.AssociatedBillNo, string.Format("{0} 号营销出库单,请主管审核", marketPartBill.AssociatedBillNo), BillFlowMessage_ReceivedUserType.角色, CE_RoleEnum.营销主管.ToString()); } else { error = "找不到营销出库单【" + marketPartBill.AssociatedBillNo + "】"; return(false); } break; case "财务": bill.CW_Auditor = marketPartBill.CW_Auditor; bill.CW_AuditTime = marketPartBill.CW_AuditTime; bill.Status = marketPartBill.Status; if (bill.ClientID != marketPartBill.ClientID) { SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.CW_AuditTime + "财务人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.CW_Auditor).Name + "】修改客户,将" + m_clientServer.GetClientName(result.Single().ClientID) + "修改为:" + m_clientServer.GetClientName(bill.ClientID) + "】"; log.Recorder = marketPartBill.CW_Auditor; log.RecordTime = Convert.ToDateTime(marketPartBill.CW_AuditTime); dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); } else { SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.CW_AuditTime + "财务人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.CW_Auditor).Name + "】审核"; log.Recorder = marketPartBill.CW_Auditor; log.RecordTime = Convert.ToDateTime(marketPartBill.CW_AuditTime); dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); } bill.ClientID = marketPartBill.ClientID; bill.Remark = marketPartBill.Remark; foreach (View_S_MarketintPartList item in marketPritList) { var resultList = from c in dataContxt.S_MarketintPartList where c.BillNo == item.单据号 && c.GoodsID == item.GoodsID && c.BatchNo == item.批次号 && c.Provider == item.供应商 select c; if (resultList.Count() > 0) { S_MarketintPartList list = resultList.Single(); if (list.SellUnitPrice != item.销售单价) { SystemLog_MarketPart log = new SystemLog_MarketPart(); log.BillNo = marketPartBill.BillNo; log.Content = marketPartBill.CW_AuditTime + "财务人员【" + m_personnerArchiveServer.GetPersonnelInfo(marketPartBill.CW_Auditor).Name + "】修改销售单价,将销售单价" + resultList.Single().SellUnitPrice + "修改为:" + item.销售单价 + "】"; log.Recorder = marketPartBill.CW_Auditor; log.RecordTime = Convert.ToDateTime(marketPartBill.CW_AuditTime); dataContxt.SystemLog_MarketPart.InsertOnSubmit(log); } list.Reamrk = item.备注; list.SellUnitPrice = item.销售单价; } } if (dt != null && dt.Rows.Count > 0) { if (dt.Rows[0]["DJZT_FLAG"].ToString() == "等待财务审核") { if (m_findSellIn.RetrialBill(marketPartBill.AssociatedBillNo, marketPartBill.Remark, out error)) { string storage = dt.Rows[0]["storageID"].ToString(); m_billMessageServer.BillType = "营销出库单"; m_billMessageServer.PassFlowMessage(marketPartBill.AssociatedBillNo, string.Format("{0} 号营销出库单,请仓管员确认", marketPartBill.AssociatedBillNo), m_billMessageServer.GetRoleStringForStorage(storage).ToString(), true); } else { return(false); } } } else { error = "找不到营销出库单【" + marketPartBill.AssociatedBillNo + "】"; return(false); } break; default: break; } } else { error = "未找到相关单据"; return(false); } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 检查控件 /// </summary> /// <returns>信息正确返回True,失败返回False</returns> bool CheckControl() { if (dtpEndTime.Value <= dtpBeginTime.Value) { MessageDialog.ShowPromptMessage("【起始时间】必须小于【结束时间】"); return(false); } if (MessageDialog.ShowEnquiryMessage("请确认您的\r\n【加班起始时间】:" + dtpBeginTime.Value.ToString("yyyy-MM-dd HH:mm") + "\r\n【加班结束时间】:" + dtpEndTime.Value.ToString("yyyy-MM-dd HH:mm")) == DialogResult.No) { return(false); } if (txtErrand.Text.Trim() == "") { MessageDialog.ShowPromptMessage("请填写加班任务描述!"); return(false); } if (numHours.Value == 0) { MessageDialog.ShowPromptMessage("请填写需要加班小时!"); return(false); } if (cmbCompensateMode.Text.Trim() == "") { MessageDialog.ShowPromptMessage("请选择加班补偿方式!"); return(false); } if (cmbOvertimeAddress.SelectedIndex == -1) { MessageDialog.ShowPromptMessage("请选择加班地点!"); return(false); } if (dataGridView2.Rows.Count > 0) { DateTime starDate = ServerTime.Time; DateTime endDate = ServerTime.Time; if (cmbCompensateMode.SelectedIndex == 0) { string month = ""; if (dtpBeginTime.Value.Month < 10) { month = "0" + dtpBeginTime.Value.Month; } else { month = dtpBeginTime.Value.Month.ToString(); } starDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "01"); endDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + GetDays()); if (m_highDept.Contains("ZZ") || m_highDept == "SC") { if (dtpBeginTime.Value.Month == 1) { starDate = Convert.ToDateTime((dtpBeginTime.Value.Year - 1).ToString() + "-12-26"); endDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "26"); } else { starDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + (dtpBeginTime.Value.Month - 1).ToString() + "-" + "26"); endDate = Convert.ToDateTime(dtpBeginTime.Value.Year.ToString() + "-" + month + "-" + "26"); } } } for (int i = 0; i < dataGridView2.Rows.Count; i++) { DataGridViewCellCollection cells = dataGridView2.Rows[i].Cells; if (cells["员工编号"].Value == null || GlobalObject.GeneralFunction.IsNullOrEmpty(cells["员工编号"].Value.ToString())) { MessageDialog.ShowPromptMessage(string.Format("第 {0} 行, 请选择加班人员", i + 1)); return(false); } if (cmbCompensateMode.SelectedIndex == 0) { if (!m_attendanceServer.GetAllowMobileVacationHour(cells["员工编号"].Value.ToString())) { if (m_overTimeServer.GetMonthRealHour(cells["员工编号"].Value.ToString(), starDate, endDate) <= 0) { MessageDialog.ShowPromptMessage(UniversalFunction.GetPersonnelName(cells["员工编号"].Value.ToString()) + "有欠班,只能选择调休!"); return(false); } } } } } else if (dataGridView2.Rows.Count == 0) { MessageDialog.ShowPromptMessage("请选择加班人员"); return(false); } IQueryable <View_HR_PersonnelArchive> directorGroup = m_personnerServer.GetDeptDirector( m_personnerServer.GetPersonnelInfo(txtApplicant.Tag.ToString()).Dept, "2"); bool flag = false; if (directorGroup != null && directorGroup.Count() > 0) { foreach (var item in directorGroup) { if (BasicInfo.LoginID == item.员工编号) { flag = true; break; } } } if (flag) { MessageDialog.ShowPromptMessage("您是分管领导,不用填写加班单!"); return(false); } if ((ServerTime.Time - dtpBeginTime.Value).Days > 3 && !BasicInfo.ListRoles.Contains(CE_RoleEnum.人力资源部办公室文员.ToString())) { string starTemp = dtpBeginTime.Value.ToShortDateString() + " " + "08:30"; DataTable dt = m_holidayServer.GetHolidayDays(Convert.ToDateTime(starTemp), ServerTime.Time); if (dt != null && dt.Rows.Count > 0) { int days = Convert.ToInt32(dt.Rows[0]["days"] == DBNull.Value ? "0" : dt.Rows[0]["days"]); if (days > 0) { if ((ServerTime.Time - dtpBeginTime.Value).Days > 3 + days) { MessageDialog.ShowPromptMessage("只能补三天内的加班单!"); return(false); } } else { MessageDialog.ShowPromptMessage("只能补三天内的加班单!"); return(false); } } else { MessageDialog.ShowPromptMessage("只能补三天内的加班单!"); return(false); } } HR_AttendanceSetting attendanceSet = m_attendanceSchemeServer.GetAttendanceSettingByWorkID(BasicInfo.LoginID); string[] schemeCode = attendanceSet.SchemeCode.Split(' '); string mode = m_attendanceSchemeServer.GetAttendanceSchemeByCode(schemeCode[0]).AttendanceMode; Hashtable hsTable = new Hashtable(); hsTable.Add("@ParentCode", "ZZGC"); hsTable.Add("@WorkID", BasicInfo.LoginID); DataTable tempTable = GlobalObject.DatabaseServer.QueryInfoPro("HR_Personnel_GetParentDept", hsTable, out error); #region 2017.10.27 夏石友, 向菲菲将工务人员、车间人员修改为非自然月排班考勤后出现必须加班2小时才可以填写加班单的现象 //if (mode.Contains("非自然月考勤")) if (mode.Contains("非自然月考勤") || mode.Contains("非自然月排班考勤") || tempTable.Rows.Count > 0) #endregion { if (numHours.Value < 1) { MessageDialog.ShowPromptMessage("加班1小时以上才可以填写加班申请单!"); return(false); } } else { if (numHours.Value < 2) { MessageDialog.ShowPromptMessage("加班2小时以上才可以填写加班申请单!"); return(false); } } return(true); }