F_HR_0503.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0503.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_0503 : DockPanelBase
  30. {
  31. #region 成员变量
  32. // 窗体的单例模式
  33. private static F_HR_0503 _instance;
  34. //选中行
  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_0503()
  44. {
  45. InitializeComponent();
  46. FormPermissionManager.FormPermissionControl(this.Name, this,
  47. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  48. this.SetFromTitleInfo();
  49. }
  50. #endregion
  51. #region 单例模式
  52. /// <summary>
  53. /// 单例模式,防止重复创建窗体
  54. /// </summary>
  55. public static F_HR_0503 Instance
  56. {
  57. get
  58. {
  59. if (_instance == null)
  60. {
  61. _instance = new F_HR_0503();
  62. }
  63. return _instance;
  64. }
  65. }
  66. #endregion
  67. #region 事件
  68. /// <summary>
  69. /// 页面加载事件
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. private void F_HR_0503_Load(object sender, EventArgs e)
  74. {
  75. try
  76. {
  77. FormPermissionManager.FormPermissionControl(this.Name, this,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  79. // 设置表格不自动创建列
  80. this.dgvStaffRecord.AutoGenerateColumns = false;
  81. }
  82. catch (Exception ex)
  83. {
  84. // 对异常进行共通处理
  85. ExceptionManager.HandleEventException(this.ToString(),
  86. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  87. }
  88. }
  89. /// <summary>
  90. /// 窗体关闭事件
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. private void F_HR_0503_FormClosed(object sender, FormClosedEventArgs e)
  95. {
  96. _instance = null;
  97. }
  98. /// <summary>
  99. /// 行获取焦点后查看明细
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void dgvStaffRecord_CellEnter(object sender, DataGridViewCellEventArgs e)
  104. {
  105. try
  106. {
  107. if (this.dgvStaffRecord.CurrentCell != null)
  108. {
  109. // 记录最后选择行
  110. this._selectedRowIndex = this.dgvStaffRecord.CurrentCell.RowIndex;
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. /// <summary>
  121. /// 单元格鼠标双击事件
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void dgvStaffRecord_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  126. {
  127. if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex
  128. && this.tsbtnApprover.Enabled && this.tsbtnApprover.Visible)
  129. {
  130. this.tsbtnApprover_Click(sender, e);
  131. }
  132. }
  133. /// <summary>
  134. /// 更多条件按钮
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  139. {
  140. HR_CMN_001 frmCMN001 = new HR_CMN_001();
  141. frmCMN001.StaffEntity = this._staffEntity;
  142. if (frmCMN001.ShowDialog() == DialogResult.OK)
  143. {
  144. this.txtOther.Text = frmCMN001.StaffEntity.GetSqlDispText();
  145. this._staffEntity = frmCMN001.StaffEntity;
  146. }
  147. }
  148. /// <summary>
  149. /// 清空条件
  150. /// </summary>
  151. /// <param name="sender"></param>
  152. /// <param name="e"></param>
  153. private void btnClearCondition_Click(object sender, EventArgs e)
  154. {
  155. this.txtStaffCode.Clear();
  156. this.txtStaffName.Clear();
  157. this.txtOther.Clear();
  158. this._staffEntity.ClearEntityValue();
  159. }
  160. /// <summary>
  161. /// 关闭按钮事件
  162. /// </summary>
  163. /// <param name="sender"></param>
  164. /// <param name="e"></param>
  165. private void tsbtnClose_Click(object sender, EventArgs e)
  166. {
  167. this.Close();
  168. }
  169. /// <summary>
  170. /// 自动适应列宽
  171. /// </summary>
  172. /// <param name="sender"></param>
  173. /// <param name="e"></param>
  174. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  175. {
  176. this.dgvStaffRecord.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  177. }
  178. /// <summary>
  179. /// 查询按钮
  180. /// </summary>
  181. /// <param name="sender"></param>
  182. /// <param name="e"></param>
  183. private void btnSearch_Click(object sender, EventArgs e)
  184. {
  185. try
  186. {
  187. this.GetDataGridViewInfo();
  188. // 记录当前选中行
  189. int selectRowIndex = this._selectedRowIndex;
  190. #region 选择原有行
  191. if (((DataTable)this.dgvStaffRecord.DataSource).Rows.Count <= Constant.INT_IS_ZERO)
  192. {
  193. // 提示未查找到数据
  194. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  195. MessageBoxButtons.OK, MessageBoxIcon.Information);
  196. }
  197. if (((DataTable)this.dgvStaffRecord.DataSource).Rows.Count > Constant.INT_IS_ZERO && selectRowIndex >= Constant.INT_IS_ZERO)
  198. {
  199. if (selectRowIndex >= ((DataTable)this.dgvStaffRecord.DataSource).Rows.Count)
  200. {
  201. this.dgvStaffRecord.Rows[this.dgvStaffRecord.Rows.Count - 1].Selected = true;
  202. this.dgvStaffRecord.CurrentCell = this.dgvStaffRecord.Rows[this.dgvStaffRecord.Rows.Count - 1].Cells["StaffCode"];
  203. }
  204. else
  205. {
  206. this.dgvStaffRecord.Rows[selectRowIndex].Selected = true;
  207. this.dgvStaffRecord.CurrentCell = this.dgvStaffRecord.Rows[selectRowIndex].Cells["StaffCode"];
  208. }
  209. }
  210. #endregion
  211. }
  212. catch (Exception ex)
  213. {
  214. // 对异常进行共通处理
  215. ExceptionManager.HandleEventException(this.ToString(),
  216. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  217. }
  218. }
  219. /// <summary>
  220. /// 审批按钮
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void tsbtnApprover_Click(object sender, EventArgs e)
  225. {
  226. try
  227. {
  228. if (this.dgvStaffRecord.CurrentRow != null)
  229. {
  230. int intStaffID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffID"].Value);
  231. DateTime sopTimeStamp = Convert.ToDateTime(this.dgvStaffRecord.CurrentRow.Cells["SOPTIMESTAMP"].Value);
  232. int intStaffRecordID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffRecordID"].Value);
  233. DateTime ropTimeStamp = Convert.ToDateTime(this.dgvStaffRecord.CurrentRow.Cells["ROPTIMESTAMP"].Value);
  234. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  235. staffRecordEntity.StaffRecordID = intStaffRecordID;
  236. staffRecordEntity.OPTimeStamp = ropTimeStamp;
  237. staffRecordEntity.StaffID = intStaffID;
  238. staffRecordEntity.TargetJobs = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetJobs"].Value);
  239. staffRecordEntity.TargetStaffStatus = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetStaffStatus"].Value);
  240. string strExProbationEndDate = this.dgvStaffRecord.CurrentRow.Cells["ExProbationEndDate"].Value.ToString();
  241. if (!string.IsNullOrEmpty(strExProbationEndDate))
  242. {
  243. staffRecordEntity.ExProbationEndDate = Convert.ToDateTime(strExProbationEndDate);
  244. }
  245. S_CMN_011 frmCMN011 = new S_CMN_011();
  246. if (frmCMN011.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  247. {
  248. bool bolState = frmCMN011.HRApprovalState;
  249. string strMemo = frmCMN011.ApprovalMemo;
  250. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new AsyncMethod(() =>
  251. {
  252. return HRModuleProxy.Service.SaveHRStaffJobsApprovalInfo(intStaffID, sopTimeStamp, staffRecordEntity, bolState, strMemo);
  253. }));
  254. //0 没有数据被修改 -1员工档案被其他用户修改 -2存在待审批履历 -3员工履历被其他用户修改
  255. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  256. {
  257. // 提示信息
  258. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "工种调整", "审核"),
  259. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  260. this.btnSearch_Click(sender, e);
  261. }
  262. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  263. {
  264. // 提示信息
  265. MessageBox.Show(string.Format(Messages.MSG_HR_W006, "工种调整", "审核"),
  266. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  267. }
  268. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  269. {
  270. // 提示信息
  271. MessageBox.Show(Messages.MSG_CMN_W012,
  272. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  273. }
  274. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  275. {
  276. // 提示信息
  277. MessageBox.Show(Messages.MSG_CMN_W012,
  278. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  279. }
  280. else
  281. {
  282. // 提示信息
  283. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "工种调整", "审核"),
  284. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  285. }
  286. }
  287. }
  288. }
  289. catch (Exception ex)
  290. {
  291. // 对异常进行共通处理
  292. ExceptionManager.HandleEventException(this.ToString(),
  293. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  294. }
  295. }
  296. #endregion
  297. #region 私有方法
  298. /// <summary>
  299. /// 设置窗体按钮的文本信息
  300. /// </summary>
  301. private void SetFromTitleInfo()
  302. {
  303. this.tsrOperate.BackgroundImage = global::Dongke.IBOSS.PRD.Client.HRModule.Properties.Resources.functionbackground;
  304. this.tsrOperate.Height = 35;
  305. this.toolStripSeparator1.Height = 25;
  306. this.toolStripSeparator1.Width = 6;
  307. this.tsbtnApprover.Height = 25;
  308. this.tsbtnMoreCondition.Height = 25;
  309. this.tsbtnAdaptive.Height = 25;
  310. this.tsbtnClose.Height = 25;
  311. this.btnSearch.Height = 30;
  312. this.btnSearch.Width = 85;
  313. this.btnClearCondition.Height = 30;
  314. this.btnClearCondition.Width = 85;
  315. this.dgvStaffRecord.ColumnHeadersHeight = 23;
  316. this.dgvStaffRecord.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  317. this.dgvStaffRecord.AutoGenerateColumns = false;
  318. this.dgvStaffRecord.AutoGenerateColumns = false;
  319. this.Text = FormTitles.F_HR_0503;
  320. this.tsbtnApprover.Text = ButtonText.TSBTN_APPROVER;
  321. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  322. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  323. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  324. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  325. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  326. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  327. }
  328. /// <summary>
  329. /// 获取工种调整信息
  330. /// </summary>
  331. private void GetDataGridViewInfo()
  332. {
  333. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  334. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  335. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  336. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  337. searchStaffEntity.Recordtype = Convert.ToInt32(Constant.StaffRecordType.AdjustJob);
  338. searchStaffEntity.RValueflag = Convert.ToInt32(Constant.ValueFlag.Effective);
  339. //查询
  340. DataSet dsResult = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
  341. {
  342. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffApprove(searchStaffEntity);
  343. }));
  344. if (dsResult != null && dsResult.Tables.Count > Constant.INT_IS_ZERO)
  345. {
  346. // 记录最后选择行
  347. int selectRowIndex = this._selectedRowIndex;
  348. this.dgvStaffRecord.DataSource = dsResult.Tables[0];
  349. if (dsResult.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  350. {
  351. // 定位当前行
  352. if (this.dgvStaffRecord.Rows.Count > selectRowIndex)
  353. {
  354. this._selectedRowIndex = selectRowIndex;
  355. this.dgvStaffRecord.Rows[selectRowIndex].Selected = true;
  356. }
  357. else if (this.dgvStaffRecord.Rows.Count <= selectRowIndex)
  358. {
  359. this._selectedRowIndex = dgvStaffRecord.Rows.Count - 1;
  360. this.dgvStaffRecord.Rows[dgvStaffRecord.Rows.Count - 1].Selected = true;
  361. }
  362. }
  363. }
  364. else
  365. {
  366. // 清空明细中的数据
  367. this.dgvStaffRecord.DataSource = null;
  368. // 提示未查找到数据
  369. MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  370. }
  371. }
  372. #endregion
  373. }
  374. }