F_HR_0403.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0403.cs
  5. * 2.功能描述:员工离职审批
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/09/16 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_0403 : DockPanelBase
  30. {
  31. #region 成员变量
  32. // 窗体的单例模式
  33. private static F_HR_0403 _instance;
  34. //Grid当前选中的行
  35. private int _selectedRowIndex;
  36. // 查询条件实体
  37. private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
  38. #endregion
  39. #region 构造函数
  40. /// <summary>
  41. /// 构造函数
  42. /// </summary>
  43. public F_HR_0403()
  44. {
  45. InitializeComponent();
  46. this.SetFromTitleInfo();
  47. }
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 单例模式,防止重复创建窗体
  52. /// </summary>
  53. public static F_HR_0403 Instance
  54. {
  55. get
  56. {
  57. if (_instance == null)
  58. {
  59. _instance = new F_HR_0403();
  60. }
  61. return _instance;
  62. }
  63. }
  64. #endregion
  65. #region 事件
  66. /// <summary>
  67. /// 行获取焦点后查看明细
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void dgvStaff_CellEnter(object sender, DataGridViewCellEventArgs e)
  72. {
  73. try
  74. {
  75. if (this.dgvStaff.CurrentCell != null)
  76. {
  77. // 记录最后选择行
  78. this._selectedRowIndex = this.dgvStaff.CurrentCell.RowIndex;
  79. }
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 单元格鼠标双击事件
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  94. {
  95. if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex
  96. && this.tsbtnApprover.Enabled && this.tsbtnApprover.Visible)
  97. {
  98. this.tsbtnApprover_Click(sender, e);
  99. }
  100. }
  101. /// <summary>
  102. /// 审批按钮
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void tsbtnApprover_Click(object sender, EventArgs e)
  107. {
  108. try
  109. {
  110. if (this.dgvStaff.CurrentRow != null)
  111. {
  112. int intStaffID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffID"].Value);
  113. DateTime sopTimeStamp = Convert.ToDateTime(this.dgvStaff.CurrentRow.Cells["SOPTimeStamp"].Value);
  114. int intStaffRecordID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["StaffRecordID"].Value);
  115. DateTime ropTimeStamp = Convert.ToDateTime(this.dgvStaff.CurrentRow.Cells["ROPTimeStamp"].Value);
  116. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  117. staffRecordEntity.StaffRecordID = intStaffRecordID;
  118. staffRecordEntity.OPTimeStamp = ropTimeStamp;
  119. staffRecordEntity.StaffID = intStaffID;
  120. S_CMN_011 frmCMN011 = new S_CMN_011();
  121. if (frmCMN011.ShowDialog() == DialogResult.OK)
  122. {
  123. bool bolState = frmCMN011.HRApprovalState;
  124. string strMemo = frmCMN011.ApprovalMemo;
  125. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new AsyncMethod(() =>
  126. {
  127. return HRModuleProxy.Service.SaveHRDimissionApprovalInfo(intStaffID, sopTimeStamp, staffRecordEntity, bolState, strMemo);
  128. }));
  129. //0 没有数据被修改 -1员工档案被其他用户修改 -2存在待审批履历 -3员工履历被其他用户修改
  130. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  131. {
  132. // 提示信息
  133. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "员工离职", "审核"),
  134. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  135. this.btnSearch_Click(sender, e);
  136. //this.InitializationForm();//清空输入项
  137. }
  138. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  139. {
  140. // 提示信息
  141. MessageBox.Show(string.Format(Messages.MSG_HR_W006, "员工离职", "审核"),
  142. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  143. }
  144. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  145. {
  146. // 提示信息
  147. MessageBox.Show(Messages.MSG_CMN_W012,
  148. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  149. }
  150. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  151. {
  152. // 提示信息
  153. MessageBox.Show(Messages.MSG_CMN_W012,
  154. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  155. }
  156. else
  157. {
  158. // 提示信息
  159. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "员工离职", "审核"),
  160. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  161. }
  162. }
  163. }
  164. }
  165. catch (Exception ex)
  166. {
  167. // 对异常进行共通处理
  168. ExceptionManager.HandleEventException(this.ToString(),
  169. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  170. }
  171. }
  172. /// <summary>
  173. /// 更多条件
  174. /// </summary>
  175. /// <param name="sender"></param>
  176. /// <param name="e"></param>
  177. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  178. {
  179. try
  180. {
  181. HR_CMN_001 frmCMN001 = new HR_CMN_001();
  182. frmCMN001.StaffEntity = _staffEntity;
  183. if (frmCMN001.ShowDialog() == DialogResult.OK)
  184. {
  185. this.txtOtherWhere.Text = frmCMN001.StaffEntity.GetSqlDispText();
  186. this._staffEntity = frmCMN001.StaffEntity;
  187. }
  188. }
  189. catch (Exception ex)
  190. {
  191. // 对异常进行共通处理
  192. ExceptionManager.HandleEventException(this.ToString(),
  193. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  194. }
  195. }
  196. /// <summary>
  197. /// 自动适应列宽
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  202. {
  203. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  204. }
  205. /// <summary>
  206. /// 关闭按钮事件
  207. /// </summary>
  208. /// <param name="sender"></param>
  209. /// <param name="e"></param>
  210. private void tsbtnClose_Click(object sender, EventArgs e)
  211. {
  212. this.Close();
  213. }
  214. /// <summary>
  215. /// 查询按钮
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void btnSearch_Click(object sender, EventArgs e)
  220. {
  221. try
  222. {
  223. // 记录当前选中行
  224. int selectRowIndex = this._selectedRowIndex;
  225. DataSet dsResult = (DataSet)DoAsync(new AsyncMethod(this.GetDataGridViewInfo));
  226. if (dsResult != null)
  227. {
  228. base.DataSource = dsResult;
  229. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  230. {
  231. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  232. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  233. {
  234. // 提示未查找到数据
  235. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  236. MessageBoxButtons.OK, MessageBoxIcon.Information);
  237. }
  238. else
  239. {
  240. #region 选择原有行
  241. if (selectRowIndex >= Constant.INT_IS_ZERO)
  242. {
  243. if (selectRowIndex >= dsResult.Tables[0].Rows.Count)
  244. {
  245. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  246. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffCode"];
  247. }
  248. else
  249. {
  250. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  251. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[selectRowIndex].Cells["StaffCode"];
  252. }
  253. }
  254. #endregion
  255. }
  256. }
  257. }
  258. }
  259. catch (Exception ex)
  260. {
  261. // 对异常进行共通处理
  262. ExceptionManager.HandleEventException(this.ToString(),
  263. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  264. }
  265. }
  266. /// <summary>
  267. /// 清空条件
  268. /// </summary>
  269. /// <param name="sender"></param>
  270. /// <param name="e"></param>
  271. private void btnClearCondition_Click(object sender, EventArgs e)
  272. {
  273. this.txtStaffCode.Clear();
  274. this.txtStaffName.Clear();
  275. this.txtOtherWhere.Clear();
  276. this._staffEntity.ClearEntityValue();
  277. }
  278. /// <summary>
  279. /// 窗体加载事件
  280. /// </summary>
  281. /// <param name="sender"></param>
  282. /// <param name="e"></param>
  283. private void F_HR_0403_Load(object sender, EventArgs e)
  284. {
  285. try
  286. {
  287. FormPermissionManager.FormPermissionControl(this.Name, this,
  288. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  289. }
  290. catch (Exception ex)
  291. {
  292. // 对异常进行共通处理
  293. ExceptionManager.HandleEventException(this.ToString(),
  294. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  295. }
  296. }
  297. /// <summary>
  298. /// 页面关闭事件
  299. /// </summary>
  300. /// <param name="sender"></param>
  301. /// <param name="e"></param>
  302. private void F_HR_0403_FormClosed(object sender, FormClosedEventArgs e)
  303. {
  304. _instance = null;
  305. }
  306. #endregion
  307. #region 私有方法
  308. /// <summary>
  309. /// 设置窗体按钮的文本信息
  310. /// </summary>
  311. private void SetFromTitleInfo()
  312. {
  313. this.Text = FormTitles.F_HR_0403;
  314. this.tsbtnApprover.Text = ButtonText.TSBTN_APPROVER;
  315. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  316. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  317. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  318. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  319. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  320. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  321. }
  322. /// <summary>
  323. /// 根据查询条件获取要显示的数据
  324. /// </summary>
  325. /// <returns>返回查询的结果集</returns>
  326. private DataSet GetDataGridViewInfo()
  327. {
  328. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  329. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  330. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  331. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  332. searchStaffEntity.Recordtype = Constant.StaffRecordType.Departure.GetHashCode();
  333. searchStaffEntity.RValueflag = Constant.ValueFlag.Effective.GetHashCode();
  334. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffApprove(searchStaffEntity);
  335. }
  336. #endregion
  337. }
  338. }