/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_HR_0402.cs * 2.功能描述:员工离职新建/编辑页面 * 编辑履历: * 作者 日期 版本 修改内容 * 张国印 2014/09/16 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.Basics.Library; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels.HRModule; using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService; namespace Dongke.IBOSS.PRD.Client.HRModule { /// /// 员工离职新建/编辑页面 /// public partial class F_HR_0402 : FormBase { #region 成员变量 // 窗体状态的枚举 新建/编辑 private Constant.FormMode _editStatus; // 要编辑的员工编号 private int _userId; // 员工履历编号 private int _staffRecordID; //员工表的时间戳 private DateTime _sOPTimeStamp; //员工履历表的时间戳 private DateTime? _rOPTimeStamp; // 新建的员工ID集合 private List _staffIDList = new List(); #endregion #region 构造函数 /// /// 构造函数 /// /// 新建/编辑 /// 要编辑的员工编号 public F_HR_0402(Constant.FormMode editStatus, int pUserId, int pStaffRecordID) { InitializeComponent(); this._editStatus = editStatus; this._userId = pUserId; this._staffRecordID = pStaffRecordID; this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1"; this.dkUserApplicant.WhereCondition = "StaffStatus = 2 and ValueFlag = 1"; this.SetFromTitleInfo(); } #endregion #region 属性 /// /// 员工ID集合 /// public List StaffIDList { get { return _staffIDList; } set { _staffIDList = value; } } #endregion #region 事件 /// /// 页面加载事件 /// /// /// private void F_HR_0402_Load(object sender, EventArgs e) { try { FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); if (this._editStatus == Constant.FormMode.Edit) { // 获取用户信息数据集 DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo)); if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { #region 为控件赋值 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(); List staffEntityList = DataConvert.TableConvertToObject(staffInfoData.Tables[0]); if (staffEntityList != null) { if (staffEntityList.Count > Constant.INT_IS_ZERO) { DataConvert.Convert(staffEntityList[0], this.dkUserName.StaffEntity); } } 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]["SJobsname"].ToString().Trim(); this.dkUserApplicant.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["Applicant"]); this.dkUserApplicant.UserCode = staffInfoData.Tables[0].Rows[0]["RApplicantCode"].ToString().Trim(); this.dkUserApplicant.UserName = staffInfoData.Tables[0].Rows[0]["RApplicantName"].ToString().Trim(); this.dtRecordDate.Value = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RecordDate"]); 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._sOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["SOPTIMESTAMP"]); this._rOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["ROPTIMESTAMP"]); this.dkUserName.StaffEntity.OPTimeStamp = _sOPTimeStamp; string ApprovalStatus = staffInfoData.Tables[0].Rows[0]["ApprovalStatus"].ToString(); if (!"0".Equals(ApprovalStatus))//非待审批 { //设置非待审核的履历控件禁用 this.SetControlEnable(); } #endregion } else { //设置非待审核的履历控件禁用 this.SetControlEnable(); } } } 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) { if (this.dkUserName.UserID != null) { this.txtStaffCode.Text = this.dkUserName.StaffEntity.StaffCode; this.txtOrganizationID.Text = this.dkUserName.StaffEntity.OrganizationName; this.txtJobs.Text = this.dkUserName.StaffEntity.JobsName; this._sOPTimeStamp = this.dkUserName.StaffEntity.OPTimeStamp; this._userId = this.dkUserName.UserID.Value; this.dkUserApplicant.UserID = this.dkUserName.UserID; this.dkUserApplicant.UserCode = this.dkUserName.UserCode; this.dkUserApplicant.UserName = this.dkUserName.UserName; this.dkUserApplicant.StaffEntity = this.dkUserName.StaffEntity; } } /// /// 取消按钮 /// /// /// private void btnCancel_Click(object sender, EventArgs e) { if (this._staffIDList != null && this._staffIDList.Count > 0) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } /// /// 保存按钮 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { if (IsInputValid()) { StaffRecordEntity tempRecord = SetStaffRecordEntity(); HRResultEntity resultStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(() => { if (_editStatus == Constant.FormMode.Add) { return WCF.Proxys.HRModuleProxy.Service.SaveStaffRecordDimission(_userId, _sOPTimeStamp, tempRecord, WCFConstant.FormMode.Add); } else if (_editStatus == Constant.FormMode.Edit) { return WCF.Proxys.HRModuleProxy.Service.SaveStaffRecordDimission(_userId, _sOPTimeStamp, tempRecord, WCFConstant.FormMode.Edit); } return 0; })); //0 没有数据被修改 -1员工档案被其他用户修改 -2存在待审批履历 -3员工履历被其他用户修改 if (resultStaff.OperateStatus > Constant.INT_IS_ZERO) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this._staffIDList.Add(resultStaff.HRStaffRecordID); this.InitializationForm();//清空输入项 } else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE) { // 提示信息 MessageBox.Show(Messages.MSG_HR_W009, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO) { // 提示信息 MessageBox.Show(Messages.MSG_CMN_W012, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (resultStaff.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) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私用方法 /// /// 设置窗体按钮的文本信息 /// private void SetFromTitleInfo() { if (this._editStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_HR_0402_ADD; this.dkUserName.Enabled = true; this._rOPTimeStamp = null; } else if (this._editStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_HR_0402_EDIT; this.dkUserName.Enabled = false; } this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } /// /// 根据查询条件获取要显示的数据 /// /// 返回查询的结果集 private DataSet GetDataGridViewInfo() { SearchStaffEntity searchStaffEntity = new SearchStaffEntity(); searchStaffEntity.StaffID = this._userId; searchStaffEntity.RStaffRecordID = this._staffRecordID; return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity); } /// /// 检查页面的输入项目 /// /// /// /// private bool IsInputValid() { // 员工姓名输入值 if (this.dkUserName.UserID == null) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return false; } else if (this.dkUserApplicant.UserID == null) { //申请人输入值 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请人"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return false; } else if (string.IsNullOrEmpty(this.txtReason.Text.Trim())) { //申请人输入值 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "离职原因"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return false; } else if (string.IsNullOrEmpty(this.txtSuggestion.Text.Trim())) { //申请人输入值 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return false; } else { return true; } } /// /// 根据页面输入值,给员工对象实体赋值 /// /// private StaffRecordEntity SetStaffRecordEntity() { int intUserID = this.dkUserName.UserID.Value; int intApplicantID = this.dkUserApplicant.UserID.Value; DateTime dtRecordDate = this.dtRecordDate.Value; string strReason = this.txtReason.Text.Trim(); string strSuggestion = this.txtSuggestion.Text.Trim(); string strRemarks = this.txtRemarks.Text.Trim(); StaffRecordEntity staffRecordEntity = new StaffRecordEntity(); //履历表主键 staffRecordEntity.StaffRecordID = _staffRecordID; //员工ID staffRecordEntity.StaffID = intUserID; //履历日期 staffRecordEntity.RecordDate = dtRecordDate; //申请原因 staffRecordEntity.Reason = strReason; //部门意见 staffRecordEntity.Suggestion = strSuggestion; //备注 staffRecordEntity.Remarks = strRemarks; //申请人 staffRecordEntity.Applicant = intApplicantID; if (this._rOPTimeStamp != null) { //员工履历表的时间戳 staffRecordEntity.OPTimeStamp = this._rOPTimeStamp.Value; } staffRecordEntity.RecordType = Constant.StaffRecordType.Departure.GetHashCode(); staffRecordEntity.OriginalUserID = this.dkUserName.StaffEntity.UserID; staffRecordEntity.OriginalUserCode = this.dkUserName.StaffEntity.UserCode; staffRecordEntity.TargetUserID = this.dkUserName.StaffEntity.UserID; staffRecordEntity.TargetUserCode = this.dkUserName.StaffEntity.UserCode; // MODIFY 员工转正直接审批通过 BY 付斌 2018-3-31 staffRecordEntity.ApprovalStatus = 3; return staffRecordEntity; } /// /// 清空输入项 /// private void InitializationForm() { this.dkUserName.UserID = null; this.dkUserName.UserCode = string.Empty; this.dkUserName.UserName = string.Empty; this.dkUserName.StaffEntity = null; this.txtStaffCode.Text = string.Empty; this.txtOrganizationID.Text = string.Empty; this.txtJobs.Text = string.Empty; this.dkUserApplicant.UserID = null; this.dkUserApplicant.UserCode = string.Empty; this.dkUserApplicant.UserName = string.Empty; this.dkUserApplicant.StaffEntity = null; this.dtRecordDate.Value = DateTime.Now; this.txtReason.Text = string.Empty; this.txtSuggestion.Text = string.Empty; this.txtRemarks.Text = string.Empty; } //设置非待审核的履历控件禁用 private void SetControlEnable() { this.dkUserName.Enabled = false; this.dkUserApplicant.Enabled = false; this.dtRecordDate.Enabled = false; this.txtReason.Enabled = false; this.txtSuggestion.Enabled = false; this.txtRemarks.Enabled = false; this.btnSave.Enabled = false; } #endregion } }