| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- /*******************************************************************************
- * Copyright(c) 2014 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_HR_0602.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.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
- {
- /// <summary>
- /// 职务调整窗体
- /// </summary>
- public partial class F_HR_0602 : FormBase
- {
- #region 成员变量
- // 窗体状态的枚举 新建/编辑
- private Constant.FormMode _editStatus;
- // 要编辑的员工编号
- private int _userId;
- // 调整前职务ID
- private int _originalPost;
- // 页面传过来员工ID
- private int _staffRecordID;
- // 用户履历实体类
- private StaffRecordEntity _staffRecordEntity;
- // 员工时间戳
- private DateTime _optimestamp;
- // 员工履历表的时间戳
- 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_0602(Constant.FormMode editStatus, int pUserId, int pStaffRecordID)
- {
- InitializeComponent();
- this._editStatus = editStatus;
- this._userId = pUserId;
- this._staffRecordID = pStaffRecordID;
- this.SetFromTitleInfo();
- }
- #endregion
- #region 属性
- /// <summary>
- /// 页面传过来的员工ID
- /// </summary>
- public int StaffRecordID
- {
- get
- {
- return this._staffRecordID;
- }
- set
- {
- this._staffRecordID = value;
- }
- }
- /// <summary>
- /// 时间戳
- /// </summary>
- public DateTime OPTimeStamp
- {
- get
- {
- return _optimestamp;
- }
- set
- {
- _optimestamp = value;
- }
- }
- /// <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_0602_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.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]["SJobsname"].ToString().Trim();
- this.txt_OriginalPost.Text = staffInfoData.Tables[0].Rows[0]["ROriginalPostName"].ToString().Trim();
- this._originalPost = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["OriginalPost"]);
- this.dkPostName.PostID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetPost"]);
- this.dkPostName.PostName = staffInfoData.Tables[0].Rows[0]["RTargetPostName"].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"]);
- this.dtpApplicationTime.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._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);
- }
- }
- /// <summary>
- /// 用户选择控件值改变时事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dkUserName_UserValueChanged(object sender, Controls.dkStaffSearchBox.TextChangeEventArgs e)
- {
- 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.txt_OriginalPost.Text = this.dkUserName.StaffEntity.PostName;
- this._optimestamp = this.dkUserName.StaffEntity.OPTimeStamp;
- this._originalPost = this.dkUserName.StaffEntity.Post;
- }
- }
- /// <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 (!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);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- if (this._editStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_HR_0602_ADD;
- }
- else if (this._editStatus == Constant.FormMode.Edit)
- {
- this.Text = FormTitles.F_HR_0602_EDIT;
- this.dkUserName.Enabled = false;
- }
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- /// <summary>
- /// 验证输入格式是否正确
- /// </summary>
- /// <returns></returns>
- 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.dkPostName.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整后职务"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.dkPostName.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 (this._originalPost == this.dkPostName.PostID)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W018, "调整后职务", "调整前职务"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.dkPostName.Focus();
- return false;
- }
- if (this.txtReason.Text.Trim() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整原因"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtReason.Focus();
- return false;
- }
- if (this.txtSuggestion.Text.Trim() == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"),
- this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
- this.txtSuggestion.Focus();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 根据页面输入值,给员工对象实体赋值
- /// </summary>
- /// <returns></returns>
- 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.AdjustPost);
- staffRecordEntity.ApprovalStatus = Constant.INT_IS_ZERO;
- if (this._editStatus == Constant.FormMode.Add)
- {
- staffRecordEntity.OriginalOrganizationID = this.dkUserName.StaffEntity.OrganizationID;
- staffRecordEntity.OriginalStaffStatus = this.dkUserName.StaffEntity.StaffStatus;
- staffRecordEntity.OriginalPost = this._originalPost;
- }
- staffRecordEntity.TargetOrganizationID = staffRecordEntity.OriginalOrganizationID;
- staffRecordEntity.TargetStaffStatus = staffRecordEntity.OriginalStaffStatus;
- staffRecordEntity.TargetPost = this.dkPostName.PostID.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();
- staffRecordEntity.OPTimeStamp = _optimestamp;
- staffRecordEntity.StaffRecordID = this._staffRecordID;
- // MODIFY 职务调整直接审批通过 BY 付斌 2018-3-31
- staffRecordEntity.ApprovalStatus = 3;
- return staffRecordEntity;
- }
- /// <summary>
- /// 清空输入项
- /// </summary>
- private void InitializationForm()
- {
- this.dkUserName.Text = "";
- this.txtStaffCode.Text = "";
- this.txtOrganizationID.Text = "";
- this.txtJobs.Text = "";
- this.txt_OriginalPost.Text = "";
- this.dkPostName.Text = "";
- this.dkUserApplicant.Text = "";
- this.dtpApplicationTime.Value = DateTime.Now;
- this.txtReason.Text = "";
- this.txtSuggestion.Text = "";
- this.txtRemarks.Text = "";
- }
- /// <summary>
- /// 添加职务调整
- /// </summary>
- /// <returns></returns>
- private HRResultEntity SaveStaffInfo()
- {
- try
- {
- if (this._editStatus == Constant.FormMode.Add)
- {
- return HRModuleProxy.Service.SaveTargetPostInfo(_staffRecordEntity, WCFConstant.FormMode.Add);
- }
- else if (this._editStatus == Constant.FormMode.Edit)
- {
- return HRModuleProxy.Service.SaveTargetPostInfo(_staffRecordEntity, WCFConstant.FormMode.Edit);
- }
- return new HRResultEntity();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 根据查询条件获取要显示的数据
- /// </summary>
- /// <returns>返回查询的结果集</returns>
- 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
- }
- }
|