FrmGpM.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.YdmBcPipeManage.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using System.ComponentModel;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Windows.Forms;
  16. namespace Core.StlMes.Client.YdmBcPipeManage.Demand
  17. {
  18. public partial class FrmGpM : FrmBase
  19. {
  20. string[] arr = null;
  21. OpeBase _ob;
  22. public FrmGpM(string[] plineCode, OpeBase ob)
  23. {
  24. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  25. arr = plineCode;
  26. _ob = ob;
  27. InitializeComponent();
  28. }
  29. private void FrmBcM_Load(object sender, EventArgs e)
  30. {
  31. EntityHelper.ShowGridCaption<MatGpMEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  32. initStorageNo();
  33. initDemandUser();
  34. this.ultraDemandUser.SelectedIndex = 0;
  35. }
  36. /// <summary>
  37. /// 加载需求单位
  38. /// </summary>
  39. private void initDemandUser()
  40. {
  41. BaseMethod.InitDemandUser(ultraDemandUser, _ob, arr);
  42. }
  43. /// <summary>
  44. /// 加载仓库
  45. /// </summary>
  46. private void initStorageNo()
  47. {
  48. BaseMethod.InitStorageNoGp(cmbStorageNo, _ob);
  49. }
  50. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  51. {
  52. switch (e.Tool.Key)
  53. {
  54. case "Query":
  55. doQuery();
  56. break;
  57. case "AddDemand":
  58. addDemand();
  59. break;
  60. case"Close":
  61. this.Close();
  62. break;
  63. }
  64. }
  65. /// <summary>
  66. /// 查询库存
  67. /// </summary>
  68. private void doQuery()
  69. {
  70. string judgeNo = "";
  71. string flagStoveNo = "";
  72. if (this.chkJugeHeatNo.Checked && this.txtJugeNo.Text.Trim() != "")
  73. {
  74. judgeNo = this.txtJugeNo.Text.Trim();
  75. }
  76. if (this.chkFlagStoveNo.Checked && this.txtFlagStoveNo.Text != "")
  77. {
  78. flagStoveNo = this.txtFlagStoveNo.Text.ToString();
  79. }
  80. ArrayList parmList = new ArrayList();
  81. parmList.Add(judgeNo);
  82. parmList.Add(flagStoveNo);
  83. List<MatGpMEntity> listSource = EntityHelper.GetData<MatGpMEntity>(
  84. "com.steering.Demand.sever.FrmGpM.doQuery", new object[] { parmList, arr }, _ob);
  85. matGpMEntityBindingSource.DataSource = listSource;
  86. }
  87. /// <summary>
  88. /// 生成需求
  89. /// </summary>
  90. private void addDemand()
  91. {
  92. this.ultraGrid2.UpdateData();
  93. string tarStorageNo = "";
  94. string tarStorageName = "";
  95. string demandUserCode = "";
  96. string demandUser = "";
  97. int acount = 0;
  98. decimal wgt = 0;
  99. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  100. if (checkMagRows.Count() == 0)
  101. {
  102. MessageUtil.ShowTips("请选择需要申请用车的库存信息!");
  103. return;
  104. }
  105. //int groupStatus = checkMagRows.GroupBy(a => a.GetValue("QcmStaus")).Count();
  106. //if (groupStatus > 1)
  107. //{
  108. // MessageUtil.ShowTips("只有同种交库状态的信息才能同时申请用车!");
  109. // return;
  110. //}
  111. if (this.cmbStorageNo.Text.Trim() == "")
  112. {
  113. MessageUtil.ShowTips("申请用车时请选择目标仓库!");
  114. return;
  115. }
  116. else
  117. {
  118. tarStorageNo = this.cmbStorageNo.Value.ToString2();
  119. tarStorageName = this.cmbStorageNo.Text.ToString2();
  120. }
  121. if (this.ultraDemandUser.Text == "")
  122. {
  123. MessageUtil.ShowTips("申请用车时,请选择需求单位!");
  124. return;
  125. }
  126. else
  127. {
  128. demandUserCode = this.ultraDemandUser.Value.ToString2();
  129. demandUser = this.ultraDemandUser.Text;
  130. }
  131. foreach (UltraGridRow row in checkMagRows)
  132. {
  133. acount = acount + int.Parse(row.Cells["ActCount"].Text);
  134. wgt = wgt + decimal.Parse(row.Cells["ActWeight"].Text);
  135. }
  136. ArrayList parmList = new ArrayList();
  137. int s = 0;
  138. int scrapNum = 0;
  139. foreach (UltraGridRow row in checkMagRows)
  140. {
  141. if (row.Cells["QcmStaus"].Text == "废品")
  142. {
  143. if (s > 0)
  144. {
  145. break;
  146. }
  147. MatGpMEntity matZcMEntity = (MatGpMEntity)row.ListObject;
  148. matZcMEntity.FlagStoveNo = "000000";
  149. matZcMEntity.JudgeStoveNo = "000000";
  150. matZcMEntity.PlineCode = row.Cells["PlineCode"].Text;
  151. matZcMEntity.ActCount = acount;
  152. matZcMEntity.ActWeight = wgt;
  153. matZcMEntity.PlineName = row.Cells["PlineName"].Text;
  154. matZcMEntity.StorageNo = row.Cells["StorageNo"].Text;
  155. matZcMEntity.StorageName = row.Cells["StorageName"].Text;
  156. matZcMEntity.MaterialName = "管材废品";
  157. matZcMEntity.MaterialNo = "";
  158. matZcMEntity.Dimater = row.Cells["Dimater"].Text;
  159. string matBcEntity = JSONFormat.Format(matZcMEntity);
  160. parmList.Add(matBcEntity);
  161. s = s + 1;
  162. }
  163. else
  164. {
  165. MatGpMEntity matZcMEntity = (MatGpMEntity)row.ListObject;
  166. string matBcEntity = JSONFormat.Format(matZcMEntity);
  167. parmList.Add(matBcEntity);
  168. }
  169. }
  170. CoreClientParam ccp = new CoreClientParam();
  171. ccp.ServerName = "com.steering.Demand.sever.FrmGpM";
  172. ccp.MethodName = "doWriteDemand";
  173. ccp.ServerParams = new object[] { parmList, UserInfo.GetUserName(), tarStorageNo, tarStorageName,demandUserCode,demandUser };
  174. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  175. if (ccp.ReturnCode != -1)
  176. {
  177. if (ccp.ReturnInfo.Equals("申请用车成功!"))
  178. {
  179. MessageUtil.ShowTips(ccp.ReturnInfo);
  180. }
  181. else
  182. {
  183. MessageUtil.ShowTips(ccp.ReturnInfo);
  184. }
  185. }
  186. }
  187. private void chkJugeHeatNo_CheckedChanged(object sender, EventArgs e)
  188. {
  189. this.txtJugeNo.Enabled = this.chkJugeHeatNo.Checked;
  190. }
  191. private void chkFlagStoveNo_CheckedChanged(object sender, EventArgs e)
  192. {
  193. this.txtFlagStoveNo.Enabled = this.chkFlagStoveNo.Checked;
  194. }
  195. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  196. {
  197. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  198. {
  199. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  200. {
  201. uRow.Cells["CHK"].Value = true;
  202. }
  203. }
  204. }
  205. private void ultraGrid2_CellChange(object sender, CellEventArgs e)
  206. {
  207. this.ultraGrid2.UpdateData();
  208. UltraGridRow row = this.ultraGrid2.ActiveRow;
  209. MatGpMEntity matBc = (MatGpMEntity)row.ListObject;
  210. if (matBc.ActCount.Equals("") || matBc.ActCount == null)
  211. {
  212. matBc.ActCount = 0;
  213. }
  214. string matBcEntity = JSONFormat.Format(matBc);
  215. if (e.Cell.Column.Key == "ActCount")
  216. {
  217. DataTable ds = ServerHelper.GetData("com.steering.Demand.sever.FrmGpM.doQueryWeight", new object[] { matBcEntity }, _ob);
  218. if (ds.Rows.Count > 0)
  219. {
  220. ultraGrid2.ActiveRow.Cells["ActWeight"].Value = ds.Rows[0][0].ToString();
  221. }
  222. }
  223. }
  224. }
  225. }