F_TAT_0103.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0103.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.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  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. public partial class F_TAT_0103 : FormBase
  22. {
  23. #region 成员变量
  24. // 窗体模式ID
  25. private Constant.FormMode _formType;
  26. // 操作实体ID
  27. private int? _entityId;
  28. // 操作实体信息
  29. private DefectFineEntity _dfEntity = new DefectFineEntity();
  30. #endregion
  31. #region 构造函数
  32. /// <summary>
  33. /// 窗体构造
  34. /// </summary>
  35. /// <param name="formType">窗体打开模式</param>
  36. /// <param name="entityId">操作实体ID</param>
  37. public F_TAT_0103(Constant.FormMode formType,int entityId)
  38. {
  39. InitializeComponent();
  40. _formType = formType;
  41. _entityId = entityId;
  42. }
  43. #endregion
  44. #region 事件处理
  45. /// <summary>
  46. /// 窗体加载
  47. /// </summary>
  48. /// <param name="sender"></param>
  49. /// <param name="e"></param>
  50. private void F_TAT_0103_Load(object sender, EventArgs e)
  51. {
  52. try
  53. {
  54. if (this._formType == Constant.FormMode.Add)
  55. {
  56. this.Text = FormTitles.F_TAT_0103_ADD;
  57. }
  58. else if (this._formType == Constant.FormMode.Edit)
  59. {
  60. this.Text = FormTitles.F_TAT_0103_EDIT;
  61. }
  62. else if (this._formType == Constant.FormMode.CopyAndAdd)
  63. {
  64. this.Text = FormTitles.F_TAT_0103_COPY;
  65. }
  66. else if (this._formType == Constant.FormMode.Display)
  67. {
  68. this.Text = FormTitles.F_TAT_0103_AUDIT;
  69. }
  70. //设定按钮的文本值
  71. this.btnSubmit.Text = ButtonText.BTN_SAVE;
  72. this.btnClose.Text = ButtonText.BTN_CANCEL;
  73. this.btnPass.Text = Constant.BUTTON_TEXT_AUDITPASS;
  74. this.btnReturn.Text = Constant.BUTTON_TEXT_AUDITRETURN;
  75. //绑定缺陷扣罚
  76. this.BindSelectDate();
  77. //如果是修改,要绑定选中的信息
  78. if (this._formType == Constant.FormMode.Edit)
  79. {
  80. this.BindPage();
  81. }
  82. //如果是新建,选项默认值设定
  83. else if(this._formType == Constant.FormMode.Add || this._formType == Constant.FormMode.CopyAndAdd)
  84. {
  85. this.cbCeremonial.Checked = true;
  86. this.cbCoefficient.Checked = true;
  87. // 如果是复制明细,那么扣罚类型就不可修改。
  88. if(this._formType == Constant.FormMode.CopyAndAdd)
  89. {
  90. this.cbCoefficient.Checked = false;
  91. this.cbMoney.Checked = true;
  92. this.cbCoefficient.Enabled = false;
  93. this.cbMoney.Enabled = false;
  94. this.txtCoefficient.Enabled = false;
  95. }
  96. }
  97. //如果是审核,绑定值后,所有控件不可用,保存按钮变为明细按钮,并且审批通过与不通过按钮变为可见
  98. else
  99. {
  100. //绑定页面实体成员变量
  101. this.BindPage();
  102. this.txtCoefficient.Enabled = false;
  103. this.txtDefectFineName.Enabled = false;
  104. this.txtRemarks.Enabled = false;
  105. this.lbxDefectFine.Enabled = false;
  106. this.dtpStartTime.Enabled = false;
  107. this.cbCeremonial.Enabled = false;
  108. this.cbCoefficient.Enabled = false;
  109. this.cbMoney.Enabled = false;
  110. this.cbTrial.Enabled = false;
  111. this.btnSubmit.Text = Constant.BUTTON_TEXT_DETAIL;
  112. this.btnPass.Visible = true;
  113. this.btnReturn.Visible = true;
  114. //并且,如果是按系数扣罚,明细按钮也要不可用
  115. if(this.cbCoefficient.Checked == true)
  116. {
  117. this.btnSubmit.Enabled = false;
  118. }
  119. }
  120. }
  121. catch(Exception ex)
  122. {
  123. // 对异常进行共通处理
  124. ExceptionManager.HandleEventException(this.ToString(),
  125. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  126. }
  127. }
  128. /// <summary>
  129. /// 提交操作
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. private void btnSubmit_Click(object sender, EventArgs e)
  134. {
  135. //如果是审批以外的状态,进行添加信息相关的操作
  136. if (this._formType != Constant.FormMode.Display)
  137. {
  138. //首先验证数据合法性
  139. if (this.ValidationInput() == false)
  140. {
  141. return;
  142. }
  143. //为实体绑定属性
  144. this.BindEntity();
  145. //进行添加操作
  146. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  147. {
  148. return EntityToServer();
  149. });
  150. //服务实体共通处理
  151. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  152. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  153. {
  154. this.DialogResult = DialogResult.OK;
  155. }
  156. }
  157. else//审批操作的话,只打开明细的查看模式就可以了
  158. {
  159. //模式化开启明细窗体
  160. F_TAT_0102 frmTAT0102 = new F_TAT_0102(Constant.FormMode.Display, Convert.ToInt32(this._entityId));
  161. DialogResult dialogResult = frmTAT0102.ShowDialog();
  162. }
  163. }
  164. /// <summary>
  165. /// 窗体关闭
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void btnClose_Click(object sender, EventArgs e)
  170. {
  171. this.DialogResult = DialogResult.OK;
  172. }
  173. /// <summary>
  174. /// 选项改变事件
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. private void cbCoefficient_CheckedChanged(object sender, EventArgs e)
  179. {
  180. if (this.cbCoefficient.Checked == true)
  181. {
  182. this.txtCoefficient.Enabled = true;
  183. }
  184. else
  185. {
  186. this.txtCoefficient.Enabled = false;
  187. this.txtCoefficient.Text = string.Empty;
  188. }
  189. }
  190. /// <summary>
  191. /// 选项改变事件
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. private void cbMoney_CheckedChanged(object sender, EventArgs e)
  196. {
  197. if (this.cbCoefficient.Checked == true)
  198. {
  199. this.txtCoefficient.Enabled = true;
  200. }
  201. else
  202. {
  203. this.txtCoefficient.Enabled = false;
  204. this.txtCoefficient.Text = string.Empty;
  205. }
  206. }
  207. /// <summary>
  208. /// 审批通过
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. private void btnPass_Click(object sender, EventArgs e)
  213. {
  214. //进行审核操作
  215. this._dfEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Agree);
  216. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  217. {
  218. return EntityToServer();
  219. });
  220. //服务实体共通处理
  221. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  222. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  223. {
  224. this.DialogResult = DialogResult.OK;
  225. }
  226. }
  227. /// <summary>
  228. /// 审批驳回
  229. /// </summary>
  230. /// <param name="sender"></param>
  231. /// <param name="e"></param>
  232. private void btnReturn_Click(object sender, EventArgs e)
  233. {
  234. //进行审核操作
  235. this._dfEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Disagree);
  236. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  237. {
  238. return EntityToServer();
  239. });
  240. //服务实体共通处理
  241. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  242. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  243. {
  244. this.DialogResult = DialogResult.OK;
  245. }
  246. }
  247. #endregion
  248. #region 私有方法/函数
  249. /// <summary>
  250. /// 绑定检索条件数据
  251. /// </summary>
  252. private void BindSelectDate()
  253. {
  254. try
  255. {
  256. //绑定缺陷扣罚
  257. DataTable dtDefectFine = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.ASE002, Constant.INT_IS_ONE);
  258. if (dtDefectFine != null)
  259. {
  260. lbxDefectFine.DisplayMember = "DictionaryValue";
  261. lbxDefectFine.ValueMember = "DictionaryID";
  262. lbxDefectFine.DataSource = dtDefectFine;
  263. }
  264. }
  265. catch (Exception ex)
  266. {
  267. throw ex;
  268. }
  269. }
  270. /// <summary>
  271. /// 为实体绑定页面属性
  272. /// </summary>
  273. private void BindEntity()
  274. {
  275. this._dfEntity.DefectFineName = this.txtDefectFineName.Text.Trim();
  276. this._dfEntity.DefectFine = Convert.ToInt32(this.lbxDefectFine.SelectedValue);
  277. this._dfEntity.BeginAccountMonth = this.dtpStartTime.Value.Date;
  278. if(this.cbCeremonial.Checked)
  279. {
  280. this._dfEntity.SalaryType = 1;
  281. }
  282. else
  283. {
  284. this._dfEntity.SalaryType = 0;
  285. }
  286. if(this.cbCoefficient.Checked)
  287. {
  288. this._dfEntity.FineType = 1;
  289. this._dfEntity.Coefficient = Convert.ToDecimal(this.txtCoefficient.Text);
  290. }
  291. else
  292. {
  293. this._dfEntity.FineType = 2;
  294. }
  295. this._dfEntity.Remarks = this.txtRemarks.Text;
  296. this._dfEntity.AuditStatus = 0;
  297. }
  298. /// <summary>
  299. /// 与服务交互操作
  300. /// </summary>
  301. /// <returns></returns>
  302. private ServiceResultEntity EntityToServer()
  303. {
  304. if (this._formType == Constant.FormMode.Add)
  305. {
  306. return TATModuleProxy.Service.AddDefectFine(this._dfEntity);
  307. }
  308. else if(this._formType == Constant.FormMode.Edit)
  309. {
  310. return TATModuleProxy.Service.UpdateDefectFine(this._dfEntity);
  311. }
  312. else if(_formType == Constant.FormMode.CopyAndAdd)
  313. {
  314. this._dfEntity.CopyId = Convert.ToInt32(this._entityId);
  315. return TATModuleProxy.Service.AddDefectFine(this._dfEntity);
  316. }
  317. else if(_formType == Constant.FormMode.Display)
  318. {
  319. return TATModuleProxy.Service.AuditDefectFine(this._dfEntity);
  320. }
  321. return null;
  322. }
  323. /// <summary>
  324. /// 验证必填项
  325. /// </summary>
  326. /// <returns>是否通过</returns>
  327. private bool ValidationInput()
  328. {
  329. if (string.IsNullOrWhiteSpace(this.txtDefectFineName.Text))
  330. {
  331. this.txtDefectFineName.Focus();
  332. return false;
  333. }
  334. if(this.lbxDefectFine.SelectedValue == null)
  335. {
  336. this.lbxDefectFine.Focus();
  337. return false;
  338. }
  339. if (this.cbCoefficient.Checked == true && string.IsNullOrWhiteSpace(this.txtCoefficient.Text))
  340. {
  341. this.txtCoefficient.Focus();
  342. return false;
  343. }
  344. return true;
  345. }
  346. /// <summary>
  347. /// 清空页面
  348. /// </summary>
  349. private void ClaerInput()
  350. {
  351. this.txtDefectFineName.Text = string.Empty;
  352. this.lbxDefectFine.Text = string.Empty;
  353. this.txtCoefficient.Text = string.Empty;
  354. this.cbCoefficient.Checked = true;
  355. this.cbCeremonial.Checked = true;
  356. this.txtRemarks.Text = string.Empty;
  357. }
  358. /// <summary>
  359. /// 绑定需要操作的实体信息
  360. /// </summary>
  361. private void BindPage()
  362. {
  363. if(this._entityId != 0 && this._entityId != null)
  364. {
  365. this._dfEntity.DefectFineID = this._entityId;
  366. ServiceResultEntity srEntity = TATModuleProxy.Service.GetDefectFine(this._dfEntity);
  367. if (srEntity.Data != null && srEntity.Data.Tables.Count != 0
  368. && srEntity.Data.Tables[0].Rows.Count != 0)
  369. {
  370. DataSet dsEntityData = (DataSet)srEntity.Data;
  371. DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
  372. this.txtDefectFineName.Text = drEntityRow["DefectFineName"].ToString();
  373. this.lbxDefectFine.SelectedValue = Convert.ToInt32(drEntityRow["DefectFine"]);
  374. int FineType = Convert.ToInt32(drEntityRow["FineType"]);
  375. if(FineType == 1)
  376. {
  377. this.cbCoefficient.Checked = true;
  378. this.txtCoefficient.Text = Convert.ToDecimal(drEntityRow["Coefficient"]).ToString();
  379. }
  380. else
  381. {
  382. this.cbMoney.Checked = true;
  383. }
  384. int SalaryType = Convert.ToInt32(drEntityRow["SalaryType"]);
  385. this._dfEntity.SalaryType = SalaryType;
  386. if(SalaryType == 1)
  387. {
  388. this.cbCeremonial.Checked = true;
  389. }
  390. else
  391. {
  392. this.cbTrial.Checked = true;
  393. }
  394. this.txtRemarks.Text = drEntityRow["Remarks"].ToString();
  395. this.dtpStartTime.Text = drEntityRow["BeginAccountMonth"].ToString();
  396. this._dfEntity.BeginAccountMonth = Convert.ToDateTime(drEntityRow["BeginAccountMonth"].ToString());
  397. //将时间戳给到要修改的实体中
  398. this._dfEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
  399. }
  400. }
  401. }
  402. #endregion
  403. }
  404. }