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; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd.炼钢计划 { public partial class FrmBaseLzSpecCut : FrmBase { public FrmBaseLzSpecCut() { InitializeComponent(); } private void FrmBaseLzSpecCut_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGridSpecCut.DisplayLayout.Bands[0]); BaseHelper.setOtherColumnReadOnly(ultraGridSpecCut, new string[] { "" }); BaseHelper.InitCellPosition(ultraGridSpecCut, new string[] { "DiameterLz", "CutLenBegin", "CutLenEndUnch", "CutLenEndCh" }); InitDownList(); } private void InitDownList() { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseLzSpecCut.InitSpec", new string[] { "B" }, this.ob); comSpec.DropDownListWidth = -1; comSpec.DropDownStyle = DropDownStyle.DropDownList; comSpec.DataSource = dt; comSpec.DisplayMember = "SPEC_NAME"; comSpec.ValueMember = "SPEC_NAME"; } 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.FrmBaseLzSpecCut.query", new object[] { }, this.ob); plnBaseLzSpecCutEntityBindingSource.DataSource = listSource; } private void Add() { string dimater = comSpec.Text.Trim(); if (dimater.Equals("")) { MessageUtil.ShowWarning("请选择连铸坯直径!"); return; } string cutBegin = numCutBegin.Value == null ? "0" : numCutBegin.Value.ToString(); string unCutEnd = numUnCutEnd.Value == null ? "0" : numUnCutEnd.Value.ToString(); string cutEnd = numCutEnd.Value == null ? "0" : numCutEnd.Value.ToString(); bool flag = ChcSpec(dimater); if (flag) { MessageUtil.ShowWarning("连铸坯直径"+dimater+"已经存在,不能新增!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否新增?")==DialogResult.No){ return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseLzSpecCut.add", new string[] { dimater, cutBegin, unCutEnd, cutEnd,UserInfo.GetUserName() }, this.ob); MessageUtil.ShowTips("新增成功!"); Query(); if (ultraGridSpecCut.Rows.Count>0) foreach(UltraGridRow ugr in ultraGridSpecCut.Rows){ if (ugr.Cells["DiameterLz"].Value.ToString().Equals(dimater)) { ugr.Activate(); } } } private void Delete() { UltraGridRow ugr = ultraGridSpecCut.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要删除的记录!"); return; } string dimater=ugr.Cells["DiameterLz"].Text.Trim(); if (MessageUtil.ShowYesNoAndQuestion("是否删除连铸坯直径" + dimater + "基础数据?(此删除不可恢复)") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseLzSpecCut.delete", new string[] { dimater }, this.ob); MessageUtil.ShowTips("删除成功!"); Query(); } private void Update() { string dimater = comSpec.Text.Trim(); if (dimater.Equals("")) { MessageUtil.ShowWarning("请选择连铸坯直径!"); return; } string cutBegin = numCutBegin.Value == null ? "0" : numCutBegin.Value.ToString(); string unCutEnd = numUnCutEnd.Value == null ? "0" : numUnCutEnd.Value.ToString(); string cutEnd = numCutEnd.Value == null ? "0" : numCutEnd.Value.ToString(); bool flag = ChcSpec(dimater); if (!flag) { MessageUtil.ShowWarning("连铸坯直径" + dimater + "不存在,不能修改!"); return; } if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } ServerHelper.SetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseLzSpecCut.update", new string[] { dimater, cutBegin, unCutEnd, cutEnd, UserInfo.GetUserName() }, this.ob); MessageUtil.ShowTips("修改成功!"); Query(); if (ultraGridSpecCut.Rows.Count > 0) foreach (UltraGridRow ugr in ultraGridSpecCut.Rows) { if (ugr.Cells["DiameterLz"].Value.ToString().Equals(dimater)) { ugr.Activate(); } } } bool ChcSpec(string dimater) { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.steelMarkingPlan.FrmBaseLzSpecCut.checkSpec", new string[] { dimater }, 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 ultraGridSpecCut_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = ultraGridSpecCut.ActiveRow; if (ugr == null) { return; } PlnBaseLzSpecCutEntity entity = (PlnBaseLzSpecCutEntity)ugr.ListObject; comSpec.Value = entity.DiameterLz.ToString(); numCutBegin.Value = entity.CutLenBegin; numCutEnd.Value = entity.CutLenEndCh; numUnCutEnd.Value = entity.CutLenEndUnch; } } }