FrmPlanMaterialSelection.cs 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
  5. using Core.StlMes.Client.PlnSaleOrd.Controls;
  6. using Core.StlMes.Client.PlnSaleOrd.炼钢计划;
  7. using Core.StlMes.Client.PlnSaleOrd.炉计划.Entity;
  8. using Core.StlMes.Client.PlnSaleOrd.炉计划.Tool;
  9. using CoreFS.CA06;
  10. using Infragistics.Win;
  11. using Infragistics.Win.UltraWinEditors;
  12. using Infragistics.Win.UltraWinGrid;
  13. using System;
  14. using System.Collections;
  15. using System.Collections.Generic;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Drawing;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Windows.Forms;
  22. namespace Core.StlMes.Client.PlnSaleOrd.炉计划
  23. {
  24. public partial class FrmPlanMaterialSelection : FrmBase
  25. {
  26. private OpeBase _ob;
  27. private string _inMaterialName;
  28. private string _cic;
  29. private string _ciclk;
  30. private string _dimater;
  31. private string _userName;
  32. private string _proPlanId;
  33. private string _gxPlanNo;
  34. private string cic;
  35. private string cicyL;
  36. private string desginKey;
  37. private string indexSeq;
  38. private string outMaterialNo;
  39. private string plineCode;
  40. private string inMaterialNo;
  41. private string zggradeName;
  42. private string zggradecode;
  43. private string _supplyCode;
  44. public DataRow CurrentChem { get; private set; }
  45. private bool flag = false;
  46. //DataTable dtOrder = new DataTable();
  47. //DataTable dtInwlOut = new DataTable();
  48. public bool Flag
  49. {
  50. get { return flag; }
  51. set { flag = value; }
  52. }
  53. public FrmPlanMaterialSelection(string inMaterialName, string cic, string ciclk, string dimater, string proPlanId, string gxPlanNo,string supplyCode, string userName, OpeBase ob)
  54. {
  55. InitializeComponent();
  56. _ob = ob;
  57. _inMaterialName = inMaterialName;
  58. _cic = cic;
  59. _ciclk = ciclk;
  60. _dimater = dimater;
  61. _userName = userName;
  62. _proPlanId = proPlanId;
  63. _gxPlanNo = gxPlanNo;
  64. _supplyCode = supplyCode;
  65. CurrentChem = null;
  66. this.IsLoadUserView = true;
  67. }
  68. protected override void OnLoad(EventArgs e)
  69. {
  70. base.OnLoad(e);
  71. ultraGridZgS.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  72. ulgridElement.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  73. }
  74. private void FrmPlanMaterialSelection_Load(object sender, EventArgs e)
  75. {
  76. txtMaterialName.Text = _inMaterialName;
  77. txtGradeName.Text = _cic;
  78. txtGradeNamelk.Text = _ciclk;
  79. txtDimater.Text = _dimater;
  80. //设置列头名称
  81. EntityHelper.ShowGridCaption<MatGpMEntity>(ultraGridChoose.DisplayLayout.Bands[0]);
  82. BaseHelper.setOtherColumnReadOnly(ultraGridChoose, new string[] { "CHC", "TakeCount", "CutTybe", "PlnType" });
  83. BaseHelper.InitCellPosition(ultraGridChoose, new string[] { "TakeCount", "TakeWeight", "ActLenTake", "FixLenTake", "OutnumCut", "LenCuthead", "LenCutend", "Aimlength", "RollLength", "WeightM", "WeightGpOne", "Sequenceno", "DbActCount", "GroudNo", "ActTheoryWeight", "ActWeight", "ActCount", "FixLen", "FixNum", "ActLen", "Height", "Dimater" });
  84. BaseHelper.GridColumnSum(ultraGridChoose, new string[] { "TakeWeight", "ActWeight", "ActTheoryWeight" });
  85. BaseHelper.GridColumnCount(ultraGridChoose, new string[] { "TakeCount", "ActCount", "DbActCount" });
  86. BaseHelper.setUltraGridColumnMaxInput(ultraGridChoose, new string[] { "TakeWeight", "RollLength", "Aimlength", "ActTheoryWeight", "ActWeight" });
  87. BaseHelper.setUltraGridColumnBits(ultraGridChoose, new string[] { "TakeCount", "ActCount", "DbActCount", "LenCuthead", "OutnumCut", "LenCutend"});
  88. BaseHelper.setColumnBackColor(ultraGridChoose, new string[] { "TakeCount", "CutTybe", "PlnType", "SpecCic" });
  89. UltraNumericEditor[] uneArr = new UltraNumericEditor[1];
  90. uneArr[0] = new UltraNumericEditor();
  91. uneArr[0].NumericType = NumericType.Double;
  92. uneArr[0].MaskInput = "nnnnn";
  93. uneArr[0].SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always;
  94. this.Controls.Add(uneArr[0]);
  95. uneArr[0].Visible = false;
  96. uneArr[0].SpinIncrement = 10;
  97. ultraGridChoose.DisplayLayout.Bands[0].Columns["ActLenTake"].EditorComponent = uneArr[0];
  98. ultraGridChoose.DisplayLayout.Bands[0].Columns["FixLenTake"].EditorComponent = uneArr[0];
  99. ultraGridChoose.DisplayLayout.Bands[0].Columns["SpecCic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.EditButton;
  100. UltraComboEditor uceAbc = new UltraComboEditor();
  101. ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].EditorComponent = uceAbc;
  102. ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  103. ValueList vlistSteel = new ValueList();
  104. vlistSteel.ValueListItems.Insert(0, "不切", "不切");
  105. vlistSteel.ValueListItems.Insert(1, "切坯", "切坯");
  106. //vlistSteel.ValueListItems.Insert(2, "切管", "切管");
  107. ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].ValueList = vlistSteel;
  108. ValueList vlistSteel1 = new ValueList();
  109. vlistSteel1.ValueListItems.Insert(0, "0", "正常计划");
  110. vlistSteel1.ValueListItems.Insert(1, "1", "试轧料");
  111. ultraGridChoose.DisplayLayout.Bands[0].Columns["PlnType"].ValueList = vlistSteel1;
  112. ValueList vlistSteel2 = new ValueList();
  113. vlistSteel2.ValueListItems.Insert(0, "回库", "回库");
  114. //vlistSteel2.ValueListItems.Insert(1, "返废", "返废");
  115. vlistSteel2.ValueListItems.Insert(1, "套尺", "套尺");
  116. ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTarget"].ValueList = vlistSteel2;
  117. //StoveHelper.SetComboItemHeight(vlistSteel2);
  118. StoveHelper.ForbidSort(ultraGridZgS);
  119. StoveHelper.ForbidSort(ulgridElement);
  120. QueryZgS();
  121. QueryPlanZg();
  122. //Query();
  123. }
  124. private double minLengthRing = 0;
  125. /// <summary>
  126. /// 查询产线对应最小环形炉长度
  127. /// </summary>
  128. private void QueryPline()
  129. {
  130. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.queryPline",
  131. new object[] { plineCode }, _ob);
  132. if (dt.Rows.Count>0)
  133. {
  134. minLengthRing = double.Parse(dt.Rows[0]["LENGTH_MIN_RING"].ToString());
  135. }
  136. }
  137. private void QueryZgS()
  138. {
  139. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getPlnOrderZg",
  140. new object[] { _proPlanId, _gxPlanNo }, _ob);
  141. if (dt.Rows.Count > 0)
  142. {
  143. if (dt.Rows[0]["CIC_GROUP_LK"].ToString().Contains(dt.Rows[0]["CIC_GP"].ToString()))
  144. {
  145. cic = dt.Rows[0]["CIC_GROUP_LK"].ToString();
  146. }
  147. else
  148. {
  149. if (dt.Rows[0]["CIC_GROUP_LK"].ToString().Equals(""))
  150. {
  151. cic = dt.Rows[0]["CIC_GP"].ToString();
  152. }
  153. else
  154. {
  155. cic = dt.Rows[0]["CIC_GP"].ToString() + "," + dt.Rows[0]["CIC_GROUP_LK"].ToString();
  156. }
  157. }
  158. cicyL = dt.Rows[0]["CIC_GP"].ToString();
  159. desginKey = dt.Rows[0]["DESGIN_KEY"].ToString();
  160. indexSeq = dt.Rows[0]["INDEX_SEQ"].ToString();
  161. outMaterialNo = dt.Rows[0]["OUTWL_ID"].ToString();
  162. inMaterialNo = dt.Rows[0]["INWL_ID"].ToString();
  163. plineCode = dt.Rows[0]["PLINE_CODE"].ToString();
  164. }
  165. QueryPline();
  166. }
  167. private void QueryPlanZg()
  168. {
  169. List<PlnOrderZgSOEntityGp> listSource = EntityHelper.GetData<PlnOrderZgSOEntityGp>("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getPlnOrderZgS",
  170. new object[] { _proPlanId, _gxPlanNo }, _ob);
  171. plnOrderZgSOEntityBindingSource.DataSource = listSource;
  172. GridHelper.RefreshAndAutoSize(ultraGridZgS);
  173. foreach (UltraGridRow ugr in ultraGridZgS.Rows)
  174. {
  175. #region 赋值LJ,装炉,出库
  176. int numLj = 0;
  177. double wtLj = 0;
  178. if (!ugr.Cells["LjNum"].Text.Equals(""))
  179. {
  180. numLj = int.Parse(ugr.Cells["LjNum"].Value.ToString());
  181. wtLj = double.Parse(ugr.Cells["LjWeight"].Value.ToString());
  182. }
  183. int gpNum = 0;
  184. double gpWt = 0;
  185. if (!ugr.Cells["GpreqNum"].Text.Equals(""))
  186. {
  187. gpNum = int.Parse(ugr.Cells["GpreqNum"].Value.ToString());
  188. gpWt = double.Parse(ugr.Cells["GpreqWeight"].Value.ToString());
  189. }
  190. if (gpNum - numLj <= 0)
  191. {
  192. ugr.Cells["ReallNum"].Value = "0";
  193. ugr.Cells["ReallWt"].Value = "0";
  194. }
  195. else
  196. {
  197. ugr.Cells["ReallNum"].Value = (gpNum - numLj).ToString();
  198. ugr.Cells["ReallWt"].Value = (gpWt - wtLj).ToString("f3");
  199. }
  200. #endregion
  201. zggradeName = ugr.Cells["GradecodeAll"].Text.ToString().Trim() + "," + ugr.Cells["GradenameLk"].Text.ToString().Trim() + "," + ugr.Cells["Gradename"].Text.ToString().Trim();
  202. zggradecode = ugr.Cells["Gradecode"].Text.ToString().Trim() + "," + ugr.Cells["GradecodeLk"].Text.ToString().Trim();
  203. }
  204. }
  205. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  206. {
  207. switch (e.Tool.Key)
  208. {
  209. case "Query":
  210. Query();
  211. break;
  212. case "Liku": //利库
  213. Liku();
  214. break;
  215. case "Monomer": // 脱单
  216. Monomer();
  217. break;
  218. //case "Recalcu": // 重算
  219. // Recalcu();
  220. // break;
  221. case "Close":
  222. this.Close();
  223. break;
  224. }
  225. }
  226. /// <summary>
  227. /// 查询
  228. /// </summary>
  229. private void Query()
  230. {
  231. UltraGridRow row = this.ultraGridZgS.ActiveRow;
  232. if (row == null) return;
  233. string surplusflag = "";
  234. string cicN = _cic;
  235. if (!_ciclk.Equals(""))
  236. {
  237. cicN = _cic + "," + _ciclk;
  238. }
  239. if (_dimater.Equals("250") || _dimater.Equals("251"))
  240. {
  241. _dimater ="250,251";
  242. }
  243. surplusflag = txtSurplusflag.Value.ToString();
  244. string[] gradestr = null;
  245. string gradeAll = "";
  246. if (!zggradeName.Equals(""))
  247. {
  248. gradestr = zggradeName.Split(',');
  249. }
  250. //for (int i = 0; i < gradestr.Length; i++)
  251. //{
  252. // gradeAll+="'"+gradestr[i]+"',";
  253. //}
  254. //gradeAll = gradeAll.Substring(1, gradeAll.Length-3);
  255. List<MatGpMEntity> listSourceM = EntityHelper.GetData<MatGpMEntity>
  256. ("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryMaterial", new object[] { _inMaterialName, cicN, _dimater, surplusflag, gradestr, row.Cells["PlineCode"].Text, row.Cells["TypeFlag"].Text }, _ob);
  257. matGpMEntityBindingSource.DataSource = listSourceM;
  258. //GridHelper.RefreshAndAutoSize(ultraGridChoose);
  259. foreach (UltraGridRow item in ultraGridChoose.Rows)
  260. {
  261. double dimater = 0;
  262. if (item.Cells["Dimater"].Value.ToString().Equals("251"))
  263. {
  264. dimater = 250;
  265. }
  266. else
  267. {
  268. dimater = double.Parse(item.Cells["Dimater"].Value.ToString());
  269. }
  270. double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
  271. // 倍尺坯长
  272. double lenLong = double.Parse(item.Cells["ActLen"].Value.ToString());
  273. // 倍尺坯单支重=坯米单重*倍尺坯长/1000
  274. double weightM = mSingleWeight * (lenLong / 1000);
  275. // 单倍坯重
  276. double weightGpOne = mSingleWeight
  277. * (double.Parse(item.Cells["FixLen"].Value.ToString()) / 1000);
  278. item.Cells["WeightM"].Value = weightM.ToString("f6");
  279. item.Cells["WeightGpOne"].Value = weightGpOne.ToString("f6");
  280. UltraGridRow urgzG = ultraGridZgS.ActiveRow;
  281. if (urgzG != null)
  282. {
  283. if (item.Cells["ProPlanIdZg"].Text.ToString().Equals(""))
  284. {
  285. item.Cells["OutnumCut"].Value = urgzG.Cells["OutnumCut"].Value.ToString();
  286. item.Cells["LenCuthead"].Value = urgzG.Cells["LenCuthead"].Value.ToString();
  287. item.Cells["LenCutend"].Value = urgzG.Cells["LenCutend"].Value.ToString();
  288. item.Cells["Aimlength"].Value = urgzG.Cells["Aimlength"].Value.ToString();
  289. item.Cells["RollLength"].Value = urgzG.Cells["RollLength"].Value.ToString();
  290. }
  291. item.Cells["FixLenTake"].Value = urgzG.Cells["LenGpSingle"].Value.ToString();
  292. }
  293. if (item.Cells["StorageName"].Text.Contains("天淮室外管坯库"))
  294. {
  295. item.Cells["StorageName"].Appearance.BackColor = System.Drawing.Color.OrangeRed;
  296. }
  297. }
  298. }
  299. /// <summary>
  300. /// 利库
  301. /// </summary>
  302. private void Liku()
  303. {
  304. UltraGridRow ugr=ultraGridZgS.ActiveRow;
  305. if (ugr.Cells["ReallWt"].Value.ToString().Equals("0"))
  306. {
  307. //MessageUtil.ShowTips("待炼支吨为零,不能利库?");
  308. if (MessageUtil.ShowYesNoAndQuestion("待炼支吨为零,是否继续利库?") == DialogResult.No)
  309. {
  310. return;
  311. }
  312. }
  313. UltraGridRow row = ultraGridChoose.ActiveRow;
  314. if (row == null) return;
  315. int count = 0;
  316. ArrayList list = new ArrayList();
  317. String lenSingGpTake="";
  318. String judgeNo = "";
  319. double wt = 0;
  320. int m = 0;
  321. string isDealer = "";
  322. if ("双经销".Equals(ugr.Cells["TypeFlag"].Text))
  323. {
  324. isDealer = "1";
  325. }
  326. else if ("定销订购".Equals(ugr.Cells["TypeFlag"].Text))
  327. {
  328. isDealer = "3";
  329. }
  330. else {
  331. isDealer = "0";
  332. }
  333. if (!this.UserInfo.GetDepartment().StartsWith("002023"))
  334. {
  335. isDealer = "";
  336. }
  337. foreach (UltraGridRow urg in ultraGridChoose.Rows)
  338. {
  339. ArrayList list1 = new ArrayList();
  340. if (Convert.ToBoolean(urg.Cells["CHC"].Text) == true)
  341. {
  342. count++;
  343. if (urg.Cells["HangingFlag"].Text.ToString().Equals("是"))
  344. //&& urg.Cells["CutYuLong"].Text.ToString().Equals("0"))并且切坯余长为零,
  345. {
  346. MessageUtil.ShowTips("你选择的管坯物料已生成实际炉计划,不能利库。如需利库,请先删除炉计划!");
  347. return;
  348. }
  349. if (judgeNo.Equals(""))
  350. {
  351. judgeNo = urg.Cells["JudgeStoveNo"].Value.ToString();
  352. }
  353. if (lenSingGpTake.Equals(""))
  354. {
  355. lenSingGpTake = urg.Cells["FixLenTake"].Value.ToString();
  356. }
  357. if (judgeNo.Equals(urg.Cells["JudgeStoveNo"].Value.ToString())&&!lenSingGpTake.Equals(urg.Cells["FixLenTake"].Value.ToString()))
  358. {
  359. MessageUtil.ShowTips("你选择同炉单倍坯长不一致!");
  360. return;
  361. }
  362. //string numCut=urg.Cells["FixNum"].Value.ToString();
  363. //int result = 0;
  364. if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) > int.Parse(urg.Cells["FixLenTake"].Value.ToString()))
  365. {
  366. if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) % int.Parse(urg.Cells["FixLenTake"].Value.ToString()) != 0)
  367. {
  368. MessageUtil.ShowTips("倍尺数不是整数,请修改使用坯长!");
  369. return;
  370. }
  371. }
  372. if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) > int.Parse(urg.Cells["ActLen"].Value.ToString()))
  373. {
  374. MessageUtil.ShowTips("使用坯长不能大于库存倍尺坯长!");
  375. return;
  376. }
  377. if (int.Parse(urg.Cells["ActLenTake"].Value.ToString())==0){
  378. MessageUtil.ShowTips("使用坯长不能等于0!");
  379. return;
  380. }
  381. if (!urg.Cells["ProPlanIdZg"].Text.ToString().Equals("") && !urg.Cells["ProPlanIdZg"].Text.ToString().Equals(_proPlanId + "/" + _gxPlanNo))
  382. {
  383. MessageUtil.ShowTips("你选择的管坯物料已分配给其他轧管订单,不能利库。如需利库,请先脱单!");
  384. return;
  385. }
  386. int lenGpSingle = Convert.ToInt32(row.Cells["FixLenTake"].Value.ToString());
  387. if (lenGpSingle % 10 != 0)
  388. {
  389. MessageUtil.ShowWarning("单倍坯长个位数不是0,请重新调整!");
  390. return;
  391. }
  392. if (urg.Cells["CutTybe"].Text.Equals("切坯") && urg.Cells["CutTarget"].Text.Equals(""))
  393. {
  394. MessageUtil.ShowTips("利库时需要切坯,请选择切余处理方式!");
  395. return;
  396. }
  397. string fixLenTake = urg.Cells["FixLenTake"].Value.ToString();
  398. if (double.Parse(urg.Cells["ActLenTake"].Value.ToString()) < double.Parse(urg.Cells["FixLenTake"].Value.ToString()))
  399. {
  400. fixLenTake = urg.Cells["ActLenTake"].Value.ToString();
  401. }
  402. wt += Double.Parse(urg.Cells["TakeWeight"].Value.ToString());
  403. list1.Add(urg.Cells["JudgeStoveNo"].Text.ToString());
  404. list1.Add(urg.Cells["ProPlanId"].Text.ToString());
  405. list1.Add(urg.Cells["GxPlanNo"].Text.ToString());
  406. list1.Add(urg.Cells["TakeCount"].Value.ToString());
  407. list1.Add(urg.Cells["TakeWeight"].Value.ToString());
  408. list1.Add(urg.Cells["ActLenTake"].Value.ToString());
  409. list1.Add(fixLenTake);
  410. list1.Add(urg.Cells["Furnaceno"].Text.ToString());
  411. list1.Add(urg.Cells["Sequenceno"].Text.ToString());
  412. list1.Add(urg.Cells["Gradecode"].Text.ToString());
  413. list1.Add(urg.Cells["Gradename"].Text.ToString());
  414. list1.Add(urg.Cells["FixNum"].Value.ToString());
  415. list1.Add(urg.Cells["StorageNo"].Text.ToString());
  416. list1.Add(urg.Cells["LocationNo"].Text.ToString());
  417. list1.Add(urg.Cells["StoveNo"].Text.ToString());
  418. list1.Add(urg.Cells["FlagStoveNo"].Text.ToString());
  419. list1.Add(urg.Cells["MatStatus1"].Text.ToString());
  420. list1.Add(urg.Cells["CutTarget"].Text.ToString());
  421. list1.Add(urg.Cells["PlnType"].Value.ToString());
  422. list1.Add(urg.Cells["CutNumGp"].Value.ToString());
  423. list1.Add(urg.Cells["OutnumCut"].Text.ToString());
  424. list1.Add(urg.Cells["Aimlength"].Value.ToString());
  425. list1.Add(urg.Cells["RollLength"].Value.ToString());
  426. string specCic = urg.Cells["SpecCic"].Text.ToString();
  427. if (specCic.Equals(""))
  428. {
  429. string gradeName = urg.Cells["Gradename"].Text.ToString();
  430. string cic = urg.Cells["Cic"].Text.ToString();
  431. UltraGridRow rowCic = entityGrid2.ActiveRow;
  432. if (rowCic != null)
  433. {
  434. int countCic = 0;
  435. foreach (UltraGridRow item in entityGrid2.Rows)
  436. {
  437. if (item.Cells["GRADENAME"].Text.ToString().Equals(gradeName) && item.Cells["CIC"].Text.ToString().Equals(cic))
  438. {
  439. countCic++;
  440. }
  441. }
  442. if (countCic == 0)
  443. {
  444. MessageUtil.ShowTips("库存CIC在订单炼钢CIC集合里没有,请指定CIC!");
  445. return;
  446. }
  447. }
  448. }
  449. if (!specCic.Equals(""))
  450. {
  451. list1.Add(urg.Cells["SpecCic"].Text.ToString());
  452. }
  453. else
  454. {
  455. list1.Add(urg.Cells["Cic"].Text.ToString());
  456. }
  457. list.Add(list1);
  458. list1.Add(urg.Cells["ActLen"].Value.ToString());
  459. list1.Add(urg.Cells["MatNo"].Text.ToString2());
  460. if (urg.Cells["CutTarget"].Text.Equals("返废"))
  461. {
  462. m = m + 1;
  463. }
  464. }
  465. }
  466. if (count == 0)
  467. {
  468. MessageUtil.ShowTips("请选择管坯物料信息");
  469. return;
  470. }
  471. if (m > 0)
  472. {
  473. if (MessageUtil.ShowYesNoAndQuestion("切坯处理方式为返废,是否确认继续利库?") ==
  474. DialogResult.No)
  475. return;
  476. }
  477. //if (wt - Double.Parse(ugr.Cells["ReallWt"].Value.ToString()) > 0)
  478. //{
  479. // MessageUtil.ShowTips("你选择要利库的利库吨不能大于待冶炼吨!");
  480. // return;
  481. //}
  482. if (MessageUtil.ShowYesNoAndQuestion("是否确认利库?") ==
  483. DialogResult.No)
  484. return;
  485. PlanComm.WaitFromOpen(this.Cursor);
  486. CoreClientParam ccp = new CoreClientParam();
  487. ccp.ServerName = "com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection";
  488. ccp.MethodName = "doAddLibrary";
  489. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(), _proPlanId, _gxPlanNo, isDealer };
  490. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  491. PlanComm.WaitFromColse(this.Cursor);
  492. if (ccp.ReturnCode == -1) return;
  493. MessageUtil.ShowTips(ccp.ReturnInfo);
  494. if (ccp.ReturnInfo.Equals("利库成功!"))
  495. {
  496. QueryPlanZg();
  497. Flag = true;
  498. }
  499. }
  500. /// <summary>
  501. /// 脱单
  502. /// </summary>
  503. private void Monomer()
  504. {
  505. UltraGridRow row = ultraGridChoose.ActiveRow;
  506. if (row == null) return;
  507. UltraGridRow ugr = ultraGridZgS.ActiveRow;
  508. string isDealer = "";
  509. if ("双经销".Equals(ugr.Cells["TypeFlag"].Text))
  510. {
  511. isDealer = "1";
  512. }
  513. else if ("定销订购".Equals(ugr.Cells["TypeFlag"].Text))
  514. {
  515. isDealer = "3";
  516. }
  517. else
  518. {
  519. isDealer = "0";
  520. }
  521. if (!this.UserInfo.GetDepartment().StartsWith("002023"))
  522. {
  523. isDealer = "";
  524. }
  525. int count = 0;
  526. ArrayList list = new ArrayList();
  527. foreach (UltraGridRow urg in ultraGridChoose.Rows)
  528. {
  529. ArrayList list1 = new ArrayList();
  530. if (Convert.ToBoolean(urg.Cells["CHC"].Text) == true)
  531. {
  532. count++;
  533. if (urg.Cells["ProPlanIdZg"].Text.ToString().Equals(""))
  534. {
  535. MessageUtil.ShowTips("你选择的管坯物料未分配给其他轧管订单,不能脱单!");
  536. return;
  537. }
  538. if (urg.Cells["HangingFlag"].Text.ToString().Equals("是"))
  539. {
  540. MessageUtil.ShowTips("你选择的管坯物料已生成实际炉计划,不能脱单。如需脱单,请先删除炉计划!");
  541. return;
  542. }
  543. list1.Add(urg.Cells["JudgeStoveNo"].Text.ToString());
  544. list1.Add(urg.Cells["TakeCount"].Value.ToString());
  545. list1.Add(urg.Cells["ActLen"].Value.ToString());
  546. list1.Add(urg.Cells["FixLen"].Value.ToString());
  547. list1.Add(urg.Cells["CutNumGp"].Value.ToString());
  548. list1.Add(urg.Cells["StorageNo"].Text.ToString());
  549. list1.Add(urg.Cells["LocationNo"].Text.ToString());
  550. list1.Add(urg.Cells["Dimater"].Value.ToString());
  551. list1.Add(urg.Cells["ProPlanIdZg"].Text.ToString());
  552. list.Add(list1);
  553. }
  554. }
  555. if (count == 0)
  556. {
  557. MessageUtil.ShowTips("请选择管坯物料信息");
  558. return;
  559. }
  560. PlanComm.WaitFromOpen(this.Cursor);
  561. CoreClientParam ccp = new CoreClientParam();
  562. ccp.ServerName = "com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection";
  563. ccp.MethodName = "doDeleteMonomer";
  564. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(), isDealer };
  565. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  566. PlanComm.WaitFromColse(this.Cursor);
  567. if (ccp.ReturnCode == -1) return;
  568. MessageUtil.ShowTips(ccp.ReturnInfo);
  569. if (ccp.ReturnInfo.Equals("脱单成功!"))
  570. {
  571. Query();
  572. Flag = true;
  573. }
  574. }
  575. /// <summary>
  576. /// 重算
  577. /// </summary>
  578. private void Recalcu(double lenGpSingle, UltraGridRow row)
  579. {
  580. //if (lenGpSingle % 10 != 0)
  581. //{
  582. // MessageUtil.ShowWarning("单倍坯长个位数不是0,请重新调整!");
  583. // return;
  584. //}
  585. //if (lenGpSingle > int.Parse(row.Cells["FixLen"].Text.ToString()))
  586. //{
  587. // MessageUtil.ShowTips("计划单倍坯长不能大于库存单倍坯长!");
  588. // return;
  589. //}
  590. DataTable dtOrder = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryZgMSStatus",
  591. new object[] { _proPlanId, _gxPlanNo }, _ob);
  592. if (dtOrder.Rows.Count <= 0)
  593. {
  594. MessageUtil.ShowTips("未找到轧管订单:" + _proPlanId + "/" + _gxPlanNo + "合同信息!");
  595. return;
  596. }
  597. //if (lenGpSingle >= int.Parse(dtOrder.Rows[0]["LENGTH_MAX_RING"].ToString()))
  598. //{
  599. // MessageUtil.ShowTips("计划单倍坯长必须小于等于产线(" + dtOrder.Rows[0]["PLINE_NAME"].ToString() + ")环形炉最大长度(" + dtOrder.Rows[0]["LENGTH_MAX_RING"].ToString() + ")!");
  600. // return;
  601. //}
  602. double burning = double.Parse(dtOrder.Rows[0]["BURNOUT_RATE"].ToString())/100;//烧损率
  603. //if (burning >= 1 || burning < 0)
  604. //{
  605. // MessageUtil.ShowTips("烧损率必须在0-99%之间!");
  606. // return;
  607. //}
  608. double sizing = double.Parse(dtOrder.Rows[0]["LENGTH_COLDBED"].ToString());//冷床长度
  609. //if (sizing <= 0)
  610. //{
  611. // MessageUtil.ShowTips("冷床长度必须大于零!");
  612. // return;
  613. //}
  614. DataTable dtInwlOut = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryBaseMaterialDPl",
  615. new object[] { dtOrder.Rows[0]["INWL_ID"].ToString(), dtOrder.Rows[0]["OUTWL_ID"].ToString(), dtOrder.Rows[0]["PLINE_CODE"].ToString() }, _ob);
  616. if (dtInwlOut.Rows.Count <= 0)
  617. {
  618. MessageUtil.ShowTips("未找到轧管订单:" + _proPlanId + "/" + _gxPlanNo + "投入产出物料信息!");
  619. return;
  620. }
  621. int cutMax = int.Parse(dtInwlOut.Rows[0]["DBL_LEN_MAX"].ToString());
  622. double capacity = double.Parse(dtInwlOut.Rows[0]["HR_CAPCTY"].ToString());//小时能力
  623. double wasteRate = double.Parse(dtInwlOut.Rows[0]["WASTE_RATE"].ToString()) / 1000;//万只废品数
  624. double Cuthead_tail = (double.Parse(dtOrder.Rows[0]["LEN_CUTHEAD"].ToString()) + double.Parse(dtOrder.Rows[0]["LEN_CUTEND"].ToString())) / 1000;
  625. double tubeEndRatio = double.Parse(dtOrder.Rows[0]["TUBE_END_RATIO"].ToString());
  626. // 坯料米单重
  627. double weightofm = 0;
  628. // 坯料重量
  629. double Billet_weight = 0;
  630. double lengthZzmax = 0;// 轧制长度
  631. double diame = double.Parse(dtOrder.Rows[0]["DIAMETER_GP"].ToString());// 最佳断面
  632. // /循环断面集合,找出最佳断面
  633. double weight_one = (0.02466 * double.Parse(dtOrder.Rows[0]["AIMWALLTHICK"].ToString())
  634. * (double.Parse(dtOrder.Rows[0]["AIMOUTDIAMETER"].ToString()) - double.Parse(dtOrder.Rows[0]["AIMWALLTHICK"].ToString()))) / 1000;// 轧管管单重
  635. // 坯料米单重
  636. weightofm = (7.8 * 3.1415926 / 4 * diame * diame) / 1000 / 1000;
  637. // 极限单倍坯重
  638. double billetweight = weightofm * (lenGpSingle / 1000);
  639. // 极限轧制长度
  640. lengthZzmax = billetweight * (1 - burning) / weight_one
  641. + (1 - tubeEndRatio) * Cuthead_tail;
  642. //if (lengthZzmax <= 0)
  643. //{
  644. // MessageUtil.ShowTips("轧制长度TZ必须大于零!");
  645. // return;
  646. //}
  647. // 验证:轧制长度<冷床长度,否则单倍坯长调整无效
  648. //if (lengthZzmax >= sizing)
  649. //{
  650. // MessageUtil.ShowTips("轧制长度TZ大于等于冷长长度,单倍坯长输入无效,轧制长度TZ:"
  651. // + lengthZzmax.ToString("f3") + "m,冷床长度:"
  652. // + sizing + "m!");
  653. // return;
  654. //}
  655. bool shrt_stove = false;
  656. if (double.Parse(dtOrder.Rows[0]["SHRT_LEN_RATO"].ToString()) > 0)
  657. {
  658. shrt_stove = true;
  659. }
  660. double sigl_len = double.Parse(dtOrder.Rows[0]["SIGL_LEN"].ToString());//单倍尺长M
  661. double lengthmaxZg = double.Parse(dtOrder.Rows[0]["LENGTHMAX"].ToString());
  662. double lengthminZg = double.Parse(dtOrder.Rows[0]["LENGTHMIN"].ToString());
  663. int Cutnum = 0;
  664. double aimlength = 0;
  665. double tubeYuLong = 0;//管余长
  666. //轧制长度大于零
  667. if (lengthZzmax > 0)
  668. {
  669. // /分切过程
  670. // 1.无短尺随炉and无使用单倍长度
  671. if (!shrt_stove && sigl_len <= 0)
  672. {
  673. double x = (lengthZzmax - Cuthead_tail) / lengthmaxZg;
  674. double y = (lengthZzmax - Cuthead_tail) / lengthminZg;
  675. if (y > 0)
  676. {
  677. // 获取最小整数
  678. int min = isRounded(x, y);
  679. if (min != 0)
  680. {
  681. Cutnum = min;
  682. aimlength = (lengthZzmax - Cuthead_tail) / Cutnum;// 目标转移长度
  683. tubeYuLong = 0;
  684. }
  685. else
  686. {
  687. Cutnum = (int)(x);
  688. if (Cutnum == 0)
  689. {
  690. Cutnum = 1;
  691. }
  692. aimlength = lengthmaxZg; // 目标转移长度
  693. // 管余长=((轧制长度TZ -切头尾)/轧管转移长度上限-INT(轧制长度TZ
  694. // -切头尾)/轧管转移长度上限+1))* 轧管转移长度上限
  695. tubeYuLong = lengthZzmax - Cutnum * aimlength
  696. - Cuthead_tail;
  697. }
  698. }
  699. else
  700. {
  701. //MessageUtil.ShowTips("轧管工序:轧制长度TZ" + lengthZzmax.ToString("f3")
  702. // + "米、转移长度下限" + lengthminZg.ToString("f3") + "米、切头尾"
  703. // + Cuthead_tail.ToString("f3") + "米,无法生产!");
  704. return;
  705. }
  706. }
  707. // 2.短尺随炉
  708. if (shrt_stove && sigl_len <= 0)
  709. {
  710. double x = (lengthZzmax - Cuthead_tail) / lengthmaxZg;
  711. double y = (lengthZzmax - Cuthead_tail) / lengthminZg;
  712. if (y > 0)
  713. {
  714. // 获取最小整数
  715. int min = isRounded(x, y);
  716. if (min != 0)
  717. {
  718. Cutnum = min;
  719. aimlength = (lengthZzmax - Cuthead_tail) / Cutnum;// 目标转移长度
  720. tubeYuLong = 0;
  721. }
  722. else
  723. {
  724. if (((((lengthZzmax - Cuthead_tail) / lengthminZg) - (int)((lengthZzmax - Cuthead_tail) / lengthminZg)) * lengthminZg) >= 8.5)
  725. {
  726. Cutnum = (int)(y) + 1;
  727. aimlength = lengthminZg;
  728. tubeYuLong = 0;
  729. }
  730. else
  731. {
  732. Cutnum = (int)(x);
  733. if (Cutnum == 0)
  734. {
  735. Cutnum = 1;
  736. }
  737. aimlength = lengthmaxZg; // 目标转移长度
  738. tubeYuLong = lengthZzmax - Cutnum * aimlength
  739. - Cuthead_tail;
  740. }
  741. }
  742. }
  743. else
  744. {
  745. //MessageUtil.ShowTips("轧管工序:轧制长度TZ" + lengthZzmax.ToString("f3")
  746. // + "米、转移长度下限" + lengthminZg.ToString("f3") + "米、切头尾"
  747. // + Cuthead_tail.ToString("f3") + "米,无法生产!");
  748. return;
  749. }
  750. }
  751. // 3.单倍尺长
  752. if (sigl_len > 0)
  753. {
  754. Cutnum = cutMax;
  755. if (Cutnum == 0)
  756. {
  757. Cutnum = 1;
  758. }
  759. aimlength = double.Parse(dtOrder.Rows[0]["ROLL_LENGTH"].ToString());
  760. // 管余长=轧制长度TZ-分切*目标长度+切头尾
  761. tubeYuLong = lengthZzmax - Cutnum * aimlength - Cuthead_tail;
  762. }
  763. //if (tubeYuLong < 0)
  764. //{
  765. //MessageUtil.ShowTips("管余长不能为负数:" + tubeYuLong + ",轧制长度TZ:"
  766. // + lengthZzmax.ToString("f3")
  767. // + ",分切数:"
  768. // + Cutnum
  769. // + ",目标长度:"
  770. // + aimlength.ToString("f3") + "!");
  771. //return;
  772. //}
  773. //else
  774. //{
  775. // tubeYuLong = tubeYuLong.ToString("f1");
  776. //}
  777. // 坯调整
  778. //double piStock = tubeYuLong * (weight_one * 1000)
  779. // / (7.8 * 3.1415926 * diame * diame / 4) / (1 - burning) * 1000
  780. // * 1000;
  781. //// 验证1:管余长<>0,报警=“计算验证字段写“长度需调整””
  782. //if (tubeYuLong != 0)
  783. //{
  784. // MessageUtil.ShowTips(("管余长:"
  785. // + tubeYuLong.ToString("f1")
  786. // + "m,坯调整:"
  787. // + piStock.ToString("f0")+ "mm");
  788. //}
  789. //// 验证2:目标长度>平均长度 and 目标长度>转移长度下限+J值/1000 and
  790. //// 分切<最大分切数and目标长度<=轧管转移长度上限
  791. //if (aimlength >= avg_len_min
  792. // && aimlength >= lengthminZg + chekJavl / 1000
  793. // && Cutnum <= cutMat && aimlength <= lengthmaxZg)
  794. //{
  795. // paramOut.setVerify2("");
  796. //}
  797. //else
  798. //{
  799. // paramOut
  800. // .setVerify2("长度超出范围:目标长度("
  801. // + new BigDecimal(aimlength).setScale(2,
  802. // RoundingMode.HALF_UP).doubleValue()
  803. // + "),平均长度("
  804. // + new BigDecimal(avg_len_min).setScale(2,
  805. // RoundingMode.HALF_UP).doubleValue()
  806. // + "),转移长度下限("
  807. // + new BigDecimal(lengthminZg).setScale(2,
  808. // RoundingMode.HALF_UP).doubleValue()
  809. // + "),转移长度上限("
  810. // + new BigDecimal(lengthmaxZg).setScale(2,
  811. // RoundingMode.HALF_UP).doubleValue()
  812. // + "),J值("
  813. // + new BigDecimal(chekJavl / 1000).setScale(2,
  814. // RoundingMode.HALF_UP).doubleValue()
  815. // + "),最大分切数(" + cutMat + ")");
  816. //}
  817. // 管长度太短,无法分切
  818. //if (Cutnum <= 0)
  819. //{
  820. //MessageUtil.ShowTips("分切数为:" + Cutnum + ",无法分切!(轧制长度TZ"
  821. // + lengthZzmax.ToString("f3") + ")");
  822. // return;
  823. //}
  824. // 坯单支重=(轧管管单重*(轧制长度-切头尾)+轧管管单重*管端增厚系数*切头尾)/ (1-烧损)
  825. Billet_weight = ((weight_one * (lengthZzmax - Cuthead_tail) + weight_one
  826. * tubeEndRatio * Cuthead_tail) / (1 - burning));
  827. }
  828. row.Cells["OutnumCut"].Value = Cutnum.ToString();
  829. row.Cells["Aimlength"].Value = aimlength.ToString("f2");
  830. row.Cells["RollLength"].Value = lengthZzmax.ToString("f2");
  831. }
  832. public int isRounded(double x, double y)
  833. {
  834. double inMax = 0;
  835. double inMin = 0;
  836. if (x - y > 0)
  837. {
  838. inMin = y;
  839. inMax = x;
  840. }
  841. else
  842. {
  843. inMin = x;
  844. inMax = y;
  845. }
  846. if (Mod(inMin, (int)(inMin)) == 0)
  847. {
  848. return (int)(inMin);
  849. }
  850. else if ((int)(inMax) - (int)(inMin) == 0)
  851. {
  852. return 0;
  853. }
  854. else
  855. {
  856. return (int)(inMin) + 1;
  857. }
  858. }
  859. private static double Mod(double inMin, int i)
  860. {
  861. double remainder = inMin % i;
  862. return remainder;
  863. }
  864. private void ultraGridChoose_AfterRowActivate(object sender, EventArgs e)
  865. {
  866. UltraGridRow row = ultraGridChoose.ActiveRow;
  867. if (row == null) return;
  868. QueryChenName(row.Cells["JudgeStoveNo"].Text.ToString(), row.Cells["ChemJudgeId"].Text.ToString());
  869. string gradeName = row.Cells["Gradename"].Text.ToString();
  870. entityGrid2.UpdateData();
  871. DataRow[] datarows = dtCic.Select("GRADENAME = '" + gradeName + "'");
  872. DataTable tab = StoveHelper.ToDataTable(datarows);
  873. GridHelper.CopyDataToDatatable(tab, dataTable2, true);
  874. GridHelper.RefreshAndAutoSize(entityGrid2);
  875. foreach (UltraGridRow ugr in entityGrid2.Rows)
  876. {
  877. ugr.Cells["CHC"].Value = "指定";
  878. }
  879. entityGrid2.Refresh();
  880. entityGrid2.Update();
  881. }
  882. private int countMes = 0;
  883. private int countStov = 0;
  884. /// <summary>
  885. /// 查询索引码
  886. /// </summary>
  887. private void QueryChenName(string cudgeStoveNo, string chemJudgeId)
  888. {
  889. DataTable InternalStandard = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getStlChemicalStd",
  890. new object[] { cic, desginKey, indexSeq }, _ob);
  891. dtChem.Rows.Clear();
  892. countMes = 0;
  893. countStov = 0;
  894. foreach (var colums in ulgridElement.DisplayLayout.Bands[0].Columns)
  895. {
  896. colums.Hidden = true;
  897. }
  898. ulgridElement.DisplayLayout.Bands[0].Columns["SAMPLE_NO"].Hidden = false;
  899. ulgridElement.DisplayLayout.Bands[0].Columns["CIC"].Hidden = false;
  900. if (InternalStandard != null)
  901. {
  902. foreach (DataRow dataRow in InternalStandard.Rows)
  903. {
  904. string chemsKey = dataRow["CHEM_NAME"].ToString().Replace(" ", "").Replace("/", "");
  905. if (!dtChem.Columns.Contains(chemsKey.ToUpper()) && !string.IsNullOrEmpty(chemsKey))
  906. {
  907. DataColumn newDc = new DataColumn
  908. {
  909. ColumnName = chemsKey.ToUpper(),
  910. Caption = chemsKey
  911. };
  912. dtChem.Columns.Add(newDc);
  913. }
  914. ulgridElement.DisplayLayout.Bands[0].Columns[chemsKey.ToUpper()].Hidden = false;
  915. }
  916. }
  917. DataTable distinct_object = InternalStandard.DefaultView.ToTable(true, "CIC");
  918. if (distinct_object.Rows.Count <= 0)
  919. {
  920. return;
  921. }
  922. for (int i = 0; i < distinct_object.Rows.Count; i++)
  923. {
  924. DataRow drMax = dtChem.NewRow();
  925. DataRow drMin = dtChem.NewRow();
  926. DataRow drCic = dtChem.NewRow();
  927. string cicChem = distinct_object.Rows[i]["CIC"].ToString();
  928. DataRow[] drs = InternalStandard.Select("CIC='" + cicChem + "'");
  929. if (drs.Count() > 0)
  930. {
  931. if (cicyL.Equals(drs[0][8]))
  932. {
  933. drMax["SAMPLE_NO"] = "冶炼CIC上限";
  934. drMin["SAMPLE_NO"] = "冶炼CIC下限";
  935. }
  936. else
  937. {
  938. drMax["SAMPLE_NO"] = "利库CIC上限";
  939. drMin["SAMPLE_NO"] = "利库CIC下限";
  940. }
  941. drMax["CIC"] = drs[0][8];
  942. drMin["CIC"] = drs[0][8];
  943. foreach (DataRow dataRow in drs)
  944. {
  945. string columnsName = dataRow["CHEM_NAME"].ToString().ToUpper().Replace(" ", "").Replace("/", "");
  946. drMax[columnsName] = dataRow["STDMAX_SIGN"];//+ dataRow["STDMAX"].ToString()
  947. drMin[columnsName] = dataRow["STDMIN_SIGN"];//+ dataRow["STDMIN"].ToString()
  948. ulgridElement.DisplayLayout.Bands[0].Columns[columnsName].Tag = dataRow["CHEM_FORMULA"];
  949. }
  950. dtChem.Rows.Add(drMax);
  951. dtChem.Rows.Add(drMin);
  952. countMes += 2;
  953. }
  954. }
  955. //string[] chemJudgeIdAll = chemJudgeId.Split(',');
  956. //chemJudgeId = string.Join(",", chemJudgeIdAll);
  957. DataTable dtData = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getStlChemicalData",
  958. new object[] { cudgeStoveNo, chemJudgeId }, _ob);
  959. if (dtData != null && dtData.Rows.Count > 0)
  960. {
  961. CurrentChem = dtData.Rows[0];
  962. foreach (DataRow dataRow in dtData.Rows)
  963. {
  964. foreach (DataColumn dc in dtData.Columns)
  965. {
  966. string columnsName = dc.ColumnName;
  967. if (columnsName.Equals("SAMPLE_NO")) continue;
  968. if (!dtChem.Columns.Contains(columnsName.ToUpper().Replace("ASN", "AS")) &&
  969. dataRow[columnsName] != null &&
  970. !string.IsNullOrEmpty((dataRow[columnsName].ToString())))
  971. {
  972. DataColumn newDc = new DataColumn();
  973. newDc.ColumnName = columnsName.ToUpper().Replace("ASN", "AS");
  974. newDc.Caption = columnsName;
  975. dtChem.Columns.Add(newDc);
  976. }
  977. }
  978. DataRow tempRow = dtChem.NewRow();
  979. //tempRow["CICLK"] = dataRow["STOVE_NO"];
  980. foreach (DataColumn DataColumn in dtData.Columns)
  981. {
  982. if (dtChem.Columns.Contains(DataColumn.ColumnName.Replace("ASN", "AS")))
  983. {
  984. tempRow[DataColumn.ColumnName.Replace("ASN", "AS")] = dataRow[DataColumn.ColumnName];
  985. if (dataRow[DataColumn.ColumnName] != null &&
  986. !string.IsNullOrEmpty(dataRow[DataColumn.ColumnName].ToString()))
  987. {
  988. ulgridElement.DisplayLayout.Bands[0].Columns[DataColumn.ColumnName.Replace("ASN", "AS")]
  989. .Hidden = false;
  990. ulgridElement.DisplayLayout.Bands[0].Columns["ASSAYNO"].Hidden = true;
  991. ulgridElement.DisplayLayout.Bands[0].Columns["STOVE_NO"].Hidden = true;
  992. }
  993. }
  994. }
  995. foreach (UltraGridColumn column in ulgridElement.DisplayLayout.Bands[0].Columns)
  996. {
  997. if (column.Hidden || column.Tag == null || string.IsNullOrEmpty(column.Tag.ToString())) continue;
  998. string ChemFormula = column.Tag.ToString().ToUpper();
  999. ChemFormula = ChemFormula.Replace("AS", "ASN");
  1000. //string[] str = ChemFormula.Split(new char[6] { '+', '-', '*', '/','(',')' });
  1001. //foreach (string s in str)
  1002. //{
  1003. // foreach (DataColumn DataColumn in dtData.Columns)
  1004. // {
  1005. // if (dataRow[s] == null) continue;
  1006. // ChemFormula = ChemFormula.Replace(s, dataRow[s].ToString());
  1007. // }
  1008. //}
  1009. foreach (DataColumn DataColumn in dtData.Columns)
  1010. {
  1011. if (dataRow[DataColumn.ColumnName] == null) continue;
  1012. ChemFormula = ChemFormula.Replace(DataColumn.ColumnName.Replace("ASN", "AS"),
  1013. dataRow[DataColumn.ColumnName].ToString());
  1014. }
  1015. try
  1016. {
  1017. tempRow[column.Key] = Math.Round(double.Parse(new DataTable().Compute(ChemFormula, null).ToString()), 4);
  1018. }
  1019. catch (Exception)
  1020. {
  1021. tempRow[column.Key] = null;
  1022. }
  1023. }
  1024. tempRow["SAMPLE_NO"] = dataRow["ASSAYNO"];
  1025. tempRow["CIC"] = dataRow["STOVE_NO"];
  1026. dtChem.Rows.Add(tempRow);
  1027. countStov++;
  1028. }
  1029. }
  1030. ulgridElement.Refresh();
  1031. BaseHelper.setOtherColumnReadOnly(ulgridElement, new[] { "Check" });
  1032. GridHelper.RefreshAndAutoSize(ulgridElement);
  1033. BaseHelper.ForbidSort(ulgridElement);
  1034. ulgridElement.DisplayLayout.Bands[0].Columns["CIC"].MergedCellStyle = MergedCellStyle.Always;
  1035. ulgridElement.DisplayLayout.Bands[0].Columns[0].CellAppearance.FontData.Bold = DefaultableBoolean.True;
  1036. if (ulgridElement.Rows.Count > countMes)
  1037. {
  1038. ulgridElement.Rows[countMes].Activate();
  1039. }
  1040. }
  1041. private void ulgridElement_InitializeRow(object sender, InitializeRowEventArgs e)
  1042. {
  1043. GridActiveDele();
  1044. }
  1045. private void ultraGridChoose_CellChange(object sender, CellEventArgs e)
  1046. {
  1047. UltraGridRow row = ultraGridChoose.ActiveRow;
  1048. ultraGridChoose.UpdateData();
  1049. if (e.Cell.Column.Key.Equals("CutTybe"))
  1050. {
  1051. if (row.Cells["CutTybe"].Text.ToString().Equals("切坯"))
  1052. {
  1053. row.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1054. row.Cells["ActLenTake"].Activation = Activation.AllowEdit;
  1055. row.Cells["ActLenTake"].IgnoreRowColActivation = true;
  1056. row.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1057. row.Cells["FixLenTake"].Activation = Activation.AllowEdit;
  1058. row.Cells["FixLenTake"].IgnoreRowColActivation = true;
  1059. row.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1060. row.Cells["CutTarget"].Activation = Activation.AllowEdit;
  1061. row.Cells["CutTarget"].IgnoreRowColActivation = true;
  1062. }
  1063. else
  1064. {
  1065. row.Cells["ActLenTake"].Appearance.ResetBackColor();
  1066. row.Cells["ActLenTake"].Activation = Activation.ActivateOnly;
  1067. row.Cells["ActLenTake"].IgnoreRowColActivation = true;
  1068. row.Cells["FixLenTake"].Appearance.ResetBackColor();
  1069. row.Cells["FixLenTake"].Activation = Activation.ActivateOnly;
  1070. row.Cells["FixLenTake"].IgnoreRowColActivation = true;
  1071. row.Cells["CutTarget"].Value = "";
  1072. row.Cells["CutTarget"].Appearance.ResetBackColor();
  1073. row.Cells["CutTarget"].Activation = Activation.ActivateOnly;
  1074. row.Cells["CutTarget"].IgnoreRowColActivation = true;
  1075. }
  1076. }
  1077. //输入支数
  1078. if (e.Cell.Column.Key.Equals("TakeCount"))
  1079. {
  1080. //double dimater = 0;
  1081. //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
  1082. //{
  1083. // dimater = 250;
  1084. //}
  1085. //else
  1086. //{
  1087. // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
  1088. //}
  1089. //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
  1090. //// 倍尺坯长
  1091. //double lenLong = double.Parse(row.Cells["ActLenTake"].Value.ToString());
  1092. //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
  1093. //double weightM = mSingleWeight * (lenLong / 1000);
  1094. // 单倍坯重
  1095. //double weightGpOne = mSingleWeight
  1096. // * (double.Parse(row.Cells["FixLenTake"].Value.ToString()) / 1000);
  1097. if (e.Cell.Row.Cells["TakeCount"].Value == null)
  1098. {
  1099. row.Cells["TakeCount"].Value = row.Cells["ActCount"].Value.ToString();
  1100. }
  1101. else
  1102. {
  1103. string actLen = e.Cell.Row.Cells["TakeCount"].Value.ToString();
  1104. if (!StringUtil.IsInt(actLen) || actLen == "0")
  1105. {
  1106. e.Cell.Row.Cells["TakeWeight"].Value = 0;
  1107. }
  1108. else
  1109. {
  1110. //查询库存重量
  1111. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryMatWeigth",
  1112. new object[] { row.Cells["JudgeStoveNo"].Value.ToString(), row.Cells["CutNumGp"].Value.ToString(), row.Cells["ActLen"].Value.ToString(), row.Cells["FixLen"].Value.ToString(), actLen }, _ob);
  1113. if (dt.Rows.Count > 0)
  1114. {
  1115. e.Cell.Row.Cells["TakeWeight"].Value = dt.Rows[0]["ACT_WEIGHT"].ToString();
  1116. }
  1117. }
  1118. }
  1119. }
  1120. ///输入使用坯长
  1121. if (e.Cell.Column.Key.Equals("ActLenTake"))
  1122. {
  1123. //double dimater = 0;
  1124. //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
  1125. //{
  1126. // dimater = 250;
  1127. //}
  1128. //else
  1129. //{
  1130. // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
  1131. //}
  1132. //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
  1133. // 单倍坯重
  1134. //double weightGpOne = mSingleWeight
  1135. // * (double.Parse(row.Cells["FixLenTake"].Value.ToString()) / 1000);
  1136. if (e.Cell.Row.Cells["ActLenTake"].Value == null)
  1137. {
  1138. row.Cells["TakeCount"].Value = row.Cells["ActCount"].Value.ToString();
  1139. }
  1140. else
  1141. {
  1142. string actLen = e.Cell.Row.Cells["ActLenTake"].Value.ToString();
  1143. if (!StringUtil.IsInt(actLen) || actLen == "0")
  1144. {
  1145. e.Cell.Row.Cells["ActLenTake"].Value = 0;
  1146. row.Cells["FixNum"].Value = "1";
  1147. e.Cell.Row.Cells["CutYuLong"].Value = row.Cells["ActLen"].Value.ToString();
  1148. }
  1149. else
  1150. {
  1151. if (int.Parse(actLen) > int.Parse(row.Cells["ActLen"].Value.ToString()))
  1152. {
  1153. actLen = row.Cells["ActLen"].Value.ToString();
  1154. e.Cell.Row.Cells["ActLenTake"].Value = row.Cells["ActLen"].Value.ToString();
  1155. e.Cell.Row.Cells["CutYuLong"].Value = "0";
  1156. }
  1157. else
  1158. {
  1159. e.Cell.Row.Cells["CutYuLong"].Value = (int.Parse(row.Cells["ActLen"].Value.ToString()) - int.Parse(actLen)).ToString();
  1160. }
  1161. if (double.Parse(actLen) / double.Parse(row.Cells["FixLenTake"].Value.ToString()) < 1)
  1162. {
  1163. row.Cells["FixNum"].Value = "1";
  1164. }
  1165. else
  1166. {
  1167. row.Cells["FixNum"].Value = (double.Parse(actLen) / double.Parse(row.Cells["FixLenTake"].Value.ToString())).ToString("f3");
  1168. }
  1169. //// 倍尺坯长
  1170. //double lenLong = double.Parse(actLen);
  1171. //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
  1172. //double weightM = mSingleWeight * (double.Parse(actLen) / 1000);
  1173. //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
  1174. double lenGpSingle = double.Parse(row.Cells["ActLenTake"].Value.ToString());
  1175. Recalcu(lenGpSingle, row);
  1176. }
  1177. }
  1178. }
  1179. //使用单倍坯长
  1180. if (e.Cell.Column.Key.Equals("FixLenTake"))
  1181. {
  1182. //double dimater = 0;
  1183. //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
  1184. //{
  1185. // dimater = 250;
  1186. //}
  1187. //else
  1188. //{
  1189. // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
  1190. //}
  1191. //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
  1192. if (e.Cell.Row.Cells["FixLenTake"].Value == null)
  1193. {
  1194. row.Cells["FixLenTake"].Value = row.Cells["FixLen"].Value.ToString();
  1195. }
  1196. else
  1197. {
  1198. string actLen = e.Cell.Row.Cells["FixLenTake"].Value.ToString();
  1199. if (!StringUtil.IsInt(actLen) || actLen == "0")
  1200. {
  1201. e.Cell.Row.Cells["FixLenTake"].Value = row.Cells["FixLen"].Value.ToString();
  1202. }
  1203. else
  1204. {
  1205. double lenGpSingle = double.Parse(row.Cells["FixLenTake"].Value.ToString());
  1206. //row.Cells["ActLenTake"].Value = lenGpSingle * row.Cells["FixNum"].Value;
  1207. row.Cells["FixNum"].Value = ((int)(double.Parse(row.Cells["ActLen"].Value.ToString()) / lenGpSingle)).ToString();
  1208. row.Cells["ActLenTake"].Value = (lenGpSingle * int.Parse(row.Cells["FixNum"].Value.ToString()));
  1209. //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
  1210. //double weightM = mSingleWeight * (double.Parse(row.Cells["ActLenTake"].Value.ToString()) / 1000);
  1211. //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
  1212. e.Cell.Row.Cells["CutYuLong"].Value = double.Parse(row.Cells["ActLen"].Value.ToString()) - double.Parse(row.Cells["ActLenTake"].Value.ToString());
  1213. Recalcu(lenGpSingle,row);
  1214. }
  1215. }
  1216. }
  1217. if (e.Cell.Column.Key.Equals("CHC"))
  1218. {
  1219. //int dimater = int.Parse(row.Cells["Dimater"].Value.ToString());
  1220. //if (dimater==251)
  1221. //{
  1222. // dimater = 250;
  1223. //}
  1224. //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
  1225. double lenGpSingle = double.Parse(row.Cells["FixLenTake"].Value.ToString());
  1226. e.Cell.Row.Cells["FixNum"].Value = ((int)(double.Parse(e.Cell.Row.Cells["ActLenTake"].Value.ToString()) / double.Parse(e.Cell.Row.Cells["FixLenTake"].Value.ToString()))).ToString();
  1227. row.Cells["ActLenTake"].Value = int.Parse(e.Cell.Row.Cells["FixNum"].Value.ToString()) * double.Parse(row.Cells["FixLenTake"].Value.ToString());
  1228. // 倍尺坯单支重=坯米单重*倍尺坯长/1000
  1229. //double weightM = mSingleWeight * (double.Parse(row.Cells["ActLenTake"].Value.ToString()) / 1000);
  1230. //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
  1231. e.Cell.Row.Cells["CutYuLong"].Value = double.Parse(row.Cells["ActLen"].Value.ToString()) - double.Parse(row.Cells["ActLenTake"].Value.ToString());
  1232. if (double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) > 0)
  1233. {
  1234. row.Cells["CutTybe"].Value = "切坯";
  1235. row.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1236. row.Cells["ActLenTake"].Activation = Activation.AllowEdit;
  1237. row.Cells["ActLenTake"].IgnoreRowColActivation = true;
  1238. row.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1239. row.Cells["FixLenTake"].Activation = Activation.AllowEdit;
  1240. row.Cells["FixLenTake"].IgnoreRowColActivation = true;
  1241. row.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1242. row.Cells["CutTarget"].Activation = Activation.AllowEdit;
  1243. row.Cells["CutTarget"].IgnoreRowColActivation = true;
  1244. }
  1245. Recalcu(lenGpSingle, row);
  1246. if (double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) != 0)
  1247. {
  1248. if (minLengthRing - double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) > 0)
  1249. {
  1250. row.Cells["CutTarget"].Value = "套尺";
  1251. }
  1252. else
  1253. {
  1254. row.Cells["CutTarget"].Value = "回库";
  1255. }
  1256. }
  1257. }
  1258. int xzNum = 0;
  1259. double xzWt = 0;
  1260. ultraGroupBox2.Text = "管坯物料信息";
  1261. foreach (UltraGridRow ugr in ultraGridChoose.Rows)
  1262. {
  1263. if (Convert.ToBoolean(ugr.Cells["CHC"].Text) == true)
  1264. {
  1265. xzNum += int.Parse(ugr.Cells["TakeCount"].Value.ToString());
  1266. xzWt += double.Parse(ugr.Cells["TakeWeight"].Value.ToString());
  1267. }
  1268. }
  1269. ultraGroupBox2.Text = ultraGroupBox2.Text + " 支:" + xzNum + " 吨:" + xzWt.ToString("f3");
  1270. }
  1271. private int splitterDistance = 0;
  1272. private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
  1273. {
  1274. if (ultraExpandableGroupBox1.Expanded == false)
  1275. {
  1276. this.splitContainer1.SplitterDistance = splitContainer1.Size.Height - 26;
  1277. }
  1278. else
  1279. {
  1280. this.splitContainer1.SplitterDistance = splitterDistance == 0 ? splitContainer1.Size.Height / 2 : splitterDistance;
  1281. }
  1282. }
  1283. private void GridActiveDele()
  1284. {
  1285. UltraGridRow row = ulgridElement.ActiveRow;
  1286. if (row == null) return;
  1287. if (row.Index < countMes) return;
  1288. //foreach (UltraGridRow row in ulgridElement.Rows)
  1289. //{
  1290. foreach (var Cell in row.Cells)
  1291. {
  1292. string ColumnsName = Cell.Column.Key;
  1293. if (ColumnsName.Equals("SAMPLE_NO")) continue;
  1294. if (ColumnsName.Equals("CIC")) continue;
  1295. if (ColumnsName.Equals("STOVE_NO")) continue;
  1296. if (ColumnsName.Equals("ASSAYNO")) continue;
  1297. for (int i = 0; i < countMes - 1; i = i + 2)
  1298. {
  1299. int Result = SteelManagementHelper.CompareChem(Cell.Value, ulgridElement.Rows[i].Cells[ColumnsName].Value,
  1300. ulgridElement.Rows[i + 1].Cells[ColumnsName].Value);
  1301. if (Result == 2) { Cell.Appearance.ResetBackColor(); }
  1302. else if (Result > 0)
  1303. {
  1304. ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.Red;
  1305. ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.Red;
  1306. }
  1307. else if (Result < 0)
  1308. {
  1309. ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.Yellow;
  1310. ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.Yellow;
  1311. }
  1312. else
  1313. {
  1314. ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.LightGreen;
  1315. ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.LightGreen;
  1316. //Cell.Appearance.BackColor = Color.LightGreen;
  1317. }
  1318. }
  1319. //}
  1320. }
  1321. }
  1322. private void ulgridElement_AfterRowActivate(object sender, EventArgs e)
  1323. {
  1324. try
  1325. {
  1326. this.Cursor = Cursors.WaitCursor;
  1327. ulgridElement.BeginUpdate();
  1328. DataRowView dataRow = (DataRowView)ulgridElement.ActiveRow.ListObject;
  1329. if (dataRow["SAMPLE_NO"].ToString().Contains("限"))
  1330. {
  1331. return;
  1332. }
  1333. GridActiveDele();
  1334. }
  1335. finally
  1336. {
  1337. ulgridElement.EndUpdate();
  1338. this.Cursor = Cursors.Default;
  1339. }
  1340. }
  1341. private void ultraGridChoose_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  1342. {
  1343. foreach (UltraGridRow uRow in ultraGridChoose.Selected.Rows)
  1344. {
  1345. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  1346. {
  1347. uRow.Cells["CHC"].Value = true;
  1348. }
  1349. }
  1350. int xzNum = 0;
  1351. double xzWt = 0;
  1352. ultraGroupBox2.Text = "管坯物料信息";
  1353. foreach (UltraGridRow ugr in ultraGridChoose.Rows)
  1354. {
  1355. if (Convert.ToBoolean(ugr.Cells["CHC"].Text) == true)
  1356. {
  1357. xzNum += int.Parse(ugr.Cells["TakeCount"].Value.ToString());
  1358. xzWt += double.Parse(ugr.Cells["TakeWeight"].Value.ToString());
  1359. double lenGpSingle = double.Parse(ugr.Cells["FixLenTake"].Value.ToString());
  1360. ugr.Cells["FixNum"].Value = ((int)(double.Parse(ugr.Cells["ActLenTake"].Value.ToString()) / double.Parse(ugr.Cells["FixLenTake"].Value.ToString()))).ToString();
  1361. ugr.Cells["ActLenTake"].Value = int.Parse(ugr.Cells["FixNum"].Value.ToString()) * double.Parse(ugr.Cells["FixLenTake"].Value.ToString());
  1362. ugr.Cells["CutYuLong"].Value = double.Parse(ugr.Cells["ActLen"].Value.ToString()) - double.Parse(ugr.Cells["ActLenTake"].Value.ToString());
  1363. if (double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) > 0)
  1364. {
  1365. ugr.Cells["CutTybe"].Value = "切坯";
  1366. ugr.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1367. ugr.Cells["ActLenTake"].Activation = Activation.AllowEdit;
  1368. ugr.Cells["ActLenTake"].IgnoreRowColActivation = true;
  1369. ugr.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1370. ugr.Cells["FixLenTake"].Activation = Activation.AllowEdit;
  1371. ugr.Cells["FixLenTake"].IgnoreRowColActivation = true;
  1372. ugr.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
  1373. ugr.Cells["CutTarget"].Activation = Activation.AllowEdit;
  1374. ugr.Cells["CutTarget"].IgnoreRowColActivation = true;
  1375. }
  1376. if (double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) != 0)
  1377. {
  1378. if (minLengthRing - double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) > 0)
  1379. {
  1380. ugr.Cells["CutTarget"].Value = "套尺";
  1381. }
  1382. else
  1383. {
  1384. ugr.Cells["CutTarget"].Value = "回库";
  1385. }
  1386. }
  1387. Recalcu(lenGpSingle, ugr);
  1388. }
  1389. }
  1390. ultraGroupBox2.Text = ultraGroupBox2.Text + " 支:" + xzNum + " 吨:" + xzWt.ToString("f3");
  1391. }
  1392. string inMaterialNoZg = "";
  1393. private void ultraGridZgS_AfterRowActivate(object sender, EventArgs e)
  1394. {
  1395. UltraGridRow row = ultraGridZgS.ActiveRow;
  1396. if (row == null) return;
  1397. inMaterialNoZg = row.Cells["InwlId"].Value.ToString();
  1398. string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Value.ToString();
  1399. string indexSeq = row.Cells["IndexSeq"].Value.ToString();
  1400. string carftSeq = row.Cells["CraftSeq"].Value.ToString();
  1401. QueryCic(ordLnDlyPk, indexSeq, carftSeq);
  1402. QueryBom(ordLnDlyPk, indexSeq, carftSeq);
  1403. Query();
  1404. }
  1405. DataTable dtCic = new DataTable();
  1406. private void QueryCic(string ordLnDlyPk, string indexSeq, string carftSeq)
  1407. {
  1408. dtCic = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.StoveHelper.queryCic", new object[] { ordLnDlyPk, indexSeq, carftSeq }, _ob);
  1409. GridHelper.CopyDataToDatatable(dtCic, dataTable2, true);
  1410. GridHelper.RefreshAndAutoSize(entityGrid2);
  1411. foreach (UltraGridRow ugr in entityGrid2.Rows)
  1412. {
  1413. ugr.Cells["CHC"].Value = "指定";
  1414. }
  1415. }
  1416. /// <summary>
  1417. /// 查询符合条件的投入产出物料Bom
  1418. /// </summary>
  1419. private void QueryBom(string ordLnDlyPk, string indexSeq, string carftSeq)
  1420. {
  1421. string inMaterialNoBom = "";
  1422. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialDbk.queryBaseMaterial", new object[] { ordLnDlyPk, indexSeq, carftSeq, "D" }, _ob);
  1423. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  1424. GridHelper.RefreshAndAutoSize(entityGrid1);
  1425. if (dt.Rows.Count <= 0) return;
  1426. foreach (UltraGridRow item in entityGrid1.Rows)
  1427. {
  1428. if (item.Cells["IN_MATERIAL_NO"].Text.ToString().Equals(inMaterialNoZg))
  1429. {
  1430. item.Appearance.BackColor = Color.Orange;
  1431. item.Activate();
  1432. }
  1433. }
  1434. //if (!inMaterialNoBom.Equals(""))
  1435. //{
  1436. // inMaterialNo = inMaterialNoBom.Substring(0, inMaterialNoBom.Length - 1);
  1437. //}
  1438. }
  1439. private void entityGrid2_ClickCellButton(object sender, CellEventArgs e)
  1440. {
  1441. UltraGridRow row = ultraGridChoose.ActiveRow;
  1442. if (row == null) return;
  1443. if (e.Cell.Column.Key.Equals("CHC"))
  1444. {
  1445. UltraGridRow rowCic = entityGrid2.ActiveRow;
  1446. if (rowCic == null) return;
  1447. row.Cells["SpecCic"].Value = rowCic.Cells["CIC"].Value.ToString();
  1448. }
  1449. }
  1450. private void ultraGridChoose_ClickCellButton(object sender, CellEventArgs e)
  1451. {
  1452. UltraGridRow row = ultraGridChoose.ActiveRow;
  1453. if (row == null) return;
  1454. if (e.Cell.Column.Key.Equals("SpecCic"))
  1455. {
  1456. e.Cell.Row.Cells["SpecCic"].Value = "";
  1457. }
  1458. }
  1459. private void cmbAcount_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1460. {
  1461. this.ultraGridChoose.UpdateData();
  1462. UltraGridRow row = this.ultraGridChoose.ActiveRow;
  1463. if (row == null)
  1464. {
  1465. return;
  1466. }
  1467. FrmMatGpInfo frm = new FrmMatGpInfo(row, _ob);
  1468. frm.ShowDialog();
  1469. if (frm.flag.Equals("1"))
  1470. {
  1471. row.Cells["MatNo"].Value = frm.matNo.TrimEnd(new char[] { ',' }).ToString();
  1472. row.Cells["TakeCount"].Value = frm.count.ToString();
  1473. }
  1474. else
  1475. {
  1476. return;
  1477. }
  1478. }
  1479. }
  1480. }