/******************************************************************************* * Copyright(c) 2014 dongke All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_HR_0502.cs * 2.功能描述:工种调整新增、修改 * 编辑履历: * 作者 日期 版本 修改内容 * 冯雪 2014/09/13 1.00 新建 *******************************************************************************/ using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseControls; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels.HRModule; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService; namespace Dongke.IBOSS.PRD.Client.HRModule { /// /// 工种调整新增、修改 /// public partial class F_HR_0502 : FormBase { #region 成员变量 // 窗体状态的枚举 新建/编辑 private Constant.FormMode _editStatus; // 要编辑的员工编号 private int _userId; // 页面传过来员工ID private int _staffRecordID; // 用户履历实体类 private StaffRecordEntity _staffRecordEntity; // 员工时间戳 private DateTime _optimestamp; // 调整前工种信息; private int _originalJobs; // 调整前工号信息; private int _originalUserID; // 员工履历表时间戳 private DateTime? _rExProbationEndDate; // 员工档案表的时间戳 private DateTime? _rOPTimeStamp; // 新建的员工ID集合 private List _staffIDList = new List(); #endregion #region 构造函数 /// /// 构造函数 /// /// 新建/编辑 /// 要编辑的员工编号 public F_HR_0502(Constant.FormMode editStatus, int pUserId, int pStaffRecordID) { InitializeComponent(); this._editStatus = editStatus; this._userId = pUserId; this._staffRecordID = pStaffRecordID; this.SetFromTitleInfo(); } #endregion #region 属性 /// /// 页面传过来的员工ID /// public int StaffRecordID { get { return this._staffRecordID; } set { this._staffRecordID = value; } } /// /// 时间戳 /// public DateTime OPTimeStamp { get { return this._optimestamp; } set { this._optimestamp = value; } } /// /// 员工ID集合 /// public List StaffIDList { get { return _staffIDList; } set { _staffIDList = value; } } #endregion #region 事件 /// /// 页面加载事件 /// /// /// private void F_HR_0502_Load(object sender, EventArgs e) { try { this.dkUserName.WhereCondition = "StaffStatus in(1,2) And ValueFlag = 1"; this.dkUserApplicant.WhereCondition = "StaffStatus =2 And ValueFlag = 1"; if (this._editStatus == Constant.FormMode.Edit) { // 获取用户信息数据集 DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo)); if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO) { // 编辑数据 给页面所有项赋值 if (this._editStatus == Constant.FormMode.Edit && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { this.dkUserName.StaffEntity.ExProbationEndDate = null; this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]); this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim(); this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim(); this.txtStaffCode.Text = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim(); this.txtOrganizationID.Text = staffInfoData.Tables[0].Rows[0]["SOrganizationname"].ToString().Trim(); this.txtJobs.Text = staffInfoData.Tables[0].Rows[0]["ROriginalJobsName"].ToString().Trim(); this._originalJobs = int.Parse(staffInfoData.Tables[0].Rows[0]["OriginalJobs"].ToString().Trim()); this.dkTargetobs.JobsID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetJobs"]); this.dkTargetobs.JobsName = staffInfoData.Tables[0].Rows[0]["RTargetJobsName"].ToString().Trim(); this.dkUserApplicant.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["Applicant"]); this.dkUserApplicant.UserName = staffInfoData.Tables[0].Rows[0]["RApplicantName"].ToString().Trim(); this.dtpApplicationTime.Value = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RecordDate"]); //如果调整后员工状态为试用为预计试用期状态赋值 if (staffInfoData.Tables[0].Rows[0]["TargetStaffStatus"].ToString().Equals(Constant.StaffStatus.Trial.GetHashCode().ToString())) { this.chkProbation.Checked = true; this._rExProbationEndDate = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RExProbationEndDate"]); this.dtpExProbationEndDate.Value = this._rExProbationEndDate.Value; } this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim(); this.txtSuggestion.Text = staffInfoData.Tables[0].Rows[0]["Suggestion"].ToString().Trim(); this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["RRemarks"].ToString().Trim(); this._optimestamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["SOPTimeStamp"]); this._rOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["ROPTimeStamp"]); } this.dkUserName.Enabled = false; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 用户选择控件值改变时事件 /// /// /// private void dkUserName_UserValueChanged(object sender, Controls.dkStaffSearchBox.TextChangeEventArgs e) { try { if (this.dkUserName.UserRow != null) { this.txtStaffCode.Text = this.dkUserName.StaffEntity.StaffCode; this.txtOrganizationID.Text = this.dkUserName.StaffEntity.OrganizationName; this.txtJobs.Text = this.dkUserName.StaffEntity.JobsName; this._optimestamp = this.dkUserName.StaffEntity.OPTimeStamp; this._originalJobs = this.dkUserName.StaffEntity.Jobs; this._originalUserID = this.dkUserName.StaffEntity.UserID; if (this.dkUserName.StaffEntity.StaffStatus == Constant.INT_IS_ONE) { this.chkProbation.Checked = true; if (this.dkUserName.StaffEntity.ExProbationEndDate != null) { this.dtpExProbationEndDate.Value = this.dkUserName.StaffEntity.ExProbationEndDate.Value; } } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 是否试用Changed事件 /// /// /// private void chkProbation_CheckedChanged(object sender, EventArgs e) { this.dtpExProbationEndDate.Enabled = this.chkProbation.Checked; } /// /// 保存按钮 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { // 验证输入是否正确 if (!this.CheckInputValidity()) { return; } this._staffRecordEntity = this.SetStaffRecordEntity(); this.btnSave.Enabled = false; this.btnCancel.Enabled = false; HRResultEntity returnStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(this.SaveStaffInfo)); this.btnSave.Enabled = true; this.btnCancel.Enabled = true; if (returnStaff.OperateStatus > Constant.INT_IS_ZERO) { // 保存成功提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工种调整", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this._staffIDList.Add(returnStaff.HRStaffRecordID); this.InitializationForm(); if (this._editStatus == Constant.FormMode.Edit) { this.DialogResult = DialogResult.OK; } } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE) { // 提示信息 MessageBox.Show(Messages.MSG_HR_W009, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO) { // 提示信息 MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE) { // 提示信息 MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工种调整", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { this.btnSave.Enabled = true; this.btnCancel.Enabled = true; // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 取消按钮 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { if (this._staffIDList != null && this._staffIDList.Count > Constant.INT_IS_ZERO) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } #endregion #region 私有方法 /// /// 设置窗体按钮的文本信息 /// private void SetFromTitleInfo() { if (this._editStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_HR_0502_ADD; } else if (this._editStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_HR_0502_EDIT; this.dkUserName.Enabled = false; } this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } /// /// 验证输入格式是否正确 /// /// private bool CheckInputValidity() { // 验证员工信息是否录入; if (string.IsNullOrEmpty(this.dkUserName.Text.Trim())) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.dkUserName.Focus(); return false; } // 验证调整后工种信息是否录入; if (string.IsNullOrEmpty(this.dkTargetobs.Text.Trim())) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整后工种"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.dkTargetobs.Focus(); return false; } // 验证申请人信息是否录入; if (string.IsNullOrEmpty(this.dkUserApplicant.Text.Trim())) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请人"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.dkUserApplicant.Focus(); return false; } // 验证申请原因是否录入; if (string.IsNullOrEmpty(this.txtReason.Text.Trim())) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请原因"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.txtReason.Focus(); return false; } // 验证部门意见是否录入; if (string.IsNullOrEmpty(this.txtSuggestion.Text.Trim())) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请原因"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.txtSuggestion.Focus(); return false; } // 验证调整后工种不能和调整前一样 if (this._originalJobs == this.dkTargetobs.JobsID) { MessageBox.Show(string.Format(Messages.MSG_CMN_W018, "调整后工种", "调整前工种"), this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1); this.dkTargetobs.Focus(); return false; } return true; } /// /// 根据页面输入值,给员工对象实体赋值 /// /// private StaffRecordEntity SetStaffRecordEntity() { StaffRecordEntity staffRecordEntity = new StaffRecordEntity(); staffRecordEntity.StaffID = this.dkUserName.UserID.Value; staffRecordEntity.StaffCode = this.txtStaffCode.Text.Trim(); staffRecordEntity.RecordType = Convert.ToInt32(Constant.StaffRecordType.AdjustJob); staffRecordEntity.ApprovalStatus = Convert.ToInt32(Constant.ApprovalStatus.Pending); if (this._editStatus == Constant.FormMode.Add) { staffRecordEntity.OriginalOrganizationID = this.dkUserName.StaffEntity.OrganizationID; staffRecordEntity.OriginalStaffStatus = this.dkUserName.StaffEntity.StaffStatus; staffRecordEntity.OriginalUserID = this.dkUserName.StaffEntity.UserID; staffRecordEntity.OriginalJobs = this._originalJobs; } if (this.chkProbation.Checked) { staffRecordEntity.TargetStaffStatus = Convert.ToInt32(Constant.StaffStatus.Trial); staffRecordEntity.ExProbationEndDate = this.dtpExProbationEndDate.Value; } else { staffRecordEntity.TargetStaffStatus = chkProbation.Checked ? 1 : 2; //staffRecordEntity.OriginalStaffStatus; } staffRecordEntity.TargetOrganizationID = staffRecordEntity.OriginalOrganizationID; staffRecordEntity.TargetJobs = this.dkTargetobs.JobsID.Value; staffRecordEntity.Applicant = this.dkUserApplicant.UserID.Value; staffRecordEntity.RecordDate = this.dtpApplicationTime.Value; staffRecordEntity.Reason = this.txtReason.Text.Trim(); staffRecordEntity.Suggestion = this.txtSuggestion.Text.Trim(); staffRecordEntity.Remarks = this.txtRemarks.Text.Trim(); if (this._rOPTimeStamp != null) { staffRecordEntity.OPTimeStamp = this._rOPTimeStamp.Value; } staffRecordEntity.StaffRecordID = this._staffRecordID; // MODIFY 工种调整直接审批通过 BY 付斌 2018-3-31 staffRecordEntity.ApprovalStatus = 3; return staffRecordEntity; } /// /// 清空输入项 /// private void InitializationForm() { this.dkUserName.Text = ""; this.dkUserName.UserRow = null; this.txtStaffCode.Text = ""; this.txtOrganizationID.Text = ""; this.txtJobs.Text = ""; this.dkTargetobs.Text = ""; this.dkUserApplicant.Text = ""; this.dtpExProbationEndDate.Value = DateTime.Now; this.dtpApplicationTime.Value = DateTime.Now; this.txtReason.Text = ""; this.txtSuggestion.Text = ""; this.txtRemarks.Text = ""; } /// /// 添加员工档案 /// /// private HRResultEntity SaveStaffInfo() { try { if (this._editStatus == Constant.FormMode.Add) { return HRModuleProxy.Service.SaveTargetJobInfo(this._staffRecordEntity, WCFConstant.FormMode.Add); } else if (this._editStatus == Constant.FormMode.Edit) { return HRModuleProxy.Service.SaveTargetJobInfo(this._staffRecordEntity, WCFConstant.FormMode.Edit); } return new HRResultEntity(); } catch (Exception ex) { throw ex; } } /// /// 根据查询条件获取要显示的数据 /// /// 返回查询的结果集 private DataSet GetDataGridViewInfo() { try { SearchStaffEntity searchStaffEntity = new SearchStaffEntity(); searchStaffEntity.StaffID = this._userId; searchStaffEntity.RStaffRecordID = this._staffRecordID; return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity); } catch (Exception ex) { throw ex; } } #endregion } }