F_TAT_0203.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0203.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.Client.Controls;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
  21. namespace Dongke.IBOSS.PRD.Client.TATModule
  22. {
  23. /// <summary>
  24. /// 工价策略产品关联
  25. /// </summary>
  26. public partial class F_TAT_0203 : FormBase
  27. {
  28. #region 成员变量
  29. // 窗体模式ID
  30. private Constant.FormMode _formType;
  31. // 主体信息ID
  32. private int? _WagesId;
  33. // 主体工种ID
  34. private int? _JobsId;
  35. // 数据源
  36. private DataSet _dsSourse;
  37. // 产品数据源
  38. private DataTable _dtGoodsSourse;
  39. #endregion
  40. #region 构造函数
  41. /// <summary>
  42. /// 构造函数
  43. /// </summary>
  44. /// <param name="formType">窗体开启模式</param>
  45. /// <param name="WagesId">策略ID</param>
  46. /// <param name="JobsId">工种ID</param>
  47. /// <param name="JobsName">工种名称</param>
  48. /// <param name="JobsCode">工种编码</param>
  49. public F_TAT_0203(Constant.FormMode formType,int WagesId,
  50. int JobsId,string JobsName,string JobsCode)
  51. {
  52. InitializeComponent();
  53. this._WagesId = WagesId;
  54. this._JobsId = JobsId;
  55. this._formType = formType;
  56. this.txtJobsName.Text = JobsName;
  57. this.txtJobsCode.Text = JobsCode;
  58. // 窗口标题
  59. this.Text = FormTitles.F_TAT_0203;
  60. // 按钮
  61. this.btnSubmit.Text = ButtonText.BTN_SAVE;
  62. this.btnClose.Text = ButtonText.BTN_CANCEL;
  63. }
  64. #endregion
  65. #region 事件处理
  66. /// <summary>
  67. /// 窗体加载
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void F_TAT_0203_Load(object sender, EventArgs e)
  72. {
  73. try
  74. {
  75. //绑定列表信息
  76. this.BindPage();
  77. //获取全部产品信息
  78. this.GetGoods();
  79. if(this._formType == Constant.FormMode.Display || this._formType == Constant.FormMode.CopyAndAdd)
  80. {
  81. this.dgvGoods.ReadOnly = true;
  82. this.dgvGoods.IsSetInputColumnsColor = false;
  83. this.dgvGoods.AllowUserToDeleteRows = false;
  84. this.tsbtnCreateGoods.Enabled = false;
  85. this.btnSubmit.Visible = false;
  86. }
  87. }
  88. catch(Exception ex)
  89. {
  90. // 对异常进行共通处理
  91. ExceptionManager.HandleEventException(this.ToString(),
  92. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  93. }
  94. }
  95. /// <summary>
  96. /// 创建产品
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void tsbtnCreateGoods_Click(object sender, EventArgs e)
  101. {
  102. try
  103. {
  104. //遍历产品明细添加该工种的所有明细信息
  105. foreach (DataRow drFor in this._dtGoodsSourse.Rows)
  106. {
  107. //首先查看该产品是否已存在
  108. int GoodsIsHave = 0;
  109. foreach (DataGridViewRow gvrFor in this.dgvGoods.Rows)
  110. {
  111. if (Convert.ToInt32(gvrFor.Cells["GoodsID"].Value)
  112. == Convert.ToInt32(drFor["GoodsID"]))
  113. {
  114. GoodsIsHave++;
  115. break;
  116. }
  117. }
  118. //如果不存在才进行添加
  119. if (GoodsIsHave == 0)
  120. {
  121. //向最终数据源添加扣罚明细信息
  122. DataRow drDetail = this._dsSourse.Tables[0].NewRow();
  123. drDetail["GoodsID"] = drFor["GoodsId"];
  124. drDetail["GoodsCode"] = drFor["GoodsCode"];
  125. drDetail["GoodsName"] = drFor["GoodsName"];
  126. drDetail["PieceNum"] = 1;
  127. drDetail["Wages"] = 0;
  128. drDetail["PublicWages"] = 0;
  129. this._dsSourse.Tables[0].Rows.Add(drDetail);
  130. }
  131. }
  132. this.dgvGoods.IsSetInputColumnsColor = true;
  133. }
  134. catch (Exception ex)
  135. {
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 自适应列宽
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  147. {
  148. this.dgvGoods.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  149. }
  150. /// <summary>
  151. /// 提交
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. private void btnSubmit_Click(object sender, EventArgs e)
  156. {
  157. try
  158. {
  159. //提交操作
  160. ServiceResultEntity srEntity =
  161. (ServiceResultEntity)DoAsync(() =>
  162. {
  163. return TATModuleProxy.Service.EditWagesGoodsDetail(
  164. Convert.ToInt32(this._WagesId), Convert.ToInt32(this._JobsId), this._dsSourse);
  165. });
  166. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  167. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  168. {
  169. this.DialogResult = DialogResult.OK;
  170. }
  171. }
  172. catch(Exception ex)
  173. {
  174. // 对异常进行共通处理
  175. ExceptionManager.HandleEventException(this.ToString(),
  176. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  177. }
  178. }
  179. /// <summary>
  180. /// 关闭窗体
  181. /// </summary>
  182. /// <param name="sender"></param>
  183. /// <param name="e"></param>
  184. private void btnClose_Click(object sender, EventArgs e)
  185. {
  186. this.DialogResult = DialogResult.OK;
  187. }
  188. #endregion
  189. #region 私有方法和函数
  190. /// <summary>
  191. /// 绑定列表
  192. /// </summary>
  193. private void BindPage()
  194. {
  195. try
  196. {
  197. //绑定某工种对应的产品信息
  198. if (this._WagesId != null && this._JobsId != null)
  199. {
  200. ServiceResultEntity srEntity =
  201. TATModuleProxy.Service.GetWagesGoodsDetail(Convert.ToInt32(this._WagesId), Convert.ToInt32(this._JobsId));
  202. if(srEntity != null && srEntity.Data != null && srEntity.Data.Tables.Count != 0)
  203. {
  204. this.dgvGoods.AutoGenerateColumns = false;
  205. this.dgvGoods.DataSource = srEntity.Data.Tables[0];
  206. this.dgvGoods.IsSetInputColumnsColor = true;
  207. this._dsSourse = srEntity.Data;
  208. }
  209. }
  210. }
  211. catch(Exception ex)
  212. {
  213. throw ex;
  214. }
  215. }
  216. /// <summary>
  217. /// 获取全部产品信息
  218. /// </summary>
  219. private void GetGoods()
  220. {
  221. try
  222. {
  223. GoodsEntity goods = new GoodsEntity();
  224. goods.ValueFlag = 1;
  225. DataSet dsGoods = SystemModuleProxy.Service.SerachGoods(goods);
  226. if (dsGoods != null && dsGoods.Tables.Count != 0)
  227. {
  228. this._dtGoodsSourse = dsGoods.Tables[0];
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. throw ex;
  234. }
  235. }
  236. #endregion
  237. }
  238. }