FrmMatInfo.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  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 CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.Mes.Client.Comm.Server;
  12. using Infragistics.Win.UltraWinGrid;
  13. using System.Collections;
  14. using Core.Mes.Client.Comm.Format;
  15. using Infragistics.Win.UltraWinEditors;
  16. namespace Core.StlMes.Client.SaleOrder.Dialog
  17. {
  18. /// <summary>
  19. /// 现货合同客户端
  20. /// </summary>
  21. public partial class FrmMatInfo : FrmBase
  22. {
  23. public FrmMatInfo()
  24. {
  25. InitializeComponent();
  26. }
  27. /// <summary>
  28. /// 构造函数
  29. /// </summary>
  30. /// <param name="_ob">OB对象</param>
  31. public FrmMatInfo(OpeBase _ob)
  32. {
  33. InitializeComponent();
  34. this.ob = _ob;
  35. }
  36. //销售组织
  37. string saleorg = "";
  38. public string Saleorg
  39. {
  40. get { return saleorg; }
  41. set { saleorg = value; }
  42. }
  43. /// <summary>
  44. /// 合同头PK值
  45. /// </summary>
  46. private string ordPk;
  47. /// <summary>
  48. /// 合同头PK值
  49. /// </summary>
  50. public string OrdPk
  51. {
  52. get { return ordPk; }
  53. set { ordPk = value; }
  54. }
  55. /// <summary>
  56. /// 制造商代码
  57. /// </summary>
  58. private string suppUnit;
  59. /// <summary>
  60. /// 制造商代码
  61. /// </summary>
  62. public string SuppUnit
  63. {
  64. get { return suppUnit; }
  65. set { suppUnit = value; }
  66. }
  67. private string orderNo;
  68. /// <summary>
  69. /// 合同号
  70. /// </summary>
  71. public string OrderNo
  72. {
  73. get { return orderNo; }
  74. set { orderNo = value; }
  75. }
  76. /// <summary>
  77. /// 窗体关闭属性 默认关闭
  78. /// </summary>
  79. private string closeEvent = "formClose";
  80. /// <summary>
  81. /// 窗体关闭属性
  82. /// </summary>
  83. public string CloseEvent
  84. {
  85. get { return closeEvent; }
  86. set { closeEvent = value; }
  87. }
  88. private string createDept = "";
  89. /// <summary>
  90. /// 创建部门
  91. /// </summary>
  92. public string CreateDept
  93. {
  94. get { return createDept; }
  95. set { createDept = value; }
  96. }
  97. private string createName = "";
  98. /// <summary>
  99. /// 创建人
  100. /// </summary>
  101. public string CreateName
  102. {
  103. get { return createName; }
  104. set { createName = value; }
  105. }
  106. /// <summary>
  107. /// 重写基类load事件,屏蔽平台过滤功能。
  108. /// </summary>
  109. /// <param name="e"></param>
  110. protected override void OnLoad(EventArgs e)
  111. {
  112. base.OnLoad(e);
  113. gdMat.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.FilterRow;
  114. gdMat.DisplayLayout.Override.FilterOperatorDefaultValue = Infragistics.Win.UltraWinGrid.FilterOperatorDefaultValue.Contains;
  115. }
  116. private void FrmMatInfo_Load(object sender, EventArgs e)
  117. {
  118. EntityHelper.ShowGridCaption<MatZcMEntity>(gdMat.DisplayLayout.Bands[0]);
  119. UltraComboEditor uce = new UltraComboEditor();
  120. uce.Items.Add("1", "封锁");
  121. uce.Items.Add("0", "未封锁");
  122. gdMat.DisplayLayout.Bands[0].Columns["lockFlag"].EditorComponent = uce;
  123. gdMat.DisplayLayout.Bands[0].Columns["mngLockFlag"].EditorComponent = uce;
  124. }
  125. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  126. {
  127. switch (e.Tool.Key)
  128. {
  129. case "Query":
  130. QueryMat();
  131. break;
  132. case "Add":
  133. string dept = UserInfo.GetDeptid();
  134. string name = UserInfo.GetUserName();
  135. if (dept == this.CreateDept && name == this.CreateName)
  136. {
  137. AddOrderLine();
  138. }
  139. else
  140. {
  141. MessageUtil.ShowWarning("操作权限不够!此合同是'" + this.CreateName + "'录入的!");
  142. return;
  143. }
  144. break;
  145. case "Close":
  146. this.Close();
  147. break;
  148. }
  149. }
  150. /// <summary>
  151. /// 库存信息查询
  152. /// </summary>
  153. public void QueryMat()
  154. {
  155. string[] arr = new string[4];
  156. string saleOrg = ClsBaseInfo.GetSaleOrg(UserInfo.GetDeptid());
  157. if (UserInfo.GetUserName() == "admin")
  158. {
  159. arr[0] = "100101";
  160. arr[1] = "100102";
  161. arr[2] = "100103";
  162. arr[3] = "100105";
  163. }
  164. if (saleOrg == "100101" || saleOrg == "100103")
  165. {
  166. arr[0] = "100101";
  167. arr[1] = "100103";
  168. arr[2] = "100103";
  169. arr[3] = "100105";
  170. }
  171. else if (saleOrg == "100102")
  172. {
  173. arr[0] = "100102";
  174. arr[1] = "100102";
  175. arr[2] = "100102";
  176. arr[3] = "100105";
  177. }
  178. else if (saleOrg == "100105")
  179. {
  180. arr[0] = "100101";
  181. arr[1] = "100102";
  182. arr[2] = "100103";
  183. arr[3] = "100105";
  184. }
  185. string judgeStoveNo = "";
  186. string proName = "";
  187. string steelName = "";
  188. string specName = "";
  189. if (chkJudgeStoveNo.Checked)
  190. judgeStoveNo = txtJudgeStoveNo.Text.Trim();
  191. if (chkPro.Checked)
  192. proName = txtPro.Text.Trim();
  193. if (chkSteel.Checked)
  194. steelName = txtSteel.Text.Trim();
  195. if (chkSpec.Checked)
  196. specName = txtSpec.Text.Trim();
  197. ArrayList parm = new ArrayList();
  198. parm.Add(judgeStoveNo);
  199. parm.Add(proName);
  200. parm.Add(steelName);
  201. parm.Add(specName);
  202. parm.Add(suppUnit);
  203. List<MatZcMEntity> listSource = EntityHelper.GetData<MatZcMEntity>(
  204. "com.steering.pss.sale.order.CoreMatInfo.queryMatInfo", new object[] { arr, parm }, this.ob);
  205. matZcMEntityBindingSource.DataSource = listSource;
  206. }
  207. /// <summary>
  208. /// 新增现货合同行
  209. /// </summary>
  210. public void AddOrderLine()
  211. {
  212. gdMat.UpdateData();
  213. gdOrderLine.UpdateData();
  214. string saleOrg = Saleorg;
  215. UltraGridRow[] rows = gdMat.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray();
  216. if (rows.Length <= 0)
  217. {
  218. MessageUtil.ShowWarning("请选择库存数据来新增现货合同!");
  219. return;
  220. }
  221. ArrayList orderLine = new ArrayList();
  222. foreach (UltraGridRow line in gdOrderLine.Rows)
  223. {
  224. SlmOrderLineNewEntity ole = new SlmOrderLineNewEntity();
  225. ole.Psc = "N/A";
  226. ole.PscDesc = "N/A";
  227. ole.OrderSpecCode = "N/A";
  228. ole.OrderSpecDesc = "N/A";
  229. ole.Produccode = line.Cells["PRODUCCODE"].Value.ToString();
  230. ole.Producname = line.Cells["PRODUCNAME"].Value.ToString();
  231. if (line.Cells["JUDGESTDNAME"].Value != null && line.Cells["JUDGESTDNAME"].Value.ToString() != "" && string.IsNullOrEmpty(line.Cells["STDNAME"].Value.ToString()))
  232. {
  233. ole.StdCode = "N/A";
  234. ole.StdName = line.Cells["JUDGESTDNAME"].Value.ToString();
  235. }
  236. else
  237. {
  238. ole.StdCode = line.Cells["STDCODE"].Value.ToString();
  239. ole.StdName = line.Cells["STDNAME"].Value.ToString();
  240. }
  241. ole.Steelcode = line.Cells["STEELCODE"].Value.ToString();
  242. ole.Steelname = line.Cells["STEELNAME"].Value.ToString();
  243. ole.StdStyle = line.Cells["STDSTYLE"].Value.ToString();
  244. ole.StdStyleDesc = line.Cells["STDSTYLEDESC"].Value.ToString();
  245. ole.SpecCode = line.Cells["SPECCODE"].Value.ToString();
  246. ole.SpecName = line.Cells["SPECNAME"].Value.ToString();
  247. ole.Dimater = Convert.ToDecimal(line.Cells["ACTDIMATER"].Value.ToString() == "" ? "0" : line.Cells["ACTDIMATER"].Value);
  248. ole.Height = Convert.ToDecimal(line.Cells["ACTHEIGHT"].Value.ToString() == "" ? "0" : line.Cells["ACTHEIGHT"].Value);
  249. ole.ModelCode = line.Cells["MODELCODE"].Value.ToString();
  250. ole.ModelDesc = line.Cells["MODELDESC"].Value.ToString();
  251. ole.LenDesc = line.Cells["ACTLENMIN"].Value.ToString() + "-" + line.Cells["ACTLENMAX"].Value.ToString();
  252. ole.LenMin = Convert.ToDecimal(line.Cells["ACTLENMIN"].Value.ToString3());
  253. ole.LenMax = Convert.ToDecimal(line.Cells["ACTLENMAX"].Value.ToString3());
  254. if (rdbD.Checked)
  255. {
  256. ole.OrderUnit = rdbD.Tag.ToString();
  257. }
  258. else
  259. {
  260. ole.OrderUnit = rdbZ.Tag.ToString();
  261. }
  262. ole.FinalUser = "N/A";
  263. ole.FinalUserDesc = "N/A";
  264. ole.CreateName = UserInfo.GetUserName();
  265. ole.OrdPk = this.OrdPk;
  266. if (rdbD.Checked)
  267. {
  268. ole.OrderQty = Convert.ToDecimal(line.Cells["ORDERQTY"].Value);
  269. }
  270. else
  271. {
  272. ole.OrderQty = Convert.ToDecimal(line.Cells["ORDERCOUNT"].Value);
  273. }
  274. ole.PrdctWgt = Convert.ToDecimal(line.Cells["ORDERQTY"].Value);
  275. ole.DelvryRangeTpe = "%";
  276. ole.DelvryRangeMin = 100;
  277. ole.DelvryRangeMax = 50;
  278. ole.OrderLnStatus = "12020101";
  279. ole.StoveBatchGroup = line.Cells["STOBATCHGROUP"].Value.ToString(); //这一行合同行 由哪些炉号批号组号 组成
  280. ole.OrderCount = line.Cells["ORDERCOUNT"].Value.ToString();
  281. orderLine.Add(JSONFormat.Format(ole));
  282. }
  283. ArrayList parm = new ArrayList();
  284. foreach (UltraGridRow row in rows)
  285. {
  286. ArrayList list = new ArrayList();
  287. list.Add(row.Cells["JUDGESTOVENO"].Value.ToString());
  288. list.Add(row.Cells["BATCHNO"].Value.ToString());
  289. list.Add(row.Cells["BATCHGROUDNO"].Value.ToString());
  290. list.Add(row.Cells["LKACTCOUNT"].Value.ToString());
  291. list.Add(row.Cells["BELONGCODE"].Text);
  292. list.Add(row.Cells["ActLen"].Text);
  293. list.Add(row.Cells["ActLenMin"].Text);
  294. list.Add(row.Cells["ActLenMax"].Text);
  295. if (!saleOrg.Equals(row.Cells["BELONGCODE"].Text))
  296. {
  297. MessageUtil.ShowWarning("炉号"+row.Cells["JUDGESTOVENO"].Value.ToString()+"库存销售组织与您当前的销售组织不一致,请所属权转移至您当前销售组织!");
  298. return;
  299. }
  300. parm.Add(list);
  301. //decimal actCount = Convert.ToDecimal(row.Cells["ACTCOUNT"].Value.ToString());
  302. //decimal lkActCount = Convert.ToDecimal(row.Cells["LKACTCOUNT"].Value.ToString());
  303. //decimal weight = Convert.ToDecimal(row.Cells["ACTWEIGHT"].Value.ToString());
  304. //qty += Math.Round(Convert.ToDecimal(lkActCount / actCount * weight), 3);
  305. }
  306. if (MessageUtil.ShowYesNoAndQuestion("是否使用勾选的库存信息新增[ " + gdOrderLine.Rows.Count + " ]行现货合同行?") == DialogResult.No) return;
  307. CoreClientParam ccp = new CoreClientParam();
  308. ccp.ServerName = "com.steering.pss.sale.order.CoreMatInfo";
  309. ccp.MethodName = "addSpotOrderLine";
  310. ccp.ServerParams = new object[] { orderLine, parm, this.OrderNo, this.OrdPk, saleOrg,UserInfo.GetUserName() };
  311. ccp.IfShowErrMsg = false;
  312. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  313. if (ccp != null)
  314. {
  315. if (ccp.ReturnCode == -1)
  316. {
  317. MessageUtil.ShowWarning(ccp.ReturnInfo);
  318. return;
  319. }
  320. MessageUtil.ShowTips("现货合同新增成功,请维护最终用户,交货信息!");
  321. this.CloseEvent = "Add";
  322. this.Close();
  323. }
  324. }
  325. /// <summary>
  326. /// 勾选炉号信息 之前只能新增一个合同行(相同产品信息),后改成根据产品信息自动生成多个合同行
  327. /// </summary>
  328. /// <param name="sender"></param>
  329. /// <param name="e"></param>
  330. private void gdMat_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  331. {
  332. gdMat.UpdateData();
  333. if (e.Cell.Column.Key.Equals("CHK"))
  334. {
  335. //如果材料是被 质量锁定或者管理锁定 将无法作现货合同
  336. if (e.Cell.Row.Cells["lockFlag"].Value.ToString2() == "1")
  337. {
  338. MessageUtil.ShowWarning("所选材料已被质量封锁,不能用于现货合同!");
  339. e.Cell.Value = false;
  340. return;
  341. }
  342. if (e.Cell.Row.Cells["mngLockFlag"].Value.ToString2() == "1")
  343. {
  344. MessageUtil.ShowWarning("所选材料已被管理封锁,不能用于现货合同!");
  345. e.Cell.Value = false;
  346. return;
  347. }
  348. dataTable1.Clear();
  349. Dictionary<string, decimal> dic = new Dictionary<string, decimal>(); //重量
  350. Dictionary<string, MyPoint> dicLen = new Dictionary<string, MyPoint>(); //长度上下限
  351. Dictionary<string, string> dicStove = new Dictionary<string, string>(); //炉批组
  352. Dictionary<string, decimal> dicCount = new Dictionary<string, decimal>(); //支数
  353. UltraGridRow[] rows = gdMat.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray();
  354. foreach (UltraGridRow row in rows)
  355. {
  356. decimal qty = 0;
  357. DataRow dr = dataTable1.NewRow();
  358. string str = row.Cells["PRODUCCODE"].Value.ToString() + row.Cells["STDSTYLE"].Value.ToString() +
  359. row.Cells["STEELCODE"].Value.ToString() + row.Cells["JUDGESTDNAME"].Value.ToString()
  360. + row.Cells["MODELCODE"].Value.ToString() + row.Cells["SPECCODE"].Value.ToString();
  361. decimal actCount = Convert.ToDecimal(row.Cells["ACTCOUNT"].Value.ToString());
  362. decimal lkActCount = Convert.ToDecimal(row.Cells["LKACTCOUNT"].Value.ToString());
  363. decimal weight = Convert.ToDecimal(row.Cells["ACTWEIGHT"].Value.ToString());
  364. qty = Math.Round(Convert.ToDecimal(lkActCount / actCount * weight), 3);
  365. //炉批组 @符号分割
  366. string stove = row.Cells["JudgeStoveNo"].Value.ToString() + "@" + row.Cells["BatchNo"].Value.ToString() + "@" + row.Cells["BatchGroudNo"].Value.ToString();
  367. if (!dic.ContainsKey(str) && dic.Count > 0)
  368. {
  369. //MessageUtil.ShowWarning("品种、标准类别、钢级、判定标准、扣型、规格不完全一样,不能勾选!");
  370. //e.Cell.Value = false;
  371. //return;
  372. dic.Add(str, qty);
  373. dicStove.Add(str, stove);
  374. dr["KEYSTR"] = str;
  375. dr["PRODUCCODE"] = row.Cells["PRODUCCODE"].Value.ToString();
  376. dr["PRODUCNAME"] = row.Cells["PRODUCNAME"].Value.ToString();
  377. dr["STEELCODE"] = row.Cells["STEELCODE"].Value.ToString();
  378. dr["STEELNAME"] = row.Cells["STEELNAME"].Value.ToString();
  379. dr["STDCODE"] = row.Cells["STDCODE"].Value.ToString();
  380. dr["STDNAME"] = row.Cells["STDNAME"].Value.ToString();
  381. dr["STDSTYLE"] = row.Cells["STDSTYLE"].Value.ToString();
  382. dr["STDSTYLEDESC"] = row.Cells["STDSTYLEDESC"].Value.ToString();
  383. dr["JUDGESTDNAME"] = row.Cells["JUDGESTDNAME"].Value.ToString();
  384. dr["MODELCODE"] = row.Cells["MODELCODE"].Value.ToString();
  385. dr["MODELDESC"] = row.Cells["MODELDESC"].Value.ToString();
  386. dr["ACTLENMIN"] = row.Cells["ACTLENMIN"].Value.ToString();
  387. dr["ACTLENMAX"] = row.Cells["ACTLENMAX"].Value.ToString();
  388. dr["ACTDIMATER"] = row.Cells["ACTDIMATER"].Value.ToString();
  389. dr["ACTHEIGHT"] = row.Cells["ACTHEIGHT"].Value.ToString();
  390. dr["SPECCODE"] = row.Cells["SPECCODE"].Value.ToString();
  391. dr["SPECNAME"] = row.Cells["SPECNAME"].Value.ToString();
  392. dr["ORDERQTY"] = qty;
  393. dr["STOBATCHGROUP"] = stove;
  394. dr["ORDERCOUNT"] = lkActCount;
  395. decimal x = Convert.ToDecimal(dr["ACTLENMIN"].ToString() == "" ? "0" : dr["ACTLENMIN"].ToString());
  396. decimal y = Convert.ToDecimal(dr["ACTLENMAX"].ToString() == "" ? "0" : dr["ACTLENMAX"].ToString());
  397. MyPoint point = new MyPoint(x, y);
  398. dicLen.Add(str, point);
  399. dicCount.Add(str, lkActCount);
  400. dataTable1.Rows.Add(dr);
  401. }
  402. else
  403. {
  404. if (dic.Count <= 0)
  405. {
  406. dic.Add(str, qty);
  407. dr["KEYSTR"] = str;
  408. dr["PRODUCCODE"] = row.Cells["PRODUCCODE"].Value.ToString();
  409. dr["PRODUCNAME"] = row.Cells["PRODUCNAME"].Value.ToString();
  410. dr["STEELCODE"] = row.Cells["STEELCODE"].Value.ToString();
  411. dr["STEELNAME"] = row.Cells["STEELNAME"].Value.ToString();
  412. dr["STDCODE"] = row.Cells["STDCODE"].Value.ToString();
  413. dr["STDNAME"] = row.Cells["STDNAME"].Value.ToString();
  414. dr["STDSTYLE"] = row.Cells["STDSTYLE"].Value.ToString();
  415. dr["STDSTYLEDESC"] = row.Cells["STDSTYLEDESC"].Value.ToString();
  416. dr["JUDGESTDNAME"] = row.Cells["JUDGESTDNAME"].Value.ToString();
  417. dr["MODELCODE"] = row.Cells["MODELCODE"].Value.ToString();
  418. dr["MODELDESC"] = row.Cells["MODELDESC"].Value.ToString();
  419. dr["ACTLENMIN"] = row.Cells["ACTLENMIN"].Value.ToString();
  420. dr["ACTLENMAX"] = row.Cells["ACTLENMAX"].Value.ToString();
  421. dr["ACTDIMATER"] = row.Cells["ACTDIMATER"].Value.ToString();
  422. dr["ACTHEIGHT"] = row.Cells["ACTHEIGHT"].Value.ToString();
  423. dr["SPECCODE"] = row.Cells["SPECCODE"].Value.ToString();
  424. dr["SPECNAME"] = row.Cells["SPECNAME"].Value.ToString();
  425. dr["ORDERQTY"] = qty;
  426. dr["STOBATCHGROUP"] = stove;
  427. dr["ORDERCOUNT"] = lkActCount;
  428. decimal x = Convert.ToDecimal(dr["ACTLENMIN"].ToString() == "" ? "0" : dr["ACTLENMIN"].ToString());
  429. decimal y = Convert.ToDecimal(dr["ACTLENMAX"].ToString() == "" ? "0" : dr["ACTLENMAX"].ToString());
  430. MyPoint point = new MyPoint(x, y);
  431. dicLen.Add(str, point);
  432. dicStove.Add(str, stove);
  433. dicCount.Add(str, lkActCount);
  434. dataTable1.Rows.Add(dr);
  435. }
  436. else
  437. {
  438. dic[str] = dic[str] + qty;
  439. MyPoint oldPoint = dicLen[str];
  440. decimal x = Convert.ToDecimal(row.Cells["ACTLENMIN"].Value.ToString() == "" ? "0" : row.Cells["ACTLENMIN"].Value.ToString());
  441. decimal y = Convert.ToDecimal(row.Cells["ACTLENMAX"].Value.ToString() == "" ? "0" : row.Cells["ACTLENMAX"].Value.ToString());
  442. if (oldPoint.X > x) //小中取小 大中取大
  443. oldPoint.X = x;
  444. if (oldPoint.Y < y)
  445. oldPoint.Y = y;
  446. dicLen[str] = oldPoint;
  447. dicCount[str] = dicCount[str] + lkActCount;
  448. string stove1 = dicStove[str];
  449. dicStove[str] = stove1 + "&" + stove;
  450. foreach (DataRow dRow in dataTable1.Rows)
  451. {
  452. if (dRow["KEYSTR"].ToString() == str)
  453. {
  454. dRow["ORDERQTY"] = dic[str];
  455. dRow["ACTLENMIN"] = dicLen[str].X.ToString();
  456. dRow["ACTLENMAX"] = dicLen[str].Y.ToString();
  457. dRow["STOBATCHGROUP"] = dicStove[str];
  458. dRow["ORDERCOUNT"] = dicCount[str];
  459. break;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. if (e.Cell.Value.ToString() == "True")
  466. {
  467. e.Cell.Row.Cells["LKACTCOUNT"].Activation = Activation.AllowEdit;
  468. }
  469. }
  470. else if (e.Cell.Column.Key.ToUpper().Equals("LKACTCOUNT"))
  471. {
  472. if (e.Cell.Value == null)
  473. {
  474. MessageUtil.ShowWarning("请输入利库支数!");
  475. return;
  476. }
  477. else if (Convert.ToDecimal(e.Cell.Value) > Convert.ToDecimal(e.Cell.Row.Cells["ACTCOUNT"].Value))
  478. {
  479. MessageUtil.ShowWarning("输入的利库支数不能大于炉号的支数!");
  480. e.Cell.Value = e.Cell.Row.Cells["ACTCOUNT"].Value;
  481. return;
  482. }
  483. Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
  484. Dictionary<string, decimal> dicCount = new Dictionary<string, decimal>(); //支数
  485. UltraGridRow[] rows = gdMat.Rows.AsQueryable().Where(a => a.Cells["CHK"].Value.ToString() == "True").ToArray();
  486. decimal qty = 0;
  487. foreach (UltraGridRow row in rows)
  488. {
  489. string str = row.Cells["PRODUCCODE"].Value.ToString() + row.Cells["STDSTYLE"].Value.ToString() +
  490. row.Cells["STEELCODE"].Value.ToString() + row.Cells["JUDGESTDNAME"].Value.ToString()
  491. + row.Cells["MODELCODE"].Value.ToString() + row.Cells["SPECCODE"].Value.ToString();
  492. decimal actCount = Convert.ToDecimal(row.Cells["ACTCOUNT"].Value.ToString());
  493. decimal lkActCount = Convert.ToDecimal(row.Cells["LKACTCOUNT"].Value.ToString());
  494. decimal weight = Convert.ToDecimal(row.Cells["ACTWEIGHT"].Value.ToString());
  495. qty = Math.Round(Convert.ToDecimal(lkActCount / actCount * weight), 3);
  496. if (!dic.ContainsKey(str) && dic.Count > 0)
  497. {
  498. dic.Add(str, qty);
  499. dicCount.Add(str, lkActCount);
  500. }
  501. else
  502. {
  503. if (dic.Count <= 0)
  504. {
  505. dic.Add(str, qty);
  506. dicCount.Add(str, lkActCount);
  507. }
  508. else
  509. {
  510. dic[str] += qty;
  511. dicCount[str] += lkActCount;
  512. }
  513. }
  514. }
  515. foreach (DataRow dRow in dataTable1.Rows)
  516. {
  517. if (dic.ContainsKey(dRow["KEYSTR"].ToString()))
  518. {
  519. dRow["ORDERQTY"] = dic[dRow["KEYSTR"].ToString()];
  520. dRow["ORDERCOUNT"] = dicCount[dRow["KEYSTR"].ToString()];
  521. }
  522. }
  523. }
  524. }
  525. private void gdMat_AfterRowActivate(object sender, EventArgs e)
  526. {
  527. UltraGridRow row = gdMat.ActiveRow;
  528. if (row == null)
  529. return;
  530. foreach (UltraGridCell cell in row.Cells)
  531. {
  532. if (!cell.Column.Key.Equals("CHK"))
  533. {
  534. cell.Activation = Activation.ActivateOnly;
  535. }
  536. }
  537. if (row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  538. {
  539. row.Cells["LKACTCOUNT"].Activation = Activation.AllowEdit;
  540. }
  541. }
  542. private void chkJudgeStoveNo_CheckedChanged(object sender, EventArgs e)
  543. {
  544. if (chkJudgeStoveNo.Checked)
  545. {
  546. txtJudgeStoveNo.ReadOnly = false;
  547. }
  548. else
  549. {
  550. txtJudgeStoveNo.ReadOnly = true;
  551. }
  552. }
  553. private void txtJudgeStoveNo_KeyPress(object sender, KeyPressEventArgs e)
  554. {
  555. if (e.KeyChar == 13)
  556. QueryMat();
  557. }
  558. private void chkPro_CheckedChanged(object sender, EventArgs e)
  559. {
  560. if (chkPro.Checked)
  561. {
  562. txtPro.ReadOnly = false;
  563. }
  564. else
  565. {
  566. txtPro.ReadOnly = true;
  567. }
  568. }
  569. private void chkSteel_CheckedChanged(object sender, EventArgs e)
  570. {
  571. if (chkSteel.Checked)
  572. {
  573. txtSteel.ReadOnly = false;
  574. }
  575. else
  576. {
  577. txtSteel.ReadOnly = true;
  578. }
  579. }
  580. private void chkSpec_CheckedChanged(object sender, EventArgs e)
  581. {
  582. if (chkSpec.Checked)
  583. {
  584. txtSpec.ReadOnly = false;
  585. }
  586. else
  587. {
  588. txtSpec.ReadOnly = true;
  589. }
  590. }
  591. private void txtPro_KeyPress(object sender, KeyPressEventArgs e)
  592. {
  593. if (e.KeyChar == 13)
  594. QueryMat();
  595. }
  596. private void txtSteel_KeyPress(object sender, KeyPressEventArgs e)
  597. {
  598. if (e.KeyChar == 13)
  599. QueryMat();
  600. }
  601. private void txtSpec_KeyPress(object sender, KeyPressEventArgs e)
  602. {
  603. if (e.KeyChar == 13)
  604. QueryMat();
  605. }
  606. }
  607. /// <summary>
  608. /// 坐标
  609. /// </summary>
  610. struct MyPoint
  611. {
  612. decimal x;
  613. public decimal X
  614. {
  615. get { return x; }
  616. set { x = value; }
  617. }
  618. decimal y;
  619. public decimal Y
  620. {
  621. get { return y; }
  622. set { y = value; }
  623. }
  624. public MyPoint(decimal x, decimal y)
  625. {
  626. this.x = x;
  627. this.y = y;
  628. }
  629. }
  630. }