F_TAT_0801.cs 19 KB

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