| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577 |
- using com.steering.pss.plnsaleord.jggxpln.model;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using CoreFS.CA06;
- 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.JGGXPln
- {
- public partial class FrmMatZcM : FrmBase
- {
- /// <summary>
- /// 接箍订单号
- /// </summary>
- private string proPlanId = "";
- /// <summary>
- /// 接箍订单分组号
- /// </summary>
- private string jgGroupId = "";
- /// <summary>
- /// 炉作业计划号
- /// </summary>
- private string zyPlanId = "";
- private bool isChecked = false;
- public bool IsChecked
- {
- get { return isChecked; }
- set { isChecked = value; }
- }
- public Infragistics.Win.UltraWinEditors.UltraNumericEditor UltraNumericLenBl
- {
- get { return ultraNumericLenBl; }
- set { ultraNumericLenBl = value; }
- }
- public FrmMatZcM(string _proPlanId, string _jgGroupId, OpeBase _ob)
- {
- this.ob = _ob;
- proPlanId = _proPlanId;
- jgGroupId = _jgGroupId;
- InitializeComponent();
- }
- public FrmMatZcM(string _zyPlanId, OpeBase _ob)
- {
- this.ob = _ob;
- zyPlanId = _zyPlanId;
- InitializeComponent();
- }
- private void FrmMatZcM_Load(object sender, EventArgs e)
- {
- Init();
- RefresDate();
- }
- private void ultraToolbarsManager1_ToolClick(object sender,
- Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "Query":
- DoSeleted();
- break;
- case "OutBound":
- OutBound();
- break;
- case "ModifyZy":
- DoModifyZy();
- break;
- case "Close":
- this.Close();
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// 初始化
- /// </summary>
- private void Init()
- {
- PlanComm.setGridActivation(ultraGridMat.DisplayLayout.Bands[0], "CHC", "CHECKED_NUM");
- PlanComm.setGridSummarySet(ultraGridMat, 0, "MAT_NUM", "CHECKED_NUM");
- PlanComm.setGridSummarySet(ultraGridMat, 2, "ACT_LEN");
- PlanComm.setGridDigitalCol(ultraGridMat.DisplayLayout.Bands[0], 5, 0, "MAT_NUM", "CHECKED_NUM");
- PlanComm.setGridDigitalCol(ultraGridMat.DisplayLayout.Bands[0], 5, 2, "ACT_LEN",
- "ACT_LEN_MIN", "ACT_LEN_MAX", "ACT_WEIGHT");
- if (zyPlanId.Trim().Equals(""))
- {
- ultraToolbarsManager1.Tools["ModifyZy"].SharedProps.Visible = false;
- }
- else
- {
- ultraToolbarsManager1.Tools["OutBound"].SharedProps.Visible = false;
- }
- }
- /// <summary>
- /// 刷新
- /// </summary>
- private void RefresDate()
- {
- //DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.queryBaseSort",
- // new object[] { "8014" }, this.ob);
- //ultraGridMat.DisplayLayout.Bands[1].Columns["PRODUCT_FLAG"].ValueList =
- // PlanComm.GeneralValuelist(ref dt1, "BASECODE", "BASENAME");
- //DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.queryBaseSort",
- // new object[] { "801501" }, this.ob);
- //ultraGridMat.DisplayLayout.Bands[1].Columns["MAT_STATUS"].ValueList =
- // PlanComm.GeneralValuelist(ref dt2, "BASECODE", "BASENAME");
- DoSeleted();
- }
- private void DoSeleted()
- {
- if (zyPlanId.Trim().Equals(""))
- {
- DoQuery();
- }
- else
- {
- DoQueryModify();
- }
- }
- /// <summary>
- /// 获取接箍订单备料需求号
- /// </summary>
- /// <param name="proPlanId"></param>
- /// <returns></returns>
- private string getJgMBlReq(string proPlanId)
- {
- string blReqIdlist = "";
- DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.getJgMBlReq",
- new object[] { proPlanId }, this.ob);
- if (dt != null && dt.Rows.Count > 0)
- {
- blReqIdlist = dt.Rows[0]["REQ_BL_ID"].ToString();
- }
- return blReqIdlist;
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void DoQuery()
- {
- DataTable dt = null;
- DataTable dtLen = null;
- double proplen = 0;
- string blReqList = getJgMBlReq(proPlanId);
- if (blReqList.Trim().Equals(""))
- {
- dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectJgMStoverBatch",
- new object[] { proPlanId, jgGroupId }, this.ob);
- //dtMat = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectMatZcM",
- // new object[] { proPlanId, jgGroupId }, this.ob);
- }
- else
- {
- dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectJgMStoverBatch",
- new object[] { proPlanId, jgGroupId, blReqList }, this.ob);
- //dtMat = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectMatZcM",
- // new object[] { proPlanId, jgGroupId, blReqList }, this.ob);
- }
- //dataTable1.Clear();
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- //GridHelper.CopyDataToDatatable(dtMat, dataTable1, true);
- dtLen = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.queryPlnPropLenSum",
- new object[] { proPlanId, jgGroupId }, this.ob);
- if (dtLen != null && dtLen.Rows.Count > 0)
- {
- double.TryParse(dtLen.Rows[0]["PROP_LEN_SUM"].ToString(), out proplen);
- }
- this.ultraNumericBoundLen.Value = proplen;
- this.ultraNumericOutBound.Value = 0;
- }
- /// <summary>
- /// 修改查询
- /// </summary>
- private void DoQueryModify()
- {
- DataTable dt = null;
- DataTable dtLen = null;
- double proplen = 0;
- string blReqList = getJgMBlReq(proPlanId);
- if (blReqList.Trim().Equals(""))
- {
- dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectJgMBatchGroupModify",
- new object[] { zyPlanId }, this.ob);
- }
- else
- {
- dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectJgMBatchGroupModify",
- new object[] { zyPlanId, blReqList }, this.ob);
- }
- GridHelper.CopyDataToDatatable(dt, dataTable2, true);
- if (ultraGridMat.Rows.Count > 0)
- {
- DataTable dtStatus = null;
- dtStatus = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.selectJgZyStatus",
- new object[] { zyPlanId }, this.ob);
- if (dtStatus != null && dtStatus.Rows.Count > 0)
- {
- int outNum = 0;//已经组炉的支数
- int.TryParse(dtStatus.Rows[0]["PLAN_BL_NUM"].ToString(), out outNum);
- ultraGridMat.Rows[0].Cells["CHECKED_NUM"].Value = outNum;
- }
- }
- dtLen = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy.queryPlnPropLenSum",
- new object[] { proPlanId, jgGroupId, zyPlanId }, this.ob);
- if (dtLen != null && dtLen.Rows.Count > 0)
- {
- double.TryParse(dtLen.Rows[0]["PROP_LEN_SUM"].ToString(), out proplen);
- }
- this.ultraNumericBoundLen.Value = proplen;
- this.ultraNumericOutBound.Value = 0;
- }
- /// <summary>
- /// 组炉
- /// </summary>
- //private void OutBound()
- //{
- // List<List<MatZcMEntity>> list = new List<List<MatZcMEntity>>();
- // foreach (UltraGridRow uRow in ultraGridMat.Rows)
- // {
- // if (uRow.Cells["CHC"].Value == null || Convert.ToBoolean(uRow.Cells["CHC"].Value))
- // {
- // List<MatZcMEntity> listGroup = new List<MatZcMEntity>();
- // IQueryable<UltraGridRow> ugrs = uRow.ChildBands[0].Rows.AsQueryable().Where("CHC = 'True'");
- // foreach (UltraGridRow ugr in ugrs)
- // {
- // double actLen = 0;
- // MatZcMEntity matZcM = new MatZcMEntity();
- // double.TryParse(ugr.Cells["ACT_LEN"].Value.ToString(), out actLen);
- // matZcM.MatNo = ugr.Cells["MAT_NO"].Value.ToString();
- // matZcM.JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
- // matZcM.BatchNo = ugr.Cells["BATCH_NO"].Value.ToString();
- // matZcM.BatchGroudNo = ugr.Cells["BATCH_GROUD_NO"].Value.ToString();
- // matZcM.ActLen = actLen.ToString();
- // listGroup.Add(matZcM);
- // }
- // list.Add(listGroup);
- // }
- // }
- // if (list.Count() == 0)
- // {
- // MessageUtil.ShowTips("未勾选任何材料。");
- // return;
- // }
- // CoreClientParam ccp = new CoreClientParam();
- // ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy";
- // ccp.MethodName = "outBound";
- // ccp.ServerParams = new object[] { list, proPlanId, jgGroupId, UserInfo.GetUserName() };
- // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- // if (ccp.ReturnCode != -1)
- // {
- // if (ccp.ReturnObject != null)
- // {
- // MessageUtil.ShowTips(ccp.ReturnObject.ToString());
- // }
- // }
- // DoQuery();
- //}
- /// <summary>
- /// 组炉
- /// </summary>
- private void OutBound()
- {
- IQueryable<UltraGridRow> checkRows = null;
- List<PlnZyJgEntity> list = new List<PlnZyJgEntity>();
- ultraGridMat.UpdateData();
- checkRows = ultraGridMat.Rows.AsQueryable().Where("CHC = 'True'");
- if (checkRows.Count() == 0)
- {
- MessageUtil.ShowTips("未勾选任何材料。");
- return;
- }
- IQueryable<UltraGridRow> zeroRows = checkRows.Where(a =>
- a.Cells["CHECKED_NUM"].Value.ToString().CompareTo("0") <= 0);
- if (zeroRows.Count() != 0)
- {
- string judgeStoveNo = zeroRows.First().Cells["JUDGE_STOVE_NO"].Value.ToString();
- string batchNo = zeroRows.First().Cells["BATCH_NO"].Value.ToString();
- string batchGroudNo = zeroRows.First().Cells["BATCH_GROUD_NO"].Value.ToString();
- MessageUtil.ShowTips("炉号:" + judgeStoveNo + " 批号:"
- + batchNo + " 组号:" + batchGroudNo + "未指定组炉支数。");
- return;
- }
- foreach (UltraGridRow ugr in checkRows)
- {
- PlnZyJgEntity zyJgEntity = new PlnZyJgEntity();
- zyJgEntity.ProPlanId = proPlanId;
- zyJgEntity.JgGroupId = jgGroupId;
- zyJgEntity.CreateName = UserInfo.GetUserName();
- zyJgEntity.JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
- zyJgEntity.BatchNo = ugr.Cells["BATCH_NO"].Value.ToString();
- zyJgEntity.BatchGroudNo = ugr.Cells["BATCH_GROUD_NO"].Value.ToString();
- zyJgEntity.AimlengthBl = ugr.Cells["ACT_LEN"].Value.ToString();
- zyJgEntity.PlanBlNum = ugr.Cells["CHECKED_NUM"].Value.ToString();
- list.Add(zyJgEntity);
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy";
- ccp.MethodName = "outBound";
- ccp.ServerParams = new object[] { list, proPlanId, jgGroupId };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnObject != null)
- {
- MessageUtil.ShowTips(ccp.ReturnObject.ToString());
- }
- }
- isChecked = true;
- DoQuery();
- }
- /// <summary>
- /// 修改炉次计划
- /// </summary>
- private void DoModifyZy()
- {
- UltraGridRow ugr = ultraGridMat.ActiveRow;
- if (ugr == null)
- {
- return;
- }
- int modifyNum = 0;
- PlnZyJgEntity zyJgEntity = new PlnZyJgEntity();
- CoreClientParam ccp = null;
- ugr.Update();
- int.TryParse(ugr.Cells["CHECKED_NUM"].Value.ToString(), out modifyNum);
- if (modifyNum <= 0)
- {
- MessageUtil.ShowTips("组炉支数必须大于0。");
- return;
- }
- zyJgEntity.ZyPlanId = zyPlanId;
- zyJgEntity.PlanBlNum = modifyNum.ToString();
- zyJgEntity.UpdateName = UserInfo.GetUserName();
- ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.CoreJgMPlnZy";
- ccp.MethodName = "modifyZy";
- ccp.ServerParams = new object[] { zyJgEntity };
- ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnObject != null)
- {
- MessageUtil.ShowTips(ccp.ReturnObject.ToString());
- }
- }
- isChecked = true;
- DoQueryModify();
- }
- /// <summary>
- /// 刷新组炉长度
- /// </summary>
- private void setBoundLen()
- {
- double lenSum = 0;
- ultraGridMat.UpdateData();
- foreach (UltraGridRow ugr in ultraGridMat.Rows)
- {
- if (Convert.ToBoolean(ugr.Cells["CHC"].Text))
- {
- int numChecked = 0;
- double actLen = 0;
- double.TryParse(ugr.Cells["ACT_LEN"].Value.ToString(), out actLen);
- int.TryParse(ugr.Cells["CHECKED_NUM"].Value.ToString(), out numChecked);
- lenSum += numChecked * actLen;
- }
- }
- ultraNumericOutBound.Value = lenSum;
- }
- #region 事件
- private void ultraGridMat_CellChange(object sender, CellEventArgs e)
- {
- UltraGridRow ugr = e.Cell.Row;
- if (ugr == null)
- {
- return;
- }
- if (e.Cell.Column.Key.Equals("CHECKED_NUM"))
- {
- setBoundLen();
- }
- if (e.Cell.Column.Key.Equals("CHC"))
- {
- setBoundLen();
- //ugr.Update();
- if (ugr.HasChild())
- {
- #region 父行选中
- //bool isChecked = true;
- //if (bool.TryParse(ugr.Cells["CHC"].Text, out isChecked))
- //{
- // if (isChecked)
- // {
- // foreach (UltraGridRow uRow in ugr.ChildBands[0].Rows)
- // {
- // double len = 0;
- // uRow.Cells["CHC"].Value = true;
- // if (double.TryParse(uRow.Cells["ACT_LEN"].Value.ToString(), out len)
- // && len > 0)
- // {
- // double lenOutBound = 0;
- // lenOutBound = Convert.ToDouble(ultraNumericOutBound.Value);
- // lenOutBound += len;
- // if (lenOutBound >= 0)
- // {
- // ultraNumericOutBound.Value = lenOutBound;
- // }
- // }
- // }
- // }
- // else
- // {
- // foreach (UltraGridRow uRow in ugr.ChildBands[0].Rows)
- // {
- // double len = 0;
- // uRow.Cells["CHC"].Value = false;
- // if (double.TryParse(uRow.Cells["ACT_LEN"].Value.ToString(), out len)
- // && len > 0)
- // {
- // double lenOutBound = 0;
- // lenOutBound = Convert.ToDouble(ultraNumericOutBound.Value);
- // lenOutBound -= len;
- // if (lenOutBound >= 0)
- // {
- // ultraNumericOutBound.Value = lenOutBound;
- // }
- // }
- // }
- // }
- //}
- #endregion
- }
- else
- {
- #region 子行选中
- //bool isChecked = true;
- //if (bool.TryParse(ugr.Cells["CHC"].Text, out isChecked))
- //{
- // if (isChecked)
- // {
- // double len = 0;
- // IQueryable<UltraGridRow> checkRows = ugr.ParentRow
- // .ChildBands[0].Rows.AsQueryable().Where("CHC = 'True'");
- // if (double.TryParse(ugr.Cells["ACT_LEN"].Value.ToString(), out len)
- // && len > 0)
- // {
- // double lenOutBound = 0;
- // lenOutBound = Convert.ToDouble(ultraNumericOutBound.Value);
- // lenOutBound += len;
- // if (lenOutBound >= 0)
- // {
- // ultraNumericOutBound.Value = lenOutBound;
- // }
- // }
- // if (checkRows.Count() == ugr.ParentRow
- // .ChildBands[0].Rows.Count)
- // {
- // ugr.ParentRow.Cells["CHC"].Value = true;
- // }
- // else
- // {
- // ugr.ParentRow.Cells["CHC"].Value = null;
- // }
- // }
- // else
- // {
- // double len = 0;
- // IQueryable<UltraGridRow> checkRows = ugr.ParentRow
- // .ChildBands[0].Rows.AsQueryable().Where("CHC = 'True'");
- // if (double.TryParse(ugr.Cells["ACT_LEN"].Value.ToString(), out len)
- // && len > 0)
- // {
- // double lenOutBound = 0;
- // lenOutBound = Convert.ToDouble(ultraNumericOutBound.Value);
- // lenOutBound -= len;
- // if (lenOutBound >= 0)
- // {
- // ultraNumericOutBound.Value = lenOutBound;
- // }
- // }
- // if (checkRows.Count() == 0)
- // {
- // ugr.ParentRow.Cells["CHC"].Value = false;
- // }
- // else
- // {
- // ugr.ParentRow.Cells["CHC"].Value = null;
- // }
- // }
- //}
- #endregion
- }
- }
- }
- private void ultraGridMat_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
- {
- if (e.Column.Key.Equals("CHC"))
- {
- //foreach (UltraGridRow ugr in e.Rows)
- //{
- // CellEventArgs eas = new CellEventArgs(ugr.Cells["CHC"]);
- // ultraGridMat_CellChange(sender, eas);
- //}
- setBoundLen();
- }
- }
- private void ultraGridMat_BeforeRowActivate(object sender, RowEventArgs e)
- {
- UltraGridRow ugr = e.Row;
- int matNum = 0;
- if (ugr == null)
- {
- return;
- }
- if (int.TryParse(ugr.Cells["MAT_NUM"].Value.ToString(), out matNum))
- {
- ugr.Cells["CHECKED_NUM"].Column.MaxValue = matNum;
- }
- }
- private void ultraGridMat_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
- {
- foreach (UltraGridRow uRow in ultraGridMat.Selected.Rows)
- {
- if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
- {
- uRow.Cells["CHC"].Value = true;
- }
- }
- setBoundLen();
- }
- #endregion
- }
- }
|