F_TAT_0303.cs 12 KB

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