using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Mes.Client.Comm; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.LgClassModel; using Core.StlMes.Client.LgCommon; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.LgResMgt { public partial class FrmCutBilletDetail : FrmBase { private bool _bRelated; //关联查看/单独查询 private List Pline; // 数据权限 private OpeBase pssOb = null; public string StoveNo = ""; private int SplitterWidth =426; public FrmCutBilletDetail() { InitializeComponent(); } private bool BRelated { get { return _bRelated; } set { _bRelated = value; ugpQuery.Visible = !_bRelated; cbx_STOVE_NO.Checked = _bRelated && !string.IsNullOrEmpty(StoveNo); cbx_STOVE_NO.Enabled = !_bRelated; tbSTOVE_NO.Text = _bRelated ? StoveNo : ""; tbSTOVE_NO.Enabled = !_bRelated; cbx_Time.Text = _bRelated ? "计划时间从" : "切割时间从"; if (!BRelated) QueryData(); else ProductQuery.RefreshAutomatic(); } } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": if (!BRelated) QueryData(); else ProductQuery.RefreshAutomatic(); break; case "Delete": Delete(); break; case "Comfirm": if (!BRelated) Confirm(); else ProductQuery.Confirm(); break; case "UndoConfirm": if (!BRelated) UndoConfirm(); else ProductQuery.UndoConfirm(); break; case "AddComfirm": ProductQuery.AddComfirm(); break; case "AddUndoConfirm": ProductQuery.AddUndoConfirm(); break; case "Exit": Close(); break; } } private void Delete() { ugCutData.UpdateData(); var list = stlIncisionEntityBindingSource.DataSource as List; if (list == null) { MessageBox.Show("请勾选需要删除的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ; var checkList = list.Where(p => p.Check).ToList(); if (!checkList.Any()) { MessageBox.Show("请勾选需要删除的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState != "00") > 0) { MessageBox.Show("勾选的数据已结炉!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ( MessageBox.Show( "确定要删除这" + checkList.Count + "条切割实绩吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; try { ServerHelper.SetData( "Core.LgMes.Server.LgDeviceManager.PerformanceManage.DeleteBilltetCut", new object[] {checkList.Select(p => p.IncisionNo).ToList()}, ob); MessageBox.Show("删除成功!\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); QueryData(); OrderSelectHandler(ProductQuery.PlnSteelforOrdEntity); } catch (Exception ex) { if (ex is MESException) { } else MessageBox.Show("删除失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } private void UndoConfirm() { ugCutData.UpdateData(); var list = stlIncisionEntityBindingSource.DataSource as List; if (list == null) { MessageBox.Show("请勾选需要撤销结炉的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ; var checkList = list.Where(p => p.Check).ToList(); if (!checkList.Any()) { MessageBox.Show("请勾选需要撤销结炉的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState == "00") > 0) { MessageBox.Show("勾选的数据有未结炉,无法撤销!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState == "20") > 0) { MessageBox.Show("勾选的数据有表检结束,无法撤销!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState == "30") > 0) { MessageBox.Show("勾选的数据已经下线,无法撤销!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState != "10") > 0) { MessageBox.Show("勾选的数据不在结炉状态,无法撤销!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ( MessageBox.Show( "确定撤销结炉" + checkList.Select(p => p.StoveNo).Distinct().Aggregate((a, b) => a + " " + b) + "熔炼炉号的切割实绩吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; try { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace"; ccp.MethodName = "updatePlnZyM"; ccp.ServerParams = new object[] { checkList.Select(p => p.Furnaceno).Distinct().ToArray(), UserInfo.GetUserName(), "0" }; ccp = pssOb.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnInfo != "修改成功") { MessageBox.Show("无法更新轧管炉号! \n" + ccp.ReturnInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ServerHelper.SetData( "Core.LgMes.Server.LgDeviceManager.PerformanceManage.UndoBilltetCutConfirm", new object[] {checkList.Select(p => p.Furnaceno).Distinct().ToList()}, ob); MessageBox.Show("撤销结炉成功!\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); QueryData(); } catch (Exception ex) { if (ex is MESException) { } else MessageBox.Show("撤销结炉失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } private void Confirm() { ugCutData.UpdateData(); var list = stlIncisionEntityBindingSource.DataSource as List; if (list == null) { MessageBox.Show("请勾选需要结炉的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } var checkList = list.Where(p => p.Check).ToList(); if (!checkList.Any()) { MessageBox.Show("请勾选需要结炉的数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.CcmState != "00") > 0) { MessageBox.Show("勾选的数据已结炉!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (checkList.Count(p => p.JudgeStoveNo == "") > 0) { MessageBox.Show("勾选的数据无判定炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if ( MessageBox.Show( "确定结炉" + checkList.Select(p => p.StoveNo).Distinct().Aggregate((a, b) => a + " " + b) + "熔炼炉号的切割实绩吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; try { CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.stove.ComPlanFurnace"; ccp.MethodName = "updatePlnZyM"; ccp.ServerParams = new object[] { checkList.Select(p => p.Furnaceno).Distinct().ToArray(), UserInfo.GetUserName(), "1" }; ccp = pssOb.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnInfo != "修改成功") { MessageBox.Show("无法更新轧管炉号! \n" + ccp.ReturnInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } ServerHelper.SetData( "Core.LgMes.Server.LgDeviceManager.PerformanceManage.BilltetCutConfirm", new object[] {checkList.Select(p => p.Furnaceno).Distinct().ToList(),UserInfo.GetUserName(),UserInfo.GetUserGroup() + UserInfo.GetUserOrder() }, ob); MessageBox.Show("结炉成功!\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); QueryData(); } catch (Exception ex) { if (ex is MESException) { } else MessageBox.Show("结炉失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } private void QueryData() { var datas = EntityHelper.GetData( "Core.LgMes.Server.LgDeviceManager.PerformanceManage.SelectStlIncisionEntity", BRelated ? new object[] { cbx_STOVE_NO.Checked ? tbSTOVE_NO.Text : "", Pline } : new object[] { cbx_STOVE_NO.Checked ? tbSTOVE_NO.Text : "", Pline, dtStart.Value, dtEnd.Value }, ob); ugCutData.DataBindings.Clear(); stlIncisionEntityBindingSource.DataSource = datas; PublicMethod.RefreshAndAutoSize(ugCutData); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ugCutData.DisplayLayout.Appearance.FontData.SizeInPoints = 10; dtStart.Value = DateTime.ParseExact(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00:00", "yyyy-MM-dd HH:mm:ss", null); dtEnd.Value = DateTime.ParseExact(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 23:59:59", "yyyy-MM-dd HH:mm:ss", null); Pline = ClsBusinessPack.InitDropPlinePower("B", null, this.ValidDataPurviewIds, this.ob); ProductQuery.Pline = Pline; BRelated = true; pssOb = new OpeBase {MainUrl = CoreCommon.coreCommon.UrlList["pssserver"].Url}; ProductQuery.reportSelect = proc_HeatPlanInfoChanged; ProductQuery.OrderSelectHandler += OrderSelectHandler; ProductQuery.ShiftCode = UserInfo.GetUserGroup() + UserInfo.GetUserOrder(); ProductQuery.Operator = UserInfo.GetUserName(); ProductQuery.ob = ob; ProductQuery.pssOb = pssOb; ProductQuery.GetWeightPerMeterFormula(); ProductQuery.RefreshAutomatic(); ProductQuery.Ini(); ClsControlPack.SetReadOnly(ugCutData); ugCutData.DisplayLayout.Bands[0].Columns["Check"].CellActivation = Activation.AllowEdit; // ugCutData.DisplayLayout.Bands[0].Columns["ActCount"].CellActivation = Activation.AllowEdit; EntityHelper.ShowGridCaption(ugCutData.DisplayLayout.Bands[0]); PublicMethod.RefreshAndAutoSize(ugCutData); IniVauleList(); } private void OrderSelectHandler(PlnSteelforOrdEntity plnSteelforOrdEntity) { List datas = stlIncisionEntityBindingSource.DataSource as List; if (datas==null) return; List CurrentData = new List(); foreach (var row in ugCutData.Rows) { StlIncisionEntity StlIncisionEntity = row.ListObject as StlIncisionEntity; if (StlIncisionEntity==null) continue; if (plnSteelforOrdEntity != null && StlIncisionEntity.Furnaceno == plnSteelforOrdEntity.Furnaceno && plnSteelforOrdEntity.Sequenceno == StlIncisionEntity.Sequenceno) { row.Cells["Check"].Value = true; row.Appearance.BackColor = Color.LightGreen; CurrentData.Add(StlIncisionEntity); } else { row.Cells["Check"].Value = false; row.Appearance.ResetBackColor(); } } ProductQuery.ListStlIncisionEntity = CurrentData; } private void IniVauleList() { var list = ClsBusinessPack.GetCcmState(); ClsControlPack.SetGridValuelist(ref ugCutData, "CcmState", ref list); list = ClsBusinessPack.GetCastingtype(); ClsControlPack.SetGridValuelist(ref ugCutData, "Castingtype", ref list); list = ClsBusinessPack.GetGptype(); ClsControlPack.SetGridValuelist(ref ugCutData, "Gptype", ref list); list = ClsBusinessPack.GetValuelistBanci(); ClsControlPack.SetGridValuelist(ref ugCutData, "ProShift", ref list); list = ClsBusinessPack.GetValuelistBanzu(); ClsControlPack.SetGridValuelist(ref ugCutData, "ProGroup", ref list); } private void proc_HeatPlanInfoChanged(string stoveNo) { cbx_STOVE_NO.Checked = true; cbx_STOVE_NO.Enabled = false; tbSTOVE_NO.Text = stoveNo; tbSTOVE_NO.Enabled = false; StoveNo = stoveNo; if (stoveNo == "") { ugCutData.DataBindings.Clear(); stlIncisionEntityBindingSource.DataSource = new List(); } else QueryData(); } private void cbx_STOVE_NO_CheckedChanged(object sender, EventArgs e) { if (cbx_STOVE_NO.Checked) { tbSTOVE_NO.Enabled = true; tbSTOVE_NO.BackColor = Color.LightCyan; } else { tbSTOVE_NO.Enabled = false; tbSTOVE_NO.BackColor = SystemColors.Control; } } private void FrmCutBilletDetail_Shown(object sender, EventArgs e) { splitContainer1.SplitterDistance = SplitterWidth; } private void MainContainer_ExpandedStateChanged(object sender, EventArgs e) { if (MainContainer.Expanded) { splitContainer1.SplitterDistance = SplitterWidth; BRelated = true; } else { BRelated = false; SplitterWidth = splitContainer1.SplitterDistance; splitContainer1.SplitterDistance = 25; } } } }