F_HR_0402.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0402.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.Basics.Library;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  22. namespace Dongke.IBOSS.PRD.Client.HRModule
  23. {
  24. /// <summary>
  25. /// 员工离职新建/编辑页面
  26. /// </summary>
  27. public partial class F_HR_0402 : FormBase
  28. {
  29. #region 成员变量
  30. // 窗体状态的枚举 新建/编辑
  31. private Constant.FormMode _editStatus;
  32. // 要编辑的员工编号
  33. private int _userId;
  34. // 员工履历编号
  35. private int _staffRecordID;
  36. //员工表的时间戳
  37. private DateTime _sOPTimeStamp;
  38. //员工履历表的时间戳
  39. private DateTime? _rOPTimeStamp;
  40. // 新建的员工ID集合
  41. private List<int> _staffIDList = new List<int>();
  42. #endregion
  43. #region 构造函数
  44. /// <summary>
  45. /// 构造函数
  46. /// </summary>
  47. /// <param name="editStatus">新建/编辑</param>
  48. /// <param name="pUserId">要编辑的员工编号</param>
  49. public F_HR_0402(Constant.FormMode editStatus, int pUserId, int pStaffRecordID)
  50. {
  51. InitializeComponent();
  52. this._editStatus = editStatus;
  53. this._userId = pUserId;
  54. this._staffRecordID = pStaffRecordID;
  55. this.dkUserName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
  56. this.dkUserApplicant.WhereCondition = "StaffStatus = 2 and ValueFlag = 1";
  57. this.SetFromTitleInfo();
  58. }
  59. #endregion
  60. #region 属性
  61. /// <summary>
  62. /// 员工ID集合
  63. /// </summary>
  64. public List<int> StaffIDList
  65. {
  66. get
  67. {
  68. return _staffIDList;
  69. }
  70. set
  71. {
  72. _staffIDList = value;
  73. }
  74. }
  75. #endregion
  76. #region 事件
  77. /// <summary>
  78. /// 页面加载事件
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void F_HR_0402_Load(object sender, EventArgs e)
  83. {
  84. try
  85. {
  86. FormPermissionManager.FormPermissionControl(this.Name, this,
  87. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  88. if (this._editStatus == Constant.FormMode.Edit)
  89. {
  90. // 获取用户信息数据集
  91. DataSet staffInfoData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetDataGridViewInfo));
  92. if (staffInfoData != null && staffInfoData.Tables.Count > Constant.INT_IS_ZERO && staffInfoData.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  93. {
  94. #region 为控件赋值
  95. this.dkUserName.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["StaffID"]);
  96. this.dkUserName.UserCode = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  97. this.dkUserName.UserName = staffInfoData.Tables[0].Rows[0]["StaffName"].ToString().Trim();
  98. List<DKStaffEntity> staffEntityList = DataConvert.TableConvertToObject<DKStaffEntity>(staffInfoData.Tables[0]);
  99. if (staffEntityList != null)
  100. {
  101. if (staffEntityList.Count > Constant.INT_IS_ZERO)
  102. {
  103. DataConvert.Convert(staffEntityList[0], this.dkUserName.StaffEntity);
  104. }
  105. }
  106. this.txtStaffCode.Text = staffInfoData.Tables[0].Rows[0]["StaffCode"].ToString().Trim();
  107. this.txtOrganizationID.Text = staffInfoData.Tables[0].Rows[0]["SOrganizationname"].ToString().Trim();
  108. this.txtJobs.Text = staffInfoData.Tables[0].Rows[0]["SJobsname"].ToString().Trim();
  109. this.dkUserApplicant.UserID = Convert.ToInt32(staffInfoData.Tables[0].Rows[0]["Applicant"]);
  110. this.dkUserApplicant.UserCode = staffInfoData.Tables[0].Rows[0]["RApplicantCode"].ToString().Trim();
  111. this.dkUserApplicant.UserName = staffInfoData.Tables[0].Rows[0]["RApplicantName"].ToString().Trim();
  112. this.dtRecordDate.Value = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["RecordDate"]);
  113. this.txtReason.Text = staffInfoData.Tables[0].Rows[0]["Reason"].ToString().Trim();
  114. this.txtSuggestion.Text = staffInfoData.Tables[0].Rows[0]["Suggestion"].ToString().Trim();
  115. this.txtRemarks.Text = staffInfoData.Tables[0].Rows[0]["RRemarks"].ToString().Trim();
  116. this._sOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["SOPTIMESTAMP"]);
  117. this._rOPTimeStamp = Convert.ToDateTime(staffInfoData.Tables[0].Rows[0]["ROPTIMESTAMP"]);
  118. this.dkUserName.StaffEntity.OPTimeStamp = _sOPTimeStamp;
  119. string ApprovalStatus = staffInfoData.Tables[0].Rows[0]["ApprovalStatus"].ToString();
  120. if (!"0".Equals(ApprovalStatus))//非待审批
  121. {
  122. //设置非待审核的履历控件禁用
  123. this.SetControlEnable();
  124. }
  125. #endregion
  126. }
  127. else
  128. {
  129. //设置非待审核的履历控件禁用
  130. this.SetControlEnable();
  131. }
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 用户选择控件值改变时事件
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void dkUserName_UserValueChanged(object sender, Controls.dkStaffSearchBox.TextChangeEventArgs e)
  147. {
  148. if (this.dkUserName.UserID != null)
  149. {
  150. this.txtStaffCode.Text = this.dkUserName.StaffEntity.StaffCode;
  151. this.txtOrganizationID.Text = this.dkUserName.StaffEntity.OrganizationName;
  152. this.txtJobs.Text = this.dkUserName.StaffEntity.JobsName;
  153. this._sOPTimeStamp = this.dkUserName.StaffEntity.OPTimeStamp;
  154. this._userId = this.dkUserName.UserID.Value;
  155. this.dkUserApplicant.UserID = this.dkUserName.UserID;
  156. this.dkUserApplicant.UserCode = this.dkUserName.UserCode;
  157. this.dkUserApplicant.UserName = this.dkUserName.UserName;
  158. this.dkUserApplicant.StaffEntity = this.dkUserName.StaffEntity;
  159. }
  160. }
  161. /// <summary>
  162. /// 取消按钮
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void btnCancel_Click(object sender, EventArgs e)
  167. {
  168. if (this._staffIDList != null && this._staffIDList.Count > 0)
  169. {
  170. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  171. }
  172. else
  173. {
  174. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  175. }
  176. }
  177. /// <summary>
  178. /// 保存按钮
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. private void btnSave_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. if (IsInputValid())
  187. {
  188. StaffRecordEntity tempRecord = SetStaffRecordEntity();
  189. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new BaseAsyncMethod(() =>
  190. {
  191. if (_editStatus == Constant.FormMode.Add)
  192. {
  193. return WCF.Proxys.HRModuleProxy.Service.SaveStaffRecordDimission(_userId, _sOPTimeStamp, tempRecord, WCFConstant.FormMode.Add);
  194. }
  195. else if (_editStatus == Constant.FormMode.Edit)
  196. {
  197. return WCF.Proxys.HRModuleProxy.Service.SaveStaffRecordDimission(_userId, _sOPTimeStamp, tempRecord, WCFConstant.FormMode.Edit);
  198. }
  199. return 0;
  200. }));
  201. //0 没有数据被修改 -1员工档案被其他用户修改 -2存在待审批履历 -3员工履历被其他用户修改
  202. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  203. {
  204. // 提示信息
  205. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "保存"),
  206. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  207. this._staffIDList.Add(resultStaff.HRStaffRecordID);
  208. this.InitializationForm();//清空输入项
  209. }
  210. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  211. {
  212. // 提示信息
  213. MessageBox.Show(Messages.MSG_HR_W009,
  214. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  215. }
  216. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  217. {
  218. // 提示信息
  219. MessageBox.Show(Messages.MSG_CMN_W012,
  220. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  221. }
  222. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  223. {
  224. // 提示信息
  225. MessageBox.Show(Messages.MSG_CMN_W012,
  226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  227. }
  228. else
  229. {
  230. // 提示信息
  231. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "员工离职", "保存"),
  232. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  233. }
  234. }
  235. }
  236. catch (Exception ex)
  237. {
  238. // 对异常进行共通处理
  239. ExceptionManager.HandleEventException(this.ToString(),
  240. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  241. }
  242. }
  243. #endregion
  244. #region 私用方法
  245. /// <summary>
  246. /// 设置窗体按钮的文本信息
  247. /// </summary>
  248. private void SetFromTitleInfo()
  249. {
  250. if (this._editStatus == Constant.FormMode.Add)
  251. {
  252. this.Text = FormTitles.F_HR_0402_ADD;
  253. this.dkUserName.Enabled = true;
  254. this._rOPTimeStamp = null;
  255. }
  256. else if (this._editStatus == Constant.FormMode.Edit)
  257. {
  258. this.Text = FormTitles.F_HR_0402_EDIT;
  259. this.dkUserName.Enabled = false;
  260. }
  261. this.btnSave.Text = ButtonText.BTN_SAVE;
  262. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  263. }
  264. /// <summary>
  265. /// 根据查询条件获取要显示的数据
  266. /// </summary>
  267. /// <returns>返回查询的结果集</returns>
  268. private DataSet GetDataGridViewInfo()
  269. {
  270. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  271. searchStaffEntity.StaffID = this._userId;
  272. searchStaffEntity.RStaffRecordID = this._staffRecordID;
  273. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
  274. }
  275. /// <summary>
  276. /// 检查页面的输入项目
  277. /// </summary>
  278. /// <remarks>
  279. /// </remarks>
  280. /// <returns></returns>
  281. private bool IsInputValid()
  282. {
  283. // 员工姓名输入值
  284. if (this.dkUserName.UserID == null)
  285. {
  286. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "员工姓名"),
  287. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  288. return false;
  289. }
  290. else if (this.dkUserApplicant.UserID == null)
  291. {
  292. //申请人输入值
  293. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "申请人"),
  294. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  295. return false;
  296. }
  297. else if (string.IsNullOrEmpty(this.txtReason.Text.Trim()))
  298. {
  299. //申请人输入值
  300. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "离职原因"),
  301. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  302. return false;
  303. }
  304. else if (string.IsNullOrEmpty(this.txtSuggestion.Text.Trim()))
  305. {
  306. //申请人输入值
  307. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "部门意见"),
  308. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  309. return false;
  310. }
  311. else
  312. {
  313. return true;
  314. }
  315. }
  316. /// <summary>
  317. /// 根据页面输入值,给员工对象实体赋值
  318. /// </summary>
  319. /// <returns></returns>
  320. private StaffRecordEntity SetStaffRecordEntity()
  321. {
  322. int intUserID = this.dkUserName.UserID.Value;
  323. int intApplicantID = this.dkUserApplicant.UserID.Value;
  324. DateTime dtRecordDate = this.dtRecordDate.Value;
  325. string strReason = this.txtReason.Text.Trim();
  326. string strSuggestion = this.txtSuggestion.Text.Trim();
  327. string strRemarks = this.txtRemarks.Text.Trim();
  328. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  329. //履历表主键
  330. staffRecordEntity.StaffRecordID = _staffRecordID;
  331. //员工ID
  332. staffRecordEntity.StaffID = intUserID;
  333. //履历日期
  334. staffRecordEntity.RecordDate = dtRecordDate;
  335. //申请原因
  336. staffRecordEntity.Reason = strReason;
  337. //部门意见
  338. staffRecordEntity.Suggestion = strSuggestion;
  339. //备注
  340. staffRecordEntity.Remarks = strRemarks;
  341. //申请人
  342. staffRecordEntity.Applicant = intApplicantID;
  343. if (this._rOPTimeStamp != null)
  344. {
  345. //员工履历表的时间戳
  346. staffRecordEntity.OPTimeStamp = this._rOPTimeStamp.Value;
  347. }
  348. staffRecordEntity.RecordType = Constant.StaffRecordType.Departure.GetHashCode();
  349. staffRecordEntity.OriginalUserID = this.dkUserName.StaffEntity.UserID;
  350. staffRecordEntity.OriginalUserCode = this.dkUserName.StaffEntity.UserCode;
  351. staffRecordEntity.TargetUserID = this.dkUserName.StaffEntity.UserID;
  352. staffRecordEntity.TargetUserCode = this.dkUserName.StaffEntity.UserCode;
  353. // MODIFY 员工转正直接审批通过 BY 付斌 2018-3-31
  354. staffRecordEntity.ApprovalStatus = 3;
  355. return staffRecordEntity;
  356. }
  357. /// <summary>
  358. /// 清空输入项
  359. /// </summary>
  360. private void InitializationForm()
  361. {
  362. this.dkUserName.UserID = null;
  363. this.dkUserName.UserCode = string.Empty;
  364. this.dkUserName.UserName = string.Empty;
  365. this.dkUserName.StaffEntity = null;
  366. this.txtStaffCode.Text = string.Empty;
  367. this.txtOrganizationID.Text = string.Empty;
  368. this.txtJobs.Text = string.Empty;
  369. this.dkUserApplicant.UserID = null;
  370. this.dkUserApplicant.UserCode = string.Empty;
  371. this.dkUserApplicant.UserName = string.Empty;
  372. this.dkUserApplicant.StaffEntity = null;
  373. this.dtRecordDate.Value = DateTime.Now;
  374. this.txtReason.Text = string.Empty;
  375. this.txtSuggestion.Text = string.Empty;
  376. this.txtRemarks.Text = string.Empty;
  377. }
  378. //设置非待审核的履历控件禁用
  379. private void SetControlEnable()
  380. {
  381. this.dkUserName.Enabled = false;
  382. this.dkUserApplicant.Enabled = false;
  383. this.dtRecordDate.Enabled = false;
  384. this.txtReason.Enabled = false;
  385. this.txtSuggestion.Enabled = false;
  386. this.txtRemarks.Enabled = false;
  387. this.btnSave.Enabled = false;
  388. }
  389. #endregion
  390. }
  391. }