/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_HR_0202.cs * 2.功能描述:新建/编辑员工入职 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2014/09/12 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.Client.DataModels; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService; namespace Dongke.IBOSS.PRD.Client.HRModule { /// /// 新建/编辑员工入职 /// public partial class F_HR_0202 : 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; // 图片字节集 private List _PicByte = new List(); // 缩略图节集 private List _smallByte = new List(); // 图片实体集合 private List _imgList = new List(); #endregion #region 构造函数 public F_HR_0202() { InitializeComponent(); } /// /// 构造函数 /// /// 窗体状态 public F_HR_0202(Constant.FormMode frmStatus) { InitializeComponent(); _editStatus = frmStatus; this.dkStaffName.WhereCondition = "StaffStatus in(0,3) and ValueFlag=1"; this.dkApplicant.WhereCondition = "StaffStatus in(0,3) and ValueFlag=1"; // 设置窗口标题,当为新建状态时显示新建员工,当为编辑状态时显示编辑员工 if (frmStatus == Constant.FormMode.Add) { this.Text = FormTitles.F_HR_0202_ADD; } else if (frmStatus == Constant.FormMode.Edit) { this.Text = FormTitles.F_HR_0202_EDIT; } // 工具栏按钮文本赋值 this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } #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 事件 /// /// 窗体加载事件 /// /// /// private void F_HR_0104_Load(object sender, EventArgs e) { try { // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); #region 绑定工种职务数据源 this.dropJobs.DisplayMember = "JOBSNAME"; this.dropJobs.ValueMember = "JOBSID"; this.dropJobs.DataSource = (DataTable)DoAsync(new BaseAsyncMethod(this.GetJobsData)); this.droppost.DisplayMember = "POSTNAME"; this.droppost.ValueMember = "POSTID"; this.droppost.DataSource = (DataTable)DoAsync(new BaseAsyncMethod(this.GetPostData)); #endregion #region 获取员工履历表数据, 编辑的时候去查,新增的时候不会调用 if (this._editStatus == Constant.FormMode.Edit) { DataSet dsStaffRecord = (DataSet)DoAsync(new BaseAsyncMethod(this.GetStaffRecorsRowData)); if (dsStaffRecord != null && dsStaffRecord.Tables[0].Rows.Count > Constant.INT_IS_ZERO) { this.dkStaffName.UserID = Convert.ToInt32(dsStaffRecord.Tables[0].Rows[0]["StaffID"]); this.dkStaffName.UserCode = dsStaffRecord.Tables[0].Rows[0]["StaffCode"].ToString(); this.dkStaffName.Text = dsStaffRecord.Tables[0].Rows[0]["StaffName"].ToString(); //this.dkOrganizationSearch.Text = dsStaffRecord.Tables[0].Rows[0]["organizationname"].ToString(); //this.dkOrganizationSearch.OrganizationID = Convert.ToInt32(dsStaffRecord.Tables[0].Rows[0]["OriginalOrganizationID"]); scbOrganization.InitValue(dsStaffRecord.Tables[0].Rows[0]["organizationname"].ToString().Trim() , Convert.ToInt32(dsStaffRecord.Tables[0].Rows[0]["OriginalOrganizationID"])); this.dropJobs.SelectedValue = dsStaffRecord.Tables[0].Rows[0]["OriginalJobs"].ToString(); this.droppost.SelectedValue = dsStaffRecord.Tables[0].Rows[0]["OriginalPost"].ToString(); this.txtPause.Text = dsStaffRecord.Tables[0].Rows[0]["Reason"].ToString(); this.txtSuggestion.Text = dsStaffRecord.Tables[0].Rows[0]["Suggestion"].ToString(); string ExProbationEndDate = dsStaffRecord.Tables[0].Rows[0]["ExProbationEndDate"].ToString(); this.OPTimeStamp = Convert.ToDateTime(dsStaffRecord.Tables[0].Rows[0]["OPTimeStamp"]); if (ExProbationEndDate != string.Empty) { chkExProbationEndDate.Checked = true; dateExProbationEndDate.Value = Convert.ToDateTime(dsStaffRecord.Tables[0].Rows[0]["ExProbationEndDate"]); } this.txtRecordRemarks.Text = dsStaffRecord.Tables[0].Rows[0]["Remarks"].ToString(); this.dkApplicant.Text = dsStaffRecord.Tables[0].Rows[0]["ApplicantName"].ToString(); this.dkApplicant.UserID = Convert.ToInt32(dsStaffRecord.Tables[0].Rows[0]["Applicant"]); string ApprovalStatus = dsStaffRecord.Tables[0].Rows[0]["ApprovalStatus"].ToString(); if (ApprovalStatus != Constant.INT_IS_ZERO.ToString())//非待审批 { //设置非待审核的履历控件禁用 SetControlEnable(); } } else { //设置非待审核的履历控件禁用 SetControlEnable(); } } #endregion } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 试用选择按钮事件 /// /// /// private void chkExProbationEndDate_CheckedChanged(object sender, EventArgs e) { if (chkExProbationEndDate.Checked) { dateExProbationEndDate.Enabled = true; } else { dateExProbationEndDate.Enabled = false; } } /// /// 保存按钮事件 /// /// /// 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; 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.Close(); 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(string.Format(Messages.MSG_HR_W007, "新建员工入职", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W007, "新建员工入职", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_FOUR) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W008, "预试用结束日期"), 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; this._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.DialogResult = DialogResult.OK; this.Close(); } 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(string.Format(Messages.MSG_HR_W007, "编辑员工入职", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W007, "编辑员工入职", "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_FOUR) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_HR_W008, "预试用结束日期"), 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 > 0) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } #endregion #region 私有方法 /// /// 获取员工基本数据 /// /// private DataSet GetRowData() { DataSet returnRowData = null; try { returnRowData = HRModuleProxy.Service.GetRowData(StaffID); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returnRowData; } /// /// 获取工种数据 /// /// private DataTable GetJobsData() { DataTable returntJobsData = null; try { returntJobsData = SystemModuleProxy.Service.GetJobsData(0).Tables[0]; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returntJobsData; } /// /// 获取职务数据 /// /// private DataTable GetPostData() { DataTable returntPostData = null; try { returntPostData = SystemModuleProxy.Service.GetPostData(0).Tables[0]; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returntPostData; } /// /// 获取当前职工基本数据 /// /// private DataSet GetUserRowData() { DataSet returntUserRowData = null; try { returntUserRowData = SystemModuleProxy.Service.GetUserRowData(LogInUserInfo.CurrentUser.CurrentUserEntity.UserID); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returntUserRowData; } /// /// 获取当前职工履历基本数据 /// /// private DataSet GetStaffRecorsRowData() { DataSet returntStaffRecorsRowData = null; try { returntStaffRecorsRowData = HRModuleProxy.Service.GetStaffRecorsRowData(StaffRecordID); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returntStaffRecorsRowData; } /// /// 验证输入格式是否正确 /// /// private bool CheckInputValidity() { //入职员工 if (this.dkStaffName.UserID == null) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dkStaffName.Focus(); return false; } //所属部门 if (this.scbOrganization.SearchedPKMember == 0) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "所属部门"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.scbOrganization.Focus(); return false; } //申请人 if (this.dkStaffName.UserID == null) { if (this.dkApplicant.UserID == null) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请人"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dkApplicant.Focus(); return false; } } //工号 //if (this.dkOriginalUserCode.UserID == null) //{ // this.dkOriginalUserCode.Focus(); // return false; //} //工种 if (this.dropJobs.SelectedValue == null || this.dropJobs.SelectedValue.ToString() == string.Empty) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工种"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.dropJobs.Focus(); return false; } //职务 if (this.droppost.SelectedValue == null || this.droppost.SelectedValue.ToString() == string.Empty) { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "职务"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); this.droppost.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; } return true; } /// /// 根据页面输入值,给员工对象实体赋值 /// /// private StaffRecordEntity SetStaffRecordEntity() { StaffRecordEntity staffRecordEntity = new StaffRecordEntity(); //员工ID staffRecordEntity.StaffID = Convert.ToInt32(this.dkStaffName.UserID); //员工Code staffRecordEntity.StaffCode = this.dkStaffName.UserCode; ; //履历类别 1入职 staffRecordEntity.RecordType = 1; //如果实习,添加预结束实习日期 if (chkExProbationEndDate.Checked) staffRecordEntity.ExProbationEndDate = Convert.ToDateTime(dateExProbationEndDate.Value.ToString("yyyy-MM-dd")); //履历日期 staffRecordEntity.RecordDate = DateTime.Now; //原工号 //staffRecordEntity.OriginalUserID =this.dkOriginalUserCode.UserID; //原工号编码 //staffRecordEntity.OriginalUserCode = this.dkOriginalUserCode.UserCode; //原员工状态 0未入职 staffRecordEntity.OriginalStaffStatus = 0; //原工种 staffRecordEntity.OriginalJobs = Convert.ToInt32(dropJobs.SelectedValue); //所属部门 staffRecordEntity.OriginalOrganizationID = scbOrganization.SearchedPKMember; //原职务 staffRecordEntity.OriginalPost = Convert.ToInt32(droppost.SelectedValue); //调整后的工号 staffRecordEntity.TargetUserID = this.dkOriginalUserCode.UserID; //调整后工号编码 staffRecordEntity.TargetUserCode = this.dkOriginalUserCode.UserCode; //调整后员工状态 0未入职 staffRecordEntity.TargetStaffStatus = chkExProbationEndDate.Checked ? 1 : 2; //调整后工种 staffRecordEntity.TargetJobs = Convert.ToInt32(dropJobs.SelectedValue); //调整后所属部门 staffRecordEntity.TargetOrganizationID = scbOrganization.SearchedPKMember; //调整后职务 staffRecordEntity.TargetPost = Convert.ToInt32(droppost.SelectedValue); //申请原因 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 = Convert.ToInt32(this.dkApplicant.UserID == null ? this.dkStaffName.UserID : this.dkApplicant.UserID); //备注 staffRecordEntity.Remarks = txtRecordRemarks.Text; return staffRecordEntity; } /// /// 添加员工档案 /// /// private HRResultEntity EditStaffRecord() { try { return HRModuleProxy.Service.EditStaffRecord(_staffRecordEntity); } catch (Exception ex) { throw ex; } } /// /// 编辑员工档案 /// /// private HRResultEntity AddStaffRecord() { try { return HRModuleProxy.Service.AddStaffRecord(_staffRecordEntity); } catch (Exception ex) { throw ex; } } /// /// 清空输入项 /// private void InitializationForm() { this.scbOrganization.ClearValue(); this.txtPause.Text = ""; this.dropJobs.Text = ""; this.dropJobs.SelectedValue = null; this.dropJobs.SelectedText = null; this.droppost.Text = ""; this.droppost.SelectedValue = null; this.droppost.SelectedText = null; this.chkExProbationEndDate.Checked = false; this.txtSuggestion.Text = ""; this.dkStaffName.UserID = null; this.dkApplicant.UserID = null; this.txtRecordRemarks.Text = ""; } //设置非待审核的履历控件禁用 private void SetControlEnable() { this.scbOrganization.Enabled = false; this.dropJobs.Enabled = false; this.droppost.Enabled = false; this.txtPause.Enabled = false; this.txtSuggestion.Enabled = false; this.chkExProbationEndDate.Enabled = false; this.btnSave.Enabled = false; } /// /// 获取员工图片 /// /// private DataSet GetImageByStaffId() { DataSet returnImageByStaffId = null; try { returnImageByStaffId = HRModuleProxy.Service.GetImageByStaffId(StaffID); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } return returnImageByStaffId; } #endregion } }