F_TAT_0402.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0401.cs
  5. * 2.功能描述:新建/编辑/复制缺陷扣罚信息
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 宋扬 2014/12/11 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_0402 : FormBase
  22. {
  23. #region 成员变量
  24. // 窗体模式ID
  25. private Constant.FormMode _formType;
  26. // 操作实体ID
  27. private int? _entityId;
  28. // 操作实体信息
  29. private QualityEntity _quqlityEntity = new QualityEntity();
  30. #endregion
  31. #region 构造函数
  32. /// <summary>
  33. /// 窗体构造
  34. /// </summary>
  35. /// <param name="formType">窗体打开模式</param>
  36. /// <param name="entityId">操作实体ID</param>
  37. public F_TAT_0402(Constant.FormMode formType, int entityId)
  38. {
  39. InitializeComponent();
  40. _formType = formType;
  41. _entityId = entityId;
  42. // 窗体显示的Title
  43. if (this._formType == Constant.FormMode.Add)
  44. {
  45. this.Text = FormTitles.F_TAT_0402_ADD;
  46. }
  47. else if (this._formType == Constant.FormMode.Edit)
  48. {
  49. this.Text = FormTitles.F_TAT_0402_EDIT;
  50. }
  51. else if (this._formType == Constant.FormMode.CopyAndAdd)
  52. {
  53. this.Text = FormTitles.F_TAT_0402_COPY;
  54. }
  55. else if (this._formType == Constant.FormMode.Display)
  56. {
  57. this.Text = FormTitles.F_TAT_0402_AUDIT;
  58. }
  59. }
  60. #endregion
  61. #region 事件处理
  62. /// <summary>
  63. /// 窗体加载
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_TAT_0402_Load(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. //如果是修改,要绑定选中的信息
  72. if (this._formType == Constant.FormMode.Edit)
  73. {
  74. BindPage();
  75. }
  76. //如果是新建,选项默认值设定
  77. else if (this._formType == Constant.FormMode.Add || this._formType == Constant.FormMode.CopyAndAdd)
  78. {
  79. this.cbCeremonial.Checked = true;
  80. }
  81. //如果是审核,绑定值后,所有控件不可用,保存按钮变为明细按钮,并且审批通过与不通过按钮变为可见
  82. else
  83. {
  84. //绑定页面实体成员变量
  85. this.BindPage();
  86. //绑定页面实体成员变量
  87. this.txtQualityName.Enabled = false;
  88. this.txtRemarks.Enabled = false;
  89. this.dtpStartTime.Enabled = false;
  90. this.cbCeremonial.Enabled = false;
  91. this.cbTrial.Enabled = false;
  92. this.btnSubmit.Text = Constant.BUTTON_TEXT_DETAIL;
  93. this.btnPass.Visible = true;
  94. this.btnReturn.Visible = true;
  95. }
  96. }
  97. catch (Exception ex)
  98. {
  99. // 对异常进行共通处理
  100. ExceptionManager.HandleEventException(this.ToString(),
  101. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  102. }
  103. }
  104. /// <summary>
  105. /// 提交操作按钮事件
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void btnSubmit_Click(object sender, EventArgs e)
  110. {
  111. try
  112. {
  113. if (this._formType != Constant.FormMode.Display)
  114. {
  115. //为实体绑定属性
  116. if (this.BindEntity())
  117. {
  118. return;
  119. }
  120. //进行添加操作
  121. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  122. {
  123. return EntityToServer();
  124. });
  125. //服务实体共通处理
  126. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  127. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  128. {
  129. this.DialogResult = DialogResult.OK;
  130. }
  131. }
  132. else
  133. {
  134. //模式化开启明细窗体
  135. F_TAT_0403 frmTAT0403 = new F_TAT_0403(Constant.FormMode.Display, Convert.ToInt32(this._entityId));
  136. DialogResult dialogResult = frmTAT0403.ShowDialog();
  137. }
  138. }
  139. catch(Exception ex)
  140. {
  141. throw ex;
  142. }
  143. }
  144. /// <summary>
  145. /// 窗体关闭
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void btnClose_Click(object sender, EventArgs e)
  150. {
  151. this.Close();
  152. }
  153. /// <summary>
  154. /// 窗体释放
  155. /// </summary>
  156. /// <param name="sender"></param>
  157. /// <param name="e"></param>
  158. private void F_TAT_0402_FormClosed(object sender, FormClosedEventArgs e)
  159. {
  160. this.Dispose();
  161. }
  162. /// <summary>
  163. /// 审批通过
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. private void btnPass_Click(object sender, EventArgs e)
  168. {
  169. //进行审核操作
  170. this._quqlityEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Agree);
  171. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  172. {
  173. return EntityToServer();
  174. });
  175. //服务实体共通处理
  176. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  177. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  178. {
  179. this.DialogResult = DialogResult.OK;
  180. }
  181. }
  182. /// <summary>
  183. /// 审批驳回
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void btnReturn_Click(object sender, EventArgs e)
  188. {
  189. //进行审核操作
  190. this._quqlityEntity.AuditStatus = Convert.ToInt32(Constant.AuditStatus.Disagree);
  191. ServiceResultEntity srEntity = (ServiceResultEntity)DoAsync(() =>
  192. {
  193. return EntityToServer();
  194. });
  195. //服务实体共通处理
  196. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  197. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  198. {
  199. this.DialogResult = DialogResult.OK;
  200. }
  201. }
  202. #endregion
  203. #region 私有方法/函数
  204. /// <summary>
  205. /// 为实体绑定页面属性
  206. /// </summary>
  207. private bool BindEntity()
  208. {
  209. if (string.IsNullOrEmpty(this.txtQualityName.Text.Trim()))
  210. {
  211. return true;
  212. }
  213. this._quqlityEntity.QualityName = this.txtQualityName.Text.Trim();
  214. this._quqlityEntity.Remarks = this.txtRemarks.Text.Trim();
  215. this._quqlityEntity.BeginAccountMonthStart =Convert.ToDateTime(this.dtpStartTime.Value.ToString("yyyy-MM"));
  216. if (this.cbCeremonial.Checked)
  217. {
  218. this._quqlityEntity.SalaryType = 1;
  219. }
  220. else
  221. {
  222. this._quqlityEntity.SalaryType = 0;
  223. }
  224. this._quqlityEntity.AuditStatus = 0;
  225. return false;
  226. }
  227. /// <summary>
  228. /// 与服务交互操作
  229. /// </summary>
  230. /// <returns></returns>
  231. private ServiceResultEntity EntityToServer()
  232. {
  233. if (this._formType == Constant.FormMode.Add)
  234. {
  235. return TATModuleProxy.Service.AddQuality(this._quqlityEntity);
  236. }
  237. else if (this._formType == Constant.FormMode.Edit)
  238. {
  239. return TATModuleProxy.Service.UpdateQuality(this._quqlityEntity);
  240. }
  241. else if (_formType == Constant.FormMode.CopyAndAdd)
  242. {
  243. this._quqlityEntity.CopyId = Convert.ToInt32(this._entityId);
  244. return TATModuleProxy.Service.AddQuality(this._quqlityEntity);
  245. }
  246. else if (_formType == Constant.FormMode.Display)
  247. {
  248. return TATModuleProxy.Service.AuditQuality(this._quqlityEntity);
  249. }
  250. return null;
  251. }
  252. /// <summary>
  253. /// 绑定需要操作的实体信息
  254. /// </summary>
  255. private void BindPage()
  256. {
  257. if (this._entityId != 0 && this._entityId != null)
  258. {
  259. this._quqlityEntity.QualityID = this._entityId;
  260. ServiceResultEntity srQuality = (ServiceResultEntity)DoAsync(() =>
  261. {
  262. return TATModuleProxy.Service.GetQuality(_quqlityEntity);
  263. });
  264. if (srQuality.Data != null && srQuality.Data.Tables.Count != 0
  265. && srQuality.Data.Tables[0].Rows.Count != 0)
  266. {
  267. DataRow drEntityRow = srQuality.Data.Tables[0].Rows[0];
  268. this.txtQualityName.Text = drEntityRow["QualityName"].ToString();
  269. this.txtRemarks.Text = drEntityRow["Remarks"].ToString();
  270. int SalaryType = Convert.ToInt32(drEntityRow["SalaryType"]);
  271. if (SalaryType == 1)
  272. {
  273. this.cbCeremonial.Checked = true;
  274. }
  275. else
  276. {
  277. this.cbTrial.Checked = true;
  278. }
  279. this._quqlityEntity.SalaryType = SalaryType;
  280. this.dtpStartTime.Text = drEntityRow["BeginAccountMonth"].ToString();
  281. this._quqlityEntity.BeginAccountMonthStart = Convert.ToDateTime(drEntityRow["BeginAccountMonth"].ToString());
  282. //将时间戳给到要修改的实体中
  283. this._quqlityEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
  284. }
  285. }
  286. }
  287. #endregion
  288. }
  289. }