F_HR_0502.cs 21 KB

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