F_TAT_0701.cs 19 KB

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