| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.PlnSaleOrd.BaseMethod;
- using Core.StlMes.Client.PlnSaleOrd.Controls;
- using Core.StlMes.Client.PlnSaleOrd.炼钢计划;
- using Core.StlMes.Client.PlnSaleOrd.炉计划.Entity;
- using Core.StlMes.Client.PlnSaleOrd.炉计划.Tool;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinEditors;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.PlnSaleOrd.炉计划
- {
- public partial class FrmPlanMaterialSelection : FrmBase
- {
- private OpeBase _ob;
- private string _inMaterialName;
- private string _cic;
- private string _ciclk;
- private string _dimater;
- private string _userName;
- private string _proPlanId;
- private string _gxPlanNo;
- private string cic;
- private string cicyL;
- private string desginKey;
- private string indexSeq;
- private string outMaterialNo;
- private string plineCode;
- private string inMaterialNo;
- private string zggradeName;
- private string zggradecode;
- private string _supplyCode;
- public DataRow CurrentChem { get; private set; }
- private bool flag = false;
- //DataTable dtOrder = new DataTable();
- //DataTable dtInwlOut = new DataTable();
- public bool Flag
- {
- get { return flag; }
- set { flag = value; }
- }
- public FrmPlanMaterialSelection(string inMaterialName, string cic, string ciclk, string dimater, string proPlanId, string gxPlanNo,string supplyCode, string userName, OpeBase ob)
- {
- InitializeComponent();
- _ob = ob;
- _inMaterialName = inMaterialName;
- _cic = cic;
- _ciclk = ciclk;
- _dimater = dimater;
- _userName = userName;
- _proPlanId = proPlanId;
- _gxPlanNo = gxPlanNo;
- _supplyCode = supplyCode;
- CurrentChem = null;
- this.IsLoadUserView = true;
- }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- ultraGridZgS.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- ulgridElement.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- }
- private void FrmPlanMaterialSelection_Load(object sender, EventArgs e)
- {
- txtMaterialName.Text = _inMaterialName;
- txtGradeName.Text = _cic;
- txtGradeNamelk.Text = _ciclk;
- txtDimater.Text = _dimater;
- //设置列头名称
- EntityHelper.ShowGridCaption<MatGpMEntity>(ultraGridChoose.DisplayLayout.Bands[0]);
- BaseHelper.setOtherColumnReadOnly(ultraGridChoose, new string[] { "CHC", "TakeCount", "CutTybe", "PlnType" });
- 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" });
- BaseHelper.GridColumnSum(ultraGridChoose, new string[] { "TakeWeight", "ActWeight", "ActTheoryWeight" });
- BaseHelper.GridColumnCount(ultraGridChoose, new string[] { "TakeCount", "ActCount", "DbActCount" });
- BaseHelper.setUltraGridColumnMaxInput(ultraGridChoose, new string[] { "TakeWeight", "RollLength", "Aimlength", "ActTheoryWeight", "ActWeight" });
- BaseHelper.setUltraGridColumnBits(ultraGridChoose, new string[] { "TakeCount", "ActCount", "DbActCount", "LenCuthead", "OutnumCut", "LenCutend"});
- BaseHelper.setColumnBackColor(ultraGridChoose, new string[] { "TakeCount", "CutTybe", "PlnType", "SpecCic" });
- UltraNumericEditor[] uneArr = new UltraNumericEditor[1];
- uneArr[0] = new UltraNumericEditor();
- uneArr[0].NumericType = NumericType.Double;
- uneArr[0].MaskInput = "nnnnn";
- uneArr[0].SpinButtonDisplayStyle = Infragistics.Win.ButtonDisplayStyle.Always;
- this.Controls.Add(uneArr[0]);
- uneArr[0].Visible = false;
- uneArr[0].SpinIncrement = 10;
- ultraGridChoose.DisplayLayout.Bands[0].Columns["ActLenTake"].EditorComponent = uneArr[0];
- ultraGridChoose.DisplayLayout.Bands[0].Columns["FixLenTake"].EditorComponent = uneArr[0];
- ultraGridChoose.DisplayLayout.Bands[0].Columns["SpecCic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.EditButton;
- UltraComboEditor uceAbc = new UltraComboEditor();
- ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].EditorComponent = uceAbc;
- ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- ValueList vlistSteel = new ValueList();
- vlistSteel.ValueListItems.Insert(0, "不切", "不切");
- vlistSteel.ValueListItems.Insert(1, "切坯", "切坯");
-
- //vlistSteel.ValueListItems.Insert(2, "切管", "切管");
- ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTybe"].ValueList = vlistSteel;
- ValueList vlistSteel1 = new ValueList();
- vlistSteel1.ValueListItems.Insert(0, "0", "正常计划");
- vlistSteel1.ValueListItems.Insert(1, "1", "试轧料");
- ultraGridChoose.DisplayLayout.Bands[0].Columns["PlnType"].ValueList = vlistSteel1;
- ValueList vlistSteel2 = new ValueList();
- vlistSteel2.ValueListItems.Insert(0, "回库", "回库");
- //vlistSteel2.ValueListItems.Insert(1, "返废", "返废");
- vlistSteel2.ValueListItems.Insert(1, "套尺", "套尺");
- ultraGridChoose.DisplayLayout.Bands[0].Columns["CutTarget"].ValueList = vlistSteel2;
- //StoveHelper.SetComboItemHeight(vlistSteel2);
- StoveHelper.ForbidSort(ultraGridZgS);
- StoveHelper.ForbidSort(ulgridElement);
- QueryZgS();
- QueryPlanZg();
- //Query();
- }
- private double minLengthRing = 0;
- /// <summary>
- /// 查询产线对应最小环形炉长度
- /// </summary>
- private void QueryPline()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.queryPline",
- new object[] { plineCode }, _ob);
- if (dt.Rows.Count>0)
- {
- minLengthRing = double.Parse(dt.Rows[0]["LENGTH_MIN_RING"].ToString());
- }
- }
- private void QueryZgS()
- {
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getPlnOrderZg",
- new object[] { _proPlanId, _gxPlanNo }, _ob);
- if (dt.Rows.Count > 0)
- {
- if (dt.Rows[0]["CIC_GROUP_LK"].ToString().Contains(dt.Rows[0]["CIC_GP"].ToString()))
- {
- cic = dt.Rows[0]["CIC_GROUP_LK"].ToString();
- }
- else
- {
- if (dt.Rows[0]["CIC_GROUP_LK"].ToString().Equals(""))
- {
- cic = dt.Rows[0]["CIC_GP"].ToString();
- }
- else
- {
- cic = dt.Rows[0]["CIC_GP"].ToString() + "," + dt.Rows[0]["CIC_GROUP_LK"].ToString();
- }
- }
- cicyL = dt.Rows[0]["CIC_GP"].ToString();
- desginKey = dt.Rows[0]["DESGIN_KEY"].ToString();
- indexSeq = dt.Rows[0]["INDEX_SEQ"].ToString();
- outMaterialNo = dt.Rows[0]["OUTWL_ID"].ToString();
- inMaterialNo = dt.Rows[0]["INWL_ID"].ToString();
- plineCode = dt.Rows[0]["PLINE_CODE"].ToString();
-
- }
- QueryPline();
- }
- private void QueryPlanZg()
- {
- List<PlnOrderZgSOEntityGp> listSource = EntityHelper.GetData<PlnOrderZgSOEntityGp>("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getPlnOrderZgS",
- new object[] { _proPlanId, _gxPlanNo }, _ob);
- plnOrderZgSOEntityBindingSource.DataSource = listSource;
- GridHelper.RefreshAndAutoSize(ultraGridZgS);
- foreach (UltraGridRow ugr in ultraGridZgS.Rows)
- {
- #region 赋值LJ,装炉,出库
- int numLj = 0;
- double wtLj = 0;
- if (!ugr.Cells["LjNum"].Text.Equals(""))
- {
- numLj = int.Parse(ugr.Cells["LjNum"].Value.ToString());
- wtLj = double.Parse(ugr.Cells["LjWeight"].Value.ToString());
- }
- int gpNum = 0;
- double gpWt = 0;
- if (!ugr.Cells["GpreqNum"].Text.Equals(""))
- {
- gpNum = int.Parse(ugr.Cells["GpreqNum"].Value.ToString());
- gpWt = double.Parse(ugr.Cells["GpreqWeight"].Value.ToString());
- }
- if (gpNum - numLj <= 0)
- {
- ugr.Cells["ReallNum"].Value = "0";
- ugr.Cells["ReallWt"].Value = "0";
- }
- else
- {
- ugr.Cells["ReallNum"].Value = (gpNum - numLj).ToString();
- ugr.Cells["ReallWt"].Value = (gpWt - wtLj).ToString("f3");
- }
- #endregion
- zggradeName = ugr.Cells["GradecodeAll"].Text.ToString().Trim() + "," + ugr.Cells["GradenameLk"].Text.ToString().Trim() + "," + ugr.Cells["Gradename"].Text.ToString().Trim();
- zggradecode = ugr.Cells["Gradecode"].Text.ToString().Trim() + "," + ugr.Cells["GradecodeLk"].Text.ToString().Trim();
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Query":
- Query();
- break;
- case "Liku": //利库
- Liku();
- break;
- case "Monomer": // 脱单
- Monomer();
- break;
- //case "Recalcu": // 重算
- // Recalcu();
- // break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void Query()
- {
- UltraGridRow row = this.ultraGridZgS.ActiveRow;
- if (row == null) return;
- string surplusflag = "";
- string cicN = _cic;
- if (!_ciclk.Equals(""))
- {
- cicN = _cic + "," + _ciclk;
- }
- if (_dimater.Equals("250") || _dimater.Equals("251"))
- {
- _dimater ="250,251";
- }
- surplusflag = txtSurplusflag.Value.ToString();
- string[] gradestr = null;
- string gradeAll = "";
- if (!zggradeName.Equals(""))
- {
- gradestr = zggradeName.Split(',');
- }
- //for (int i = 0; i < gradestr.Length; i++)
- //{
- // gradeAll+="'"+gradestr[i]+"',";
- //}
- //gradeAll = gradeAll.Substring(1, gradeAll.Length-3);
- List<MatGpMEntity> listSourceM = EntityHelper.GetData<MatGpMEntity>
- ("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryMaterial", new object[] { _inMaterialName, cicN, _dimater, surplusflag, gradestr, row.Cells["PlineCode"].Text, row.Cells["TypeFlag"].Text }, _ob);
- matGpMEntityBindingSource.DataSource = listSourceM;
- //GridHelper.RefreshAndAutoSize(ultraGridChoose);
- foreach (UltraGridRow item in ultraGridChoose.Rows)
- {
- double dimater = 0;
- if (item.Cells["Dimater"].Value.ToString().Equals("251"))
- {
- dimater = 250;
- }
- else
- {
- dimater = double.Parse(item.Cells["Dimater"].Value.ToString());
- }
- double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
- // 倍尺坯长
- double lenLong = double.Parse(item.Cells["ActLen"].Value.ToString());
- // 倍尺坯单支重=坯米单重*倍尺坯长/1000
- double weightM = mSingleWeight * (lenLong / 1000);
- // 单倍坯重
- double weightGpOne = mSingleWeight
- * (double.Parse(item.Cells["FixLen"].Value.ToString()) / 1000);
- item.Cells["WeightM"].Value = weightM.ToString("f6");
- item.Cells["WeightGpOne"].Value = weightGpOne.ToString("f6");
- UltraGridRow urgzG = ultraGridZgS.ActiveRow;
- if (urgzG != null)
- {
- if (item.Cells["ProPlanIdZg"].Text.ToString().Equals(""))
- {
- item.Cells["OutnumCut"].Value = urgzG.Cells["OutnumCut"].Value.ToString();
- item.Cells["LenCuthead"].Value = urgzG.Cells["LenCuthead"].Value.ToString();
- item.Cells["LenCutend"].Value = urgzG.Cells["LenCutend"].Value.ToString();
- item.Cells["Aimlength"].Value = urgzG.Cells["Aimlength"].Value.ToString();
- item.Cells["RollLength"].Value = urgzG.Cells["RollLength"].Value.ToString();
- }
- item.Cells["FixLenTake"].Value = urgzG.Cells["LenGpSingle"].Value.ToString();
- }
- if (item.Cells["StorageName"].Text.Contains("天淮室外管坯库"))
- {
- item.Cells["StorageName"].Appearance.BackColor = System.Drawing.Color.OrangeRed;
- }
- }
- }
- /// <summary>
- /// 利库
- /// </summary>
- private void Liku()
- {
- UltraGridRow ugr=ultraGridZgS.ActiveRow;
- if (ugr.Cells["ReallWt"].Value.ToString().Equals("0"))
- {
- //MessageUtil.ShowTips("待炼支吨为零,不能利库?");
- if (MessageUtil.ShowYesNoAndQuestion("待炼支吨为零,是否继续利库?") == DialogResult.No)
- {
- return;
- }
- }
- UltraGridRow row = ultraGridChoose.ActiveRow;
- if (row == null) return;
- int count = 0;
- ArrayList list = new ArrayList();
- String lenSingGpTake="";
- String judgeNo = "";
- double wt = 0;
- int m = 0;
- string isDealer = "";
- if ("双经销".Equals(ugr.Cells["TypeFlag"].Text))
- {
- isDealer = "1";
- }
- else if ("定销订购".Equals(ugr.Cells["TypeFlag"].Text))
- {
- isDealer = "3";
- }
- else {
- isDealer = "0";
- }
- if (!this.UserInfo.GetDepartment().StartsWith("002023"))
- {
- isDealer = "";
- }
- foreach (UltraGridRow urg in ultraGridChoose.Rows)
- {
- ArrayList list1 = new ArrayList();
- if (Convert.ToBoolean(urg.Cells["CHC"].Text) == true)
- {
- count++;
- if (urg.Cells["HangingFlag"].Text.ToString().Equals("是"))
- //&& urg.Cells["CutYuLong"].Text.ToString().Equals("0"))并且切坯余长为零,
- {
- MessageUtil.ShowTips("你选择的管坯物料已生成实际炉计划,不能利库。如需利库,请先删除炉计划!");
- return;
- }
- if (judgeNo.Equals(""))
- {
- judgeNo = urg.Cells["JudgeStoveNo"].Value.ToString();
- }
- if (lenSingGpTake.Equals(""))
- {
- lenSingGpTake = urg.Cells["FixLenTake"].Value.ToString();
- }
- if (judgeNo.Equals(urg.Cells["JudgeStoveNo"].Value.ToString())&&!lenSingGpTake.Equals(urg.Cells["FixLenTake"].Value.ToString()))
- {
- MessageUtil.ShowTips("你选择同炉单倍坯长不一致!");
- return;
- }
- //string numCut=urg.Cells["FixNum"].Value.ToString();
- //int result = 0;
- if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) > int.Parse(urg.Cells["FixLenTake"].Value.ToString()))
- {
- if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) % int.Parse(urg.Cells["FixLenTake"].Value.ToString()) != 0)
- {
- MessageUtil.ShowTips("倍尺数不是整数,请修改使用坯长!");
- return;
- }
- }
- if (int.Parse(urg.Cells["ActLenTake"].Value.ToString()) > int.Parse(urg.Cells["ActLen"].Value.ToString()))
- {
- MessageUtil.ShowTips("使用坯长不能大于库存倍尺坯长!");
- return;
- }
- if (int.Parse(urg.Cells["ActLenTake"].Value.ToString())==0){
- MessageUtil.ShowTips("使用坯长不能等于0!");
- return;
- }
- if (!urg.Cells["ProPlanIdZg"].Text.ToString().Equals("") && !urg.Cells["ProPlanIdZg"].Text.ToString().Equals(_proPlanId + "/" + _gxPlanNo))
- {
- MessageUtil.ShowTips("你选择的管坯物料已分配给其他轧管订单,不能利库。如需利库,请先脱单!");
- return;
- }
- int lenGpSingle = Convert.ToInt32(row.Cells["FixLenTake"].Value.ToString());
- if (lenGpSingle % 10 != 0)
- {
- MessageUtil.ShowWarning("单倍坯长个位数不是0,请重新调整!");
- return;
- }
- if (urg.Cells["CutTybe"].Text.Equals("切坯") && urg.Cells["CutTarget"].Text.Equals(""))
- {
- MessageUtil.ShowTips("利库时需要切坯,请选择切余处理方式!");
- return;
- }
- string fixLenTake = urg.Cells["FixLenTake"].Value.ToString();
- if (double.Parse(urg.Cells["ActLenTake"].Value.ToString()) < double.Parse(urg.Cells["FixLenTake"].Value.ToString()))
- {
- fixLenTake = urg.Cells["ActLenTake"].Value.ToString();
- }
- wt += Double.Parse(urg.Cells["TakeWeight"].Value.ToString());
- list1.Add(urg.Cells["JudgeStoveNo"].Text.ToString());
- list1.Add(urg.Cells["ProPlanId"].Text.ToString());
- list1.Add(urg.Cells["GxPlanNo"].Text.ToString());
- list1.Add(urg.Cells["TakeCount"].Value.ToString());
- list1.Add(urg.Cells["TakeWeight"].Value.ToString());
- list1.Add(urg.Cells["ActLenTake"].Value.ToString());
- list1.Add(fixLenTake);
- list1.Add(urg.Cells["Furnaceno"].Text.ToString());
- list1.Add(urg.Cells["Sequenceno"].Text.ToString());
- list1.Add(urg.Cells["Gradecode"].Text.ToString());
- list1.Add(urg.Cells["Gradename"].Text.ToString());
- list1.Add(urg.Cells["FixNum"].Value.ToString());
- list1.Add(urg.Cells["StorageNo"].Text.ToString());
- list1.Add(urg.Cells["LocationNo"].Text.ToString());
- list1.Add(urg.Cells["StoveNo"].Text.ToString());
- list1.Add(urg.Cells["FlagStoveNo"].Text.ToString());
- list1.Add(urg.Cells["MatStatus1"].Text.ToString());
- list1.Add(urg.Cells["CutTarget"].Text.ToString());
- list1.Add(urg.Cells["PlnType"].Value.ToString());
- list1.Add(urg.Cells["CutNumGp"].Value.ToString());
- list1.Add(urg.Cells["OutnumCut"].Text.ToString());
- list1.Add(urg.Cells["Aimlength"].Value.ToString());
- list1.Add(urg.Cells["RollLength"].Value.ToString());
- string specCic = urg.Cells["SpecCic"].Text.ToString();
- if (specCic.Equals(""))
- {
- string gradeName = urg.Cells["Gradename"].Text.ToString();
- string cic = urg.Cells["Cic"].Text.ToString();
- UltraGridRow rowCic = entityGrid2.ActiveRow;
- if (rowCic != null)
- {
- int countCic = 0;
- foreach (UltraGridRow item in entityGrid2.Rows)
- {
- if (item.Cells["GRADENAME"].Text.ToString().Equals(gradeName) && item.Cells["CIC"].Text.ToString().Equals(cic))
- {
- countCic++;
- }
- }
- if (countCic == 0)
- {
- MessageUtil.ShowTips("库存CIC在订单炼钢CIC集合里没有,请指定CIC!");
- return;
- }
- }
- }
- if (!specCic.Equals(""))
- {
- list1.Add(urg.Cells["SpecCic"].Text.ToString());
- }
- else
- {
- list1.Add(urg.Cells["Cic"].Text.ToString());
- }
- list.Add(list1);
- list1.Add(urg.Cells["ActLen"].Value.ToString());
- list1.Add(urg.Cells["MatNo"].Text.ToString2());
- if (urg.Cells["CutTarget"].Text.Equals("返废"))
- {
- m = m + 1;
- }
- }
- }
- if (count == 0)
- {
- MessageUtil.ShowTips("请选择管坯物料信息");
- return;
- }
- if (m > 0)
- {
- if (MessageUtil.ShowYesNoAndQuestion("切坯处理方式为返废,是否确认继续利库?") ==
- DialogResult.No)
- return;
- }
- //if (wt - Double.Parse(ugr.Cells["ReallWt"].Value.ToString()) > 0)
- //{
- // MessageUtil.ShowTips("你选择要利库的利库吨不能大于待冶炼吨!");
- // return;
- //}
- if (MessageUtil.ShowYesNoAndQuestion("是否确认利库?") ==
- DialogResult.No)
- return;
- PlanComm.WaitFromOpen(this.Cursor);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection";
- ccp.MethodName = "doAddLibrary";
- ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(), _proPlanId, _gxPlanNo, isDealer };
- ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- PlanComm.WaitFromColse(this.Cursor);
- if (ccp.ReturnCode == -1) return;
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("利库成功!"))
- {
- QueryPlanZg();
- Flag = true;
- }
- }
- /// <summary>
- /// 脱单
- /// </summary>
- private void Monomer()
- {
- UltraGridRow row = ultraGridChoose.ActiveRow;
- if (row == null) return;
- UltraGridRow ugr = ultraGridZgS.ActiveRow;
- string isDealer = "";
- if ("双经销".Equals(ugr.Cells["TypeFlag"].Text))
- {
- isDealer = "1";
- }
- else if ("定销订购".Equals(ugr.Cells["TypeFlag"].Text))
- {
- isDealer = "3";
- }
- else
- {
- isDealer = "0";
- }
- if (!this.UserInfo.GetDepartment().StartsWith("002023"))
- {
- isDealer = "";
- }
- int count = 0;
- ArrayList list = new ArrayList();
- foreach (UltraGridRow urg in ultraGridChoose.Rows)
- {
- ArrayList list1 = new ArrayList();
- if (Convert.ToBoolean(urg.Cells["CHC"].Text) == true)
- {
- count++;
- if (urg.Cells["ProPlanIdZg"].Text.ToString().Equals(""))
- {
- MessageUtil.ShowTips("你选择的管坯物料未分配给其他轧管订单,不能脱单!");
- return;
- }
- if (urg.Cells["HangingFlag"].Text.ToString().Equals("是"))
- {
- MessageUtil.ShowTips("你选择的管坯物料已生成实际炉计划,不能脱单。如需脱单,请先删除炉计划!");
- return;
- }
- list1.Add(urg.Cells["JudgeStoveNo"].Text.ToString());
- list1.Add(urg.Cells["TakeCount"].Value.ToString());
- list1.Add(urg.Cells["ActLen"].Value.ToString());
- list1.Add(urg.Cells["FixLen"].Value.ToString());
- list1.Add(urg.Cells["CutNumGp"].Value.ToString());
- list1.Add(urg.Cells["StorageNo"].Text.ToString());
- list1.Add(urg.Cells["LocationNo"].Text.ToString());
- list1.Add(urg.Cells["Dimater"].Value.ToString());
- list1.Add(urg.Cells["ProPlanIdZg"].Text.ToString());
- list.Add(list1);
- }
- }
- if (count == 0)
- {
- MessageUtil.ShowTips("请选择管坯物料信息");
- return;
- }
- PlanComm.WaitFromOpen(this.Cursor);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection";
- ccp.MethodName = "doDeleteMonomer";
- ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(), isDealer };
- ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- PlanComm.WaitFromColse(this.Cursor);
- if (ccp.ReturnCode == -1) return;
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("脱单成功!"))
- {
- Query();
- Flag = true;
- }
- }
- /// <summary>
- /// 重算
- /// </summary>
- private void Recalcu(double lenGpSingle, UltraGridRow row)
- {
- //if (lenGpSingle % 10 != 0)
- //{
- // MessageUtil.ShowWarning("单倍坯长个位数不是0,请重新调整!");
- // return;
- //}
- //if (lenGpSingle > int.Parse(row.Cells["FixLen"].Text.ToString()))
- //{
- // MessageUtil.ShowTips("计划单倍坯长不能大于库存单倍坯长!");
- // return;
- //}
- DataTable dtOrder = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryZgMSStatus",
- new object[] { _proPlanId, _gxPlanNo }, _ob);
- if (dtOrder.Rows.Count <= 0)
- {
- MessageUtil.ShowTips("未找到轧管订单:" + _proPlanId + "/" + _gxPlanNo + "合同信息!");
- return;
- }
- //if (lenGpSingle >= int.Parse(dtOrder.Rows[0]["LENGTH_MAX_RING"].ToString()))
- //{
- // MessageUtil.ShowTips("计划单倍坯长必须小于等于产线(" + dtOrder.Rows[0]["PLINE_NAME"].ToString() + ")环形炉最大长度(" + dtOrder.Rows[0]["LENGTH_MAX_RING"].ToString() + ")!");
- // return;
- //}
- double burning = double.Parse(dtOrder.Rows[0]["BURNOUT_RATE"].ToString())/100;//烧损率
- //if (burning >= 1 || burning < 0)
- //{
- // MessageUtil.ShowTips("烧损率必须在0-99%之间!");
- // return;
- //}
- double sizing = double.Parse(dtOrder.Rows[0]["LENGTH_COLDBED"].ToString());//冷床长度
- //if (sizing <= 0)
- //{
- // MessageUtil.ShowTips("冷床长度必须大于零!");
- // return;
- //}
- DataTable dtInwlOut = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryBaseMaterialDPl",
- new object[] { dtOrder.Rows[0]["INWL_ID"].ToString(), dtOrder.Rows[0]["OUTWL_ID"].ToString(), dtOrder.Rows[0]["PLINE_CODE"].ToString() }, _ob);
- if (dtInwlOut.Rows.Count <= 0)
- {
- MessageUtil.ShowTips("未找到轧管订单:" + _proPlanId + "/" + _gxPlanNo + "投入产出物料信息!");
- return;
- }
- int cutMax = int.Parse(dtInwlOut.Rows[0]["DBL_LEN_MAX"].ToString());
- double capacity = double.Parse(dtInwlOut.Rows[0]["HR_CAPCTY"].ToString());//小时能力
- double wasteRate = double.Parse(dtInwlOut.Rows[0]["WASTE_RATE"].ToString()) / 1000;//万只废品数
- double Cuthead_tail = (double.Parse(dtOrder.Rows[0]["LEN_CUTHEAD"].ToString()) + double.Parse(dtOrder.Rows[0]["LEN_CUTEND"].ToString())) / 1000;
- double tubeEndRatio = double.Parse(dtOrder.Rows[0]["TUBE_END_RATIO"].ToString());
- // 坯料米单重
- double weightofm = 0;
- // 坯料重量
- double Billet_weight = 0;
- double lengthZzmax = 0;// 轧制长度
- double diame = double.Parse(dtOrder.Rows[0]["DIAMETER_GP"].ToString());// 最佳断面
- // /循环断面集合,找出最佳断面
- double weight_one = (0.02466 * double.Parse(dtOrder.Rows[0]["AIMWALLTHICK"].ToString())
- * (double.Parse(dtOrder.Rows[0]["AIMOUTDIAMETER"].ToString()) - double.Parse(dtOrder.Rows[0]["AIMWALLTHICK"].ToString()))) / 1000;// 轧管管单重
- // 坯料米单重
- weightofm = (7.8 * 3.1415926 / 4 * diame * diame) / 1000 / 1000;
- // 极限单倍坯重
- double billetweight = weightofm * (lenGpSingle / 1000);
- // 极限轧制长度
- lengthZzmax = billetweight * (1 - burning) / weight_one
- + (1 - tubeEndRatio) * Cuthead_tail;
- //if (lengthZzmax <= 0)
- //{
- // MessageUtil.ShowTips("轧制长度TZ必须大于零!");
- // return;
- //}
- // 验证:轧制长度<冷床长度,否则单倍坯长调整无效
- //if (lengthZzmax >= sizing)
- //{
- // MessageUtil.ShowTips("轧制长度TZ大于等于冷长长度,单倍坯长输入无效,轧制长度TZ:"
- // + lengthZzmax.ToString("f3") + "m,冷床长度:"
- // + sizing + "m!");
- // return;
- //}
- bool shrt_stove = false;
- if (double.Parse(dtOrder.Rows[0]["SHRT_LEN_RATO"].ToString()) > 0)
- {
- shrt_stove = true;
- }
- double sigl_len = double.Parse(dtOrder.Rows[0]["SIGL_LEN"].ToString());//单倍尺长M
- double lengthmaxZg = double.Parse(dtOrder.Rows[0]["LENGTHMAX"].ToString());
- double lengthminZg = double.Parse(dtOrder.Rows[0]["LENGTHMIN"].ToString());
- int Cutnum = 0;
- double aimlength = 0;
- double tubeYuLong = 0;//管余长
- //轧制长度大于零
- if (lengthZzmax > 0)
- {
- // /分切过程
- // 1.无短尺随炉and无使用单倍长度
- if (!shrt_stove && sigl_len <= 0)
- {
- double x = (lengthZzmax - Cuthead_tail) / lengthmaxZg;
- double y = (lengthZzmax - Cuthead_tail) / lengthminZg;
- if (y > 0)
- {
- // 获取最小整数
- int min = isRounded(x, y);
- if (min != 0)
- {
- Cutnum = min;
- aimlength = (lengthZzmax - Cuthead_tail) / Cutnum;// 目标转移长度
- tubeYuLong = 0;
- }
- else
- {
- Cutnum = (int)(x);
- if (Cutnum == 0)
- {
- Cutnum = 1;
- }
- aimlength = lengthmaxZg; // 目标转移长度
- // 管余长=((轧制长度TZ -切头尾)/轧管转移长度上限-INT(轧制长度TZ
- // -切头尾)/轧管转移长度上限+1))* 轧管转移长度上限
- tubeYuLong = lengthZzmax - Cutnum * aimlength
- - Cuthead_tail;
- }
- }
- else
- {
- //MessageUtil.ShowTips("轧管工序:轧制长度TZ" + lengthZzmax.ToString("f3")
- // + "米、转移长度下限" + lengthminZg.ToString("f3") + "米、切头尾"
- // + Cuthead_tail.ToString("f3") + "米,无法生产!");
- return;
- }
- }
- // 2.短尺随炉
- if (shrt_stove && sigl_len <= 0)
- {
- double x = (lengthZzmax - Cuthead_tail) / lengthmaxZg;
- double y = (lengthZzmax - Cuthead_tail) / lengthminZg;
- if (y > 0)
- {
- // 获取最小整数
- int min = isRounded(x, y);
- if (min != 0)
- {
- Cutnum = min;
- aimlength = (lengthZzmax - Cuthead_tail) / Cutnum;// 目标转移长度
- tubeYuLong = 0;
- }
- else
- {
- if (((((lengthZzmax - Cuthead_tail) / lengthminZg) - (int)((lengthZzmax - Cuthead_tail) / lengthminZg)) * lengthminZg) >= 8.5)
- {
- Cutnum = (int)(y) + 1;
- aimlength = lengthminZg;
- tubeYuLong = 0;
- }
- else
- {
- Cutnum = (int)(x);
- if (Cutnum == 0)
- {
- Cutnum = 1;
- }
- aimlength = lengthmaxZg; // 目标转移长度
- tubeYuLong = lengthZzmax - Cutnum * aimlength
- - Cuthead_tail;
- }
- }
- }
- else
- {
- //MessageUtil.ShowTips("轧管工序:轧制长度TZ" + lengthZzmax.ToString("f3")
- // + "米、转移长度下限" + lengthminZg.ToString("f3") + "米、切头尾"
- // + Cuthead_tail.ToString("f3") + "米,无法生产!");
- return;
- }
- }
- // 3.单倍尺长
- if (sigl_len > 0)
- {
- Cutnum = cutMax;
- if (Cutnum == 0)
- {
- Cutnum = 1;
- }
- aimlength = double.Parse(dtOrder.Rows[0]["ROLL_LENGTH"].ToString());
- // 管余长=轧制长度TZ-分切*目标长度+切头尾
- tubeYuLong = lengthZzmax - Cutnum * aimlength - Cuthead_tail;
- }
- //if (tubeYuLong < 0)
- //{
- //MessageUtil.ShowTips("管余长不能为负数:" + tubeYuLong + ",轧制长度TZ:"
- // + lengthZzmax.ToString("f3")
- // + ",分切数:"
- // + Cutnum
- // + ",目标长度:"
- // + aimlength.ToString("f3") + "!");
- //return;
- //}
- //else
- //{
- // tubeYuLong = tubeYuLong.ToString("f1");
- //}
- // 坯调整
- //double piStock = tubeYuLong * (weight_one * 1000)
- // / (7.8 * 3.1415926 * diame * diame / 4) / (1 - burning) * 1000
- // * 1000;
- //// 验证1:管余长<>0,报警=“计算验证字段写“长度需调整””
- //if (tubeYuLong != 0)
- //{
- // MessageUtil.ShowTips(("管余长:"
- // + tubeYuLong.ToString("f1")
- // + "m,坯调整:"
- // + piStock.ToString("f0")+ "mm");
- //}
- //// 验证2:目标长度>平均长度 and 目标长度>转移长度下限+J值/1000 and
- //// 分切<最大分切数and目标长度<=轧管转移长度上限
- //if (aimlength >= avg_len_min
- // && aimlength >= lengthminZg + chekJavl / 1000
- // && Cutnum <= cutMat && aimlength <= lengthmaxZg)
- //{
- // paramOut.setVerify2("");
- //}
- //else
- //{
- // paramOut
- // .setVerify2("长度超出范围:目标长度("
- // + new BigDecimal(aimlength).setScale(2,
- // RoundingMode.HALF_UP).doubleValue()
- // + "),平均长度("
- // + new BigDecimal(avg_len_min).setScale(2,
- // RoundingMode.HALF_UP).doubleValue()
- // + "),转移长度下限("
- // + new BigDecimal(lengthminZg).setScale(2,
- // RoundingMode.HALF_UP).doubleValue()
- // + "),转移长度上限("
- // + new BigDecimal(lengthmaxZg).setScale(2,
- // RoundingMode.HALF_UP).doubleValue()
- // + "),J值("
- // + new BigDecimal(chekJavl / 1000).setScale(2,
- // RoundingMode.HALF_UP).doubleValue()
- // + "),最大分切数(" + cutMat + ")");
- //}
- // 管长度太短,无法分切
- //if (Cutnum <= 0)
- //{
- //MessageUtil.ShowTips("分切数为:" + Cutnum + ",无法分切!(轧制长度TZ"
- // + lengthZzmax.ToString("f3") + ")");
- // return;
- //}
- // 坯单支重=(轧管管单重*(轧制长度-切头尾)+轧管管单重*管端增厚系数*切头尾)/ (1-烧损)
- Billet_weight = ((weight_one * (lengthZzmax - Cuthead_tail) + weight_one
- * tubeEndRatio * Cuthead_tail) / (1 - burning));
- }
- row.Cells["OutnumCut"].Value = Cutnum.ToString();
- row.Cells["Aimlength"].Value = aimlength.ToString("f2");
- row.Cells["RollLength"].Value = lengthZzmax.ToString("f2");
- }
- public int isRounded(double x, double y)
- {
- double inMax = 0;
- double inMin = 0;
- if (x - y > 0)
- {
- inMin = y;
- inMax = x;
- }
- else
- {
- inMin = x;
- inMax = y;
- }
- if (Mod(inMin, (int)(inMin)) == 0)
- {
- return (int)(inMin);
- }
- else if ((int)(inMax) - (int)(inMin) == 0)
- {
- return 0;
- }
- else
- {
- return (int)(inMin) + 1;
- }
- }
- private static double Mod(double inMin, int i)
- {
- double remainder = inMin % i;
- return remainder;
- }
- private void ultraGridChoose_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow row = ultraGridChoose.ActiveRow;
- if (row == null) return;
- QueryChenName(row.Cells["JudgeStoveNo"].Text.ToString(), row.Cells["ChemJudgeId"].Text.ToString());
- string gradeName = row.Cells["Gradename"].Text.ToString();
- entityGrid2.UpdateData();
- DataRow[] datarows = dtCic.Select("GRADENAME = '" + gradeName + "'");
- DataTable tab = StoveHelper.ToDataTable(datarows);
- GridHelper.CopyDataToDatatable(tab, dataTable2, true);
- GridHelper.RefreshAndAutoSize(entityGrid2);
- foreach (UltraGridRow ugr in entityGrid2.Rows)
- {
- ugr.Cells["CHC"].Value = "指定";
- }
- entityGrid2.Refresh();
- entityGrid2.Update();
- }
- private int countMes = 0;
- private int countStov = 0;
- /// <summary>
- /// 查询索引码
- /// </summary>
- private void QueryChenName(string cudgeStoveNo, string chemJudgeId)
- {
- DataTable InternalStandard = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getStlChemicalStd",
- new object[] { cic, desginKey, indexSeq }, _ob);
- dtChem.Rows.Clear();
- countMes = 0;
- countStov = 0;
- foreach (var colums in ulgridElement.DisplayLayout.Bands[0].Columns)
- {
- colums.Hidden = true;
- }
- ulgridElement.DisplayLayout.Bands[0].Columns["SAMPLE_NO"].Hidden = false;
- ulgridElement.DisplayLayout.Bands[0].Columns["CIC"].Hidden = false;
- if (InternalStandard != null)
- {
- foreach (DataRow dataRow in InternalStandard.Rows)
- {
- string chemsKey = dataRow["CHEM_NAME"].ToString().Replace(" ", "").Replace("/", "");
- if (!dtChem.Columns.Contains(chemsKey.ToUpper()) && !string.IsNullOrEmpty(chemsKey))
- {
- DataColumn newDc = new DataColumn
- {
- ColumnName = chemsKey.ToUpper(),
- Caption = chemsKey
- };
- dtChem.Columns.Add(newDc);
- }
- ulgridElement.DisplayLayout.Bands[0].Columns[chemsKey.ToUpper()].Hidden = false;
- }
- }
-
- DataTable distinct_object = InternalStandard.DefaultView.ToTable(true, "CIC");
- if (distinct_object.Rows.Count <= 0)
- {
- return;
- }
- for (int i = 0; i < distinct_object.Rows.Count; i++)
- {
- DataRow drMax = dtChem.NewRow();
- DataRow drMin = dtChem.NewRow();
- DataRow drCic = dtChem.NewRow();
- string cicChem = distinct_object.Rows[i]["CIC"].ToString();
- DataRow[] drs = InternalStandard.Select("CIC='" + cicChem + "'");
- if (drs.Count() > 0)
- {
- if (cicyL.Equals(drs[0][8]))
- {
- drMax["SAMPLE_NO"] = "冶炼CIC上限";
- drMin["SAMPLE_NO"] = "冶炼CIC下限";
- }
- else
- {
- drMax["SAMPLE_NO"] = "利库CIC上限";
- drMin["SAMPLE_NO"] = "利库CIC下限";
- }
- drMax["CIC"] = drs[0][8];
- drMin["CIC"] = drs[0][8];
- foreach (DataRow dataRow in drs)
- {
- string columnsName = dataRow["CHEM_NAME"].ToString().ToUpper().Replace(" ", "").Replace("/", "");
- drMax[columnsName] = dataRow["STDMAX_SIGN"];//+ dataRow["STDMAX"].ToString()
- drMin[columnsName] = dataRow["STDMIN_SIGN"];//+ dataRow["STDMIN"].ToString()
- ulgridElement.DisplayLayout.Bands[0].Columns[columnsName].Tag = dataRow["CHEM_FORMULA"];
- }
- dtChem.Rows.Add(drMax);
- dtChem.Rows.Add(drMin);
- countMes += 2;
- }
- }
- //string[] chemJudgeIdAll = chemJudgeId.Split(',');
- //chemJudgeId = string.Join(",", chemJudgeIdAll);
- DataTable dtData = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmRollTubeLibraryZg.getStlChemicalData",
- new object[] { cudgeStoveNo, chemJudgeId }, _ob);
- if (dtData != null && dtData.Rows.Count > 0)
- {
- CurrentChem = dtData.Rows[0];
- foreach (DataRow dataRow in dtData.Rows)
- {
- foreach (DataColumn dc in dtData.Columns)
- {
- string columnsName = dc.ColumnName;
- if (columnsName.Equals("SAMPLE_NO")) continue;
- if (!dtChem.Columns.Contains(columnsName.ToUpper().Replace("ASN", "AS")) &&
- dataRow[columnsName] != null &&
- !string.IsNullOrEmpty((dataRow[columnsName].ToString())))
- {
- DataColumn newDc = new DataColumn();
- newDc.ColumnName = columnsName.ToUpper().Replace("ASN", "AS");
- newDc.Caption = columnsName;
- dtChem.Columns.Add(newDc);
- }
- }
- DataRow tempRow = dtChem.NewRow();
-
- //tempRow["CICLK"] = dataRow["STOVE_NO"];
- foreach (DataColumn DataColumn in dtData.Columns)
- {
- if (dtChem.Columns.Contains(DataColumn.ColumnName.Replace("ASN", "AS")))
- {
- tempRow[DataColumn.ColumnName.Replace("ASN", "AS")] = dataRow[DataColumn.ColumnName];
- if (dataRow[DataColumn.ColumnName] != null &&
- !string.IsNullOrEmpty(dataRow[DataColumn.ColumnName].ToString()))
- {
- ulgridElement.DisplayLayout.Bands[0].Columns[DataColumn.ColumnName.Replace("ASN", "AS")]
- .Hidden = false;
- ulgridElement.DisplayLayout.Bands[0].Columns["ASSAYNO"].Hidden = true;
- ulgridElement.DisplayLayout.Bands[0].Columns["STOVE_NO"].Hidden = true;
- }
- }
- }
- foreach (UltraGridColumn column in ulgridElement.DisplayLayout.Bands[0].Columns)
- {
- if (column.Hidden || column.Tag == null || string.IsNullOrEmpty(column.Tag.ToString())) continue;
- string ChemFormula = column.Tag.ToString().ToUpper();
- ChemFormula = ChemFormula.Replace("AS", "ASN");
-
- //string[] str = ChemFormula.Split(new char[6] { '+', '-', '*', '/','(',')' });
- //foreach (string s in str)
- //{
- // foreach (DataColumn DataColumn in dtData.Columns)
- // {
- // if (dataRow[s] == null) continue;
- // ChemFormula = ChemFormula.Replace(s, dataRow[s].ToString());
-
- // }
- //}
- foreach (DataColumn DataColumn in dtData.Columns)
- {
- if (dataRow[DataColumn.ColumnName] == null) continue;
- ChemFormula = ChemFormula.Replace(DataColumn.ColumnName.Replace("ASN", "AS"),
- dataRow[DataColumn.ColumnName].ToString());
- }
- try
- {
- tempRow[column.Key] = Math.Round(double.Parse(new DataTable().Compute(ChemFormula, null).ToString()), 4);
- }
- catch (Exception)
- {
- tempRow[column.Key] = null;
- }
- }
- tempRow["SAMPLE_NO"] = dataRow["ASSAYNO"];
- tempRow["CIC"] = dataRow["STOVE_NO"];
- dtChem.Rows.Add(tempRow);
- countStov++;
- }
- }
- ulgridElement.Refresh();
- BaseHelper.setOtherColumnReadOnly(ulgridElement, new[] { "Check" });
- GridHelper.RefreshAndAutoSize(ulgridElement);
- BaseHelper.ForbidSort(ulgridElement);
- ulgridElement.DisplayLayout.Bands[0].Columns["CIC"].MergedCellStyle = MergedCellStyle.Always;
- ulgridElement.DisplayLayout.Bands[0].Columns[0].CellAppearance.FontData.Bold = DefaultableBoolean.True;
- if (ulgridElement.Rows.Count > countMes)
- {
- ulgridElement.Rows[countMes].Activate();
- }
- }
- private void ulgridElement_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- GridActiveDele();
- }
- private void ultraGridChoose_CellChange(object sender, CellEventArgs e)
- {
- UltraGridRow row = ultraGridChoose.ActiveRow;
- ultraGridChoose.UpdateData();
-
- if (e.Cell.Column.Key.Equals("CutTybe"))
- {
- if (row.Cells["CutTybe"].Text.ToString().Equals("切坯"))
- {
- row.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["ActLenTake"].Activation = Activation.AllowEdit;
- row.Cells["ActLenTake"].IgnoreRowColActivation = true;
- row.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["FixLenTake"].Activation = Activation.AllowEdit;
- row.Cells["FixLenTake"].IgnoreRowColActivation = true;
- row.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["CutTarget"].Activation = Activation.AllowEdit;
- row.Cells["CutTarget"].IgnoreRowColActivation = true;
- }
- else
- {
- row.Cells["ActLenTake"].Appearance.ResetBackColor();
- row.Cells["ActLenTake"].Activation = Activation.ActivateOnly;
- row.Cells["ActLenTake"].IgnoreRowColActivation = true;
- row.Cells["FixLenTake"].Appearance.ResetBackColor();
- row.Cells["FixLenTake"].Activation = Activation.ActivateOnly;
- row.Cells["FixLenTake"].IgnoreRowColActivation = true;
- row.Cells["CutTarget"].Value = "";
- row.Cells["CutTarget"].Appearance.ResetBackColor();
- row.Cells["CutTarget"].Activation = Activation.ActivateOnly;
- row.Cells["CutTarget"].IgnoreRowColActivation = true;
- }
- }
- //输入支数
- if (e.Cell.Column.Key.Equals("TakeCount"))
- {
- //double dimater = 0;
- //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
- //{
- // dimater = 250;
- //}
- //else
- //{
- // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
- //}
- //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
- //// 倍尺坯长
- //double lenLong = double.Parse(row.Cells["ActLenTake"].Value.ToString());
- //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
- //double weightM = mSingleWeight * (lenLong / 1000);
- // 单倍坯重
- //double weightGpOne = mSingleWeight
- // * (double.Parse(row.Cells["FixLenTake"].Value.ToString()) / 1000);
- if (e.Cell.Row.Cells["TakeCount"].Value == null)
- {
- row.Cells["TakeCount"].Value = row.Cells["ActCount"].Value.ToString();
- }
- else
- {
- string actLen = e.Cell.Row.Cells["TakeCount"].Value.ToString();
- if (!StringUtil.IsInt(actLen) || actLen == "0")
- {
- e.Cell.Row.Cells["TakeWeight"].Value = 0;
- }
- else
- {
- //查询库存重量
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialSelection.queryMatWeigth",
- new object[] { row.Cells["JudgeStoveNo"].Value.ToString(), row.Cells["CutNumGp"].Value.ToString(), row.Cells["ActLen"].Value.ToString(), row.Cells["FixLen"].Value.ToString(), actLen }, _ob);
- if (dt.Rows.Count > 0)
- {
- e.Cell.Row.Cells["TakeWeight"].Value = dt.Rows[0]["ACT_WEIGHT"].ToString();
- }
- }
- }
- }
- ///输入使用坯长
- if (e.Cell.Column.Key.Equals("ActLenTake"))
- {
- //double dimater = 0;
- //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
- //{
- // dimater = 250;
- //}
- //else
- //{
- // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
- //}
- //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
- // 单倍坯重
- //double weightGpOne = mSingleWeight
- // * (double.Parse(row.Cells["FixLenTake"].Value.ToString()) / 1000);
- if (e.Cell.Row.Cells["ActLenTake"].Value == null)
- {
- row.Cells["TakeCount"].Value = row.Cells["ActCount"].Value.ToString();
- }
- else
- {
- string actLen = e.Cell.Row.Cells["ActLenTake"].Value.ToString();
- if (!StringUtil.IsInt(actLen) || actLen == "0")
- {
- e.Cell.Row.Cells["ActLenTake"].Value = 0;
- row.Cells["FixNum"].Value = "1";
- e.Cell.Row.Cells["CutYuLong"].Value = row.Cells["ActLen"].Value.ToString();
- }
- else
- {
- if (int.Parse(actLen) > int.Parse(row.Cells["ActLen"].Value.ToString()))
- {
- actLen = row.Cells["ActLen"].Value.ToString();
- e.Cell.Row.Cells["ActLenTake"].Value = row.Cells["ActLen"].Value.ToString();
- e.Cell.Row.Cells["CutYuLong"].Value = "0";
- }
- else
- {
- e.Cell.Row.Cells["CutYuLong"].Value = (int.Parse(row.Cells["ActLen"].Value.ToString()) - int.Parse(actLen)).ToString();
- }
- if (double.Parse(actLen) / double.Parse(row.Cells["FixLenTake"].Value.ToString()) < 1)
- {
- row.Cells["FixNum"].Value = "1";
- }
- else
- {
- row.Cells["FixNum"].Value = (double.Parse(actLen) / double.Parse(row.Cells["FixLenTake"].Value.ToString())).ToString("f3");
- }
- //// 倍尺坯长
- //double lenLong = double.Parse(actLen);
- //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
- //double weightM = mSingleWeight * (double.Parse(actLen) / 1000);
- //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
- double lenGpSingle = double.Parse(row.Cells["ActLenTake"].Value.ToString());
- Recalcu(lenGpSingle, row);
- }
- }
- }
- //使用单倍坯长
- if (e.Cell.Column.Key.Equals("FixLenTake"))
- {
- //double dimater = 0;
- //if (row.Cells["Dimater"].Value.ToString().Equals("251"))
- //{
- // dimater = 250;
- //}
- //else
- //{
- // dimater = double.Parse(row.Cells["Dimater"].Value.ToString());
- //}
- //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
- if (e.Cell.Row.Cells["FixLenTake"].Value == null)
- {
- row.Cells["FixLenTake"].Value = row.Cells["FixLen"].Value.ToString();
- }
- else
- {
- string actLen = e.Cell.Row.Cells["FixLenTake"].Value.ToString();
- if (!StringUtil.IsInt(actLen) || actLen == "0")
- {
- e.Cell.Row.Cells["FixLenTake"].Value = row.Cells["FixLen"].Value.ToString();
- }
- else
- {
- double lenGpSingle = double.Parse(row.Cells["FixLenTake"].Value.ToString());
- //row.Cells["ActLenTake"].Value = lenGpSingle * row.Cells["FixNum"].Value;
- row.Cells["FixNum"].Value = ((int)(double.Parse(row.Cells["ActLen"].Value.ToString()) / lenGpSingle)).ToString();
- row.Cells["ActLenTake"].Value = (lenGpSingle * int.Parse(row.Cells["FixNum"].Value.ToString()));
- //// 倍尺坯单支重=坯米单重*倍尺坯长/1000
- //double weightM = mSingleWeight * (double.Parse(row.Cells["ActLenTake"].Value.ToString()) / 1000);
- //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
- e.Cell.Row.Cells["CutYuLong"].Value = double.Parse(row.Cells["ActLen"].Value.ToString()) - double.Parse(row.Cells["ActLenTake"].Value.ToString());
- Recalcu(lenGpSingle,row);
- }
- }
- }
- if (e.Cell.Column.Key.Equals("CHC"))
- {
- //int dimater = int.Parse(row.Cells["Dimater"].Value.ToString());
- //if (dimater==251)
- //{
- // dimater = 250;
- //}
- //double mSingleWeight = (7.8 * 3.1415926 / 4 * dimater * dimater) / 1000 / 1000;//米单重
- double lenGpSingle = double.Parse(row.Cells["FixLenTake"].Value.ToString());
- 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();
- row.Cells["ActLenTake"].Value = int.Parse(e.Cell.Row.Cells["FixNum"].Value.ToString()) * double.Parse(row.Cells["FixLenTake"].Value.ToString());
- // 倍尺坯单支重=坯米单重*倍尺坯长/1000
- //double weightM = mSingleWeight * (double.Parse(row.Cells["ActLenTake"].Value.ToString()) / 1000);
- //e.Cell.Row.Cells["TakeWeight"].Value = (int.Parse(row.Cells["TakeCount"].Value.ToString()) * weightM).ToString("f3");
- e.Cell.Row.Cells["CutYuLong"].Value = double.Parse(row.Cells["ActLen"].Value.ToString()) - double.Parse(row.Cells["ActLenTake"].Value.ToString());
- if (double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) > 0)
- {
- row.Cells["CutTybe"].Value = "切坯";
- row.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["ActLenTake"].Activation = Activation.AllowEdit;
- row.Cells["ActLenTake"].IgnoreRowColActivation = true;
- row.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["FixLenTake"].Activation = Activation.AllowEdit;
- row.Cells["FixLenTake"].IgnoreRowColActivation = true;
- row.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- row.Cells["CutTarget"].Activation = Activation.AllowEdit;
- row.Cells["CutTarget"].IgnoreRowColActivation = true;
- }
- Recalcu(lenGpSingle, row);
- if (double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) != 0)
- {
- if (minLengthRing - double.Parse(e.Cell.Row.Cells["CutYuLong"].Value.ToString()) > 0)
- {
- row.Cells["CutTarget"].Value = "套尺";
- }
- else
- {
- row.Cells["CutTarget"].Value = "回库";
- }
- }
- }
-
- int xzNum = 0;
- double xzWt = 0;
- ultraGroupBox2.Text = "管坯物料信息";
- foreach (UltraGridRow ugr in ultraGridChoose.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHC"].Text) == true)
- {
- xzNum += int.Parse(ugr.Cells["TakeCount"].Value.ToString());
- xzWt += double.Parse(ugr.Cells["TakeWeight"].Value.ToString());
- }
- }
- ultraGroupBox2.Text = ultraGroupBox2.Text + " 支:" + xzNum + " 吨:" + xzWt.ToString("f3");
- }
- private int splitterDistance = 0;
- private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
- {
- if (ultraExpandableGroupBox1.Expanded == false)
- {
- this.splitContainer1.SplitterDistance = splitContainer1.Size.Height - 26;
- }
- else
- {
- this.splitContainer1.SplitterDistance = splitterDistance == 0 ? splitContainer1.Size.Height / 2 : splitterDistance;
- }
- }
- private void GridActiveDele()
- {
- UltraGridRow row = ulgridElement.ActiveRow;
- if (row == null) return;
- if (row.Index < countMes) return;
- //foreach (UltraGridRow row in ulgridElement.Rows)
- //{
- foreach (var Cell in row.Cells)
- {
- string ColumnsName = Cell.Column.Key;
- if (ColumnsName.Equals("SAMPLE_NO")) continue;
- if (ColumnsName.Equals("CIC")) continue;
- if (ColumnsName.Equals("STOVE_NO")) continue;
- if (ColumnsName.Equals("ASSAYNO")) continue;
- for (int i = 0; i < countMes - 1; i = i + 2)
- {
- int Result = SteelManagementHelper.CompareChem(Cell.Value, ulgridElement.Rows[i].Cells[ColumnsName].Value,
- ulgridElement.Rows[i + 1].Cells[ColumnsName].Value);
- if (Result == 2) { Cell.Appearance.ResetBackColor(); }
- else if (Result > 0)
- {
- ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.Red;
- ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.Red;
- }
- else if (Result < 0)
- {
- ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.Yellow;
- ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.Yellow;
- }
- else
- {
- ulgridElement.Rows[i].Cells[ColumnsName].Appearance.BackColor = Color.LightGreen;
- ulgridElement.Rows[i + 1].Cells[ColumnsName].Appearance.BackColor = Color.LightGreen;
- //Cell.Appearance.BackColor = Color.LightGreen;
- }
- }
- //}
- }
- }
- private void ulgridElement_AfterRowActivate(object sender, EventArgs e)
- {
- try
- {
- this.Cursor = Cursors.WaitCursor;
- ulgridElement.BeginUpdate();
- DataRowView dataRow = (DataRowView)ulgridElement.ActiveRow.ListObject;
- if (dataRow["SAMPLE_NO"].ToString().Contains("限"))
- {
- return;
- }
- GridActiveDele();
- }
- finally
- {
- ulgridElement.EndUpdate();
- this.Cursor = Cursors.Default;
- }
- }
- private void ultraGridChoose_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ultraGridChoose.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHC"].Value = true;
- }
- }
- int xzNum = 0;
- double xzWt = 0;
- ultraGroupBox2.Text = "管坯物料信息";
- foreach (UltraGridRow ugr in ultraGridChoose.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHC"].Text) == true)
- {
- xzNum += int.Parse(ugr.Cells["TakeCount"].Value.ToString());
- xzWt += double.Parse(ugr.Cells["TakeWeight"].Value.ToString());
-
- double lenGpSingle = double.Parse(ugr.Cells["FixLenTake"].Value.ToString());
- ugr.Cells["FixNum"].Value = ((int)(double.Parse(ugr.Cells["ActLenTake"].Value.ToString()) / double.Parse(ugr.Cells["FixLenTake"].Value.ToString()))).ToString();
- ugr.Cells["ActLenTake"].Value = int.Parse(ugr.Cells["FixNum"].Value.ToString()) * double.Parse(ugr.Cells["FixLenTake"].Value.ToString());
- ugr.Cells["CutYuLong"].Value = double.Parse(ugr.Cells["ActLen"].Value.ToString()) - double.Parse(ugr.Cells["ActLenTake"].Value.ToString());
- if (double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) > 0)
- {
- ugr.Cells["CutTybe"].Value = "切坯";
- ugr.Cells["ActLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- ugr.Cells["ActLenTake"].Activation = Activation.AllowEdit;
- ugr.Cells["ActLenTake"].IgnoreRowColActivation = true;
- ugr.Cells["FixLenTake"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- ugr.Cells["FixLenTake"].Activation = Activation.AllowEdit;
- ugr.Cells["FixLenTake"].IgnoreRowColActivation = true;
- ugr.Cells["CutTarget"].Appearance.BackColor = Color.FromArgb(255, 255, 128);
- ugr.Cells["CutTarget"].Activation = Activation.AllowEdit;
- ugr.Cells["CutTarget"].IgnoreRowColActivation = true;
- }
- if (double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) != 0)
- {
- if (minLengthRing - double.Parse(ugr.Cells["CutYuLong"].Value.ToString()) > 0)
- {
- ugr.Cells["CutTarget"].Value = "套尺";
- }
- else
- {
- ugr.Cells["CutTarget"].Value = "回库";
- }
- }
- Recalcu(lenGpSingle, ugr);
- }
- }
- ultraGroupBox2.Text = ultraGroupBox2.Text + " 支:" + xzNum + " 吨:" + xzWt.ToString("f3");
- }
- string inMaterialNoZg = "";
- private void ultraGridZgS_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow row = ultraGridZgS.ActiveRow;
- if (row == null) return;
- inMaterialNoZg = row.Cells["InwlId"].Value.ToString();
- string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Value.ToString();
- string indexSeq = row.Cells["IndexSeq"].Value.ToString();
- string carftSeq = row.Cells["CraftSeq"].Value.ToString();
- QueryCic(ordLnDlyPk, indexSeq, carftSeq);
- QueryBom(ordLnDlyPk, indexSeq, carftSeq);
- Query();
- }
- DataTable dtCic = new DataTable();
- private void QueryCic(string ordLnDlyPk, string indexSeq, string carftSeq)
- {
- dtCic = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.StoveHelper.queryCic", new object[] { ordLnDlyPk, indexSeq, carftSeq }, _ob);
- GridHelper.CopyDataToDatatable(dtCic, dataTable2, true);
- GridHelper.RefreshAndAutoSize(entityGrid2);
- foreach (UltraGridRow ugr in entityGrid2.Rows)
- {
- ugr.Cells["CHC"].Value = "指定";
- }
- }
- /// <summary>
- /// 查询符合条件的投入产出物料Bom
- /// </summary>
- private void QueryBom(string ordLnDlyPk, string indexSeq, string carftSeq)
- {
- string inMaterialNoBom = "";
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.planStove.FrmPlanMaterialDbk.queryBaseMaterial", new object[] { ordLnDlyPk, indexSeq, carftSeq, "D" }, _ob);
- GridHelper.CopyDataToDatatable(dt, dataTable1, true);
- GridHelper.RefreshAndAutoSize(entityGrid1);
- if (dt.Rows.Count <= 0) return;
- foreach (UltraGridRow item in entityGrid1.Rows)
- {
- if (item.Cells["IN_MATERIAL_NO"].Text.ToString().Equals(inMaterialNoZg))
- {
- item.Appearance.BackColor = Color.Orange;
- item.Activate();
- }
- }
- //if (!inMaterialNoBom.Equals(""))
- //{
- // inMaterialNo = inMaterialNoBom.Substring(0, inMaterialNoBom.Length - 1);
- //}
- }
- private void entityGrid2_ClickCellButton(object sender, CellEventArgs e)
- {
- UltraGridRow row = ultraGridChoose.ActiveRow;
- if (row == null) return;
- if (e.Cell.Column.Key.Equals("CHC"))
- {
- UltraGridRow rowCic = entityGrid2.ActiveRow;
- if (rowCic == null) return;
- row.Cells["SpecCic"].Value = rowCic.Cells["CIC"].Value.ToString();
- }
- }
- private void ultraGridChoose_ClickCellButton(object sender, CellEventArgs e)
- {
- UltraGridRow row = ultraGridChoose.ActiveRow;
- if (row == null) return;
- if (e.Cell.Column.Key.Equals("SpecCic"))
- {
- e.Cell.Row.Cells["SpecCic"].Value = "";
- }
- }
- private void cmbAcount_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- this.ultraGridChoose.UpdateData();
- UltraGridRow row = this.ultraGridChoose.ActiveRow;
- if (row == null)
- {
- return;
- }
- FrmMatGpInfo frm = new FrmMatGpInfo(row, _ob);
- frm.ShowDialog();
- if (frm.flag.Equals("1"))
- {
- row.Cells["MatNo"].Value = frm.matNo.TrimEnd(new char[] { ',' }).ToString();
- row.Cells["TakeCount"].Value = frm.count.ToString();
- }
- else
- {
- return;
- }
- }
- }
- }
|