F_TAT_0803.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0803.cs
  5. * 2.功能描述:出勤考核扣罚明细
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 任海 2014/12/16 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.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.BaseResources;
  20. using Dongke.IBOSS.PRD.Client.CommonModule;
  21. using Dongke.IBOSS.PRD.Client.Controls;
  22. using Dongke.IBOSS.PRD.WCF.DataModels;
  23. using Dongke.IBOSS.PRD.WCF.Proxys;
  24. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  25. using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
  26. namespace Dongke.IBOSS.PRD.Client.TATModule
  27. {
  28. /// <summary>
  29. /// 出勤考核扣罚明细
  30. /// </summary>
  31. public partial class F_TAT_0803 : FormBase
  32. {
  33. #region 成员变量
  34. // 窗体模式ID
  35. private Constant.FormMode _formType;
  36. // 操作实体ID
  37. private int? _entityId;
  38. // 主体工种ID
  39. private int? _JobsId;
  40. // 操作实体名称
  41. //private string _entityname;
  42. // 操作出勤考核实体
  43. private AttendanceEntity _attendanceEntity = new AttendanceEntity();
  44. // 操作出勤考核明细实体
  45. private AttendanceDetailEntity _attendanceDetailEntity = new AttendanceDetailEntity();
  46. // 选择窗体弹出标识
  47. //private bool _showFlag = true;
  48. // 数据源
  49. private DataSet _dsSourse;
  50. // 窗体加载完毕标识
  51. //private bool _pageLoadOK = false;
  52. #endregion
  53. #region 构造函数
  54. /// <summary>
  55. /// 窗体构造
  56. /// </summary>
  57. /// <param name="formType">窗体开启模式</param>
  58. /// <param name="entityId">操作实体ID</param>
  59. public F_TAT_0803(Constant.FormMode formType, int AttendanceID,
  60. int JobsId)
  61. {
  62. InitializeComponent();
  63. this._formType = formType;
  64. this._entityId = AttendanceID;
  65. this._JobsId = JobsId;
  66. this.btnSubmit.Text = ButtonText.BTN_SAVE;
  67. this.btnClose.Text = ButtonText.BTN_CANCEL;
  68. }
  69. #endregion
  70. #region 事件处理
  71. /// <summary>
  72. /// 窗体加载
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_TAT_0803_Load(object sender, EventArgs e)
  77. {
  78. try
  79. {
  80. this.WeekData();
  81. ///不自动创建列
  82. this.dgvPunishMode.AutoGenerateColumns = false;
  83. this.BindAttFinesRules();
  84. ///绑定主体信息
  85. this.BindPage();
  86. /// 加载控件
  87. this.Loading();
  88. if (this._formType == Constant.FormMode.CopyAndAdd)
  89. {
  90. this.dgvPunishMode.ReadOnly = true;
  91. this.dgvPunishMode.IsSetInputColumnsColor = false;
  92. this.dgvPunishMode.AllowUserToAddRows = false;
  93. }
  94. if (this._formType == Constant.FormMode.Display)
  95. {
  96. //列表设置为只读
  97. this.dgvPunishMode.ReadOnly = true;
  98. this.dgvPunishMode.IsSetInputColumnsColor = false;
  99. this.dgvPunishMode.AllowUserToAddRows = false;
  100. //控件除关闭外全部不可用
  101. this.txtday.Enabled = false;
  102. this.cbday.Enabled = false;
  103. this.cbWeek.Enabled = false;
  104. this.SelWeek.Enabled = false;
  105. this.cbPunishSetting.Enabled = false;
  106. this.cbBasicSalaryScale.Enabled = false;
  107. this.btnSubmit.Enabled = false;
  108. }
  109. }
  110. catch (Exception ex)
  111. {
  112. // 对异常进行共通处理
  113. ExceptionManager.HandleEventException(this.ToString(),
  114. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  115. }
  116. }
  117. /// <summary>
  118. /// 选中控件时休息天数控件不可用
  119. /// </summary>
  120. private void cbWeek_Click(object sender, EventArgs e)
  121. {
  122. this.SelWeek.Enabled = true;
  123. this.txtday.Enabled = false;
  124. }
  125. /// <summary>
  126. /// 选中控件时按星期控件不可用
  127. /// </summary>
  128. private void cbday_Click(object sender, EventArgs e)
  129. {
  130. this.txtday.Enabled = true;
  131. this.SelWeek.Enabled = false;
  132. }
  133. // <summary>
  134. /// 选中控件时表格不可用
  135. /// </summary>
  136. private void cbBasicSalaryScale_Click(object sender, EventArgs e)
  137. {
  138. try
  139. {
  140. this.dgvPunishMode.Enabled = false;
  141. this.dgvPunishMode.ReadOnly = true;
  142. this.dgvPunishMode.IsSetInputColumnsColor = false;
  143. DataTable dtCurrentTable = this.dgvPunishMode.DataSource as DataTable;
  144. if (dtCurrentTable != null)
  145. {
  146. foreach(DataRow r in dtCurrentTable.Rows)
  147. {
  148. r.Delete();
  149. }
  150. }
  151. this.dgvPunishMode.DataSource = dtCurrentTable;
  152. }
  153. catch (Exception ex)
  154. {
  155. // 对异常进行共通处理
  156. ExceptionManager.HandleEventException(this.ToString(),
  157. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  158. }
  159. }
  160. /// <summary>
  161. /// 选中控件时表格可用
  162. /// </summary>
  163. private void cbPunishSetting_Click(object sender, EventArgs e)
  164. {
  165. this.dgvPunishMode.Enabled = true;
  166. this.dgvPunishMode.ReadOnly = false;
  167. this.dgvPunishMode.IsSetInputColumnsColor = true;
  168. }
  169. /// <summary>
  170. /// 提交操作
  171. /// </summary>
  172. /// <param name="sender"></param>
  173. /// <param name="e"></param>
  174. private void btnSubmit_Click(object sender, EventArgs e)
  175. {
  176. try
  177. {
  178. //获取页面值绑定属性
  179. this.BindEntity();
  180. DataTable datatPunishMode = (DataTable)this.dgvPunishMode.DataSource;
  181. int StartIndex = 1;
  182. if (datatPunishMode != null && datatPunishMode.Rows.Count > 0)
  183. {
  184. if (datatPunishMode.Rows[0].RowState != DataRowState.Deleted)
  185. StartIndex = Convert.ToInt32(datatPunishMode.Rows[0]["BeginAbsentDays"]);
  186. }
  187. bool isError = false;
  188. if (datatPunishMode != null)
  189. {
  190. foreach (DataRow drproductionData in datatPunishMode.Rows)
  191. {
  192. if (drproductionData.RowState != DataRowState.Deleted)
  193. {
  194. if (drproductionData["BeginAbsentDays"].ToString() == "" || drproductionData["EndAbsentDays"].ToString() == "")
  195. {
  196. isError = true;
  197. break;
  198. }
  199. if (Convert.ToInt32(drproductionData["BeginAbsentDays"]) != StartIndex)
  200. {
  201. isError = true;
  202. break;
  203. }
  204. int number = Convert.ToInt32(drproductionData["EndAbsentDays"]) - Convert.ToInt32(drproductionData["BeginAbsentDays"]);
  205. if (number < 0)
  206. {
  207. isError = true;
  208. break;
  209. }
  210. StartIndex = (Convert.ToInt32(drproductionData["EndAbsentDays"]) + 1);
  211. }
  212. }
  213. if (isError)
  214. {
  215. MessageBox.Show(string.Format("日期区间不能有间隔或重叠"),
  216. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  217. return;
  218. }
  219. if (this.dgvPunishMode.CurrentRow != null)
  220. {
  221. DataGridViewRow gvrNow = this.dgvPunishMode.CurrentRow;
  222. if (gvrNow.Cells["PunishAmount"].Value.ToString() == "")
  223. {
  224. // 单元格的错误消息
  225. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "扣罚金额"),
  226. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  227. return;
  228. }
  229. }
  230. }
  231. //
  232. //DataSet ds = new DataSet();
  233. //ds.Tables.Add(datatPunishMode.Copy());
  234. //DataSet dss = _dsSourse;
  235. //提交操作
  236. ServiceResultEntity srEntity =
  237. (ServiceResultEntity)DoAsync(() =>
  238. {
  239. return TATModuleProxy.Service.EditAttendanceDetail(this._attendanceDetailEntity, _dsSourse);//_dsSourse
  240. });
  241. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  242. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  243. {
  244. this.DialogResult = DialogResult.OK;
  245. }
  246. }
  247. catch (Exception ex)
  248. {
  249. // 对异常进行共通处理
  250. ExceptionManager.HandleEventException(this.ToString(),
  251. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  252. }
  253. }
  254. /// <summary>
  255. /// 关闭窗体
  256. /// </summary>
  257. /// <param name="sender"></param>
  258. /// <param name="e"></param>
  259. private void btnClose_Click(object sender, EventArgs e)
  260. {
  261. this.Close();
  262. }
  263. #endregion
  264. #region 私有方法/函数
  265. /// <summary>
  266. /// 加载控件
  267. /// </summary>
  268. private void Loading()
  269. {
  270. //扣罚方式选中状态,判断表格是否可用
  271. if (this.cbBasicSalaryScale.Checked)
  272. {
  273. this.dgvPunishMode.Enabled = false;
  274. this.dgvPunishMode.ReadOnly = true;
  275. this.dgvPunishMode.IsSetInputColumnsColor = false;
  276. }
  277. else
  278. {
  279. this.dgvPunishMode.Enabled = true;
  280. this.dgvPunishMode.ReadOnly = false;
  281. this.dgvPunishMode.IsSetInputColumnsColor = true;
  282. }
  283. if (this.cbWeek.Checked)
  284. {
  285. this.SelWeek.Enabled = true;
  286. this.txtday.Enabled = false;
  287. }
  288. else
  289. {
  290. this.SelWeek.Enabled = false;
  291. this.txtday.Enabled = true;
  292. }
  293. }
  294. /// <summary>
  295. /// 绑定对应扣罚明细
  296. /// </summary>
  297. private void BindAttFinesRules()
  298. {
  299. try
  300. {
  301. //获取对应扣罚明细
  302. ServiceResultEntity srEntityDetail
  303. = TATModuleProxy.Service.GetAttFinesRulesById(Convert.ToInt32(this._entityId), Convert.ToInt32(this._JobsId));
  304. if (srEntityDetail.Data != null && srEntityDetail.Data.Tables.Count != 0)
  305. {
  306. this._dsSourse = srEntityDetail.Data;
  307. this.dgvPunishMode.DataSource = srEntityDetail.Data.Tables[0];
  308. this.dgvPunishMode.IsSetInputColumnsColor = true;
  309. }
  310. }
  311. catch (Exception ex)
  312. {
  313. throw ex;
  314. }
  315. }
  316. /// <summary>
  317. /// 绑定需要操作的实体信息
  318. /// </summary>
  319. private void BindPage()
  320. {
  321. try
  322. {
  323. if (this._entityId != 0 && this._entityId != null)
  324. {
  325. this._attendanceDetailEntity.AttendanceID = this._entityId;
  326. this._attendanceDetailEntity.JobsID = this._JobsId;
  327. //获取出勤考核明细
  328. ServiceResultEntity srEntity
  329. = TATModuleProxy.Service.GetAttendanceDetail(_attendanceDetailEntity);
  330. //如果取出了对应的数据
  331. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0
  332. && srEntity.Data.Tables[0].Rows.Count != 0)
  333. {
  334. //为实体及页面相关赋值
  335. DataSet dsEntityData = (DataSet)srEntity.Data;
  336. DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
  337. this.txtday.Text = drEntityRow["RestDays"].ToString();
  338. int RestmMode = Convert.ToInt32(drEntityRow["RestmMode"]);
  339. this._attendanceDetailEntity.RestmMode = RestmMode;
  340. if (RestmMode == 1)
  341. {
  342. this.cbWeek.Checked = true;
  343. }
  344. else
  345. {
  346. this.cbday.Checked = true;
  347. }
  348. int PunishMode = Convert.ToInt32(drEntityRow["PunishMode"]);
  349. this._attendanceDetailEntity.PunishMode = PunishMode;
  350. if (PunishMode == 1)
  351. {
  352. this.cbBasicSalaryScale.Checked = true;
  353. }
  354. else
  355. {
  356. this.cbPunishSetting.Checked = true;
  357. }
  358. //绑定多选的选项
  359. object[] objec = new object[7];
  360. if (drEntityRow["Monday"].ToString() == "1")
  361. {
  362. objec[0] = 1;
  363. }
  364. else
  365. {
  366. objec[0] = 0;
  367. }
  368. if (drEntityRow["Tuesday"].ToString() == "1")
  369. {
  370. objec[1] = 2;
  371. }
  372. else
  373. {
  374. objec[1] = 0;
  375. }
  376. if (drEntityRow["Wednesday"].ToString() == "1")
  377. {
  378. objec[2] = 3;
  379. }
  380. else
  381. {
  382. objec[2] = 0;
  383. }
  384. if (drEntityRow["Thursday"].ToString() == "1")
  385. {
  386. objec[3] = 4;
  387. }
  388. else
  389. {
  390. objec[3] = 0;
  391. }
  392. if (drEntityRow["Friday"].ToString() == "1")
  393. {
  394. objec[4] = 5;
  395. }
  396. else
  397. {
  398. objec[4] = 0;
  399. }
  400. if (drEntityRow["Saturday"].ToString() == "1")
  401. {
  402. objec[5] = 6;
  403. }
  404. else
  405. {
  406. objec[5] = 0;
  407. }
  408. if (drEntityRow["Sunday"].ToString() == "1")
  409. {
  410. objec[6] = 7;
  411. }
  412. else
  413. {
  414. objec[6] = 0;
  415. }
  416. this.SelWeek.SelectedValues = objec;
  417. this._attendanceDetailEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
  418. }
  419. }
  420. }
  421. catch (Exception ex)
  422. {
  423. throw ex;
  424. }
  425. }
  426. /// <summary>
  427. /// 设置绑定星期信息
  428. /// </summary>
  429. private void WeekData()
  430. {
  431. DataTable dtWeek = new DataTable();
  432. dtWeek.Columns.Add("WeekName");
  433. dtWeek.Columns.Add("WeekValue");
  434. DataRow drWeekOne = dtWeek.NewRow();
  435. drWeekOne["WeekName"] = "星期一";
  436. drWeekOne["WeekValue"] = "1";
  437. dtWeek.Rows.Add(drWeekOne);
  438. DataRow drWeekTwo = dtWeek.NewRow();
  439. drWeekTwo["WeekName"] = "星期二";
  440. drWeekTwo["WeekValue"] = "2";
  441. dtWeek.Rows.Add(drWeekTwo);
  442. DataRow drWeekThree = dtWeek.NewRow();
  443. drWeekThree["WeekName"] = "星期三";
  444. drWeekThree["WeekValue"] = "3";
  445. dtWeek.Rows.Add(drWeekThree);
  446. DataRow drWeekfour = dtWeek.NewRow();
  447. drWeekfour["WeekName"] = "星期四";
  448. drWeekfour["WeekValue"] = "4";
  449. dtWeek.Rows.Add(drWeekfour);
  450. DataRow drWeekfive = dtWeek.NewRow();
  451. drWeekfive["WeekName"] = "星期五";
  452. drWeekfive["WeekValue"] = "5";
  453. dtWeek.Rows.Add(drWeekfive);
  454. DataRow drWeeksix = dtWeek.NewRow();
  455. drWeeksix["WeekName"] = "星期六";
  456. drWeeksix["WeekValue"] = "6";
  457. dtWeek.Rows.Add(drWeeksix);
  458. DataRow drWeekseven = dtWeek.NewRow();
  459. drWeekseven["WeekName"] = "星期日";
  460. drWeekseven["WeekValue"] = "7";
  461. dtWeek.Rows.Add(drWeekseven);
  462. this.SelWeek.DisplayMember = "WeekName";
  463. this.SelWeek.ValueMember = "WeekValue";
  464. this.SelWeek.DataSource = dtWeek;
  465. }
  466. /// <summary>
  467. /// 为实体绑定页面属性
  468. /// </summary>
  469. private void BindEntity()
  470. {
  471. this._attendanceDetailEntity.RestDays = Convert.ToInt32(this.txtday.Text);
  472. if (this.cbWeek.Checked)
  473. {
  474. this._attendanceDetailEntity.RestmMode = 1;
  475. }
  476. else
  477. {
  478. this._attendanceDetailEntity.RestmMode = 2;
  479. }
  480. if (this.cbBasicSalaryScale.Checked)
  481. {
  482. this._attendanceDetailEntity.PunishMode = 1;
  483. }
  484. else
  485. {
  486. this._attendanceDetailEntity.PunishMode = 2;
  487. }
  488. //绑定星期页面属性
  489. string[] sub = this.SelWeek.SelectedArray.Split(',');
  490. int Monday = 0;
  491. int Tuesday = 0;
  492. int Wednesday = 0;
  493. int Thursday = 0;
  494. int Friday = 0;
  495. int Saturday = 0;
  496. int Sunday = 0;
  497. if (sub.Length > 0)
  498. {
  499. for (int i = 0; i < sub.Length; i++)
  500. {
  501. switch (Convert.ToInt32(sub[i]))
  502. {
  503. case 1:
  504. Monday = 1;
  505. break;
  506. case 2:
  507. Tuesday = 1;
  508. break;
  509. case 3:
  510. Wednesday = 1;
  511. break;
  512. case 4:
  513. Thursday = 1;
  514. break;
  515. case 5:
  516. Friday = 1;
  517. break;
  518. case 6:
  519. Saturday = 1;
  520. break;
  521. case 7:
  522. Sunday = 1;
  523. break;
  524. }
  525. }
  526. }
  527. this._attendanceDetailEntity.Monday = Monday;
  528. this._attendanceDetailEntity.Tuesday = Tuesday;
  529. this._attendanceDetailEntity.Wednesday = Wednesday;
  530. this._attendanceDetailEntity.Thursday = Thursday;
  531. this._attendanceDetailEntity.Friday = Friday;
  532. this._attendanceDetailEntity.Saturday = Saturday;
  533. this._attendanceDetailEntity.Sunday = Sunday;
  534. }
  535. #endregion
  536. }
  537. }