| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- /*******************************************************************************
- * Copyright(c) 2014 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_HR_0702.cs
- * 2.功能描述:部门调整新增、修改
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 冯雪 2014/09/18 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_0702 : FormBase
- {
- #region 成员变量
- // 窗体状态的枚举 新建/编辑
- private Constant.FormMode _editStatus;
- // 要编辑的员工编号
- private int _userId;
- // 页面传过来员工ID
- private int _staffRecordID;
- // 用户履历实体类
- private StaffRecordEntity _staffRecordEntity;
- // 员工时间戳
- private DateTime _optimestamp;
- // 调整前部门信息;
- private int _originalOrganization;
- // 调整前工号信息;
- private int _originalUserID;
- // 调整前工种信息;
- private int _originalJobs;
- // 调整前职务ID
- private int _originalPost;
- // 员工履历表的时间戳
- private DateTime? _rOPTimeStamp;
- // 预计试用结束日期
- private DateTime? _rExProbationEndDate;
- // 新建的员工ID集合
- private List<int> _staffIDList = new List<int>();
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="editStatus">新建/编辑</param>
- /// <param name="pUserId">要编辑的员工编号</param>
- public F_HR_0702(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_0702_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._originalOrganization = int.Parse(staffInfoData.Tables[0].Rows[0]["OriginalOrganizationID"].ToString().Trim());
- this.txtJobs.Text = staffInfoData.Tables[0].Rows[0]["ROriginalJobsName"].ToString().Trim();
- this._originalJobs = int.Parse(staffInfoData.Tables[0].Rows[0]["OriginalJobs"].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.dkTargetOrganization.OrganizationID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetOrganizationID"]);
- //this.dkTargetOrganization.OrganizationName = staffInfoData.Tables[0].Rows[0]["RTargetOrganizationName"].ToString().Trim();
- scbTargetOrganization.InitValue(staffInfoData.Tables[0].Rows[0]["RTargetOrganizationName"].ToString().Trim()
- , Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetOrganizationID"]));
- // 如果调整后员工工种信息不为空,为调整后工种赋值
- if (!string.IsNullOrEmpty(staffInfoData.Tables[0].Rows[0]["TargetJobs"].ToString()))
- {
- this.dkTargetJobs.JobsID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetJobs"]);
- this.dkTargetJobs.JobsName = staffInfoData.Tables[0].Rows[0]["RTargetJobsName"].ToString().Trim();
- }
- // 如果调整后员工职务信息不为空,为调整后员工职务赋值
- if (!string.IsNullOrEmpty(staffInfoData.Tables[0].Rows[0]["TargetPost"].ToString()))
- {
- 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"]);
- // 如果调整后员工状态为试用为预计试用期状态赋值
- if (staffInfoData.Tables[0].Rows[0]["TargetStaffStatus"].ToString().Equals(Constant.StaffStatus.Trial.GetHashCode().ToString()))
- {
- this.chkProbation.Checked = true;
- this._rExProbationEndDate = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RExProbationEndDate"]);
- this.dtpExProbationEndDate.Value = this._rExProbationEndDate.Value;
- }
- 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.txtJobs.Text = this.dkUserName.StaffEntity.JobsName;
- this.txt_OriginalPost.Text = this.dkUserName.StaffEntity.PostName;
- this._originalJobs = this.dkUserName.StaffEntity.Jobs;
- this._originalUserID = this.dkUserName.StaffEntity.UserID;
- this._originalPost = this.dkUserName.StaffEntity.Post;
- this._optimestamp = this.dkUserName.StaffEntity.OPTimeStamp;
- this._originalOrganization = this.dkUserName.StaffEntity.OrganizationID;
- if (this.dkUserName.StaffEntity.StaffStatus == Convert.ToInt32(Constant.StaffStatus.Trial))
- {
- this.chkProbation.Checked = true;
- if (this.dkUserName.StaffEntity.ExProbationEndDate != null)
- {
- this.dtpExProbationEndDate.Value = this.dkUserName.StaffEntity.ExProbationEndDate.Value;
- }
- }
- }
- }
- /// <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);
- }
- }
- /// <summary>
- /// 是否试用Changed事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chkProbation_CheckedChanged(object sender, EventArgs e)
- {
- this.dtpExProbationEndDate.Enabled = this.chkProbation.Checked;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 设置窗体按钮的文本信息
- /// </summary>
- private void SetFromTitleInfo()
- {
- if (this._editStatus == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_HR_0702_ADD;
- }
- else if (this._editStatus == Constant.FormMode.Edit)
- {
- this.Text = FormTitles.F_HR_0702_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.scbTargetOrganization.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整后部门"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.scbTargetOrganization.Focus();
- return false;
- }
- // 验证调整后部门不能和调整前一样
- if (this._originalOrganization == this.scbTargetOrganization.SearchedPKMember)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W018, "调整后部门", "调整前部门"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.scbTargetOrganization.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 (string.IsNullOrEmpty(this.txtReason.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请原因"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtReason.Focus();
- return false;
- }
- // 验证部门意见是否录入;
- if (string.IsNullOrEmpty(this.txtSuggestion.Text.Trim()))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtSuggestion.Focus();
- return false;
- }
- //// 验证调整后工种不能和调整前一样
- //if (this._originalJobs == this.dkTargetJobs.JobsID)
- //{
- // MessageBox.Show(string.Format(Messages.MSG_CMN_W018, "调整后工种", "调整前工种"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- // this.dkTargetJobs.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.AdjustOrganization);
- staffRecordEntity.ApprovalStatus = Convert.ToInt32(Constant.ApprovalStatus.Pending);
- if (this._editStatus == Constant.FormMode.Add)
- {
- staffRecordEntity.OriginalOrganizationID = this.dkUserName.StaffEntity.OrganizationID;
- staffRecordEntity.OriginalStaffStatus = this.dkUserName.StaffEntity.StaffStatus;
- staffRecordEntity.OriginalOrganizationID = this._originalOrganization;
- staffRecordEntity.OriginalJobs = this.dkUserName.StaffEntity.Jobs;
- staffRecordEntity.OriginalPost = this.dkUserName.StaffEntity.Post;
- staffRecordEntity.OriginalUserID = this.dkUserName.StaffEntity.UserID;
- staffRecordEntity.OriginalUserCode = this.dkUserName.StaffEntity.UserCode;
- }
- // 如果是否试用为真,则取录入预计试用结束日期,否则取用户档案表中预计试用结束日期
- if (this.chkProbation.Checked)
- {
- staffRecordEntity.TargetStaffStatus = Convert.ToInt32(Constant.StaffStatus.Trial);
- staffRecordEntity.ExProbationEndDate = this.dtpExProbationEndDate.Value;
- }
- else
- {
- staffRecordEntity.TargetStaffStatus = chkProbation.Checked ? 1 : 2; //staffRecordEntity.OriginalStaffStatus;
- }
- staffRecordEntity.TargetOrganizationID = this.scbTargetOrganization.SearchedPKMember;
- staffRecordEntity.TargetJobs = this.dkTargetJobs.JobsID;
- staffRecordEntity.TargetPost = this.dkPostName.PostID;
- 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();
- if (this._rOPTimeStamp != null)
- {
- staffRecordEntity.OPTimeStamp = this._rOPTimeStamp.Value;
- }
- 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.scbTargetOrganization.ClearValue();
- this.chkProbation.Checked = false;
- this.dkTargetJobs.Text = "";
- this.dkPostName.Text = "";
- this.dkUserApplicant.Text = "";
- this.dtpExProbationEndDate.Value = DateTime.Now;
- 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.SaveTargetOrganizationInfo(this._staffRecordEntity, WCFConstant.FormMode.Add);
- }
- else if (this._editStatus == Constant.FormMode.Edit)
- {
- return HRModuleProxy.Service.SaveTargetOrganizationInfo(this._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
- }
- }
|