FrmReqRequest.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Collections;
  10. using CoreFS.CA06;
  11. using com.steering.pss.plan.order.model;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.Mes.Client.Comm.Server;
  14. using Core.Mes.Client.Comm;
  15. using Infragistics.Win.UltraWinGrid;
  16. namespace Core.StlMes.Client.Plan.Order.PopupWindow
  17. {
  18. public partial class FrmReqRequest : FrmBase
  19. {
  20. /// <summary>
  21. /// 合同订货量
  22. /// </summary>
  23. private double orderQty = 0;
  24. /// <summary>
  25. /// 米单重
  26. /// </summary>
  27. private double weightPerM = 0;
  28. private PlnSaleorderRNumEntity reqEntity = null;
  29. public FrmReqRequest()
  30. {
  31. InitializeComponent();
  32. }
  33. public FrmReqRequest(OpeBase opeBase, PlnSaleorderRNumEntity reqentity, double qty, double weightM)
  34. {
  35. orderQty = qty;
  36. weightPerM = weightM;
  37. reqEntity = reqentity;
  38. this.ob = opeBase;
  39. InitializeComponent();
  40. }
  41. private void FrmReqRequest_Load(object sender, EventArgs e)
  42. {
  43. ultraTextOrderNo.Value = reqEntity.OrderNo + "/" + reqEntity.OrderSeq;
  44. ultraTextOrderUnit.Value = reqEntity.OrderUnit;
  45. ultraNumericOrderQty.Value = orderQty;
  46. EntityHelper.ShowGridCaption<PlnSaleorderRNumEntity>(ultraGridReqApply.DisplayLayout.Bands[0]);
  47. DoQuery();
  48. }
  49. private void ultraToolbarsReq_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  50. {
  51. switch (e.Tool.Key)
  52. {
  53. case "doQuery":
  54. DoQuery();
  55. break;
  56. case "doAdd":
  57. DoAdd();
  58. break;
  59. case "doModify":
  60. DoModify();
  61. break;
  62. case "doDelete":
  63. DoDelete();
  64. break;
  65. case "Close":
  66. this.Close();
  67. break;
  68. }
  69. }
  70. /// <summary>
  71. /// 查询
  72. /// </summary>
  73. private void DoQuery()
  74. {
  75. List<PlnSaleorderRNumEntity> listSource = EntityHelper.GetData<PlnSaleorderRNumEntity>(
  76. "com.steering.pss.plan.order.CoreReqRequest.getOrdRNum", new object[] { reqEntity.OrdLnDlyPk }, this.ob);
  77. slmPlnSaleorderRNumEntitybindingSource.DataSource = listSource;
  78. PlanComm.setGridActivation(ultraGridReqApply.DisplayLayout.Bands[0], "CHC");
  79. }
  80. /// <summary>
  81. /// 新增补量申请
  82. /// </summary>
  83. private void DoAdd()
  84. {
  85. try
  86. {
  87. ArrayList list = new ArrayList();
  88. if (Convert.ToDecimal(this.ultraNumericReq.Value) <= 0)
  89. {
  90. MessageUtil.ShowTips("申请量不能小于零!");
  91. return;
  92. }
  93. reqEntity.RepQty = this.ultraNumericReq.Value.ToString();
  94. reqEntity.RepReason = this.ultraTextReqReason.Text.Trim();
  95. reqEntity.ReqName = UserInfo.GetUserName();
  96. switch (reqEntity.OrderUnit)
  97. {
  98. case "米":
  99. reqEntity.Reqweight = Math.Round(weightPerM *
  100. Convert.ToDouble(ultraNumericReq.Value), 3).ToString();
  101. break;
  102. case "英尺":
  103. reqEntity.Reqweight = Math.Round(weightPerM *
  104. PlanComm.FootoMi(Convert.ToDouble(ultraNumericReq.Value)), 3).ToString();
  105. break;
  106. default:
  107. reqEntity.Reqweight = this.ultraNumericReq.Value.ToString();
  108. break;
  109. }
  110. list.Add(reqEntity);
  111. int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreReqRequest.addOrderRNum",
  112. new Object[] { list }, this.ob);
  113. if (succed > 0)
  114. {
  115. MessageUtil.ShowTips("新增成功!");
  116. }
  117. else
  118. {
  119. MessageUtil.ShowTips("新增失败!");
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. if (ex is MESException)
  125. {
  126. }
  127. else
  128. {
  129. MessageBox.Show(ex.Message);
  130. }
  131. }
  132. DoQuery();
  133. }
  134. /// <summary>
  135. /// 修改申请
  136. /// </summary>
  137. private void DoModify()
  138. {
  139. try
  140. {
  141. UltraGridRow ugr = ultraGridReqApply.ActiveRow;
  142. if (ugr == null)
  143. {
  144. return;
  145. }
  146. PlnSaleorderRNumEntity rNumEntity = new PlnSaleorderRNumEntity();
  147. rNumEntity.RNumId = ugr.Cells["RNumId"].Value.ToString();
  148. rNumEntity.RepQty = ultraNumericReq.Value.ToString();
  149. rNumEntity.RepReason = ultraTextReqReason.Text.Trim();
  150. switch (ugr.Cells["OrderUnit"].Value.ToString())
  151. {
  152. case "米":
  153. rNumEntity.Reqweight = Math.Round(weightPerM *
  154. Convert.ToDouble(ultraNumericReq.Value), 3).ToString();
  155. break;
  156. case "英尺":
  157. rNumEntity.Reqweight = Math.Round(weightPerM *
  158. PlanComm.FootoMi(Convert.ToDouble(ultraNumericReq.Value)), 3).ToString();
  159. break;
  160. default:
  161. rNumEntity.Reqweight = this.ultraNumericReq.Value.ToString();
  162. break;
  163. }
  164. CoreClientParam ccp = new CoreClientParam();
  165. ccp.ServerName = "com.steering.pss.plan.order.CoreReqRequest";
  166. ccp.MethodName = "doModify";
  167. ccp.ServerParams = new object[] { rNumEntity };
  168. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  169. if (ccp.ReturnCode != -1)
  170. {
  171. if (ccp.ReturnInfo.Equals(""))
  172. {
  173. MessageUtil.ShowTips("修改成功!");
  174. }
  175. else
  176. {
  177. MessageUtil.ShowError("修改失败:" + ccp.ReturnInfo);
  178. }
  179. }
  180. else
  181. {
  182. MessageUtil.ShowError("修改失败:" + ccp.ReturnInfo);
  183. }
  184. }
  185. catch (Exception ex)
  186. {
  187. MessageBox.Show(ex.Message);
  188. }
  189. DoQuery();
  190. }
  191. /// <summary>
  192. /// 删除申请
  193. /// </summary>
  194. private void DoDelete()
  195. {
  196. try
  197. {
  198. ArrayList list = new ArrayList();
  199. ultraGridReqApply.UpdateData();
  200. IQueryable<UltraGridRow> checkRows = ultraGridReqApply.Rows.AsQueryable().Where(" CHC = 'True' ");
  201. if (checkRows.Count() == 0)
  202. {
  203. MessageUtil.ShowTips("未勾选任何行!");
  204. return;
  205. }
  206. foreach (UltraGridRow uRow in checkRows)
  207. {
  208. list.Add(uRow.Cells["RNumId"].Value.ToString());
  209. }
  210. CoreClientParam ccp = new CoreClientParam();
  211. ccp.ServerName = "com.steering.pss.plan.order.CoreReqRequest";
  212. ccp.MethodName = "deleteOrderRNum";
  213. ccp.ServerParams = new object[] { list };
  214. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  215. if (ccp.ReturnCode != -1)
  216. {
  217. if (ccp.ReturnInfo.Equals(""))
  218. {
  219. MessageUtil.ShowTips("删除成功!");
  220. }
  221. else
  222. {
  223. MessageUtil.ShowError("删除失败:" + ccp.ReturnInfo);
  224. }
  225. }
  226. else
  227. {
  228. MessageUtil.ShowError("删除失败:" + ccp.ReturnInfo);
  229. }
  230. }
  231. catch (Exception ex)
  232. {
  233. MessageBox.Show(ex.Message);
  234. }
  235. DoQuery();
  236. }
  237. private void ultraGridReqApply_BeforeRowActivate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  238. {
  239. if (e.Row != null && e.Row.Cells["RepQty"].Value != null)
  240. {
  241. this.ultraNumericReq.Value = e.Row.Cells["RepQty"].Value.ToString();
  242. this.ultraTextReqReason.Value = e.Row.Cells["RepReason"].Value.ToString();
  243. }
  244. }
  245. }
  246. }