F_HR_0703.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_HR_0703.cs
  5. * 2.功能描述:部门调整审批
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 冯雪 2014/09/19 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_0703 : DockPanelBase
  30. {
  31. #region 成员变量
  32. // 窗体的单例模式
  33. private static F_HR_0703 _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_0703()
  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_0703 Instance
  56. {
  57. get
  58. {
  59. if (_instance == null)
  60. {
  61. _instance = new F_HR_0703();
  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_0703_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_0703_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. if (((DataTable)this.dgvStaffRecord.DataSource).Rows.Count <= Constant.INT_IS_ZERO)
  189. {
  190. // 提示未查找到数据
  191. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  192. MessageBoxButtons.OK, MessageBoxIcon.Information);
  193. }
  194. }
  195. catch (Exception ex)
  196. {
  197. // 对异常进行共通处理
  198. ExceptionManager.HandleEventException(this.ToString(),
  199. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  200. }
  201. }
  202. /// <summary>
  203. /// 审批按钮
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void tsbtnApprover_Click(object sender, EventArgs e)
  208. {
  209. try
  210. {
  211. if (this.dgvStaffRecord.CurrentRow != null)
  212. {
  213. int intStaffID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffID"].Value);
  214. DateTime sopTimeStamp = Convert.ToDateTime(this.dgvStaffRecord.CurrentRow.Cells["SOPTIMESTAMP"].Value);
  215. int intStaffRecordID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffRecordID"].Value);
  216. DateTime ropTimeStamp = Convert.ToDateTime(this.dgvStaffRecord.CurrentRow.Cells["ROPTIMESTAMP"].Value);
  217. StaffRecordEntity staffRecordEntity = new StaffRecordEntity();
  218. staffRecordEntity.StaffRecordID = intStaffRecordID;
  219. staffRecordEntity.OPTimeStamp = ropTimeStamp;
  220. staffRecordEntity.StaffID = intStaffID;
  221. staffRecordEntity.TargetOrganizationID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetOrganizationID"].Value);
  222. if (!string.IsNullOrEmpty(this.dgvStaffRecord.CurrentRow.Cells["TargetJobs"].Value.ToString()))
  223. {
  224. staffRecordEntity.TargetJobs = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetJobs"].Value);
  225. staffRecordEntity.TargetStaffStatus = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetStaffStatus"].Value);
  226. if (this.dgvStaffRecord.CurrentRow.Cells["ExProbationEndDate"] != null && this.dgvStaffRecord.CurrentRow.Cells["ExProbationEndDate"].Value != DBNull.Value)
  227. {
  228. staffRecordEntity.ExProbationEndDate = Convert.ToDateTime(this.dgvStaffRecord.CurrentRow.Cells["ExProbationEndDate"].Value);
  229. }
  230. }
  231. else
  232. {
  233. staffRecordEntity.TargetJobs = -1000;
  234. }
  235. if (!string.IsNullOrEmpty(this.dgvStaffRecord.CurrentRow.Cells["TargetPost"].Value.ToString()))
  236. {
  237. staffRecordEntity.TargetPost = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["TargetPost"].Value);
  238. }
  239. else
  240. {
  241. staffRecordEntity.TargetPost = -1000;
  242. }
  243. S_CMN_011 frmCMN011 = new S_CMN_011();
  244. if (frmCMN011.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  245. {
  246. bool bolState = frmCMN011.HRApprovalState;
  247. string strMemo = frmCMN011.ApprovalMemo;
  248. HRResultEntity resultStaff = (HRResultEntity)DoAsync(new AsyncMethod(() =>
  249. {
  250. return HRModuleProxy.Service.SaveHRStaffOrganizationApprovalInfo(intStaffID, sopTimeStamp, staffRecordEntity, bolState, strMemo);
  251. }));
  252. //0 没有数据被修改 -1员工档案被其他用户修改 -2存在待审批履历 -3员工履历被其他用户修改
  253. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  254. {
  255. // 提示信息
  256. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "部门调整", "审核"),
  257. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  258. this.btnSearch_Click(sender, e);
  259. }
  260. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  261. {
  262. // 提示信息
  263. MessageBox.Show(string.Format(Messages.MSG_HR_W006, "部门调整", "审核"),
  264. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  265. }
  266. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_TWO)
  267. {
  268. // 提示信息
  269. MessageBox.Show(Messages.MSG_CMN_W012,
  270. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  271. }
  272. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  273. {
  274. // 提示信息
  275. MessageBox.Show(Messages.MSG_CMN_W012,
  276. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  277. }
  278. else
  279. {
  280. // 提示信息
  281. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "部门调整", "审核"),
  282. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  283. }
  284. }
  285. }
  286. }
  287. catch (Exception ex)
  288. {
  289. // 对异常进行共通处理
  290. ExceptionManager.HandleEventException(this.ToString(),
  291. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  292. }
  293. }
  294. #endregion
  295. #region 私有方法
  296. /// <summary>
  297. /// 设置窗体按钮的文本信息
  298. /// </summary>
  299. private void SetFromTitleInfo()
  300. {
  301. this.tsrOperate.BackgroundImage = global::Dongke.IBOSS.PRD.Client.HRModule.Properties.Resources.functionbackground;
  302. this.tsrOperate.Height = 35;
  303. this.toolStripSeparator1.Height = 25;
  304. this.toolStripSeparator1.Width = 6;
  305. this.tsbtnApprover.Height = 25;
  306. this.tsbtnMoreCondition.Height = 25;
  307. this.tsbtnAdaptive.Height = 25;
  308. this.tsbtnClose.Height = 25;
  309. this.btnSearch.Height = 30;
  310. this.btnSearch.Width = 85;
  311. this.btnClearCondition.Height = 30;
  312. this.btnClearCondition.Width = 85;
  313. this.dgvStaffRecord.ColumnHeadersHeight = 23;
  314. this.dgvStaffRecord.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  315. this.dgvStaffRecord.AutoGenerateColumns = false;
  316. this.dgvStaffRecord.AutoGenerateColumns = false;
  317. this.Text = FormTitles.F_HR_0703;
  318. this.tsbtnApprover.Text = ButtonText.TSBTN_APPROVER;
  319. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  320. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  321. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  322. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  323. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  324. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  325. }
  326. /// <summary>
  327. /// 获取职务调整信息
  328. /// </summary>
  329. private void GetDataGridViewInfo()
  330. {
  331. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  332. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  333. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  334. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  335. searchStaffEntity.Recordtype = Convert.ToInt32(Constant.StaffRecordType.AdjustOrganization);
  336. searchStaffEntity.RValueflag = Convert.ToInt32(Constant.ValueFlag.Effective);
  337. //查询
  338. DataSet dsResult = (DataSet)DoAsync(new AsyncMethod(() =>
  339. {
  340. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffApprove(searchStaffEntity);
  341. }));
  342. if (dsResult != null && dsResult.Tables.Count > Constant.INT_IS_ZERO)
  343. {
  344. // 记录最后选择行
  345. int selectRowIndex = this._selectedRowIndex;
  346. this.dgvStaffRecord.DataSource = dsResult.Tables[0];
  347. if (dsResult.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  348. {
  349. // 定位当前行
  350. if (this.dgvStaffRecord.Rows.Count > selectRowIndex)
  351. {
  352. this._selectedRowIndex = selectRowIndex;
  353. this.dgvStaffRecord.Rows[selectRowIndex].Selected = true;
  354. }
  355. else if (this.dgvStaffRecord.Rows.Count <= selectRowIndex)
  356. {
  357. this._selectedRowIndex = dgvStaffRecord.Rows.Count - 1;
  358. this.dgvStaffRecord.Rows[dgvStaffRecord.Rows.Count - 1].Selected = true;
  359. }
  360. }
  361. }
  362. else
  363. {
  364. // 清空明细中的数据
  365. this.dgvStaffRecord.DataSource = null;
  366. // 提示未查找到数据
  367. MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  368. }
  369. }
  370. #endregion
  371. }
  372. }