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.Mes.Client.Comm.Tool; using CoreFS.CA06; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.PlnSaleOrd.工序排产; using Core.StlMes.Client.PlnSaleOrd.窗体; namespace Core.StlMes.Client.PlnSaleOrd { public partial class FrmSpitWgtZg : FrmBase { /// /// 可分配重量 /// private double waitSpitWgt; /// /// 可分配支数 /// private int waitSpitNum; /// /// 已分配重量 /// private double alreadySpitWgt = 0; /// /// 可分配剩余支数 /// private int numF; public double AlreadySpitWgt { get { return alreadySpitWgt; } set { alreadySpitWgt = value; } } /// /// 已分配支数 /// private int alreadySpitNum = 0; public int AlreadySpitNum { get { return alreadySpitNum; } set { alreadySpitNum = value; } } private string heatPlanNo = ""; /// /// 炉计划ID /// public string HeatPlanNo { get { return heatPlanNo; } set { heatPlanNo = value; } } private string judgeStoveNo = ""; /// /// 上料炉号 /// public string JudgeStoveNo { get { return judgeStoveNo; } set { judgeStoveNo = value; } } /// /// 重量与支数比例 /// private double spitRatio; private string procesCode; private OpeBase ob; private ProducEntity entity = null; public FrmSpitWgtZg(double waitSpitWgt, int waitSpitNum, double spitRatio, string _procesCode, int _numF, ProducEntity _entity, OpeBase _ob) { this.waitSpitWgt = waitSpitWgt; this.waitSpitNum = waitSpitNum; this.spitRatio = spitRatio; this.procesCode = _procesCode; numF = _numF; entity = _entity; ob = _ob; //窗体居中 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; //取消窗体默认关闭按钮 this.ControlBox = false; InitializeComponent(); } private void FrmSpitWgt_Load(object sender, EventArgs e) { numEditorAllow.Value = waitSpitWgt; ultraNumericEditor1.Value = waitSpitNum; numEditorAlready.Value = 0; ultraNumericEditor2.Value = 0; if (procesCode.Equals("D")) { ultraLabel2.Text = "可分配需坯重量:"; ultraLabel7.Text = "可分配需坯支数:"; } else { ultraLabel2.Text = "可分配重量:"; ultraLabel7.Text = "可分配支数:"; } if (numF != 0) { int spitNum = int.Parse(waitSpitNum.ToString()) - numF; if (spitNum > 0) { ultraNumericEditor2.Value = spitNum; double spitWgt = spitNum * spitRatio; numEditorAlready.Value = spitWgt; } } double expectWt = 0; if (entity.ExpectWt != null && !entity.ExpectWt.Equals("")) { expectWt= double.Parse(entity.ExpectWt) ; } double reducedWt = 0; if (entity.ReducedWt != null && !entity.ReducedWt.Equals("")) { reducedWt = double.Parse(entity.ReducedWt); } if (double.Parse(entity.WeigthSMin) - expectWt > 0) { if (reducedWt> 0) { ultraLabel9.Visible = true; ultraTextEditor1.Visible = true; txtWeight.Visible = true; ultraLabel10.Visible = true; DoQuery(); } else { ultraLabel9.Visible = false; ultraTextEditor1.Visible = false; txtWeight.Visible = false; ultraLabel10.Visible = false; } } else { ultraLabel9.Visible = true; ultraTextEditor1.Visible = true; txtWeight.Visible = true; ultraLabel10.Visible = true; DoQuery(); } } /// /// 查询 /// private void DoQuery() { double reducedWt = 0; double wtk = 0; DataTable dt = new DataTable(); if (procesCode.Equals("D")) { dt = ServerHelper.GetData ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryActualM", new object[] { entity.ProPlanId, entity.GxPlanNo }, ob); if (dt.Rows.Count <= 0) return; for (int i = 0; i < dt.Rows.Count; i++) { reducedWt += double.Parse(dt.Rows[i]["REDUCED_WT"].ToString()); if (JudgeStoveNo.Equals("")) { JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } else { JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } } wtk = double.Parse(entity.GpreqWeight) - reducedWt; } else if (procesCode.Equals("H")) { dt = ServerHelper.GetData ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryStarM", new object[] { entity.ProPlanId, entity.GxPlanNo,"H" }, ob); if (dt.Rows.Count <= 0) return; for (int i = 0; i < dt.Rows.Count; i++) { reducedWt += double.Parse(dt.Rows[i]["PLAN_BL_NUM"].ToString()); if (JudgeStoveNo.Equals("")) { JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } else { JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } } wtk = double.Parse(entity.InWeightS) - reducedWt; } else { dt = ServerHelper.GetData ("com.steering.pss.plnsaleord.processOrder.base.ProducHelper.doQueryStarM", new object[] { entity.ProPlanId, entity.GxPlanNo, procesCode }, ob); if (dt.Rows.Count <= 0) return; for (int i = 0; i < dt.Rows.Count; i++) { reducedWt += double.Parse(dt.Rows[i]["PLN_OUTDOUBLE_W"].ToString()); if (procesCode.Equals("E")) { if (JudgeStoveNo.Equals("")) { JudgeStoveNo = dt.Rows[i]["FEED_HEAT_NO"].ToString(); } else { JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["FEED_HEAT_NO"].ToString(); } } else { if (JudgeStoveNo.Equals("")) { JudgeStoveNo = dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } else { JudgeStoveNo = JudgeStoveNo + "," + dt.Rows[i]["JUDGE_STOVE_NO"].ToString(); } } } wtk = double.Parse(entity.InWeightS) - reducedWt; } ultraTextEditor1.Text = JudgeStoveNo; txtWeight.Text = reducedWt.ToString(); int spitNum = (int)Math.Ceiling(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } private void buttonCommit_Click(object sender, EventArgs e) { string spitNum = ultraNumericEditor2.Value == null ? "0" : ultraNumericEditor2.Value.ToString(); //string spitWgt = numEditorAlready.Value == null ? "0" : numEditorAlready.Value.ToString(); if (int.Parse(spitNum) <= 0) { MessageUtil.ShowWarning("分配支数不能为0支!"); return; } if (Convert.ToInt32(spitNum) >= waitSpitNum) { MessageUtil.ShowWarning("分配支数不能大于/等于可分配支数!"); return; } double spitWgt = Convert.ToInt32(spitNum) * spitRatio; alreadySpitWgt = Convert.ToDouble(spitWgt); //通过重量与支数的比例计划 分配支数 alreadySpitNum = Convert.ToInt32(spitNum); if (double.Parse(entity.WeigthSMin) - double.Parse(entity.ExpectWt) > 0) { if (double.Parse(entity.ReducedWt) > 0) { if (JudgeStoveNo.Equals("")) { if (MessageUtil.ShowYesNoAndQuestion("是否需要选择保留炉?") == DialogResult.Yes) { return; } } } else { ultraLabel9.Visible = false; ultraTextEditor1.Visible = false; txtWeight.Visible = false; ultraLabel10.Visible = false; } } else { if (JudgeStoveNo.Equals("")) { if (MessageUtil.ShowYesNoAndQuestion("是否需要选择保留炉?") == DialogResult.Yes) { return; } } } this.Close(); } private void buttonCancel_Click(object sender, EventArgs e) { this.Close(); } //输入支数 private void ultraNumericEditor2_ValueChanged(object sender, EventArgs e) { if (ultraNumericEditor2 == null) { numEditorAlready.Value = 0; ultraNumericEditor2.Value = 0; return; } string spitNum = ultraNumericEditor2.Value.ToString(); if (int.Parse(spitNum) > waitSpitNum) { numEditorAlready.Value = waitSpitWgt; ultraNumericEditor2.Value = waitSpitNum; return; } double spitWgt = int.Parse(spitNum) * spitRatio; numEditorAlready.Value = spitWgt; } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (procesCode.Equals("D")) { FrmSpitPlanZgM frmSpitZgm = new FrmSpitPlanZgM(entity.ProPlanId, entity.GxPlanNo, ob); frmSpitZgm.ShowDialog(); HeatPlanNo = frmSpitZgm.HeatPlanNo; JudgeStoveNo = frmSpitZgm.JudgeStoveNo; ultraTextEditor1.Text = JudgeStoveNo; txtWeight.Text = frmSpitZgm.ReducedWt.ToString(); double wtk = 0; if (frmSpitZgm.ReducedWt == 0) { wtk = frmSpitZgm.ReducedWtKc; int spitNum = (int)(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } else { wtk = double.Parse(entity.GpreqWeight) - frmSpitZgm.ReducedWt; int spitNum = (int)Math.Ceiling(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } } else if (procesCode.Equals("H")) { FrmSpitPlanJg frmSpitZgm = new FrmSpitPlanJg(entity.ProPlanId, entity.GxPlanNo, ob); frmSpitZgm.ShowDialog(); HeatPlanNo = frmSpitZgm.HeatPlanNo; JudgeStoveNo = frmSpitZgm.JudgeStoveNo; ultraTextEditor1.Text = JudgeStoveNo; txtWeight.Text = frmSpitZgm.ReducedWt.ToString(); double wtk = 0; if (frmSpitZgm.ReducedWt == 0) { wtk = frmSpitZgm.ReducedWtKc; int spitNum = (int)(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } else { wtk = double.Parse(entity.InWeightS) - frmSpitZgm.ReducedWt; int spitNum = (int)Math.Ceiling(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } } else { FrmSpitPlanM frmSpitZgm = new FrmSpitPlanM(entity.ProPlanId, entity.GxPlanNo, ob, procesCode); frmSpitZgm.ShowDialog(); HeatPlanNo = frmSpitZgm.HeatPlanNo; JudgeStoveNo = frmSpitZgm.JudgeStoveNo; ultraTextEditor1.Text = JudgeStoveNo; txtWeight.Text = frmSpitZgm.ReducedWt.ToString(); double wtk = 0; if (frmSpitZgm.ReducedWt == 0) { wtk = frmSpitZgm.ReducedWtKc; int spitNum = (int)(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } else { wtk = double.Parse(entity.InWeightS) - frmSpitZgm.ReducedWt; int spitNum = (int)Math.Ceiling(wtk / spitRatio); ultraNumericEditor2.Value = spitNum; numEditorAlready.Value = spitNum * spitRatio; } } //if (wtk <= 0) //{ // MessageUtil.ShowWarning("可分配量不能小于等于0!"); // return; //} //double spitRatoR = double.Parse(entity.GpreqWeight) / double.Parse(entity.ReducedWt); } } }