F_HR_0601.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0601.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.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. using Dongke.IBOSS.PRD.WCF.Proxys.HRModuleService;
  23. namespace Dongke.IBOSS.PRD.Client.HRModule
  24. {
  25. /// <summary>
  26. /// 职务调整
  27. /// </summary>
  28. public partial class F_HR_0601 : DockPanelBase
  29. {
  30. #region 成员变量
  31. // 窗体的单例模式
  32. private static F_HR_0601 _instance;
  33. // 选择的行
  34. private int _selectedRowIndex;
  35. // 查询条件实体
  36. private HR_CMN_StaffEntity _staffEntity = new HR_CMN_StaffEntity();
  37. //用户编辑的ID集合
  38. int[] _staffIDList;
  39. #endregion
  40. #region 构造函数
  41. /// <summary>
  42. /// 构造函数
  43. /// </summary>
  44. public F_HR_0601()
  45. {
  46. InitializeComponent();
  47. FormPermissionManager.FormPermissionControl(this.Name, this,
  48. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  49. this.SetFromTitleInfo();
  50. }
  51. #endregion
  52. #region 单例模式
  53. /// <summary>
  54. /// 单例模式,防止重复创建窗体
  55. /// </summary>
  56. public static F_HR_0601 Instance
  57. {
  58. get
  59. {
  60. if (_instance == null)
  61. {
  62. _instance = new F_HR_0601();
  63. }
  64. return _instance;
  65. }
  66. }
  67. #endregion
  68. #region 事件
  69. /// <summary>
  70. /// 页面加载事件
  71. /// </summary>
  72. /// <param name="sender"></param>
  73. /// <param name="e"></param>
  74. private void F_HR_0601_Load(object sender, EventArgs e)
  75. {
  76. try
  77. {
  78. // 加载权限
  79. FormPermissionManager.FormPermissionControl(this.Name, this,
  80. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  81. // 设置表格不自动创建列
  82. this.dgvStaffRecord.AutoGenerateColumns = false;
  83. // 设置ToolStripButton状态
  84. this.SetToolStripButtonEnable();
  85. this.tsbtnDisable.Visible = false;
  86. }
  87. catch (Exception ex)
  88. {
  89. // 对异常进行共通处理
  90. ExceptionManager.HandleEventException(this.ToString(),
  91. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  92. }
  93. }
  94. /// <summary>
  95. /// 窗体关闭事件
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void F_HR_0601_FormClosed(object sender, FormClosedEventArgs e)
  100. {
  101. _instance = null;
  102. }
  103. /// <summary>
  104. /// 行获取焦点后查看明细
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. private void dgvStaffRecord_CellEnter(object sender, DataGridViewCellEventArgs e)
  109. {
  110. try
  111. {
  112. if (this.dgvStaffRecord.CurrentCell != null)
  113. {
  114. // 记录最后选择行
  115. this._selectedRowIndex = this.dgvStaffRecord.CurrentCell.RowIndex;
  116. }
  117. }
  118. catch (Exception ex)
  119. {
  120. // 对异常进行共通处理
  121. ExceptionManager.HandleEventException(this.ToString(),
  122. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  123. }
  124. }
  125. /// <summary>
  126. /// 更多条件按钮
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void tsbtnMoreCondition_Click(object sender, EventArgs e)
  131. {
  132. HR_CMN_001 frmCMN001 = new HR_CMN_001();
  133. frmCMN001.StaffEntity = this._staffEntity;
  134. if (frmCMN001.ShowDialog() == DialogResult.OK)
  135. {
  136. this.txtOther.Text = frmCMN001.StaffEntity.GetSqlDispText();
  137. this._staffEntity = frmCMN001.StaffEntity;
  138. }
  139. }
  140. /// <summary>
  141. /// 清空条件
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void btnClearCondition_Click(object sender, EventArgs e)
  146. {
  147. this.txtStaffCode.Clear();
  148. this.txtStaffName.Clear();
  149. this.txtOther.Clear();
  150. this._staffEntity.ClearEntityValue();
  151. }
  152. /// <summary>
  153. /// 关闭按钮事件
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. private void tsbtnClose_Click(object sender, EventArgs e)
  158. {
  159. this.Close();
  160. }
  161. /// <summary>
  162. /// 自动适应列宽
  163. /// </summary>
  164. /// <param name="sender"></param>
  165. /// <param name="e"></param>
  166. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  167. {
  168. this.dgvStaffRecord.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  169. }
  170. /// <summary>
  171. /// 查询按钮
  172. /// </summary>
  173. /// <param name="sender"></param>
  174. /// <param name="e"></param>
  175. private void btnSearch_Click(object sender, EventArgs e)
  176. {
  177. try
  178. {
  179. this._staffIDList = null;
  180. // 记录当前选中行
  181. int selectRowIndex = this._selectedRowIndex;
  182. this.GetDataGridViewInfo();
  183. #region 选择原有行
  184. if (((DataTable)this.dgvStaffRecord.DataSource).Rows.Count <= Constant.INT_IS_ZERO)
  185. {
  186. // 提示未查找到数据
  187. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  188. MessageBoxButtons.OK, MessageBoxIcon.Information);
  189. }
  190. if (((DataTable)this.dgvStaffRecord.DataSource).Rows.Count > Constant.INT_IS_ZERO && selectRowIndex >= Constant.INT_IS_ZERO)
  191. {
  192. if (selectRowIndex >= ((DataTable)this.dgvStaffRecord.DataSource).Rows.Count)
  193. {
  194. this.dgvStaffRecord.Rows[this.dgvStaffRecord.Rows.Count - 1].Selected = true;
  195. this.dgvStaffRecord.CurrentCell = this.dgvStaffRecord.Rows[this.dgvStaffRecord.Rows.Count - 1].Cells["StaffCode"];
  196. }
  197. else
  198. {
  199. this.dgvStaffRecord.Rows[selectRowIndex].Selected = true;
  200. this.dgvStaffRecord.CurrentCell = this.dgvStaffRecord.Rows[selectRowIndex].Cells["StaffCode"];
  201. }
  202. }
  203. #endregion
  204. }
  205. catch (Exception ex)
  206. {
  207. // 对异常进行共通处理
  208. ExceptionManager.HandleEventException(this.ToString(),
  209. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  210. }
  211. }
  212. /// <summary>
  213. /// 添加按钮
  214. /// </summary>
  215. /// <param name="sender"></param>
  216. /// <param name="e"></param>
  217. private void tsbtnAdd_Click(object sender, EventArgs e)
  218. {
  219. try
  220. {
  221. F_HR_0602 frmHR0602 = new F_HR_0602(Constant.FormMode.Add, Constant.INT_IS_NEGATIE_ONE, Constant.INT_IS_NEGATIE_ONE);
  222. DialogResult dialogresult = frmHR0602.ShowDialog();
  223. if (dialogresult.Equals(DialogResult.OK))
  224. {
  225. this._staffIDList = frmHR0602.StaffIDList.ToArray();
  226. this.GetDataGridViewInfo();
  227. }
  228. }
  229. catch (Exception ex)
  230. {
  231. // 对异常进行共通处理
  232. ExceptionManager.HandleEventException(this.ToString(),
  233. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  234. }
  235. }
  236. /// <summary>
  237. /// 更新按钮
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void tsbtnEdit_Click(object sender, EventArgs e)
  242. {
  243. try
  244. {
  245. if (this.dgvStaffRecord.CurrentRow != null)
  246. {
  247. if (this.dgvStaffRecord.CurrentRow.Cells["ApprovalStatus"].Value == null
  248. || this.dgvStaffRecord.CurrentRow.Cells["RecordType"].Value == null)
  249. {
  250. // 不能进行修改
  251. MessageBox.Show(string.Format(Messages.MSG_HR_W005, "工种调整"),
  252. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  253. }
  254. string strApprovalStatus = this.dgvStaffRecord.CurrentRow.Cells["ApprovalStatus"].Value.ToString();
  255. string strRecordType = this.dgvStaffRecord.CurrentRow.Cells["RecordType"].Value.ToString();
  256. if (strApprovalStatus.Equals(Constant.ApprovalStatus.Pending.GetHashCode().ToString()) &&
  257. strRecordType.Equals(Constant.StaffRecordType.AdjustPost.GetHashCode().ToString()))
  258. {
  259. int intStaffID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffID"].Value);
  260. int intStaffRecordID = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffRecordID"].Value);
  261. F_HR_0602 frmHR0602 = new F_HR_0602(Constant.FormMode.Edit, intStaffID, intStaffRecordID);
  262. DialogResult dialogresult = frmHR0602.ShowDialog();
  263. if (dialogresult.Equals(DialogResult.OK))
  264. {
  265. this._staffIDList = frmHR0602.StaffIDList.ToArray();
  266. this.GetDataGridViewInfo();
  267. }
  268. }
  269. else
  270. {
  271. // 不能进行修改
  272. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "已经审核过的数据不能编辑"),
  273. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  274. }
  275. }
  276. }
  277. catch (Exception ex)
  278. {
  279. // 对异常进行共通处理
  280. ExceptionManager.HandleEventException(this.ToString(),
  281. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  282. }
  283. }
  284. /// <summary>
  285. /// 单元格鼠标双击事件
  286. /// </summary>
  287. /// <param name="sender"></param>
  288. /// <param name="e"></param>
  289. private void dgvStaffRecord_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  290. {
  291. if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  292. {
  293. this.tsbtnEdit_Click(sender, e);
  294. }
  295. }
  296. /// <summary>
  297. /// 停用按钮事件
  298. /// </summary>
  299. /// <param name="sender"></param>
  300. /// <param name="e"></param>
  301. private void tsbtnDisable_Click(object sender, EventArgs e)
  302. {
  303. try
  304. {
  305. if (this.dgvStaffRecord.SelectedRows.Count == Constant.INT_IS_ZERO)
  306. {
  307. return;
  308. }
  309. DialogResult msgBoxResult = MessageBox.Show(
  310. string.Format(Messages.MSG_CMN_Q002, "该职务调整申请", "停用"), this.Text,
  311. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  312. if (msgBoxResult == DialogResult.Yes)
  313. {
  314. int staffid = Convert.ToInt32(this.dgvStaffRecord.CurrentRow.Cells["StaffRecordID"].Value);
  315. HRResultEntity resultStaff = (HRResultEntity)DoAsync(() =>
  316. {
  317. return HRModuleProxy.Service.SetStaffRecordValueFlag(staffid);
  318. }
  319. );
  320. this.dgvStaffRecord.ReadOnly = true;
  321. // 修改成功
  322. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  323. {
  324. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "职务调整", "停用"),
  325. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  326. this.btnSearch_Click(sender, e);
  327. }
  328. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_FIVE)
  329. {
  330. MessageBox.Show(Messages.MSG_HR_W002,
  331. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  332. }
  333. else
  334. {
  335. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "职务调整", "停用"),
  336. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  337. }
  338. }
  339. }
  340. catch (Exception ex)
  341. {
  342. // 对异常进行共通处理
  343. ExceptionManager.HandleEventException(this.ToString(),
  344. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  345. }
  346. }
  347. #endregion
  348. #region 私有方法
  349. /// <summary>
  350. /// 设置窗体按钮的文本信息
  351. /// </summary>
  352. private void SetFromTitleInfo()
  353. {
  354. this.tsrOperate.BackgroundImage = global::Dongke.IBOSS.PRD.Client.HRModule.Properties.Resources.functionbackground;
  355. this.tsrOperate.Height = 35;
  356. this.toolStripSeparator1.Height = 25;
  357. this.toolStripSeparator1.Width = 6;
  358. this.tsbtnAdd.Height = 25;
  359. this.tsbtnEdit.Height = 25;
  360. this.tsbtnDisable.Height = 25;
  361. this.tsbtnMoreCondition.Height = 25;
  362. this.tsbtnAdaptive.Height = 25;
  363. this.tsbtnClose.Height = 25;
  364. this.btnSearch.Height = 30;
  365. this.btnSearch.Width = 85;
  366. this.btnClearCondition.Height = 30;
  367. this.btnClearCondition.Width = 85;
  368. this.dgvStaffRecord.ColumnHeadersHeight = 23;
  369. this.dgvStaffRecord.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  370. this.dgvStaffRecord.AutoGenerateColumns = false;
  371. this.dgvStaffRecord.AutoGenerateColumns = false;
  372. this.Text = FormTitles.F_HR_0601;
  373. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  374. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  375. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  376. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  377. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  378. this.tsbtnMoreCondition.Text = ButtonText.TSBTN_MORECONDITION;
  379. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  380. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  381. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  382. }
  383. /// <summary>
  384. /// 设置工具按钮的可用状态
  385. /// </summary>
  386. /// <remarks>
  387. private void SetToolStripButtonEnable()
  388. {
  389. if (this.dgvStaffRecord.CurrentCell != null)
  390. {
  391. this.tsbtnEdit.Enabled = true;
  392. }
  393. else
  394. {
  395. this.tsbtnEdit.Enabled = false;
  396. }
  397. }
  398. /// <summary>
  399. /// 获取职调整信息
  400. /// </summary>
  401. private void GetDataGridViewInfo()
  402. {
  403. try
  404. {
  405. SearchStaffEntity searchStaffEntity = new SearchStaffEntity();
  406. DataConvert.Convert(this._staffEntity, searchStaffEntity);
  407. searchStaffEntity.StaffCode = this.txtStaffCode.Text.Trim();
  408. searchStaffEntity.StaffName = this.txtStaffName.Text.Trim();
  409. searchStaffEntity.Recordtype = Convert.ToInt32(Constant.StaffRecordType.AdjustPost);
  410. searchStaffEntity.RValueflag = Convert.ToInt32(Constant.ValueFlag.Effective);
  411. if (this._staffIDList != null && this._staffIDList.Length > 0)
  412. {
  413. searchStaffEntity.RStaffRecordIDList = this._staffIDList;
  414. }
  415. //查询
  416. DataSet dsResult = (DataSet)DoAsync(new AsyncMethod(() =>
  417. {
  418. return WCF.Proxys.HRModuleProxy.Service.SearchHrStaffAndRecord(searchStaffEntity);
  419. }));
  420. if (dsResult != null && dsResult.Tables.Count > Constant.INT_IS_ZERO)
  421. {
  422. // 记录最后选择行
  423. int selectRowIndex = this._selectedRowIndex;
  424. this.dgvStaffRecord.DataSource = dsResult.Tables[0];
  425. if (dsResult.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  426. {
  427. // 定位当前行
  428. if (this.dgvStaffRecord.Rows.Count > selectRowIndex)
  429. {
  430. this._selectedRowIndex = selectRowIndex;
  431. this.dgvStaffRecord.Rows[selectRowIndex].Selected = true;
  432. }
  433. else if (this.dgvStaffRecord.Rows.Count <= selectRowIndex)
  434. {
  435. this._selectedRowIndex = this.dgvStaffRecord.Rows.Count - 1;
  436. this.dgvStaffRecord.Rows[this.dgvStaffRecord.Rows.Count - 1].Selected = true;
  437. }
  438. // 设置ToolStripButton按钮状态
  439. this.SetToolStripButtonEnable();
  440. this.dgvStaffRecord.ReadOnly = true;
  441. }
  442. }
  443. else
  444. {
  445. // 清空明细中的数据
  446. this.dgvStaffRecord.DataSource = null;
  447. // 提示未查找到数据
  448. MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  449. }
  450. }
  451. catch (Exception ex)
  452. {
  453. throw ex;
  454. }
  455. }
  456. #endregion
  457. }
  458. }