| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- /*******************************************************************************
- * 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
- {
- /// <summary>
- /// 员工离职新建/编辑页面
- /// </summary>
- 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<int> _staffIDList = new List<int>();
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="editStatus">新建/编辑</param>
- /// <param name="pUserId">要编辑的员工编号</param>
- 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 属性
- /// <summary>
- /// 员工ID集合
- /// </summary>
- public List<int> StaffIDList
- {
- get
- {
- return _staffIDList;
- }
- set
- {
- _staffIDList = value;
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 页面加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<DKStaffEntity> staffEntityList = DataConvert.TableConvertToObject<DKStaffEntity>(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);
- }
- }
- /// <summary>
- /// 用户选择控件值改变时事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 取消按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 私用方法
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- 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;
- }
- /// <summary>
- /// 根据查询条件获取要显示的数据
- /// </summary>
- /// <returns>返回查询的结果集</returns>
- private DataSet GetDataGridViewInfo()
- {
- SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
- searchStaffEntity.StaffID = this._userId;
- searchStaffEntity.RStaffRecordID = this._staffRecordID;
- return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
- }
- /// <summary>
- /// 检查页面的输入项目
- /// </summary>
- /// <remarks>
- /// </remarks>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- /// 根据页面输入值,给员工对象实体赋值
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 清空输入项
- /// </summary>
- 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
- }
- }
|