F_PAM_0501.cs 18 KB

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