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.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.PlnSaleOrd.BaseMethod; using Core.StlMes.Client.PlnSaleOrd.炼钢计划.entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd.炼钢计划 { public partial class FrmPlnBasePlineLz : FrmBase { public FrmPlnBasePlineLz() { InitializeComponent(); } private void FrmPlnBasePlineLz_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridBaseLz.DisplayLayout.Bands[0]); BaseHelper.setOtherColumnReadOnly(ultraGridBaseLz, new string[] { "" }); BaseHelper.InitCellPosition(ultraGridBaseLz, new string[] { "FlowNumMax", "ZbLeftWt", "FurnaceNumMax" }); SteelHelper.InitPline(comPlineB, "B", this.ob); SteelHelper.InitPline(comPlineA, "A", this.ob); SteelHelper.InitProcess(comProcess, "B", this.ob); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey.Trim()) { case "Query"://查询 Query(); break; case "Add"://新增 Add(); break; case "Update"://修改 Update(); break; case "Delete"://删除 Delete(); break; default: break; } } private void Query() { List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLz.query", new object[] { }, this.ob); plnBasePlineLzEntityBindingSource.DataSource = listSource; } private void Add() { string plineCode = comPlineB.Value == null ? "" : comPlineB.Value.ToString(); if (plineCode.Equals("")) { MessageUtil.ShowWarning("请选择铸机产线!"); return; } string plineName = comPlineB.Text; string plineCodeA = comPlineA.Value == null ? "" : comPlineA.Value.ToString(); string plineNameA = comPlineA.Text; bool flag = ChcSpec(plineCode, plineCodeA); if (flag) { MessageUtil.ShowWarning("铸机产线:" + plineName + ",电炉产线:" + plineNameA + "已经存在,不能新增!"); return; } string processCode = comProcess.Value == null ? "" : comProcess.Value.ToString(); string processDesc = comProcess.Text; string zbLeftWgt = numZb.Value == null ? "0" : numZb.Value.ToString(); string maxNum = numMaxnum.Value == null ? "0" : numMaxnum.Value.ToString(); string maxFlow = numMaxFlow.Value == null ? "0" : numMaxFlow.Value.ToString(); string defVer = "0"; if (chkdefVer.Checked) { defVer = "1"; } if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLz.add", new string[] { plineCode, plineName, plineCodeA, plineNameA, processCode, processDesc, zbLeftWgt, maxFlow, maxNum, UserInfo.GetUserName(),defVer}, this.ob); MessageUtil.ShowTips("新增成功!"); Query(); if (ultraGridBaseLz.Rows.Count > 0) foreach (UltraGridRow ugr in ultraGridBaseLz.Rows) { if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode)) { ugr.Activate(); } } } private void Delete() { UltraGridRow ugr = ultraGridBaseLz.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要删除的记录!"); return; } string PlineCodeB = ugr.Cells["PlineCode"].Text.Trim(); string PlineNameB = ugr.Cells["PlineName"].Text.Trim(); if (MessageUtil.ShowYesNoAndQuestion("是否删除铸机" + PlineNameB + "基础数据?(此删除不可恢复)") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLz.delete", new string[] { PlineCodeB }, this.ob); MessageUtil.ShowTips("删除成功!"); Query(); } private void Update() { string plineCode = comPlineB.Value == null ? "" : comPlineB.Value.ToString(); if (plineCode.Equals("")) { MessageUtil.ShowWarning("请选择铸机产线!"); return; } string plineName = comPlineB.Text; string plineCodeA = comPlineA.Value == null ? "" : comPlineA.Value.ToString(); string plineNameA = comPlineA.Text; bool flag = ChcSpec(plineCode, plineCodeA); if (!flag) { MessageUtil.ShowWarning("铸机产线:" + plineName + ",电炉产线:" + plineNameA + "不存在,不能修改!"); return; } string processCode = comProcess.Value == null ? "" : comProcess.Value.ToString(); string processDesc = comProcess.Text; string zbLeftWgt = numZb.Value == null ? "0" : numZb.Value.ToString(); string maxNum = numMaxnum.Value == null ? "0" : numMaxnum.Value.ToString(); string maxFlow = numMaxFlow.Value == null ? "0" : numMaxFlow.Value.ToString(); string defVer = "0"; if (chkdefVer.Checked) { defVer = "1"; } if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLz.update", new string[] { plineCode, plineName, plineCodeA, plineNameA, processCode, processDesc, zbLeftWgt, maxFlow, maxNum, UserInfo.GetUserName(),defVer }, this.ob); MessageUtil.ShowTips("修改成功!"); Query(); if (ultraGridBaseLz.Rows.Count > 0) foreach (UltraGridRow ugr in ultraGridBaseLz.Rows) { if (ugr.Cells["PlineCode"].Value.ToString().Equals(plineCode)) { ugr.Activate(); } } } bool ChcSpec(string plineCode, string plineCodeA) { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmPlnBasePlineLz.checkPline", new string[] { plineCode, plineCodeA }, this.ob); if (dt == null || dt.Rows.Count == 0) { return false; } else { if (dt.Rows[0][0].ToString().Equals("1")) { return true; } else { return false; } } } private void ultraGridBaseLz_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridBaseLz.ActiveRow; if (ugr == null) { return; } PlnBasePlineLzEntity entity = (PlnBasePlineLzEntity)ugr.ListObject; comPlineA.Value = entity.PlineCodeA; comPlineB.Value = entity.PlineCode; comProcess.Value = entity.ProcessCode; numMaxFlow.Value = entity.FlowNumMax; numMaxnum.Value = entity.FurnaceNumMax; numZb.Value = entity.ZbLeftWt; if (entity.DefVal.Equals("是")) { chkdefVer.Checked = true; } else { chkdefVer.Checked = false; } } } }