F_HR_0602.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0602.cs
  5. * 2.功能描述:职务、修改
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 冯雪 2014/09/16 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.HRModule
  22. {
  23. /// <summary>
  24. /// 职务调整窗体
  25. /// </summary>
  26. public partial class F_HR_0602 : FormBase
  27. {
  28. #region 成员变量
  29. // 窗体状态的枚举 新建/编辑
  30. private Constant.FormMode _editStatus;
  31. // 要编辑的员工编号
  32. private int _userId;
  33. // 调整前职务ID
  34. private int _originalPost;
  35. // 页面传过来员工ID
  36. private int _staffRecordID;
  37. // 用户履历实体类
  38. private StaffRecordEntity _staffRecordEntity;
  39. // 员工时间戳
  40. private DateTime _optimestamp;
  41. // 员工履历表的时间戳
  42. private DateTime? _rOPTimeStamp;
  43. // 新建的员工ID集合
  44. private List<int> _staffIDList = new List<int>();
  45. #endregion
  46. #region 构造函数
  47. /// <summary>
  48. /// 构造函数
  49. /// </summary>
  50. /// <param name="editStatus">新建/编辑</param>
  51. /// <param name="pUserId">要编辑的员工编号</param>
  52. public F_HR_0602(Constant.FormMode editStatus, int pUserId, int pStaffRecordID)
  53. {
  54. InitializeComponent();
  55. this._editStatus = editStatus;
  56. this._userId = pUserId;
  57. this._staffRecordID = pStaffRecordID;
  58. this.SetFromTitleInfo();
  59. }
  60. #endregion
  61. #region 属性
  62. /// <summary>
  63. /// 页面传过来的员工ID
  64. /// </summary>
  65. public int StaffRecordID
  66. {
  67. get
  68. {
  69. return this._staffRecordID;
  70. }
  71. set
  72. {
  73. this._staffRecordID = value;
  74. }
  75. }
  76. /// <summary>
  77. /// 时间戳
  78. /// </summary>
  79. public DateTime OPTimeStamp
  80. {
  81. get
  82. {
  83. return _optimestamp;
  84. }
  85. set
  86. {
  87. _optimestamp = value;
  88. }
  89. }
  90. /// <summary>
  91. /// 员工ID集合
  92. /// </summary>
  93. public List<int> StaffIDList
  94. {
  95. get
  96. {
  97. return _staffIDList;
  98. }
  99. set
  100. {
  101. _staffIDList = value;
  102. }
  103. }
  104. #endregion
  105. #region 事件
  106. /// <summary>
  107. /// 页面加载事件
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. private void F_HR_0602_Load(object sender, EventArgs e)
  112. {
  113. try
  114. {
  115. this.dkUserName.WhereCondition = "StaffStatus in(1,2) And ValueFlag = 1";
  116. this.dkUserApplicant.WhereCondition = "StaffStatus =2 And ValueFlag = 1";
  117. if (this._editStatus == Constant.FormMode.Edit)
  118. {
  119. // 获取用户信息数据集
  120. DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo));
  121. if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO)
  122. {
  123. // 编辑数据 给页面所有项赋值
  124. if (this._editStatus == Constant.FormMode.Edit && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  125. {
  126. this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]);
  127. this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  128. this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim();
  129. this.txtStaffCode.Text = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  130. this.txtOrganizationID.Text = staffInfoData.Tables[0].Rows[0]["SOrganizationname"].ToString().Trim();
  131. this.txtJobs.Text = staffInfoData.Tables[0].Rows[0]["SJobsname"].ToString().Trim();
  132. this.txt_OriginalPost.Text = staffInfoData.Tables[0].Rows[0]["ROriginalPostName"].ToString().Trim();
  133. this._originalPost = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["OriginalPost"]);
  134. this.dkPostName.PostID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["TargetPost"]);
  135. this.dkPostName.PostName = staffInfoData.Tables[0].Rows[0]["RTargetPostName"].ToString().Trim();
  136. this.dkUserApplicant.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["Applicant"]);
  137. this.dkUserApplicant.UserName = staffInfoData.Tables[0].Rows[0]["RApplicantName"].ToString().Trim();
  138. this.dtpApplicationTime.Value = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RecordDate"]);
  139. this.dtpApplicationTime.Value = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RecordDate"]);
  140. this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim();
  141. this.txtSuggestion.Text = staffInfoData.Tables[0].Rows[0]["Suggestion"].ToString().Trim();
  142. this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["RRemarks"].ToString().Trim();
  143. this._optimestamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["SOPTIMESTAMP"]);
  144. this._rOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["ROPTIMESTAMP"]);
  145. }
  146. this.dkUserName.Enabled = false;
  147. }
  148. }
  149. }
  150. catch (Exception ex)
  151. {
  152. // 对异常进行共通处理
  153. ExceptionManager.HandleEventException(this.ToString(),
  154. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  155. }
  156. }
  157. /// <summary>
  158. /// 用户选择控件值改变时事件
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. private void dkUserName_UserValueChanged(object sender, Controls.dkStaffSearchBox.TextChangeEventArgs e)
  163. {
  164. if (this.dkUserName.UserRow != null)
  165. {
  166. this.txtStaffCode.Text = this.dkUserName.StaffEntity.StaffCode;
  167. this.txtOrganizationID.Text = this.dkUserName.StaffEntity.OrganizationName;
  168. this.txtJobs.Text = this.dkUserName.StaffEntity.JobsName;
  169. this.txt_OriginalPost.Text = this.dkUserName.StaffEntity.PostName;
  170. this._optimestamp = this.dkUserName.StaffEntity.OPTimeStamp;
  171. this._originalPost = this.dkUserName.StaffEntity.Post;
  172. }
  173. }
  174. /// <summary>
  175. /// 取消按钮
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. private void btnCancel_Click(object sender, EventArgs e)
  180. {
  181. if (this._staffIDList != null && this._staffIDList.Count > 0)
  182. {
  183. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  184. }
  185. else
  186. {
  187. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  188. }
  189. }
  190. /// <summary>
  191. /// 保存按钮
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. private void btnSave_Click(object sender, EventArgs e)
  196. {
  197. try
  198. {
  199. // 验证输入是否正确
  200. if (!this.CheckInputValidity())
  201. {
  202. return;
  203. }
  204. this._staffRecordEntity = this.SetStaffRecordEntity();
  205. this.btnSave.Enabled = false;
  206. this.btnCancel.Enabled = false;
  207. HRResultEntity returnStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(this.SaveStaffInfo));
  208. this.btnSave.Enabled = true;
  209. this.btnCancel.Enabled = true;
  210. if (returnStaff.OperateStatus > Constant.INT_IS_ZERO)
  211. {
  212. // 保存成功提示信息
  213. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "职务调整", "保存"),
  214. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  215. this._staffIDList.Add(returnStaff.HRStaffRecordID);
  216. this.InitializationForm();
  217. if (this._editStatus == Constant.FormMode.Edit)
  218. {
  219. this.DialogResult = DialogResult.OK;
  220. }
  221. }
  222. else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  223. {
  224. // 提示信息
  225. MessageBox.Show(Messages.MSG_HR_W009,
  226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  227. }
  228. else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  229. {
  230. // 提示信息
  231. MessageBox.Show(Messages.MSG_CMN_W012,
  232. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  233. }
  234. else if (returnStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  235. {
  236. // 提示信息
  237. MessageBox.Show(Messages.MSG_CMN_W012,
  238. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  239. }
  240. else
  241. {
  242. // 提示信息
  243. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "职务调整", "保存"),
  244. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  245. }
  246. }
  247. catch (Exception ex)
  248. {
  249. this.btnSave.Enabled = true;
  250. this.btnCancel.Enabled = true;
  251. // 对异常进行共通处理
  252. ExceptionManager.HandleEventException(this.ToString(),
  253. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  254. }
  255. }
  256. #endregion
  257. #region 私有方法
  258. /// <summary>
  259. /// 设置窗体按钮的文本信息
  260. /// </summary>
  261. private void SetFromTitleInfo()
  262. {
  263. if (this._editStatus == Constant.FormMode.Add)
  264. {
  265. this.Text = FormTitles.F_HR_0602_ADD;
  266. }
  267. else if (this._editStatus == Constant.FormMode.Edit)
  268. {
  269. this.Text = FormTitles.F_HR_0602_EDIT;
  270. this.dkUserName.Enabled = false;
  271. }
  272. this.btnSave.Text = ButtonText.BTN_SAVE;
  273. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  274. }
  275. /// <summary>
  276. /// 验证输入格式是否正确
  277. /// </summary>
  278. /// <returns></returns>
  279. private bool CheckInputValidity()
  280. {
  281. // 验证员工信息是否录入;
  282. if (string.IsNullOrEmpty(this.dkUserName.Text.Trim()))
  283. {
  284. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"),
  285. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  286. this.dkUserName.Focus();
  287. return false;
  288. }
  289. // 验证调整后工种信息是否录入;
  290. if (string.IsNullOrEmpty(this.dkPostName.Text.Trim()))
  291. {
  292. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整后职务"),
  293. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  294. this.dkPostName.Focus();
  295. return false;
  296. }
  297. // 验证申请人信息是否录入;
  298. if (string.IsNullOrEmpty(this.dkUserApplicant.Text.Trim()))
  299. {
  300. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请人"),
  301. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  302. this.dkUserApplicant.Focus();
  303. return false;
  304. }
  305. // 验证调整后职务不能和调整前一样
  306. if (this._originalPost == this.dkPostName.PostID)
  307. {
  308. MessageBox.Show(string.Format(Messages.MSG_CMN_W018, "调整后职务", "调整前职务"),
  309. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  310. this.dkPostName.Focus();
  311. return false;
  312. }
  313. if (this.txtReason.Text.Trim() == string.Empty)
  314. {
  315. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "调整原因"),
  316. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  317. this.txtReason.Focus();
  318. return false;
  319. }
  320. if (this.txtSuggestion.Text.Trim() == string.Empty)
  321. {
  322. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"),
  323. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1);
  324. this.txtSuggestion.Focus();
  325. return false;
  326. }
  327. return true;
  328. }
  329. /// <summary>
  330. /// 根据页面输入值,给员工对象实体赋值
  331. /// </summary>
  332. /// <returns></returns>
  333. private StaffRecordEntity SetStaffRecordEntity()
  334. {
  335. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  336. staffRecordEntity.StaffID = this.dkUserName.UserID.Value;
  337. staffRecordEntity.StaffCode = this.txtStaffCode.Text.Trim();
  338. staffRecordEntity.RecordType = Convert.ToInt32(Constant.StaffRecordType.AdjustPost);
  339. staffRecordEntity.ApprovalStatus = Constant.INT_IS_ZERO;
  340. if (this._editStatus == Constant.FormMode.Add)
  341. {
  342. staffRecordEntity.OriginalOrganizationID = this.dkUserName.StaffEntity.OrganizationID;
  343. staffRecordEntity.OriginalStaffStatus = this.dkUserName.StaffEntity.StaffStatus;
  344. staffRecordEntity.OriginalPost = this._originalPost;
  345. }
  346. staffRecordEntity.TargetOrganizationID = staffRecordEntity.OriginalOrganizationID;
  347. staffRecordEntity.TargetStaffStatus = staffRecordEntity.OriginalStaffStatus;
  348. staffRecordEntity.TargetPost = this.dkPostName.PostID.Value;
  349. staffRecordEntity.Applicant = this.dkUserApplicant.UserID.Value;
  350. staffRecordEntity.RecordDate = this.dtpApplicationTime.Value;
  351. staffRecordEntity.Reason = this.txtReason.Text.Trim();
  352. staffRecordEntity.Suggestion = this.txtSuggestion.Text.Trim();
  353. staffRecordEntity.Remarks = this.txtRemarks.Text.Trim();
  354. staffRecordEntity.OPTimeStamp = _optimestamp;
  355. staffRecordEntity.StaffRecordID = this._staffRecordID;
  356. // MODIFY 职务调整直接审批通过 BY 付斌 2018-3-31
  357. staffRecordEntity.ApprovalStatus = 3;
  358. return staffRecordEntity;
  359. }
  360. /// <summary>
  361. /// 清空输入项
  362. /// </summary>
  363. private void InitializationForm()
  364. {
  365. this.dkUserName.Text = "";
  366. this.txtStaffCode.Text = "";
  367. this.txtOrganizationID.Text = "";
  368. this.txtJobs.Text = "";
  369. this.txt_OriginalPost.Text = "";
  370. this.dkPostName.Text = "";
  371. this.dkUserApplicant.Text = "";
  372. this.dtpApplicationTime.Value = DateTime.Now;
  373. this.txtReason.Text = "";
  374. this.txtSuggestion.Text = "";
  375. this.txtRemarks.Text = "";
  376. }
  377. /// <summary>
  378. /// 添加职务调整
  379. /// </summary>
  380. /// <returns></returns>
  381. private HRResultEntity SaveStaffInfo()
  382. {
  383. try
  384. {
  385. if (this._editStatus == Constant.FormMode.Add)
  386. {
  387. return HRModuleProxy.Service.SaveTargetPostInfo(_staffRecordEntity, WCFConstant.FormMode.Add);
  388. }
  389. else if (this._editStatus == Constant.FormMode.Edit)
  390. {
  391. return HRModuleProxy.Service.SaveTargetPostInfo(_staffRecordEntity, WCFConstant.FormMode.Edit);
  392. }
  393. return new HRResultEntity();
  394. }
  395. catch (Exception ex)
  396. {
  397. throw ex;
  398. }
  399. }
  400. /// <summary>
  401. /// 根据查询条件获取要显示的数据
  402. /// </summary>
  403. /// <returns>返回查询的结果集</returns>
  404. private DataSet GetDataGridViewInfo()
  405. {
  406. try
  407. {
  408. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  409. searchStaffEntity.StaffID = this._userId;
  410. searchStaffEntity.RStaffRecordID = this._staffRecordID;
  411. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
  412. }
  413. catch (Exception ex)
  414. {
  415. throw ex;
  416. }
  417. }
  418. #endregion
  419. }
  420. }