F_TAT_0301.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0301.cs
  5. * 2.功能描述:基本工资策略一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 任海 2014/12/10 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. using Dongke.IBOSS.PRD.Basics.DockPanel;
  19. using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
  20. using Dongke.IBOSS.PRD.Basics.BaseResources;
  21. using Dongke.IBOSS.PRD.Client.CommonModule;
  22. using Dongke.IBOSS.PRD.WCF.Proxys;
  23. using Dongke.IBOSS.PRD.WCF.DataModels;
  24. namespace Dongke.IBOSS.PRD.Client.TATModule
  25. {
  26. /// <summary>
  27. /// 基本工资策略一览
  28. /// </summary>
  29. public partial class F_TAT_0301 : DockPanelBase
  30. {
  31. #region 成员变量
  32. // 单例模式
  33. private static F_TAT_0301 _instance;
  34. // 检索用加载条件实体
  35. private BasicSalaryEntity _basicSalaryEntity = new BasicSalaryEntity();
  36. // 审核状态选择值
  37. private int? _auditStatusValue;
  38. // 策略类型选择值
  39. private int? _salaryTypeValue;
  40. #endregion
  41. #region 构造函数
  42. /// <summary>
  43. /// 窗体构造
  44. /// </summary>
  45. public F_TAT_0301()
  46. {
  47. InitializeComponent();
  48. }
  49. #endregion
  50. #region 单例模式
  51. /// <summary>
  52. /// 单例模式
  53. /// </summary>
  54. public static F_TAT_0301 Instance
  55. {
  56. get
  57. {
  58. if (_instance == null)
  59. {
  60. _instance = new F_TAT_0301();
  61. }
  62. return _instance;
  63. }
  64. }
  65. #endregion
  66. #region 事件处理
  67. /// <summary>
  68. /// 窗体加载
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_TAT_0301_Load(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. this.Text = FormTitles.F_TAT_0301;
  77. this.dgvBasicSalary.AutoGenerateColumns = false;
  78. //绑定页面各查询条件的数据源
  79. this.BindSelectData();
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 窗体关闭后
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void F_TAT_0301_FormClosed(object sender, FormClosedEventArgs e)
  94. {
  95. _instance = null;
  96. }
  97. /// <summary>
  98. /// 开始时间启用/关闭
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. private void cbStartTime_CheckedChanged(object sender, EventArgs e)
  103. {
  104. this.dtpStartTimeBetween.Enabled = this.cbStartTime.Checked;
  105. this.dtpStartTimeAfter.Enabled = this.cbStartTime.Checked;
  106. }
  107. private void cbEndTime_CheckedChanged(object sender, EventArgs e)
  108. {
  109. this.dtpEndTimeBetween.Enabled = this.cbEndTime.Checked;
  110. this.dtpEndTimeAfter.Enabled = this.cbEndTime.Checked;
  111. }
  112. /// <summary>
  113. /// 清空条件
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. private void btnClearCondition_Click(object sender, EventArgs e)
  118. {
  119. this.txtWagesName.Text = string.Empty;
  120. this.lbxAuditStatus.Text = string.Empty;
  121. this._auditStatusValue = null;
  122. this.txtRemarks.Text = string.Empty;
  123. this.cbStartTime.Checked = false;
  124. this.cbEndTime.Checked = false;
  125. this.lbxSalaryType.Text = string.Empty;
  126. this._salaryTypeValue = null;
  127. }
  128. /// <summary>
  129. /// 查询一览
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. private void btnSearch_Click(object sender, EventArgs e)
  134. {
  135. try
  136. {
  137. //置空列表
  138. this.dgvBasicSalary.DataSource = null;
  139. //绑定下拉框数据
  140. this.BindSelectedData();
  141. //获取数据源
  142. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  143. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  144. {
  145. this.BindGridView(srEntity.Data.Tables[0]);
  146. }
  147. //服务实体共通处理
  148. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  149. }
  150. catch (Exception ex)
  151. {
  152. // 对异常进行共通处理
  153. ExceptionManager.HandleEventException(this.ToString(),
  154. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  155. }
  156. }
  157. /// <summary>
  158. /// 选中行改变
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. private void dgvBasicSalary_SelectionChanged(object sender, EventArgs e)
  163. {
  164. DataGridViewRow gvrNow = this.dgvBasicSalary.CurrentRow;
  165. if (gvrNow != null)
  166. {
  167. //如果是待审核就可以进行修改,审核,停用
  168. if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
  169. == Convert.ToInt32(Constant.AuditStatus.Pending))
  170. {
  171. this.tsbtnEdit.Enabled = true;
  172. this.tsbtnApprover.Enabled = true;
  173. this.tsbtnDisable.Enabled = true;
  174. }
  175. else //否则不可以
  176. {
  177. //如果是审批通过的则不可以删除
  178. if (Convert.ToInt32(gvrNow.Cells["colAuditStatus"].Value)
  179. == Convert.ToInt32(Constant.AuditStatus.Agree))
  180. {
  181. this.tsbtnDisable.Enabled = false;
  182. }
  183. else
  184. {
  185. this.tsbtnDisable.Enabled = true;
  186. }
  187. this.tsbtnEdit.Enabled = false;
  188. this.tsbtnApprover.Enabled = false;
  189. }
  190. }
  191. }
  192. /// <summary>
  193. /// 新建信息
  194. /// </summary>
  195. /// <param name="sender"></param>
  196. /// <param name="e"></param>
  197. private void tsbtnAdd_Click(object sender, EventArgs e)
  198. {
  199. try
  200. {
  201. //以新建模式打开信息窗体
  202. F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Add, 0);
  203. DialogResult dialogResult = frmTAT0303.ShowDialog();
  204. //操作成功后刷新数据源
  205. if (dialogResult == DialogResult.OK)
  206. {
  207. this.dgvBasicSalary.DataSource = null;
  208. this.BindSelectedData();
  209. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  210. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  211. {
  212. this.BindGridView(srEntity.Data.Tables[0]);
  213. }
  214. //服务实体共通处理
  215. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. // 对异常进行共通处理
  221. ExceptionManager.HandleEventException(this.ToString(),
  222. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  223. }
  224. }
  225. /// <summary>
  226. /// 编辑信息
  227. /// </summary>
  228. /// <param name="sender"></param>
  229. /// <param name="e"></param>
  230. private void tsbtnEdit_Click(object sender, EventArgs e)
  231. {
  232. try
  233. {
  234. DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
  235. if (currentRow != null)
  236. {
  237. //获取需要添加明细的信息ID
  238. int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
  239. //以编辑模式打开信息窗体
  240. F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Edit, entityId);
  241. DialogResult dialogResult = frmTAT0303.ShowDialog();
  242. //操作成功后刷新数据源
  243. if (dialogResult == DialogResult.OK)
  244. {
  245. this.dgvBasicSalary.DataSource = null;
  246. this.BindSelectedData();
  247. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  248. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  249. {
  250. this.BindGridView(srEntity.Data.Tables[0]);
  251. }
  252. //服务实体共通处理
  253. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  254. }
  255. }
  256. }
  257. catch (Exception ex)
  258. {
  259. // 对异常进行共通处理
  260. ExceptionManager.HandleEventException(this.ToString(),
  261. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  262. }
  263. }
  264. /// <summary>
  265. /// 操作明细
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void tsbtnDetail_Click(object sender, EventArgs e)
  270. {
  271. try
  272. {
  273. DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
  274. if (currentRow != null)
  275. {
  276. //获取需要添加明细的信息ID
  277. int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
  278. String entityname = Convert.ToString(currentRow.Cells["colWagesName"].Value);
  279. //以编辑模式打开明细窗体
  280. F_TAT_0302 frmTAT0302 = new F_TAT_0302(Constant.FormMode.Edit, entityId, entityname);
  281. DialogResult dialogResult = frmTAT0302.ShowDialog();
  282. //操作成功后刷新数据源
  283. if (dialogResult == DialogResult.OK)
  284. {
  285. this.dgvBasicSalary.DataSource = null;
  286. this.BindSelectedData();
  287. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  288. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  289. {
  290. this.BindGridView(srEntity.Data.Tables[0]);
  291. }
  292. //服务实体共通处理
  293. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  294. }
  295. }
  296. }
  297. catch (Exception ex)
  298. {
  299. // 对异常进行共通处理
  300. ExceptionManager.HandleEventException(this.ToString(),
  301. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  302. }
  303. }
  304. /// <summary>
  305. /// 审核信息
  306. /// </summary>
  307. /// <param name="sender"></param>
  308. /// <param name="e"></param>
  309. private void tsbtnApprover_Click(object sender, EventArgs e)
  310. {
  311. try
  312. {
  313. DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
  314. if (currentRow != null)
  315. {
  316. //获取需审核的信息ID
  317. int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
  318. //编辑窗体以审核模式开启
  319. F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.Display, entityId);
  320. DialogResult dialogResult = frmTAT0303.ShowDialog();
  321. //操作成功后刷新数据源与列表
  322. if (dialogResult == DialogResult.OK)
  323. {
  324. this.dgvBasicSalary.DataSource = null;
  325. this.BindSelectedData();
  326. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  327. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  328. {
  329. this.BindGridView(srEntity.Data.Tables[0]);
  330. }
  331. //服务实体共通处理
  332. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  333. }
  334. }
  335. }
  336. catch (Exception ex)
  337. {
  338. // 对异常进行共通处理
  339. ExceptionManager.HandleEventException(this.ToString(),
  340. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  341. }
  342. }
  343. /// <summary>
  344. /// 停用信息
  345. /// </summary>
  346. /// <param name="sender"></param>
  347. /// <param name="e"></param>
  348. private void tsbtnDisable_Click(object sender, EventArgs e)
  349. {
  350. try
  351. {
  352. DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
  353. if (currentRow != null)
  354. {
  355. BasicSalaryEntity dfEntity = new BasicSalaryEntity();
  356. //获取ID以及时间戳
  357. dfEntity.BasicSalaryID = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
  358. dfEntity.OPTimeStamp = Convert.ToDateTime(currentRow.Cells["colOPTimeStamp"].Value);
  359. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  360. {
  361. return TATModuleProxy.Service.StopBasicSalary(dfEntity);
  362. });
  363. //服务实体共通处理
  364. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  365. //成功后刷新数据源
  366. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  367. {
  368. this.dgvBasicSalary.DataSource = null;
  369. this.BindSelectedData();
  370. srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  371. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  372. {
  373. this.BindGridView(srEntity.Data.Tables[0]);
  374. }
  375. //服务实体共通处理
  376. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  377. }
  378. }
  379. }
  380. catch (Exception ex)
  381. {
  382. // 对异常进行共通处理
  383. ExceptionManager.HandleEventException(this.ToString(),
  384. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  385. }
  386. }
  387. /// <summary>
  388. /// 复制添加信息
  389. /// </summary>
  390. /// <param name="sender"></param>
  391. /// <param name="e"></param>
  392. private void tsbtnCopy_Click(object sender, EventArgs e)
  393. {
  394. try
  395. {
  396. DataGridViewRow currentRow = this.dgvBasicSalary.CurrentRow;
  397. if (currentRow != null)
  398. {
  399. //获取需要添加明细的信息ID
  400. int entityId = Convert.ToInt32(currentRow.Cells["colWagesID"].Value);
  401. //以复制模式打开信息窗体
  402. F_TAT_0303 frmTAT0303 = new F_TAT_0303(Constant.FormMode.CopyAndAdd, entityId);
  403. DialogResult dialogResult = frmTAT0303.ShowDialog();
  404. //操作成功后刷新数据源
  405. if (dialogResult == DialogResult.OK)
  406. {
  407. this.dgvBasicSalary.DataSource = null;
  408. this.BindSelectedData();
  409. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(this.GetDate);
  410. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  411. {
  412. this.BindGridView(srEntity.Data.Tables[0]);
  413. }
  414. //服务实体共通处理
  415. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  416. }
  417. }
  418. }
  419. catch (Exception ex)
  420. {
  421. // 对异常进行共通处理
  422. ExceptionManager.HandleEventException(this.ToString(),
  423. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  424. }
  425. }
  426. /// <summary>
  427. /// 自适应列宽
  428. /// </summary>
  429. /// <param name="sender"></param>
  430. /// <param name="e"></param>
  431. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  432. {
  433. this.dgvBasicSalary.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  434. }
  435. /// <summary>
  436. /// 窗体关闭
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void tsbtnClose_Click(object sender, EventArgs e)
  441. {
  442. this.Close();
  443. }
  444. #endregion
  445. #region 私有方法/函数
  446. /// <summary>
  447. /// 绑定检索条件数据
  448. /// </summary>
  449. private void BindSelectData()
  450. {
  451. try
  452. {
  453. //绑定审核状态
  454. DataSet dsStatus = SystemModuleProxy.Service.GetAuditStatus();
  455. this.lbxAuditStatus.DataSource = dsStatus.Tables[0];
  456. this.lbxAuditStatus.ValueMember = "AuditStatusID";
  457. this.lbxAuditStatus.DisplayMember = "AuditStatusName";
  458. this.lbxAuditStatus.Text = "";
  459. //绑定策略类型
  460. DataTable dtSalaryType = new DataTable();
  461. dtSalaryType.Columns.Add("SalaryTypeValue");
  462. dtSalaryType.Columns.Add("SalaryTypeName");
  463. Type SalaryTypeEnum = typeof(Constant.SalaryType);
  464. Array SalaryTypeArray = Enum.GetValues(SalaryTypeEnum);
  465. for (int i = 0; i < Constant.SalaryTypeName.Length; i++)
  466. {
  467. dtSalaryType.Rows.Add(Convert.ToInt32(SalaryTypeArray.GetValue(i)), Constant.SalaryTypeName[i]);
  468. }
  469. this.lbxSalaryType.DisplayMember = "SalaryTypeName";
  470. this.lbxSalaryType.ValueMember = "SalaryTypeValue";
  471. this.lbxSalaryType.DataSource = dtSalaryType;
  472. this.lbxSalaryType.Text = "";
  473. }
  474. catch (Exception ex)
  475. {
  476. throw ex;
  477. }
  478. }
  479. /// <summary>
  480. /// 获取页面的输入值
  481. /// </summary>
  482. private void BindSelectedData()
  483. {
  484. try
  485. {
  486. if (this.lbxSalaryType.SelectedValue != null)
  487. {
  488. this._salaryTypeValue = Convert.ToInt32(this.lbxSalaryType.SelectedValue);
  489. }
  490. else
  491. {
  492. this._salaryTypeValue = null;
  493. }
  494. if (this.lbxAuditStatus.SelectedValue != null)
  495. {
  496. this._auditStatusValue = Convert.ToInt32(this.lbxAuditStatus.SelectedValue);
  497. }
  498. else
  499. {
  500. this._auditStatusValue = null;
  501. }
  502. //为查询用实体赋值
  503. this._basicSalaryEntity = new BasicSalaryEntity();
  504. if (!string.IsNullOrWhiteSpace(this.txtWagesName.Text))
  505. {
  506. this._basicSalaryEntity.BasicSalaryName = this.txtWagesName.Text.Trim();
  507. }
  508. if (this._auditStatusValue != null)
  509. {
  510. this._basicSalaryEntity.AuditStatus = this._auditStatusValue;
  511. }
  512. if (!string.IsNullOrWhiteSpace(this.txtRemarks.Text))
  513. {
  514. this._basicSalaryEntity.Remarks = this.txtRemarks.Text;
  515. }
  516. if (this.cbStartTime.Checked)
  517. {
  518. this._basicSalaryEntity.BeginAccountMonth = this.dtpStartTimeBetween.Value;
  519. this._basicSalaryEntity.BeginAccountMonthEnd = this.dtpStartTimeAfter.Value.AddDays(1);
  520. }
  521. if (this.cbEndTime.Checked)
  522. {
  523. this._basicSalaryEntity.EndAccountMonth = this.dtpEndTimeBetween.Value;
  524. this._basicSalaryEntity.EndAccountMonthEnd = this.dtpEndTimeAfter.Value.AddDays(1);
  525. }
  526. if (this._salaryTypeValue != null)
  527. {
  528. this._basicSalaryEntity.SalaryType = Convert.ToInt32(this._salaryTypeValue);
  529. }
  530. }
  531. catch (Exception ex)
  532. {
  533. throw ex;
  534. }
  535. }
  536. /// <summary>
  537. /// 绑定列表查询数据
  538. /// </summary>
  539. private ServiceResultEntity GetDate()
  540. {
  541. try
  542. {
  543. return TATModuleProxy.Service.GetBasicSalary(this._basicSalaryEntity);
  544. }
  545. catch (Exception ex)
  546. {
  547. throw ex;
  548. }
  549. }
  550. /// <summary>
  551. /// 绑定页面数据源
  552. /// </summary>
  553. /// <param name="dtSourse">数据源TABLE</param>
  554. private void BindGridView(DataTable dtSourse)
  555. {
  556. this.dgvBasicSalary.DataSource = dtSourse;
  557. this.dgvBasicSalary.ReadOnly = true;
  558. }
  559. #endregion
  560. }
  561. }