F_PM_1104.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1104.cs
  5. * 2.功能描述:进度奖惩
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/10/9 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Client.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  20. namespace Dongke.IBOSS.PRD.Client.PMModule
  21. {
  22. /// <summary>
  23. /// 进度奖惩
  24. /// </summary>
  25. public partial class F_PM_1104 : DockPanelBase
  26. {
  27. #region 成员变量
  28. // 窗体的单例模式
  29. private static F_PM_1104 _instance;
  30. //Grid当前选中的行
  31. private int _selectedRowIndex;
  32. //用户编辑的ID集合
  33. int[] _staffIDList;
  34. #endregion
  35. #region 构造函数
  36. /// <summary>
  37. /// 构造函数
  38. /// </summary>
  39. public F_PM_1104()
  40. {
  41. InitializeComponent();
  42. this.SetFromTitleInfo();
  43. // 设置ToolStripButton状态
  44. this.SetToolStripButtonEnable();
  45. }
  46. #endregion
  47. #region 单例模式
  48. /// <summary>
  49. /// 单例模式,防止重复创建窗体
  50. /// </summary>
  51. public static F_PM_1104 Instance
  52. {
  53. get
  54. {
  55. if (_instance == null)
  56. {
  57. _instance = new F_PM_1104();
  58. }
  59. return _instance;
  60. }
  61. }
  62. #endregion
  63. #region 事件
  64. /// <summary>
  65. /// 窗体加载事件
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void F_PM_1104_Load(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. #region 绑定数据源
  74. this.dkStaffName.WhereCondition = "(StaffStatus = 1 Or StaffStatus = 2) AND ValueFlag = 1";
  75. this.comRAPType.DataSource = GetRAPTypeInfo();
  76. this.comRAPType.DisplayMember = "TypeName";
  77. this.comRAPType.ValueMember = "TypeID";
  78. this.comSettlementFlag.DataSource = GetSettlementFlagInfo();
  79. this.comSettlementFlag.DisplayMember = "SettlementFlagName";
  80. this.comSettlementFlag.ValueMember = "SettlementFlagID";
  81. this.comAuditStatus.DataSource = GetAuditStatusInfo();
  82. this.comAuditStatus.DisplayMember = "AuditstatusName";
  83. this.comAuditStatus.ValueMember = "AuditstatusID";
  84. #endregion
  85. FormPermissionManager.FormPermissionControl(this.Name, this,
  86. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  87. }
  88. catch (Exception ex)
  89. {
  90. // 对异常进行共通处理
  91. ExceptionManager.HandleEventException(this.ToString(),
  92. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  93. }
  94. }
  95. /// <summary>
  96. /// 窗体关闭事件
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void F_PM_1104_FormClosed(object sender, FormClosedEventArgs e)
  101. {
  102. _instance = null;
  103. }
  104. /// <summary>
  105. /// 行获取焦点事件
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void dgvStaff_CellEnter(object sender, DataGridViewCellEventArgs e)
  110. {
  111. try
  112. {
  113. if (this.dgvStaff.CurrentCell != null)
  114. {
  115. // 记录最后选择行
  116. this._selectedRowIndex = this.dgvStaff.CurrentCell.RowIndex;
  117. }
  118. }
  119. catch (Exception ex)
  120. {
  121. // 对异常进行共通处理
  122. ExceptionManager.HandleEventException(this.ToString(),
  123. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  124. }
  125. }
  126. /// <summary>
  127. /// 单元格鼠标双击事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void dgvStaff_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  132. {
  133. if (Constant.INT_IS_NEGATIE_ONE < e.RowIndex && Constant.INT_IS_NEGATIE_ONE < e.ColumnIndex
  134. && this.tsbtnEdit.Enabled && this.tsbtnEdit.Visible)
  135. {
  136. this.tsbtnEdit_Click(sender, e);
  137. }
  138. }
  139. /// <summary>
  140. /// 添加按钮
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. private void tsbtnAdd_Click(object sender, EventArgs e)
  145. {
  146. try
  147. {
  148. F_PM_1105 frmHR1105 = new F_PM_1105(Constant.FormMode.Add, Constant.INT_IS_NEGATIE_ONE);
  149. if (frmHR1105.ShowDialog() == DialogResult.OK)
  150. {
  151. this._staffIDList = frmHR1105.StaffIDList.ToArray();
  152. SearchProgressRAPEntity searchProgressRAPEntity = SetSearchProgressRAPEntity();
  153. searchProgressRAPEntity.IDList = this._staffIDList;
  154. searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  155. DataSet dsResultStaff = (DataSet)DoAsync(new AsyncMethod(() =>
  156. {
  157. return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
  158. }));
  159. if (dsResultStaff != null && dsResultStaff.Tables.Count > Constant.INT_IS_ZERO
  160. && dsResultStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  161. {
  162. this.dgvStaff.DataSource = null;
  163. this.dgvStaff.DataSource = dsResultStaff.Tables[0];
  164. // 设置ToolStripButton按钮状态
  165. this.SetToolStripButtonEnable();
  166. this.dgvStaff.ReadOnly = true;
  167. }
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. // 对异常进行共通处理
  173. ExceptionManager.HandleEventException(this.ToString(),
  174. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  175. }
  176. }
  177. /// <summary>
  178. /// 编辑按钮
  179. /// </summary>
  180. /// <param name="sender"></param>
  181. /// <param name="e"></param>
  182. private void tsbtnEdit_Click(object sender, EventArgs e)
  183. {
  184. try
  185. {
  186. if (this.dgvStaff.CurrentRow != null)
  187. {
  188. if (this.dgvStaff.CurrentRow.Cells["AUDITSTATUS"].Value == null)
  189. {
  190. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, " 审批状态错误"),
  191. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  192. return;
  193. }
  194. string strAUDITSTATUS = this.dgvStaff.CurrentRow.Cells["AUDITSTATUS"].Value.ToString();
  195. if (Constant.ApprovalStatus.Pending.GetHashCode().ToString().Equals(strAUDITSTATUS))
  196. {
  197. int intRAPID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["RAPID"].Value);
  198. F_PM_1105 frmHR1105 = new F_PM_1105(Constant.FormMode.Edit, intRAPID);
  199. if (frmHR1105.ShowDialog() == DialogResult.OK)
  200. {
  201. this._staffIDList = frmHR1105.StaffIDList.ToArray();
  202. SearchProgressRAPEntity searchProgressRAPEntity = SetSearchProgressRAPEntity();
  203. searchProgressRAPEntity.IDList = this._staffIDList;
  204. searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  205. DataSet dsResultStaff = (DataSet)DoAsync(new AsyncMethod(() =>
  206. {
  207. return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
  208. }));
  209. if (dsResultStaff != null && dsResultStaff.Tables.Count > Constant.INT_IS_ZERO
  210. && dsResultStaff.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  211. {
  212. this.dgvStaff.DataSource = null;
  213. this.dgvStaff.DataSource = dsResultStaff.Tables[0];
  214. // 设置ToolStripButton按钮状态
  215. this.SetToolStripButtonEnable();
  216. this.dgvStaff.ReadOnly = true;
  217. }
  218. }
  219. }
  220. else
  221. {
  222. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, " 审批状态错误"),
  223. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  224. return;
  225. }
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. // 对异常进行共通处理
  231. ExceptionManager.HandleEventException(this.ToString(),
  232. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  233. }
  234. }
  235. /// <summary>
  236. /// 停用按钮事件
  237. /// </summary>
  238. /// <param name="sender"></param>
  239. /// <param name="e"></param>
  240. private void tsbtnDisable_Click(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. DialogResult msgBoxResult = MessageBox.Show(
  245. string.Format(Messages.MSG_CMN_Q002, "该信息", "停用"), this.Text,
  246. MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  247. if (msgBoxResult == DialogResult.Yes)
  248. {
  249. int intRAPID = Convert.ToInt32(this.dgvStaff.CurrentRow.Cells["RAPID"].Value);
  250. PMResultEntity resultStaff = (PMResultEntity)DoAsync(() =>
  251. {
  252. return PMModuleProxy.Service.SetStaffProgressRAPValueFlag(intRAPID);
  253. }
  254. );
  255. this.dgvStaff.ReadOnly = true;
  256. // 修改成功
  257. if (resultStaff.OperateStatus > Constant.INT_IS_ZERO)
  258. {
  259. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "进度考核奖惩", "停用"),
  260. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  261. this.btnSearch_Click(sender, e);
  262. }
  263. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_ONE)
  264. {
  265. MessageBox.Show(string.Format(Messages.MSG_HR_W003, "进度考核奖惩"),
  266. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  267. }
  268. else if (resultStaff.OperateStatus == Constant.INT_IS_NEGATIE_THREE)
  269. {
  270. MessageBox.Show(string.Format(Messages.MSG_HR_W004, "进度考核奖惩"),
  271. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  272. }
  273. else
  274. {
  275. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "进度考核奖惩", "停用"),
  276. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  277. }
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. // 对异常进行共通处理
  283. ExceptionManager.HandleEventException(this.ToString(),
  284. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  285. }
  286. }
  287. /// <summary>
  288. /// 自动适应列宽
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  293. {
  294. this.dgvStaff.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  295. }
  296. /// <summary>
  297. /// 关闭按钮事件
  298. /// </summary>
  299. /// <param name="sender"></param>
  300. /// <param name="e"></param>
  301. private void tsbtnClose_Click(object sender, EventArgs e)
  302. {
  303. this.Close();
  304. }
  305. /// <summary>
  306. /// 查询按钮事件
  307. /// </summary>
  308. /// <param name="sender"></param>
  309. /// <param name="e"></param>
  310. private void btnSearch_Click(object sender, EventArgs e)
  311. {
  312. try
  313. {
  314. this._staffIDList = null;
  315. // 记录当前选中行
  316. int selectRowIndex = this._selectedRowIndex;
  317. SearchProgressRAPEntity searchProgressRAPEntity = SetSearchProgressRAPEntity();
  318. DataSet dsResultStaff = (DataSet)DoAsync(new AsyncMethod(() =>
  319. {
  320. return PMModuleProxy.Service.SearcStaffAdminRAPInfo(searchProgressRAPEntity);
  321. }));
  322. if (dsResultStaff != null)
  323. {
  324. base.DataSource = dsResultStaff;
  325. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  326. {
  327. this.dgvStaff.DataSource = this.DataSource.Tables[0];
  328. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  329. {
  330. // 提示未查找到数据
  331. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  332. MessageBoxButtons.OK, MessageBoxIcon.Information);
  333. }
  334. else
  335. {
  336. #region 选择原有行
  337. if (selectRowIndex >= Constant.INT_IS_ZERO)
  338. {
  339. if (selectRowIndex >= dsResultStaff.Tables[0].Rows.Count)
  340. {
  341. this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Selected = true;
  342. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[this.dgvStaff.Rows.Count - 1].Cells["StaffName"];
  343. }
  344. else
  345. {
  346. this.dgvStaff.Rows[selectRowIndex].Selected = true;
  347. this.dgvStaff.CurrentCell = this.dgvStaff.Rows[selectRowIndex].Cells["StaffName"];
  348. }
  349. }
  350. #endregion
  351. }
  352. }
  353. }
  354. this.SetToolStripButtonEnable();
  355. }
  356. catch (Exception ex)
  357. {
  358. // 对异常进行共通处理
  359. ExceptionManager.HandleEventException(this.ToString(),
  360. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  361. }
  362. }
  363. /// <summary>
  364. /// 清空条件
  365. /// </summary>
  366. /// <param name="sender"></param>
  367. /// <param name="e"></param>
  368. private void btnClearCondition_Click(object sender, EventArgs e)
  369. {
  370. this.dkStaffName.UserID = null;
  371. this.dkStaffName.UserCode = string.Empty;
  372. this.dkStaffName.UserName = string.Empty;
  373. this.dkStaffName.StaffEntity = null;
  374. this.comRAPType.SelectedIndex = 0;
  375. this.comAuditStatus.SelectedIndex = 0;
  376. this.comSettlementFlag.SelectedIndex = 0;
  377. }
  378. #endregion
  379. #region 私有方法
  380. /// <summary>
  381. /// 设置窗体按钮的文本信息
  382. /// </summary>
  383. private void SetFromTitleInfo()
  384. {
  385. this.Text = FormTitles.F_PM_1104;
  386. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  387. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  388. this.tsbtnDisable.Text = ButtonText.TSBTN_DISABLE;
  389. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  390. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  391. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  392. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  393. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  394. }
  395. /// <summary>
  396. /// 设置工具按钮的可用状态
  397. /// </summary>
  398. /// <remarks>
  399. private void SetToolStripButtonEnable()
  400. {
  401. if (this.dgvStaff.CurrentCell != null)
  402. {
  403. this.tsbtnEdit.Enabled = true;
  404. }
  405. else
  406. {
  407. this.tsbtnEdit.Enabled = false;
  408. }
  409. }
  410. /// <summary>
  411. /// 获取奖惩类型数据源
  412. /// </summary>
  413. /// <returns></returns>
  414. private DataTable GetRAPTypeInfo()
  415. {
  416. //1:奖励;-1:惩罚
  417. DataTable dtRAPType = new DataTable();
  418. dtRAPType.Columns.Add("TypeID");
  419. dtRAPType.Columns.Add("TypeName");
  420. DataRow newRowType = dtRAPType.NewRow();
  421. newRowType["TypeID"] = Constant.CBO_SELECT_ALL_VALUE;
  422. newRowType["TypeName"] = Constant.CBO_SELECT_ALL_NAME;
  423. dtRAPType.Rows.Add(newRowType);
  424. newRowType = dtRAPType.NewRow();
  425. newRowType["TypeID"] = "1";
  426. newRowType["TypeName"] = "奖励";
  427. dtRAPType.Rows.Add(newRowType);
  428. newRowType = dtRAPType.NewRow();
  429. newRowType["TypeID"] = "-1";
  430. newRowType["TypeName"] = "惩罚";
  431. dtRAPType.Rows.Add(newRowType);
  432. return dtRAPType;
  433. }
  434. /// <summary>
  435. /// 获取审批状态信息
  436. /// </summary>
  437. /// <returns></returns>
  438. public DataTable GetAuditStatusInfo()
  439. {
  440. DataTable dtAudit = LogInUserInfo.CurrentUser.GetSystemParameterByName(Constant.SysCacheTable.TP_SYS_AuditStatus);
  441. DataRow newRowAudit = dtAudit.NewRow();
  442. newRowAudit["AuditstatusID"] = Constant.CBO_SELECT_ALL_VALUE;
  443. newRowAudit["AuditstatusName"] = Constant.CBO_SELECT_ALL_NAME;
  444. dtAudit.Rows.InsertAt(newRowAudit, 0);
  445. return dtAudit;
  446. }
  447. /// <summary>
  448. /// 工资结算标识数据源
  449. /// </summary>
  450. /// <returns></returns>
  451. private DataTable GetSettlementFlagInfo()
  452. {
  453. //1:已经结算 0:未结算
  454. DataTable dtRAPType = new DataTable();
  455. dtRAPType.Columns.Add("SettlementFlagID");
  456. dtRAPType.Columns.Add("SettlementFlagName");
  457. DataRow newRowType = dtRAPType.NewRow();
  458. newRowType["SettlementFlagID"] = Constant.CBO_SELECT_ALL_VALUE;
  459. newRowType["SettlementFlagName"] = Constant.CBO_SELECT_ALL_NAME;
  460. dtRAPType.Rows.Add(newRowType);
  461. newRowType = dtRAPType.NewRow();
  462. newRowType["SettlementFlagID"] = "0";
  463. newRowType["SettlementFlagName"] = "未结算";
  464. dtRAPType.Rows.Add(newRowType);
  465. newRowType = dtRAPType.NewRow();
  466. newRowType["SettlementFlagID"] = "1";
  467. newRowType["SettlementFlagName"] = "已经结算";
  468. dtRAPType.Rows.Add(newRowType);
  469. return dtRAPType;
  470. }
  471. /// <summary>
  472. /// 根据查询条件 形成查询实体
  473. /// </summary>
  474. /// <returns></returns>
  475. public SearchProgressRAPEntity SetSearchProgressRAPEntity()
  476. {
  477. SearchProgressRAPEntity searchProgressRAPEntity = new SearchProgressRAPEntity();
  478. searchProgressRAPEntity.ValueFlag = Constant.ValueFlag.Effective.GetHashCode().ToString();
  479. if (this.dkStaffName.UserID != null)
  480. {
  481. searchProgressRAPEntity.StaffID = this.dkStaffName.UserID;
  482. }
  483. //if (
  484. // !Constant.CBO_SELECT_ALL_VALUE.Equals(this.comRAPType.SelectedValue.ToString()))
  485. if (Convert.ToInt32(this.comRAPType.SelectedValue)!=-99)
  486. {
  487. searchProgressRAPEntity.RAPType = Convert.ToDouble(this.comRAPType.SelectedValue);
  488. }
  489. if (this.comSettlementFlag.SelectedValue != null
  490. && !Constant.CBO_SELECT_ALL_VALUE.Equals(this.comSettlementFlag.SelectedValue.ToString()))
  491. {
  492. searchProgressRAPEntity.SettlementFlag = this.comSettlementFlag.SelectedValue.ToString();
  493. }
  494. if (Convert.ToInt32(this.comAuditStatus.SelectedValue) != -99)
  495. //if (this.comAuditStatus.SelectedValue != null
  496. // && !Constant.CBO_SELECT_ALL_VALUE.Equals(this.comAuditStatus.SelectedValue.ToString()))
  497. {
  498. searchProgressRAPEntity.AuditStatus = Convert.ToInt32(this.comAuditStatus.SelectedValue);
  499. }
  500. if (this._staffIDList != null && this._staffIDList.Length > Constant.INT_IS_ZERO)
  501. {
  502. searchProgressRAPEntity.IDList = this._staffIDList;
  503. }
  504. return searchProgressRAPEntity;
  505. }
  506. #endregion
  507. }
  508. }