| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- 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
- {
- /// <summary>
- /// 可分配重量
- /// </summary>
- private double waitSpitWgt;
- /// <summary>
- /// 可分配支数
- /// </summary>
- private int waitSpitNum;
- /// <summary>
- /// 已分配重量
- /// </summary>
- private double alreadySpitWgt = 0;
- /// <summary>
- /// 可分配剩余支数
- /// </summary>
- private int numF;
- public double AlreadySpitWgt
- {
- get { return alreadySpitWgt; }
- set { alreadySpitWgt = value; }
- }
- /// <summary>
- /// 已分配支数
- /// </summary>
- private int alreadySpitNum = 0;
- public int AlreadySpitNum
- {
- get { return alreadySpitNum; }
- set { alreadySpitNum = value; }
- }
- private string heatPlanNo = "";
- /// <summary>
- /// 炉计划ID
- /// </summary>
- public string HeatPlanNo
- {
- get { return heatPlanNo; }
- set { heatPlanNo = value; }
- }
- private string judgeStoveNo = "";
- /// <summary>
- /// 上料炉号
- /// </summary>
- public string JudgeStoveNo
- {
- get { return judgeStoveNo; }
- set { judgeStoveNo = value; }
- }
- /// <summary>
- /// 重量与支数比例
- /// </summary>
- 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();
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- 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);
-
-
- }
- }
- }
|