F_HR_0303.cs 14 KB

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