FrmBcM.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 FrmBcM : FrmBase
  19. {
  20. string[] arr = null;
  21. OpeBase _ob;
  22. public FrmBcM(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<MatBcMEntity1>(ultraGrid1.DisplayLayout.Bands[0]);
  32. initStorageNo();
  33. initDemandUser();
  34. this.ultraDemandUser.SelectedIndex = 0;
  35. this.cmbUnload.SelectedIndex = 0;
  36. this.ultraTrainPort.SelectedIndex = 0;
  37. }
  38. /// <summary>
  39. /// 加载需求单位
  40. /// </summary>
  41. private void initDemandUser()
  42. {
  43. BaseMethod.InitDemandUser(ultraDemandUser, _ob, arr);
  44. }
  45. /// <summary>
  46. /// 加载仓库
  47. /// </summary>
  48. private void initStorageNo()
  49. {
  50. BaseMethod.InitStorageNo(cmbStorageNo, _ob);
  51. }
  52. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  53. {
  54. switch (e.Tool.Key)
  55. {
  56. case "Query":
  57. doQuery();
  58. break;
  59. case "AddDemand":
  60. addDemand();
  61. break;
  62. case"Close":
  63. this.Close();
  64. break;
  65. }
  66. }
  67. /// <summary>
  68. /// 查询库存
  69. /// </summary>
  70. private void doQuery()
  71. {
  72. string judgeNo = "";
  73. string flagStoveNo = "";
  74. if (this.chkJugeHeatNo.Checked && this.txtJugeNo.Text.Trim() != "")
  75. {
  76. judgeNo = this.txtJugeNo.Text.Trim();
  77. }
  78. if (this.chkFlagStoveNo.Checked && this.txtFlagStoveNo.Text != "")
  79. {
  80. flagStoveNo = this.txtFlagStoveNo.Text.ToString();
  81. }
  82. if(judgeNo == "" && flagStoveNo == "")
  83. {
  84. MessageUtil.ShowTips("查询库存请车时,请输入判定炉号或者标识炉号!");
  85. return;
  86. }
  87. ArrayList parmList = new ArrayList();
  88. parmList.Add(judgeNo);
  89. parmList.Add(flagStoveNo);
  90. List<MatBcMEntity1> listSource = EntityHelper.GetData<MatBcMEntity1>(
  91. "com.steering.Demand.sever.FrmBcM.doQuery", new object[] { parmList, arr }, _ob);
  92. matBcMEntity1BindingSource.DataSource = listSource;
  93. }
  94. /// <summary>
  95. /// 生成需求
  96. /// </summary>
  97. private void addDemand()
  98. {
  99. this.ultraGrid1.UpdateData();
  100. string tarStorageNo = "";
  101. string tarStorageName = "";
  102. string demandUserCode = "";
  103. string demandUser = "";
  104. string unloadCode = "";
  105. string unloadDesc = "";
  106. int acount = 0;
  107. decimal wgt = 0;
  108. string trainPortType = "";
  109. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  110. if (checkMagRows.Count() == 0)
  111. {
  112. MessageUtil.ShowTips("请选择需要生成用车需求的库存信息!");
  113. return;
  114. }
  115. int groupStatus = checkMagRows.GroupBy(a => a.GetValue("QcmStaus")).Count();
  116. if (groupStatus > 1)
  117. {
  118. MessageUtil.ShowTips("只有同种交库状态的信息才能同时生成用车需求!");
  119. return;
  120. }
  121. if (this.cmbStorageNo.Text.Trim() == "")
  122. {
  123. MessageUtil.ShowTips("生成用车需求时请选择目标仓库!");
  124. return;
  125. }
  126. else
  127. {
  128. tarStorageNo = this.cmbStorageNo.Value.ToString2();
  129. tarStorageName = this.cmbStorageNo.Text.ToString2();
  130. }
  131. if (this.ultraDemandUser.Text == "")
  132. {
  133. MessageUtil.ShowTips("生成用车需求时,请选择需求单位!");
  134. return;
  135. }
  136. else
  137. {
  138. demandUserCode = this.ultraDemandUser.Value.ToString2();
  139. demandUser = this.ultraDemandUser.Text;
  140. }
  141. if (this.cmbUnload.Text == "")
  142. {
  143. MessageUtil.ShowTips("生成用车需求时,请选择目标装卸点!");
  144. return;
  145. }
  146. else
  147. {
  148. unloadCode = this.cmbUnload.Value.ToString2();
  149. unloadDesc = this.cmbUnload.Text;
  150. }
  151. if (ultraTrainPort.Text == "")
  152. {
  153. MessageUtil.ShowTips("生成用车需求时,请选择用途类型!");
  154. }
  155. else
  156. {
  157. trainPortType = this.ultraTrainPort.Value.ToString2();
  158. }
  159. foreach (UltraGridRow row in checkMagRows)
  160. {
  161. acount = acount + int.Parse(row.Cells["ActCount"].Text);
  162. wgt = wgt + decimal.Parse(row.Cells["ActWeight"].Text);
  163. }
  164. string valueFlag = this.ultraOptionSet1.CheckedItem.DataValue.ToString();
  165. ArrayList parmList = new ArrayList();
  166. int s = 0;
  167. int scrapNum = 0;
  168. foreach (UltraGridRow row in checkMagRows)
  169. {
  170. if (row.Cells["QcmStaus"].Text == "废品")
  171. {
  172. if(valueFlag.Equals("1"))
  173. {
  174. scrapNum = scrapNum + 1;
  175. }
  176. if (s > 0)
  177. {
  178. break;
  179. }
  180. MatBcMEntity1 matZcMEntity = (MatBcMEntity1)row.ListObject;
  181. matZcMEntity.FlagStoveNoZg = "000000";
  182. matZcMEntity.JudgeStoveNo = "000000";
  183. matZcMEntity.BatchNo = "F";
  184. matZcMEntity.BatchGroudNo = "001";
  185. matZcMEntity.PlineCode = row.Cells["PlineCode"].Text;
  186. matZcMEntity.ActCount = acount;
  187. matZcMEntity.ActWeight = wgt;
  188. matZcMEntity.PlineName = row.Cells["PlineName"].Text;
  189. matZcMEntity.StorageNo = row.Cells["StorageNo"].Text;
  190. matZcMEntity.StorageName = row.Cells["StorageName"].Text;
  191. matZcMEntity.MaterialName = "管材废品";
  192. matZcMEntity.MaterialNo = "";
  193. matZcMEntity.ActLenMin = "";
  194. matZcMEntity.ActLenMax = "";
  195. matZcMEntity.ActHeight = 0;
  196. matZcMEntity.ActDimater = 0;
  197. matZcMEntity.SpecName = "";
  198. matZcMEntity.SpecCode = "";
  199. string matBcEntity = JSONFormat.Format(matZcMEntity);
  200. parmList.Add(matBcEntity);
  201. s = s + 1;
  202. }
  203. else
  204. {
  205. MatBcMEntity1 matZcMEntity = (MatBcMEntity1)row.ListObject;
  206. string matBcEntity = JSONFormat.Format(matZcMEntity);
  207. parmList.Add(matBcEntity);
  208. }
  209. }
  210. if(scrapNum > 0)
  211. {
  212. MessageUtil.ShowTips("废品运输只允许申请单向需求!");
  213. return;
  214. }
  215. CoreClientParam ccp = new CoreClientParam();
  216. ccp.ServerName = "com.steering.Demand.sever.FrmBcM";
  217. ccp.MethodName = "doWriteDemand";
  218. ccp.ServerParams = new object[] { parmList, UserInfo.GetUserName(), tarStorageNo, tarStorageName, valueFlag, demandUserCode, demandUser, unloadCode, unloadDesc, trainPortType };
  219. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  220. if (ccp.ReturnCode != -1)
  221. {
  222. if (ccp.ReturnInfo.Equals("生成用车需求成功!"))
  223. {
  224. MessageUtil.ShowTips(ccp.ReturnInfo);
  225. }
  226. else
  227. {
  228. MessageUtil.ShowTips(ccp.ReturnInfo);
  229. }
  230. }
  231. }
  232. private void chkJugeHeatNo_CheckedChanged(object sender, EventArgs e)
  233. {
  234. this.txtJugeNo.Enabled = this.chkJugeHeatNo.Checked;
  235. }
  236. private void chkFlagStoveNo_CheckedChanged(object sender, EventArgs e)
  237. {
  238. this.txtFlagStoveNo.Enabled = this.chkFlagStoveNo.Checked;
  239. }
  240. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  241. {
  242. foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows)
  243. {
  244. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  245. {
  246. uRow.Cells["CHK"].Value = true;
  247. }
  248. }
  249. }
  250. private void InitUnload(string strageNo)
  251. {
  252. BaseMethod.InitUnLoad(cmbUnload, _ob, strageNo);
  253. this.cmbUnload.SelectedIndex = 0;
  254. }
  255. private void cmbStorageNo_ValueChanged(object sender, EventArgs e)
  256. {
  257. InitUnload(this.cmbStorageNo.Value.ToString2());
  258. }
  259. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  260. {
  261. this.ultraGrid1.UpdateData();
  262. UltraGridRow row = this.ultraGrid1.ActiveRow;
  263. MatBcMEntity1 matBc = (MatBcMEntity1)row.ListObject;
  264. if (matBc.ActCount.Equals("") || matBc.ActCount == null)
  265. {
  266. matBc.ActCount = 0;
  267. }
  268. string matBcEntity = JSONFormat.Format(matBc);
  269. if (e.Cell.Column.Key == "ActCount")
  270. {
  271. DataTable ds = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.doQueryWeight", new object[] { matBcEntity }, _ob);
  272. if (ds.Rows.Count > 0)
  273. {
  274. ultraGrid1.ActiveRow.Cells["ActWeight"].Value = ds.Rows[0][0].ToString();
  275. }
  276. }
  277. }
  278. }
  279. }