| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819 |
- using Core.Mes.Client.Comm.Tool;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Core.StlMes.Client.PlnSaleOrd.PlanStove.entity;
- using CoreFS.CA06;
- using CoreFS.SA06;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Control;
- using Infragistics.Win.UltraWinGrid;
- using System.Text.RegularExpressions;
- namespace Core.StlMes.Client.PlnSaleOrd.PlanStove.Dlg
- {
- public partial class FrmMaterialSeparate : FrmBase
- {
- private string m_userName;
- private bool isFirstInit=true;
- //action
- public event Action OnDataChange;
- public FrmMaterialSeparate(string _CustomInfo,OpeBase _ob,string _userName)
- {
- InitializeComponent();
- this.CustomInfo = _CustomInfo;
- this.ob = _ob;
- m_userName = _userName;
- this.ultraGrid1.CellChange += ultraGrid1_CellChange;
- this.ultraGrid1.AfterRowActivate += ultraGrid1_AfterRowActivate;
- this.ultraGrid2.CellChange += ultraGrid2_CellChange;
- }
- private void FrmMaterialSeprate_Load(object sender, EventArgs e)
- {
- switch (CustomInfo)
- {
- case CustomInfoDef.DEFINE_CUSTOMER_DBK:
- this.ultraGrid2.DataSource = this.plnZyDbkMEntityBindingSource;
- this.ultraGrid2.DataBind();
- EntityHelper.ShowGridCaption<PlnZyDbkMEntity>(this.ultraGrid2.DisplayLayout.Bands[0]);
- AddZYChooseColumn(0);
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_JG:
- this.ultraGrid2.DataSource = this.plnZyJgxMEntityBindingSource;
- this.ultraGrid2.DataBind();
- EntityHelper.ShowGridCaption<PlnZyJgxMEntity>(this.ultraGrid2.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<PlnZyJgxCEntity>(this.ultraGrid2.DisplayLayout.Bands[1]);
- AddZYChooseColumn(1);
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_RCL:
- this.ultraGrid2.DataSource = this.plnZyRclMEntityBindingSource;
- this.ultraGrid2.DataBind();
- EntityHelper.ShowGridCaption<PlnZyRclMEntity>(this.ultraGrid2.DisplayLayout.Bands[0]);
- AddZYChooseColumn(0);
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_ZG:
- this.ultraGrid2.DataSource = this.plnZyZgMEntityBindingSource;
- this.ultraGrid2.DataBind();
- EntityHelper.ShowGridCaption<PlnZyZgMEntity>(this.ultraGrid2.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<PlnZyZgCEntity>(this.ultraGrid2.DisplayLayout.Bands[1]);
- AddZYChooseColumn(1);
- break;
- }
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["HeatPlanNo"].Header.Caption = "炉计划号";
- AddZYEditedColumn();
- CommHelper.SetGridColNoEdit(this.ultraGrid1.DisplayLayout.Bands[0], new string[] { "Choose", "USER_ACT_COUNT" });
- CommHelper.SetGridColNoEdit(this.ultraGrid2.DisplayLayout.Bands[0], new string[] { "ChooseZY", "USER_ACT_COUNT" });
- if (this.ultraGrid2.DisplayLayout.Bands.Count > 1)
- {
- CommHelper.SetGridColNoEdit(this.ultraGrid2.DisplayLayout.Bands[1], new string[] { "USER_ACT_COUNT" });
- }
- queryMat();
- CommHelper.SetColumnAutoFitSize1(this.ultraGrid1.DisplayLayout.Bands[0]);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "PlineName", 1);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "OrderNo", 2);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "OrderSeq", 3);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "USER_ACT_COUNT", 4);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "InNum", 5);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "USER_ACT_WEIGHT", 6);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "InWt", 7);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "ProPlanId", 8);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "GxPlanNo", 9);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "HeatPlanNo", 10);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "HeatnoLast", 11);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "ZgBatchNo", 12);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "LastBatchNo", 13);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "BatchGroudNo", 14);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "OrderSource", 15);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "OutNum", 16);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "OutWt", 17);
- CommHelper.SetColumsHide(this.ultraGrid2.DisplayLayout.Bands[0], new List<string>() { "PlineCode", "InwlId" });
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["OrderSource"].Header.Caption = "主合同来源";
- this.ultraGrid2.DisplayLayout.Bands[0].Columns["Planstatus"].Header.Caption = "执行状态";
- }
- #region 初始化
- /// <summary>
- /// 往作业计划表中加入选择列,如果有子表,insertIndex应为1
- /// </summary>
- /// <param name="insertIndex"></param>
- private void AddZYChooseColumn(int insertIndex)
- {
- Infragistics.Win.UltraWinGrid.UltraGridColumn col = CommHelper.InsertColumn("ChooseZY", "", this.ultraGrid2.DisplayLayout.Bands[0], insertIndex);
- col.DataType = typeof(bool);
- col.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
- col.CellAppearance.BackColor = Color.Yellow;
- col.Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
- }
- private void AddZYEditedColumn()
- {
- UltraGridColumn col = CommHelper.InsertColumn("USER_ACT_COUNT", "脱单支数", this.ultraGrid2.DisplayLayout.Bands[0], 4);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "InNum", 5);
- col.DataType = typeof(long);
- col.EditorComponent = this.ultraNumericEditor1;
- col.MaskInput = "";
- col.PromptChar = ' ';
- col.CellAppearance.BackColor = Color.Yellow;
- if (ultraGrid2.DisplayLayout.Bands.Count > 1)
- {
- UltraGridColumn childcol = CommHelper.InsertColumn("USER_ACT_COUNT", "脱单支数", this.ultraGrid2.DisplayLayout.Bands[1], 4);
- childcol.EditorComponent = this.ultraNumericEditor1;
- childcol.DataType = typeof(long);
- childcol.MaskInput = "";
- childcol.PromptChar = ' ';
- childcol.CellAppearance.BackColor = Color.Yellow;
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[1], "InGpNum", 5);
- UltraGridColumn childcol1 = CommHelper.InsertColumn("USER_ACT_WEIGHT", "脱单重量", this.ultraGrid2.DisplayLayout.Bands[1], 6);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[1], "InGpWt", 7);
- }
- else
- {
- UltraGridColumn col1 = CommHelper.InsertColumn("USER_ACT_WEIGHT", "脱单重量", this.ultraGrid2.DisplayLayout.Bands[0], 6);
- CommHelper.SetColumnPosition(this.ultraGrid2.DisplayLayout.Bands[0], "InWt", 7);
- }
-
- }
- #endregion
- #region 控件事件
- void ultraGrid2_CellChange(object sender, CellEventArgs e)
- {
- this.ultraGrid2.UpdateData();
- if (e.Cell.Column.Key.Equals("USER_ACT_COUNT"))
- {
- if (!Regex.IsMatch(e.Cell.Value.ToString().Trim(), @"^-?[1-9]\d*$|^0$"))
- {
- e.Cell.Value = 0;
- return;
- }
- }
- if (e.Cell.Text != null)
- {
- if (!e.Cell.Row.HasParent() && e.Cell.Column.Key.Equals("USER_ACT_COUNT"))
- {
- if ( e.Cell.Row.Cells["ChooseZY"].Text.Equals("True"))
- {
- e.Cell.Value = 0;
- return;
- }
- if (Convert.ToInt64(e.Cell.Value) != 0)
- {
- long user_act_count = Convert.ToInt64(e.Cell.Value);
- long act_count = 0;
- if (CustomInfo != CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- act_count = Convert.ToInt64(e.Cell.Row.Cells["InNum"].Text);
- }
- else
- {
- act_count = Convert.ToInt64(e.Cell.Row.Cells["PlanGpNum"].Text);
- }
-
- int nTotalCount=0;
- var matrow = this.ultraGrid1.Rows.FirstOrDefault(c => c.Cells["Choose"].Text.Equals("True"));
- int maxCount = 0;
- if (!String.IsNullOrEmpty(matrow.Cells["USER_ACT_COUNT"].Text.Trim()))
- {
- maxCount = Convert.ToInt32(matrow.Cells["USER_ACT_COUNT"].Value);
- }
- var rows = this.ultraGrid2.Rows.Where(c => !String.IsNullOrEmpty(c.Cells["USER_ACT_COUNT"].Text) && c.Cells["ChooseZY"].Text.Equals("True"));
- foreach(var row in rows)
- {
- nTotalCount += Convert.ToInt32(row.Cells["USER_ACT_COUNT"].Value);
- }
- if (nTotalCount > maxCount || user_act_count > act_count)
- {
- e.Cell.Value = e.Cell.OriginalValue;
- }
- else
- {
- UltraGridRow childrow =null;
- double act_weight = 0;
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- childrow = e.Cell.Row.ChildBands[0].Rows.FirstOrDefault(c => c.Cells["LengthGp"].Text.Trim().Equals(matrow.Cells["ACT_LEN"].Text.Trim()));
- act_weight =Convert.ToDouble(childrow.Cells["InGpWt"].Text);
- }
- else
- {
- act_weight = Convert.ToDouble(e.Cell.Row.Cells["InWt"].Value);
- }
-
- double single_weight = act_weight / act_count;
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- }
- else
- {
- e.Cell.Row.Cells["USER_ACT_WEIGHT"].Value = CommHelper.GetSpecDecimalBit(user_act_count * single_weight, 3);
- }
-
- e.Cell.Appearance.BackColor = System.Drawing.Color.Pink;
- }
- }
- else
- {
- e.Cell.Row.Cells["USER_ACT_WEIGHT"].Value = 0;
- }
- }
- else if (e.Cell.Column.Key.Equals("ChooseZY"))
- {
- if (e.Cell.Text.ToLower() == "true")
- {
- e.Cell.Row.Cells["USER_ACT_COUNT"].Activation = Activation.AllowEdit;
- }
- else
- {
- e.Cell.Row.Cells["USER_ACT_COUNT"].Value = 0 ;
- }
- }
- }
- }
- void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- this.ultraGrid1.UpdateData();
-
- //throw new NotImplementedException();
- }
- void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- this.ultraGrid1.UpdateData();
- if (e.Cell.Column.Key.Equals("USER_ACT_COUNT"))
- {
- if (!Regex.IsMatch(e.Cell.Value.ToString(), @"^-?[1-9]\d*$|^0$"))
- {
- e.Cell.Value = 0;
- return;
- }
- }
- if (e.Cell.Text != null)
- {
- if (e.Cell.Column.Key.Equals("USER_ACT_COUNT"))
- {
- if (!e.Cell.Row.Cells["Choose"].Text.Equals("True"))
- {
- e.Cell.Value = e.Cell.OriginalValue;
- return;
- }
- long user_act_count = Convert.ToInt64(e.Cell.Value);
- long act_count = Convert.ToInt64(e.Cell.Row.Cells["ACT_COUNT"].Value);
- if (user_act_count > act_count)
- {
- e.Cell.Value = e.Cell.OriginalValue;
- }
- else
- {
- double act_weight = Convert.ToDouble(e.Cell.Row.Cells["ACT_WEIGHT"].Value);
- double single_weight = act_weight / act_count;
- e.Cell.Row.Cells["USER_ACT_WEIGHT"].Value = CommHelper.GetSpecDecimalBit(user_act_count * single_weight, 3);
- e.Cell.Appearance.BackColor = System.Drawing.Color.Pink;
- if (this.ultraGrid2.Rows.Count > 0)
- {
- setUserActCount(user_act_count, e.Cell.Row.Cells["ACT_LEN"].Value);
- }
- this.ultraGrid1.Refresh();
- }
-
- }
- else if (e.Cell.Column.Key.Equals("Choose"))
- {
- if (e.Cell.Text.ToLower() == "true")
- {
- e.Cell.Row.Cells["USER_ACT_COUNT"].Activation = Activation.AllowEdit;
- this.ultraGrid1.Refresh();
- var rows = this.ultraGrid1.Rows.Where(c => c.Cells["Choose"].Text.ToLower() == "true");
- if (rows.Count() > 1)
- {
- e.Cell.Row.Cells["Choose"].Value = false;
- }
- else if(rows.Count() == 1)
- {
- var row = rows.First();
- InitZYData(row.Cells["JUDGE_STOVE_NO"].Text, row.Cells["BATCH_NO"].Text, row.Cells["BATCH_GROUD_NO"].Text, row.Cells["PRO_ORDER_ID"].Text, row.Cells["GX_PLAN_NO"].Text);
- }
- }
- else
- {
- e.Cell.Row.Cells["USER_ACT_COUNT"].Value = 0;
- switch (CustomInfo)
- {
- case CustomInfoDef.DEFINE_CUSTOMER_DBK:
- this.plnZyDbkMEntityBindingSource.Clear();
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_JG:
- this.plnZyJgxMEntityBindingSource.Clear();
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_RCL:
- this.plnZyRclMEntityBindingSource.Clear();
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_ZG:
- this.plnZyZgMEntityBindingSource.Clear();
- break;
- }
- }
- }
- }
- //throw new NotImplementedException();
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "separate": separate(); break;
- case "close":
- if (OnDataChange != null)
- {
- OnDataChange();
- }
- this.Close();
- break;
- case "search": queryMat(); break;
- }
- }
- #endregion
- #region 数据库操作
- private void InitZYData(string stoveNo, string BatchNo, string BatchGroupNo, string proPlanId, string GxPlanNo)
- {
- Object[] parameters = new object[] { stoveNo, BatchNo, BatchGroupNo, proPlanId, GxPlanNo };
- switch (CustomInfo)
- {
- case CustomInfoDef.DEFINE_CUSTOMER_DBK:
- var datasourcedbkM = EntityHelper.GetData<PlnZyDbkMEntity>(MethodDef.PlanLuDBK.queryZYDBK, parameters, this.ob);
- this.plnZyDbkMEntityBindingSource.DataSource = datasourcedbkM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_JG:
- var datasourcesjgxM = EntityHelper.GetData<PlnZyJgxMEntity>(MethodDef.PlanLuJGX.queryZYJGXM, parameters, this.ob);
- var datasourcesjgxC = EntityHelper.GetData<PlnZyJgxCEntity>(MethodDef.StoveBase.queryZy, new Object[] { SqlIDDef.PlanLuJGX.queryZYJGXC }, this.ob);
- EntityHelper.AddEntityRelation<PlnZyJgxMEntity, PlnZyJgxCEntity>(datasourcesjgxM, datasourcesjgxC, "HeatPlanNo", "HeatPlanNo");
- this.plnZyJgxMEntityBindingSource.DataSource = datasourcesjgxM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_RCL:
- var datasourcerclM = EntityHelper.GetData<PlnZyRclMEntity>(MethodDef.PlanLuRCL.queryZYRCL, parameters, this.ob);
- this.plnZyRclMEntityBindingSource.DataSource = datasourcerclM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_ZG:
- var datasourcesZgM = EntityHelper.GetData<PlnZyZgMEntity>(MethodDef.PlanLuZG.queryZYZGM, parameters, this.ob);
- var datasourcesZgC = EntityHelper.GetData<PlnZyZgCEntity>(MethodDef.StoveBase.queryZy, new Object[] { SqlIDDef.PlanLuZG.queryZYZGC }, this.ob);
- EntityHelper.AddEntityRelation<PlnZyZgMEntity, PlnZyZgCEntity>(datasourcesZgM, datasourcesZgC, "HeatPlanNo", "HeatPlanNo");
- this.plnZyZgMEntityBindingSource.DataSource = datasourcesZgM;
- break;
- }
- if (isFirstInit)
- {
- CommHelper.SetColumnAutoFitSize1(this.ultraGrid2.DisplayLayout.Bands[0]);
- if (this.ultraGrid2.DisplayLayout.Bands.Count > 1)
- {
- CommHelper.SetColumnAutoFitSize1(this.ultraGrid2.DisplayLayout.Bands[1]);
- }
- isFirstInit = false;
- }
- }
- private void separate()
- {
- var matrow = this.ultraGrid1.Rows.FirstOrDefault(c => c.Cells["Choose"].Text.Equals("True"));
- if (matrow == null)
- {
- MessageUtil.ShowWarning("没有勾选物料!");
- return;
- }
- int maxCount = 0;
- if (!String.IsNullOrEmpty(matrow.Cells["USER_ACT_COUNT"].Text.Trim()))
- {
- maxCount = Convert.ToInt32(matrow.Cells["USER_ACT_COUNT"].Text.Trim());
- }
- int nTotalCount = 0;
-
- var rows = this.ultraGrid2.Rows.Where(c => !String.IsNullOrEmpty(c.Cells["USER_ACT_COUNT"].Text) && c.Cells["ChooseZY"].Text.Equals("True"));
- if (rows.Count() <= 0)
- {
- MessageUtil.ShowTips("没有勾选作业计划或者没有指定脱单量,脱单时需要指定作业计划以及脱单量!");
- return;
- }
- foreach (var row in rows)
- {
- if (row.HasChild())
- {
- var childrows = row.ChildBands[0].Rows.Where(c=>!CommHelper.IsNullOrEmptry(c.Cells["USER_ACT_COUNT"].Text));
- foreach(var childRow in childrows)
- {
- nTotalCount += Convert.ToInt32(childRow.Cells["USER_ACT_COUNT"].Text);
- }
- }
- else
- {
- nTotalCount += Convert.ToInt32(row.Cells["USER_ACT_COUNT"].Text);
- }
-
- }
- if (nTotalCount != maxCount)
- {
- MessageUtil.ShowError("所选物料脱单支数和计划脱单支数不一致,请检查输入!");
- return;
- }
- List<string> sqlidList = new List<string>();
- List<List<Object>> parameters = new List<List<object>>();
- foreach (var row in rows)//针对所选的作业计划逐行脱单
- {
- int sepOutNum = 0;//脱单的计划产出数
- double sepOutWt = 0;//脱单的计划产出重量
- int sepcount = Convert.ToInt32(row.Cells["USER_ACT_COUNT"].Text);//脱单支数
- int innum = 0;
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- if (!row.Cells["Planstatus"].Text.Trim().Equals("计划"))
- {
- MessageUtil.ShowWarning("轧管只允状态为计划的作业计划进行脱单");
- return;
- }
- if(row.HasChild())
- {
- innum = Convert.ToInt32(row.ChildBands[0].Rows.FirstOrDefault(c => c.Cells["LengthGp"].Text.Trim().Equals(matrow.Cells["ACT_LEN"].Text.Trim())).Cells["InGpNum"].Value);
- }
- else
- {
- continue;
- }
- }
- else
- {
- innum = Convert.ToInt32(row.Cells["InNum"].Text);//原投入支数;
- }
- double singleinwt = Convert.ToDouble(matrow.Cells["ACT_WEIGHT"].Text) / Convert.ToInt32(matrow.Cells["ACT_COUNT"].Text);//投入料单支重量
- double singleoutwt = Convert.ToDouble(row.Cells["OutWt"].Value) / Convert.ToInt32(row.Cells["OutNum"].Value);//产出料单支重量
- string sqlIdDelete = "";
- string sqlUpdateZy = "";
- string sqlIdUpdateMatBack = SqlIDDef.MaterialChoose.updateMaterialBack;
- string sqlIdUpdateBatch = "";
- string sqlIdUpdateMatch = "";
- switch (CustomInfo)
- {
- case CustomInfoDef.DEFINE_CUSTOMER_DBK:
- sqlIdDelete = SqlIDDef.PlanLuDBK.deleteZyDbkM;
- sqlUpdateZy = SqlIDDef.PlanLuDBK.UpdateZYDBK_WT_NUM;
- sqlIdUpdateBatch = SqlIDDef.PlanLuDBK.UpdateOrderDBK_WT_NUM;
- sqlIdUpdateMatch = SqlIDDef.PlanLuDBK.UpdateOrderDBK_MATCH_WT_NUM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_JG:
- sqlIdDelete = SqlIDDef.PlanLuJGX.deleteZyJgxM;
- sqlUpdateZy = SqlIDDef.PlanLuJGX.UpdateZYJGX_WT_NUM;
- sqlIdUpdateBatch = SqlIDDef.PlanLuJGX.UpdateOrderJGX_WT_NUM;
- sqlIdUpdateMatch = SqlIDDef.PlanLuJGX.UpdateOrderJGX_MATCH_WT_NUM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_RCL:
- sqlIdDelete = SqlIDDef.PlanLuRCL.deleteZyRclM;
- sqlUpdateZy = SqlIDDef.PlanLuRCL.UpdateZYRCL_WT_NUM;
- sqlIdUpdateBatch = SqlIDDef.PlanLuRCL.UpdateRCLORDER_WT_NUM;
- sqlIdUpdateMatch = SqlIDDef.PlanLuRCL.UpdateOrderRCL_MATCH_WT_NUM;
- break;
- case CustomInfoDef.DEFINE_CUSTOMER_ZG:
- sqlIdDelete = SqlIDDef.PlanLuZG.deleteZyZgM;
- sqlUpdateZy = SqlIDDef.PlanLuZG.UpdateZYZG_WT_NUM;
- sqlIdUpdateMatBack = SqlIDDef.MaterialChoose.updateGPBack;
- sqlIdUpdateBatch = SqlIDDef.PlanLuZG.UpdateOrderZG_WT_NUM;
- sqlIdUpdateMatch = SqlIDDef.PlanLuZG.UpdateOrderZG_MATCH_WT_NUM;
- break;
- }
- if (sepcount == innum)
- {
- //删除作业计划(轧管和加工线可能只删除从表)
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_JG)
- {
- sqlidList.Add(SqlIDDef.PlanLuJGX.deleteZyJgxC);
- parameters.Add(new List<Object>() { row.Cells["HeatPlanNo"].Text });
- }
- else if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)//只删除对应长度的从表
- {
- if (row.HasChild())
- {
- UltraGridRow childrow = row.ChildBands[0].Rows.FirstOrDefault(c => c.Cells["LengthGp"].Text.Trim().Equals(matrow.Cells["ACT_LEN"].Text.Trim()));
- PlnZyZgCEntity zyzgc = (PlnZyZgCEntity)childrow.ListObject;
- PlnZyZgMEntity zyzgm = (PlnZyZgMEntity)row.ListObject;
- sqlidList.Add(SqlIDDef.PlanLuZG.deleteZyZgCByCutNo);
- parameters.Add(new List<Object>() { zyzgm.HeatPlanNo, zyzgc.GpCutNo });
- if (row.ChildBands[0].Rows.Count == 1)
- {
- sqlidList.Add(SqlIDDef.PlanLuZG.deleteZyZgM);
- parameters.Add(new List<Object>() {zyzgm.HeatPlanNo });
- }
- else//冲减作业计划量
- {
- int cutsinglenum = Convert.ToInt32(zyzgm.CutSingleNum);
- double cutsinglewt = Convert.ToDouble(zyzgm.CutSingleWt);
- //脱单单倍坯量
- int sepCutSingleNum = Convert.ToInt32(zyzgc.CutSingleNum);
- double sepCutSingleWt = Convert.ToDouble(zyzgc.CutSingleWt);
- //原始量
- int OriOutNum=Convert.ToInt32(zyzgm.OutNum);
- Double OriOutWt = Convert.ToDouble(zyzgm.OutWt);
- int OrioutNumCut = Convert.ToInt32(zyzgm.OutnumCut);
- //脱单计划产出量
- sepOutNum = sepCutSingleNum * OrioutNumCut;
- sepOutWt = CommHelper.GetSpecDecimalBit(sepOutNum * PlanComm.WeightOfMi(Convert.ToDouble(zyzgm.Aimoutdiameter), Convert.ToDouble(zyzgm.Aimwallthick)) * Convert.ToDouble(zyzgm.Aimlength), 3);
- cutsinglewt -= sepCutSingleWt;
- cutsinglenum -= sepCutSingleNum;
- int outNum = OriOutNum - sepOutNum;
- double outWt = OriOutWt - sepOutWt;
- int plngpnum = Convert.ToInt32(zyzgm.PlanGpNum) - sepcount;
- sqlidList.Add(SqlIDDef.PlanLuZG.UpdateZYZG_WT_NUM);
- parameters.Add(new List<Object>() {cutsinglenum,cutsinglewt,outNum,outWt,m_userName,plngpnum,zyzgm.HeatPlanNo });
- }
- }
- else
- {
- sqlidList.Add(sqlIdDelete);
- parameters.Add(new List<Object>() { row.Cells["HeatPlanNo"].Text });
- }
-
- }
- else
- {
- sqlidList.Add(sqlIdDelete);
- parameters.Add(new List<Object>() { row.Cells["HeatPlanNo"].Text });
- }
-
- }
- else if (sepcount < innum)
- {
- //冲减作业计划量
- int finalinnum = innum - sepcount;//最终投入支数
- int finaloutnum = innum - sepcount;//最终产出重量(轧管不可用)
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- //冲减从表作业计划量
- if (row.HasChild())
- {
- UltraGridRow childrow = row.ChildBands[0].Rows.FirstOrDefault(c => c.Cells["LengthGp"].Text.Trim().Equals(matrow.Cells["ACT_LEN"].Text.Trim()));
- PlnZyZgCEntity zyzgc = (PlnZyZgCEntity)childrow.ListObject;
- PlnZyZgMEntity zyzgm = (PlnZyZgMEntity)row.ListObject;
- int oriInGpNum = Convert.ToInt32(zyzgc.InGpNum);
- double oriInGpWt = Convert.ToDouble(zyzgc.InGpWt);
- int oriCutSingleNum = Convert.ToInt32(zyzgc.CutSingleNum);
- double oriCutSingleWt = Convert.ToDouble(zyzgc.CutSingleWt);
- double sepGpWt = sepcount * singleinwt;
- int sepCutSingleNum = sepcount * Convert.ToInt32(zyzgc.MultipleNum);
- double sepCutSingleWt = Convert.ToInt32(zyzgc.LenGpSingle) * PlanComm.GpweightOfmi(Convert.ToDouble(zyzgm.DiameterGp)) * sepCutSingleNum * 0.001;
- oriInGpNum -= sepcount;
- oriInGpWt -= sepGpWt;
- oriCutSingleNum -= sepCutSingleNum;
- oriCutSingleWt -= sepCutSingleWt;//单倍坯长*米单重*单倍坯支数
- sqlidList.Add(SqlIDDef.PlanLuZG.UpdateZYZGC_GPWT_GPNUM);
- parameters.Add(new List<Object>() {oriCutSingleNum,CommHelper.GetSpecDecimalBit(oriCutSingleWt,3),oriInGpNum,CommHelper.GetSpecDecimalBit(oriInGpWt,3),zyzgc.HeatPlanNo,zyzgc.GpCutNo });
-
- //冲减主表作业计划量
- int oriMCutSingleNum = Convert.ToInt32(zyzgm.CutSingleNum);
- double oriMCutSingleWt = Convert.ToDouble(zyzgm.CutSingleWt);
- int oriPlnGpNum = Convert.ToInt32(zyzgm.PlanGpNum);
- int oriOutNum = Convert.ToInt32(zyzgm.OutNum);
- double oriOutWt = Convert.ToDouble(zyzgm.OutWt);
- sepOutNum = sepCutSingleNum * Convert.ToInt32(zyzgm.OutnumCut);
- sepOutWt = CommHelper.GetSpecDecimalBit(sepOutNum * PlanComm.WeightOfMi(Convert.ToDouble(zyzgm.Aimoutdiameter), Convert.ToDouble(zyzgm.Aimwallthick)) * Convert.ToDouble(zyzgm.Aimlength), 3);//计划产出重量= 计划产出支数*管米单重*工序目标长度
- oriMCutSingleNum -= sepCutSingleNum;
- oriMCutSingleWt -=sepCutSingleWt ;
- oriOutNum -= sepOutNum;
- oriOutWt -= sepOutWt;
- oriPlnGpNum -= sepcount;
- sqlidList.Add(SqlIDDef.PlanLuZG.UpdateZYZG_WT_NUM);
- parameters.Add(new List<Object>() {oriMCutSingleNum,CommHelper.GetSpecDecimalBit(oriMCutSingleWt,3),oriOutNum,CommHelper.GetSpecDecimalBit(oriOutWt,3),m_userName,oriPlnGpNum,zyzgm.HeatPlanNo });
- }
- }
- else
- {
- sqlidList.Add(sqlUpdateZy);
- double inWt = CommHelper.GetSpecDecimalBit(singleinwt * (finalinnum), 3);
- double outWt = CommHelper.GetSpecDecimalBit(singleoutwt * (finaloutnum), 3);
- parameters.Add(new List<Object>() { inWt, finalinnum, finaloutnum, outWt, m_userName, row.Cells["HeatPlanNo"].Text });
- }
- }
- //退回物料
- string stoveNo = row.Cells["HeatnoLast"].Text;
- string batchedNo = "";
- string batchGroupNo = "";
- if (CustomInfo != CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- batchedNo = CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_DBK ? row.Cells["ZgBatchNo"].Text : row.Cells["LastBatchNo"].Text;
- batchGroupNo = row.Cells["BatchGroudNo"].Text;
- }
- string materialNo = row.Cells["InwlId"].Text;
- string gxPlanNo = row.Cells["GxPlanNo"].Text;
- string proPlanId = row.Cells["ProPlanId"].Text;
- int lockliku = 0;
- lockliku = DBComm.queryLockLiku(stoveNo, batchedNo, batchGroupNo, proPlanId, gxPlanNo, this.ob);
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- sqlidList.Add(SqlIDDef.MaterialChoose.updateGPBack);
- parameters.Add(new List<Object>() { materialNo, stoveNo, proPlanId, gxPlanNo, matrow.Cells["ACT_LEN"].Value, CommHelper.getProcessCode(CustomInfo), CommHelper.getProcessDesc(CustomInfo), CommHelper.getProcessCode(CustomInfo), sepcount, m_userName });
- }
- else
- {
- sqlidList.Add(SqlIDDef.MaterialChoose.updateMaterialBack);
- parameters.Add(new List<object>() { materialNo, stoveNo, gxPlanNo, batchedNo, batchGroupNo, CommHelper.getProcessCode(CustomInfo), CommHelper.getProcessDesc(CustomInfo), proPlanId, CommHelper.getProcessCode(CustomInfo), sepcount, 0, m_userName });
- }
- //更新工序订单炉计划已排量
- DataTable dt = ServerHelper.GetData(MethodDef.StoveBase.queryBatchMatch, new Object[] { CommHelper.GetOrdertableName(CustomInfo), proPlanId, gxPlanNo }, this.ob);
- var OrderRow = dt.Rows[0];
- double Batch_Wt = 0;
- int Batch_Num = 0;
- double Match_Wt_In = 0;
- int Match_Num_In = 0;
- try
- {
- Batch_Num = Convert.ToInt32(OrderRow["BATCHED_NUM"].ToString());
- Batch_Wt = Convert.ToDouble(OrderRow["BATCHED_WT"].ToString());
- if (CustomInfo != CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- Batch_Num -= sepcount;
- Batch_Wt -= CommHelper.GetSpecDecimalBit(singleoutwt * sepcount, 3);
- }
- else
- {
- Batch_Num -= sepOutNum;
- Batch_Wt -= sepOutWt;
- }
- }
- catch
- {
- }
- Batch_Num = Batch_Num < 0 ? 0 : Batch_Num;
- Batch_Wt = Batch_Wt < 0 ? 0 : Batch_Wt;
- sqlidList.Add(sqlIdUpdateBatch);
- parameters.Add(new List<Object>() { Batch_Wt, Batch_Num, proPlanId, gxPlanNo });
- //更新工序订单投入利库量
- if (lockliku == 1)
- {
- try
- {
- Match_Wt_In = Convert.ToDouble(OrderRow["MATCH_WT_IN"].ToString());
- Match_Num_In = Convert.ToInt32(OrderRow["MATCH_NUM_IN"].ToString());
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- Match_Num_In -= sepOutNum;
- Match_Wt_In -= sepOutWt;
- }
- else
- {
- Match_Num_In -= sepcount;
- Match_Wt_In -= CommHelper.GetSpecDecimalBit(sepcount * singleoutwt, 3);
- }
- }
- catch
- {
- }
- Match_Num_In = Match_Num_In < 0 ? 0 : Match_Num_In;
- Match_Wt_In = Match_Wt_In < 0 ? 0 : Match_Wt_In;
- sqlidList.Add(sqlIdUpdateMatch);
- parameters.Add(new List<object>() { Match_Wt_In, Match_Num_In, proPlanId, gxPlanNo });
- }
- }
- if (sqlidList.Count > 0)
- {
- BaseEntityDAL.ExcuteTransaction(sqlidList, parameters, this.ob);
- queryMat();
- }
- }
- private void queryMat()
- {
- DataTable dt=new DataTable();
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- dt = ServerHelper.GetData(MethodDef.MaterialChoose.getBindedGp, new Object[] { CommHelper.getProcessCode(CustomInfo), CommHelper.getProcessDesc(CustomInfo) }, this.ob);
- }
- else
- {
- dt = ServerHelper.GetData(MethodDef.MaterialChoose.getBindedMaterial, new Object[] { CommHelper.getProcessCode(CustomInfo), CommHelper.getProcessDesc(CustomInfo) }, this.ob);
- }
-
- GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
- switch (CustomInfo)
- {
- case CustomInfoDef.DEFINE_CUSTOMER_DBK: this.plnZyDbkMEntityBindingSource.Clear(); break;
- case CustomInfoDef.DEFINE_CUSTOMER_JG: this.plnZyJgxMEntityBindingSource.Clear(); break;
- case CustomInfoDef.DEFINE_CUSTOMER_RCL: this.plnZyRclMEntityBindingSource.Clear(); break;
- case CustomInfoDef.DEFINE_CUSTOMER_ZG: this.plnZyZgMEntityBindingSource.Clear(); break;
- }
- }
- #endregion
- private void setUserActCount(long leftNum,Object ActLen)
- {
-
- foreach (var row in this.ultraGrid2.Rows)
- {
- int inNum = 0;
- double inWt = 0;
- UltraGridRow childrow = null;
- if (CustomInfo != CustomInfoDef.DEFINE_CUSTOMER_ZG)
- {
- inNum = Convert.ToInt32(row.Cells["InNum"].Text);
- inWt = Convert.ToDouble(row.Cells["InWt"].Text);
- }
- else
- {
- childrow = row.ChildBands[0].Rows.FirstOrDefault(c => c.Cells["LengthGp"].Text.Trim().Equals(ActLen.ToString()));
- if(childrow != null)
- {
- inNum = Convert.ToInt32(childrow.Cells["InGpNum"].Value);
- inWt = Convert.ToDouble(childrow.Cells["InGpWt"].Value);
- }
- row.Expanded = true;
- }
- double singleInWt = inWt/inNum;
- if (inNum >= leftNum)
- {
- row.Cells["ChooseZY"].Value = true;
- row.Cells["USER_ACT_COUNT"].Appearance.BackColor = Color.Pink;
- row.Cells["USER_ACT_COUNT"].Value = leftNum;
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG && row.HasChild())
- {
- childrow.Cells["USER_ACT_COUNT"].Value = leftNum;
- childrow.Cells["USER_ACT_WEIGHT"].Value = leftNum * singleInWt;
- childrow.Cells["USER_ACT_COUNT"].Appearance.BackColor = Color.Pink;
- }
- else
- {
- row.Cells["USER_ACT_WEIGHT"].Value = leftNum * singleInWt;
- }
- break;
- }
- else
- {
- row.Cells["ChooseZY"].Value = true;
- row.Cells["USER_ACT_COUNT"].Appearance.BackColor = Color.Pink;
- row.Cells["USER_ACT_COUNT"].Value = inNum;
- if (CustomInfo == CustomInfoDef.DEFINE_CUSTOMER_ZG && row.HasChild())
- {
- childrow.Cells["USER_ACT_COUNT"].Value = inNum;
- childrow.Cells["USER_ACT_WEIGHT"].Value = inNum * singleInWt;
- childrow.Cells["USER_ACT_COUNT"].Appearance.BackColor = Color.Pink;
- }
- else
- {
- row.Cells["USER_ACT_WEIGHT"].Value = inNum * singleInWt;
- }
- leftNum -=inNum;
- }
- }
- }
- }
- }
|