F_HR_0203.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0203.cs
  5. * 2.功能描述:员工入职审批
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/15 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.Basics.Library;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
  22. using Dongke.IBOSS.PRD.WCF.Proxys;
  23. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  24. namespace Dongke.IBOSS.PRD.Client.HRModule
  25. {
  26. /// <summary>
  27. /// 员工入职审批
  28. /// </summary>
  29. public partial class F_HR_0203 : DockPanelBase
  30. {
  31. #region 成员变量
  32. // 单例模式
  33. private static F_HR_0203 _instance;
  34. // 最后选择行
  35. private int _selecedRow;
  36. //员工ID
  37. private int _intStaffID;
  38. //员工时间戳
  39. private DateTime _sopTimeStamp;
  40. //员工履历实体类
  41. private StaffRecordEntity _staffRecordEntity;
  42. //审批状态
  43. private bool _bolState;
  44. //审批备注
  45. private string _strMemo;
  46. // 查询条件实体
  47. private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 单例模式,防止重复创建窗体
  52. /// </summary>
  53. public static F_HR_0203 Instance
  54. {
  55. get
  56. {
  57. if (_instance == null)
  58. {
  59. _instance = new F_HR_0203();
  60. }
  61. return _instance;
  62. }
  63. }
  64. #endregion
  65. #region 构造函数
  66. public F_HR_0203()
  67. {
  68. InitializeComponent();
  69. //设置窗体文本信息
  70. this.tsbtnApprover.Text = ButtonText.TSBTN_APPROVER;
  71. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  72. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  73. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  74. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  75. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  76. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  77. this.Text = FormTitles.F_HR_0203;
  78. }
  79. #endregion
  80. #region 事件
  81. /// <summary>
  82. /// 单元格双击事件
  83. /// </summary>
  84. /// <param name="sender"></param>
  85. /// <param name="e"></param>
  86. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  87. {
  88. if (-Constant.INT_IS_ONE < e.RowIndex && -Constant.INT_IS_ONE < e.ColumnIndex && this.tsbtnApprover.Enabled && this.tsbtnApprover.Visible)
  89. {
  90. this.tsbtnApprover_Click(sender, e);
  91. }
  92. }
  93. /// <summary>
  94. /// 更多条件按钮事件
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void tsbtnMoreCondition_Click(object sender, System.EventArgs e)
  99. {
  100. HR_CMN_001 frmHRCMN001 = new HR_CMN_001();
  101. frmHRCMN001.StaffEntity = _staffEntity;
  102. if (frmHRCMN001.ShowDialog() == DialogResult.OK)
  103. {
  104. this.txtOther.Text = frmHRCMN001.StaffEntity.GetSqlDispText();//窗体显示的值
  105. this._staffEntity = frmHRCMN001.StaffEntity;
  106. }
  107. }
  108. /// <summary>
  109. /// 自动适应列宽
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  114. {
  115. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  116. }
  117. /// <summary>
  118. /// 关闭按钮事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. }
  126. /// <summary>
  127. /// 清空条件按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnClearCondition_Click(object sender, EventArgs e)
  132. {
  133. this.txtStaffCode.Clear();
  134. this.txtStaffName.Clear();
  135. this.txtOther.Clear();
  136. this._staffEntity.ClearEntityValue();
  137. }
  138. /// <summary>
  139. /// 窗体加载事件
  140. /// </summary>
  141. /// <param name="sender"></param>
  142. /// <param name="e"></param>
  143. private void F_HR_0201_Load(object sender, EventArgs e)
  144. {
  145. try
  146. {
  147. // 加载权限
  148. FormPermissionManager.FormPermissionControl(this.Name, this,
  149. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  150. // 设置表格不自动创建列
  151. this.dgvStaff.AutoGenerateColumns = false;
  152. // 设置ToolStripButton状态
  153. this.SetToolStripButtonEnable();
  154. }
  155. catch (Exception ex)
  156. {
  157. // 对异常进行共通处理
  158. ExceptionManager.HandleEventException(this.ToString(),
  159. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  160. }
  161. }
  162. /// <summary>
  163. /// 窗体关闭事件
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. private void F_HR_0201_FormClosed(object sender, FormClosedEventArgs e)
  168. {
  169. _instance = null;
  170. }
  171. /// <summary>
  172. /// 搜索按钮事件
  173. /// </summary>
  174. /// <param name="sender"></param>
  175. /// <param name="e"></param>
  176. private void btnSearch_Click(object sender, EventArgs e)
  177. {
  178. try
  179. {
  180. // 记录当前选中行
  181. int selectRowIndex = this._selecedRow;
  182. // 异步处理
  183. this.btnSearch.Enabled = false;
  184. this.btnClearCondition.Enabled = false;
  185. DataSet userDataSet
  186. = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(this.SearchHrStaffApprove));
  187. this.btnSearch.Enabled = true;
  188. this.btnClearCondition.Enabled = true;
  189. if (userDataSet != null)
  190. {
  191. base.DataSource = (DataSet)userDataSet;
  192. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  193. {
  194. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  195. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  196. {
  197. // 提示未查找到数据
  198. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  199. MessageBoxButtons.OK, MessageBoxIcon.Information);
  200. }
  201. else
  202. {
  203. if (selectRowIndex >= Constant.INT_IS_ZERO)
  204. {
  205. if (selectRowIndex >= userDataSet.Tables[0].Rows.Count)
  206. {
  207. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  208. this.dgvStaff.CurrentCell
  209. = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffCode"];
  210. }
  211. else
  212. {
  213. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  214. this.dgvStaff.CurrentCell
  215. = this.dgvStaff.Rows[selectRowIndex].Cells["StaffCode"];
  216. }
  217. }
  218. }
  219. }
  220. }
  221. this.SetToolStripButtonEnable();
  222. }
  223. catch (Exception ex)
  224. {
  225. this.btnSearch.Enabled = true;
  226. this.btnClearCondition.Enabled = true;
  227. // 对异常进行共通处理
  228. ExceptionManager.HandleEventException(this.ToString(),
  229. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  230. }
  231. }
  232. /// <summary>
  233. /// 审批按钮事件
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void tsbtnApprover_Click(object sender, EventArgs e)
  238. {
  239. try
  240. {
  241. if (this.dgvStaff.CurrentRow != null)
  242. {
  243. if (this.dgvStaff.CurrentRow.Cells["RApprovalStatusName"].Value.ToString().Trim() != "待审批")
  244. {
  245. // 提示信息
  246. MessageBox.Show(string.Format(Messages.MSG_HR_W006, "入职审批", "审批"),
  247. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  248. }
  249. else
  250. {
  251. this._intStaffID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffID"].Value);
  252. this._sopTimeStamp = Convert.ToDateTime(this.dgvStaff.CurrentRow.Cells["SOPTIMESTAMP"].Value);
  253. int intStaffRecordID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffRecordID"].Value);
  254. DateTime ropTimeStamp = Convert.ToDateTime(this.dgvStaff.CurrentRow.Cells["ROPTIMESTAMP"].Value);
  255. string EXPROBATIONENDDATE = this.dgvStaff.CurrentRow.Cells["EXPROBATIONENDDATE"].Value.ToString();
  256. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  257. staffRecordEntity.StaffRecordID = intStaffRecordID;
  258. staffRecordEntity.OPTimeStamp = ropTimeStamp;
  259. staffRecordEntity.StaffID = _intStaffID;
  260. if (EXPROBATIONENDDATE != string.Empty)
  261. {
  262. staffRecordEntity.ExProbationEndDate = Convert.ToDateTime(EXPROBATIONENDDATE);
  263. }
  264. this._staffRecordEntity = staffRecordEntity;
  265. S_CMN_011 frmCMN011 = new S_CMN_011();
  266. if (frmCMN011.ShowDialog() == DialogResult.OK)
  267. {
  268. this._bolState = frmCMN011.HRApprovalState;
  269. this._strMemo = frmCMN011.ApprovalMemo;
  270. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new AsyncMethod(this.SaveHRStaffRecordApprovalInfo));
  271. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  272. {
  273. // 提示信息
  274. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "入职审批", "保存"),
  275. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  276. this.btnSearch_Click(sender, e);
  277. }
  278. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  279. {
  280. // 提示信息
  281. MessageBox.Show(string.Format(Messages.MSG_HR_W006, "入职审批", "保存"),
  282. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  283. }
  284. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  285. {
  286. // 提示信息
  287. MessageBox.Show(Messages.MSG_CMN_W012,
  288. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  289. }
  290. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  291. {
  292. // 提示信息
  293. MessageBox.Show(Messages.MSG_CMN_W012,
  294. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  295. }
  296. else
  297. {
  298. // 提示信息
  299. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "入职审批", "保存"),
  300. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  301. }
  302. }
  303. }
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. // 对异常进行共通处理
  309. ExceptionManager.HandleEventException(this.ToString(),
  310. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  311. }
  312. }
  313. #endregion
  314. #region 私有方法
  315. /// <summary>
  316. /// 搜索履历类别为入职,且为待审批的数据集
  317. /// </summary>
  318. /// <returns></returns>
  319. private DataSet SearchHrStaffApprove()
  320. {
  321. DataSet dsStaffEntity = null;
  322. try
  323. {
  324. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  325. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  326. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  327. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  328. searchStaffEntity.Recordtype = 1;
  329. searchStaffEntity.RValueflag = 1;
  330. dsStaffEntity = HRModuleProxy.Service.SearchHrStaffApprove(searchStaffEntity);
  331. }
  332. catch (Exception ex)
  333. {
  334. // 对异常进行共通处理
  335. ExceptionManager.HandleEventException(this.ToString(),
  336. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  337. }
  338. return dsStaffEntity;
  339. }
  340. /// <summary>
  341. /// 设置工具按钮的可用状态
  342. /// </summary>
  343. private void SetToolStripButtonEnable()
  344. {
  345. if (this.dgvStaff.CurrentCell != null)
  346. {
  347. this.tsbtnAdaptive.Enabled = true;
  348. }
  349. else
  350. {
  351. this.tsbtnAdaptive.Enabled = false;
  352. }
  353. }
  354. /// <summary>
  355. /// 审批方法
  356. /// </summary>
  357. /// <param name="staffRecordEntity"></param>
  358. /// <returns></returns>
  359. private HRResultEntity SaveHRStaffRecordApprovalInfo()
  360. {
  361. try
  362. {
  363. return HRModuleProxy.Service.SaveHRStaffRecordApprovalInfo(_intStaffID, _sopTimeStamp, _staffRecordEntity, _bolState, _strMemo);
  364. }
  365. catch (Exception ex)
  366. {
  367. throw ex;
  368. }
  369. }
  370. #endregion
  371. }
  372. }