/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_HR_0302.cs * 2.功能描述:新建/编辑员工转正 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2014/09/19 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; using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService; namespace Dongke.IBOSS.PRD.Client.HRModule { /// /// 新建/编辑员工转正 /// public partial class F_HR_0302 : FormBase { #region 成员变量 // 页面传过来员工ID private int _staffID; // 页面传过来员工编码 private string _staffCode; // 性别 private string _gender; // 婚姻情况 private string _maritalstatus; // 民族 private string _nationalname; // 学历 private string _educational; // 编辑状态 private Constant.FormMode _editStatus; // 新建的员工ID集合 private List _staffIDList = new List(); // 时间戳 private DateTime _optimestamp; //组织机构 private string _organizationcode; // 员工履历实体类 private StaffRecordEntity _staffRecordEntity; // 员工履历表ID private int _staffrecordID; #endregion #region 属性 /// /// 页面传过来的员工ID /// public int StaffID { get { return this._staffID; } set { this._staffID = value; } } /// /// 页面传过来的员工ID /// public string StaffCode { get { return this._staffCode; } set { this._staffCode = value; } } /// /// 性别 /// public string Gender { get { return this._gender; } set { this._gender = value; } } /// /// 婚姻状况 /// public string MaritalStatus { get { return this._maritalstatus; } set { this._maritalstatus = value; } } /// /// 民族 /// public string NationalName { get { return this._nationalname; } set { this._nationalname = value; } } /// /// 学历 /// public string Educational { get { return this._educational; } set { this._educational = value; } } /// /// 时间戳 /// public DateTime OPTimeStamp { get { return _optimestamp; } set { _optimestamp = value; } } /// /// 当前用户组织机构Code /// public string OrganizationCode { get { return _organizationcode; } set { _organizationcode = value; } } /// /// 员工履历表ID /// public int StaffRecordID { get { return this._staffrecordID; } set { this._staffrecordID = value; } } /// /// 员工ID集合 /// public List StaffIDList { get { return _staffIDList; } set { _staffIDList = value; } } #endregion #region 构造函数 /// /// 构造函数 /// /// 窗体状态 /// 员工档案编号 /// 员工履历编号 public F_HR_0302(Constant.FormMode frmStatus, int pStaffId, int pStaffRecordID) { InitializeComponent(); this._editStatus = frmStatus; this._staffID = pStaffId; this._staffrecordID = pStaffRecordID; this.dkStaffName.WhereCondition = "StaffStatus =1 and ValueFlag=1";//筛选适用的员工 this.dkUserApplicant.WhereCondition = "(StaffStatus = 1 OR StaffStatus = 2) and ValueFlag = 1"; this.SetFromTitleInfo(); } #endregion #region 事件 /// /// 窗体加载事件 /// /// /// private void F_HR_0302_Load(object sender, EventArgs e) { try { FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); #region 获取员工履历表数据, 编辑的时候去查,新增的时候不会调用 if (_editStatus == Constant.FormMode.Edit) { // 获取用户信息数据集 DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo)); if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO) { this.dkStaffName.StaffEntity.ExProbationEndDate = null; this.dkStaffName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]); this.dkStaffName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim(); this.dkStaffName.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.dkStaffName.StaffEntity); } } 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.txtOrganization.Text = staffInfoData.Tables[0].Rows[0]["SOrganizationname"].ToString().Trim(); this.txtUser.Text = staffInfoData.Tables[0].Rows[0]["SUserCode"].ToString().Trim(); this.txtJobs.Text = staffInfoData.Tables[0].Rows[0]["SJobsname"].ToString().Trim(); this.txtPost.Text = staffInfoData.Tables[0].Rows[0]["SPostname"].ToString().Trim(); this.txtPause.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim(); this.txtSuggestion.Text = staffInfoData.Tables[0].Rows[0]["Suggestion"].ToString().Trim(); this.txtRecordRemarks.Text = staffInfoData.Tables[0].Rows[0]["RRemarks"].ToString().Trim(); string ExProbationEndDate = staffInfoData.Tables[0].Rows[0]["ExProbationEndDate"].ToString(); if (ExProbationEndDate != "") { lblExProbationEndDateValue.Text = staffInfoData.Tables[0].Rows[0]["ExProbationEndDate"].ToString(); } this.OPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["ROPTimeStamp"]); string ApprovalStatus = staffInfoData.Tables[0].Rows[0]["ApprovalStatus"].ToString(); if (!"0".Equals(ApprovalStatus))//非待审批 { //设置非待审核的履历控件禁用 SetControlEnable(); } } else //设置非待审核的履历控件禁用 SetControlEnable(); } #endregion } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 员工选择事件 /// /// /// private void dkStaffName_UserValueChanged(object sender, Controls.dkStaffSearchBox.TextChangeEventArgs e) { if (this.dkStaffName.UserID != null) { this.txtOrganization.Text = this.dkStaffName.StaffEntity.OrganizationName; this.txtUser.Text = this.dkStaffName.StaffEntity.UserCode; this.txtJobs.Text = this.dkStaffName.StaffEntity.JobsName; this.txtPost.Text = this.dkStaffName.StaffEntity.PostName; this.dkUserApplicant.UserID = this.dkStaffName.UserID; this.dkUserApplicant.UserCode = this.dkStaffName.UserCode; this.dkUserApplicant.UserName = this.dkStaffName.UserName; this.dkUserApplicant.StaffEntity = this.dkStaffName.StaffEntity; if (this.dkStaffName.StaffEntity.ExProbationEndDate != null) { lblExProbationEndDateValue.Text = this.dkStaffName.StaffEntity.ExProbationEndDate.Value.ToString("yyyy-MM-dd"); } } } /// /// 取消按钮 /// /// /// 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 (!this.CheckInputValidity()) { return; } this._staffRecordEntity = this.SetStaffRecordEntity();//获取员工履历实体 if (this._editStatus == Constant.FormMode.Add) { // 新建员工转正 this.btnSave.Enabled = false; this.btnCancel.Enabled = false; _staffRecordEntity.TargetStaffStatus = 2; HRResultEntity returnStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(this.AddStaffRecord)); 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();//清空输入项 } 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); } } else { // 编辑员工入职 this.btnSave.Enabled = false; this.btnCancel.Enabled = false; _staffRecordEntity.StaffRecordID = StaffRecordID; HRResultEntity returnStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(this.EditStaffRecord)); 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();//清空输入项 } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W006, "编辑员工转正", "保存"), 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); } } #endregion #region 私有方法 /// /// 设置窗体按钮的文本信息 /// private void SetFromTitleInfo() { // 设置窗口标题,当为新建状态时显示新建员工,当为编辑状态时显示编辑员工 if (_editStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_HR_0302_ADD; } else if (_editStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_HR_0302_EDIT; } // 工具栏按钮文本赋值 this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } /// /// 根据查询条件获取要显示的数据 /// /// 返回查询的结果集 private DataSet GetDataGridViewInfo() { SearchStaffEntity searchStaffEntity = new SearchStaffEntity(); searchStaffEntity.StaffID = this._staffID; searchStaffEntity.RStaffRecordID = this._staffrecordID; return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity); } /// /// 验证输入格式是否正确 /// /// private bool CheckInputValidity() { //入职员工 if (this.dkStaffName.UserID == null) { this.dkStaffName.Focus(); return false; } if (this.txtPause.Text.Trim() == string.Empty) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请原因"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtPause.Focus(); return false; } if (this.txtSuggestion.Text.Trim() == string.Empty) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.txtSuggestion.Focus(); return false; } //判断员工是否已经申请 SearchStaffEntity searchStaffEntity = new SearchStaffEntity(); searchStaffEntity.StaffCode = this.dkStaffName.UserCode; searchStaffEntity.StaffName = this.dkStaffName.UserName; searchStaffEntity.Recordtype = Constant.StaffRecordType.Positive.GetHashCode(); //2:转正 searchStaffEntity.RValueflag = Constant.ValueFlag.Effective.GetHashCode(); //1:正常 DataSet dsUser = HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity); if (dsUser != null && dsUser.Tables[Constant.INT_IS_ZERO].Rows.Count > 0) { MessageBox.Show(string.Format(Messages.MSG_HR_W006, "申请转正","员工"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dkStaffName.Focus(); return false; } return true; } /// /// 根据页面输入值,给员工对象实体赋值 /// /// private StaffRecordEntity SetStaffRecordEntity() { StaffRecordEntity staffRecordEntity = new StaffRecordEntity(); //员工ID staffRecordEntity.StaffID = Convert.ToInt32(this.dkStaffName.UserID); //员工Code staffRecordEntity.StaffCode = this.dkStaffName.UserCode; //履历类别 2转正 staffRecordEntity.RecordType = Constant.StaffRecordType.Positive.GetHashCode(); //如果实习,添加预结束实习日期 if (lblExProbationEndDateValue.Text != string.Empty) { staffRecordEntity.ExProbationEndDate = Convert.ToDateTime(lblExProbationEndDateValue.Text); } //履历日期 staffRecordEntity.RecordDate = DateTime.Now; //原工号 staffRecordEntity.OriginalUserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID; //原工号编码 staffRecordEntity.OriginalUserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode; //原员工状态 0未入职 staffRecordEntity.OriginalStaffStatus = 0; //原工种 staffRecordEntity.OriginalJobs = Convert.ToInt32(this.dkStaffName.StaffEntity.Jobs); //所属部门 staffRecordEntity.OriginalOrganizationID = Convert.ToInt32(this.dkStaffName.StaffEntity.OrganizationID); //原职务 staffRecordEntity.OriginalPost = Convert.ToInt32(this.dkStaffName.StaffEntity.Post); //调整后的工号 staffRecordEntity.TargetUserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID; //调整后工号编码 staffRecordEntity.TargetUserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode; //调整后员工状态 0未入职 staffRecordEntity.TargetStaffStatus = 0; //调整后工种 staffRecordEntity.TargetJobs = Convert.ToInt32(this.dkStaffName.StaffEntity.Jobs); //调整后所属部门 staffRecordEntity.TargetOrganizationID = Convert.ToInt32(this.dkStaffName.StaffEntity.OrganizationID); //调整后职务 staffRecordEntity.TargetPost = Convert.ToInt32(this.dkStaffName.StaffEntity.Post); //申请原因 staffRecordEntity.Reason = txtPause.Text.Trim(); //审批状态0 待审批 // MODIFY 员工转正直接审批通过 BY 付斌 2018-3-31 staffRecordEntity.ApprovalStatus = 3; //部门原因 staffRecordEntity.Suggestion = txtSuggestion.Text; //有效标识 staffRecordEntity.ValueFlag = 1; //时间戳 staffRecordEntity.OPTimeStamp = OPTimeStamp; //申请人 staffRecordEntity.Applicant = this.dkUserApplicant.UserID.Value; //备注 staffRecordEntity.Remarks = txtRecordRemarks.Text; return staffRecordEntity; } /// /// 添加员工档案 /// /// private HRResultEntity EditStaffRecord() { return HRModuleProxy.Service.EditStaffRecord(_staffRecordEntity); } /// /// 编辑员工档案 /// /// private HRResultEntity AddStaffRecord() { return HRModuleProxy.Service.AddStaffRecord(_staffRecordEntity); } /// /// 清空输入项 /// private void InitializationForm() { this.dkStaffName.UserID = null; this.dkStaffName.UserCode = string.Empty; this.dkStaffName.UserName = string.Empty; this.dkStaffName.StaffEntity = null; this.txtOrganization.Text = string.Empty; this.txtUser.Text = string.Empty; this.txtJobs.Text = string.Empty; this.txtPost.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.txtPause.Text = string.Empty; this.txtSuggestion.Text = string.Empty; this.txtRecordRemarks.Text = string.Empty; this.lblExProbationEndDateValue.Text = string.Empty; } //设置非待审核的履历控件禁用 private void SetControlEnable() { this.dkStaffName.Enabled = false; this.dkUserApplicant.Enabled = false; this.txtPause.Enabled = false; this.txtSuggestion.Enabled = false; this.txtRecordRemarks.Enabled = false; this.btnSave.Enabled = false; } #endregion } }