/*******************************************************************************
* 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
{
///
/// 职务调整窗体
///
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 _staffIDList = new List();
#endregion
#region 构造函数
///
/// 构造函数
///
/// 新建/编辑
/// 要编辑的员工编号
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 属性
///
/// 页面传过来的员工ID
///
public int StaffRecordID
{
get
{
return this._staffRecordID;
}
set
{
this._staffRecordID = value;
}
}
///
/// 时间戳
///
public DateTime OPTimeStamp
{
get
{
return _optimestamp;
}
set
{
_optimestamp = value;
}
}
///
/// 员工ID集合
///
public List StaffIDList
{
get
{
return _staffIDList;
}
set
{
_staffIDList = value;
}
}
#endregion
#region 事件
///
/// 页面加载事件
///
///
///
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);
}
}
///
/// 用户选择控件值改变时事件
///
///
///
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;
}
}
///
/// 取消按钮
///
///
///
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();
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 私有方法
///
/// 设置窗体按钮的文本信息
///
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;
}
///
/// 验证输入格式是否正确
///
///
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;
}
///
/// 根据页面输入值,给员工对象实体赋值
///
///
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;
}
///
/// 清空输入项
///
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 = "";
}
///
/// 添加职务调整
///
///
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;
}
}
///
/// 根据查询条件获取要显示的数据
///
/// 返回查询的结果集
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
}
}