using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.StlMes.Client.PlnSaleOrd.BaseMethod; using Core.Mes.Client.Comm.Control; using Core.StlMes.Client.PlnSaleOrd.工序排产.entity; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.PlnSaleOrd.工序排产.control { public partial class BaseMandrelSpec : UserControl { private string id = ""; private OpeBase ob = null; public OpeBase Ob { get { return ob; } set { ob = value; } } private string creName = ""; /// /// 创建人 /// public string CreName { get { return creName; } set { creName = value; } } /// /// 芯棒编码 /// private string mandrelId = ""; /// /// 芯棒编码 /// public string MandrelId { get { return mandrelId; } set { mandrelId = value; } } /// /// 芯棒直径 /// private string mandDimater = ""; /// /// 芯棒直径 /// public string MandDimater { get { return mandDimater; } set { mandDimater = value;} } public BaseMandrelSpec(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); this.ob = ob; container.Controls.Add(this); this.Dock = DockStyle.Fill; } /// /// 初始化 /// public void Init() { //BaseHelper.NitializeDropDownBox(txtDimater, "com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.initDimater", new Object[] { }, "DIAMETER_MANDREL", "MANDREL_ID", false, ob); PlanHelper.InitDropPline("D", "", txtPline1, this.ob); PlanHelper.InitDropPline("D", "", txtPline2, this.ob); PlanHelper.InitDropGroup("4047", txtPassModel, this.ob); BaseHelper.setOtherColumnReadOnly(entityGridMandrel, null); BaseHelper.InitCellPosition(entityGridMandrel, new string[] { "MinD", "MaxD", "MinH", "MaxH", "DiameterMandrel", "PassName", "LenSingerBill" }); ClsBaseInfo.SetComboItemHeight(txtDimater); ClsBaseInfo.SetComboItemHeight(txtPassModel); ClsBaseInfo.SetComboItemHeight(txtPline2); ClsBaseInfo.SetComboItemHeight(txtPline1); Query(); } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { //case "Query"://查询 // Query(); // break; case "Add"://新增 Add(); break; case "Update"://修改 q DoUpdate(); break; case "Delete"://删除 Delete(); break; case "Export": //导出 GridHelper.ulGridToExcel(entityGridMandrel, "芯棒产线适用规格信息"); break; default: break; } } public void Query() { txtDimater.Text = MandDimater.ToString(); //string plineCode = ""; //if (chcPline.Checked && txtPline1.Value != null) //{ plineCode = txtPline1.Value.ToString(); } List listSource = EntityHelper.GetData ("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.query1", new object[] { mandrelId }, ob); comBaseMandrelSpecEntityBindingSource.DataSource = listSource; if (!id.Equals("") && entityGridMandrel.Rows.Count > 0) { foreach (UltraGridRow ugr in entityGridMandrel.Rows) { if (ugr.Cells["RelationId"].Text.Equals(id)) { ugr.Activate(); break; } } } id = ""; } private bool CheckParams() { if (txtPline2.Value == null) { MessageUtil.ShowWarning("请选择产线!", txtPline2); return false; } if (txtPassModel.Value == null) { MessageUtil.ShowWarning("请选择孔型!", txtPassModel); return false; } if (txtDimater.Value == null) { MessageUtil.ShowWarning("请选择芯棒直径!", txtDimater); return false; } if (txtMinD == null || txtMinD.Value.ToString().Length == 0) { MessageUtil.ShowWarning("请输入外径最小值!", txtMinD); return false; } if (txtMaxD == null || txtMaxD.Value.ToString().Length == 0) { MessageUtil.ShowWarning("请输入外径最大值!", txtMaxD); return false; } if (txtMinH == null || txtMinH.Value.ToString().Length == 0) { MessageUtil.ShowWarning("请输入壁厚最小值!", txtMinH); return false; } if (txtMaxH == null || txtMaxH.Value.ToString().Length == 0) { MessageUtil.ShowWarning("请输入壁厚最大值!", txtMaxH); return false; } //if (numLenSinger == null || numLenSinger.Value.ToString().Length == 0) //{ // MessageUtil.ShowWarning("请输入单倍坯最长!", txtMaxH); // return false; //} double minD = Convert.ToDouble(txtMinD.Value.ToString()); double maxD = Convert.ToDouble(txtMaxD.Value.ToString()); if (minD > maxD) { MessageUtil.ShowWarning("外径最小值不能大于外径最大值!", txtMinD); return false; } double minH = Convert.ToDouble(txtMinH.Value.ToString()); double maxH = Convert.ToDouble(txtMaxH.Value.ToString()); if (minH > maxH) { MessageUtil.ShowWarning("壁厚最小值不能大于壁厚最大值!", txtMinH); return false; } return true; } private void Add() { if (!CheckParams()) { return; } ComBaseMandrelSpecEntity entity = new ComBaseMandrelSpecEntity(); string plineCode = txtPline2.Value.ToString(); string plineName = txtPline2.Text.Trim(); string passCode = txtPassModel.Value.ToString(); string passName = txtPassModel.Text.Trim(); string dimaterId = MandrelId.ToString(); string dimater = txtDimater.Text; string memo = txtMemo.Text.Trim(); string minD = txtMinD.Value.ToString(); string maxD = txtMaxD.Value.ToString(); string minH = txtMinH.Value.ToString(); string maxH = txtMaxH.Value.ToString(); string lenSinger = numLenSinger.Value.ToString(); entity.CreateName = creName; entity.DiameterMandrel = (decimal?)Convert.ToDouble(dimater); entity.MandrelId = dimaterId; entity.MaxD = (decimal?)Convert.ToDouble(maxD); entity.MinD = (decimal?)Convert.ToDouble(minD); entity.MaxH = (decimal?)Convert.ToDouble(maxH); entity.MinH = (decimal?)Convert.ToDouble(minH); entity.PlineCode = plineCode; entity.PlineName = plineName; entity.PassCode = passCode; entity.PassName = passName; entity.Memo = memo; entity.LenSingerBill = lenSinger; //if (double.Parse(passName)<=double.Parse(dimater)){ // MessageUtil.ShowTips("孔型不能小于等于芯棒直径!"); // return; //} if (MessageUtil.ShowYesNoAndQuestion("是否新增?") == DialogResult.No) { return; } string jsonStr = JSONFormat.Format(entity); int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.add", new object[] { jsonStr }, ob); if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; } else { MessageUtil.ShowWarning("新增成功!", entityGridMandrel); Query(); } } private void DoUpdate() { UltraGridRow ugr = entityGridMandrel.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要修改的记录!", entityGridMandrel); return; } if (!CheckParams()) { return; } ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject; string plineCode = txtPline2.Value.ToString(); string plineName = txtPline2.Text.Trim(); string passCode = txtPassModel.Value.ToString(); string passName = txtPassModel.Text.Trim(); string dimaterId = MandrelId.ToString(); string dimater = txtDimater.Text; string memo = txtMemo.Text.Trim(); string minD = txtMinD.Value.ToString(); string maxD = txtMaxD.Value.ToString(); string minH = txtMinH.Value.ToString(); string maxH = txtMaxH.Value.ToString(); string lenSinger = numLenSinger.Value.ToString(); entity.UpdateName = creName; entity.DiameterMandrel = (decimal?)Convert.ToDouble(dimater); entity.MandrelId = dimaterId; entity.MaxD = (decimal?)Convert.ToDouble(maxD); entity.MinD = (decimal?)Convert.ToDouble(minD); entity.MaxH = (decimal?)Convert.ToDouble(maxH); entity.MinH = (decimal?)Convert.ToDouble(minH); entity.PlineCode = plineCode; entity.PlineName = plineName; entity.PassCode = passCode; entity.PassName = passName; entity.Memo = memo; entity.LenSingerBill = lenSinger; //if (double.Parse(passName) <= double.Parse(dimater)) //{ // MessageUtil.ShowTips("孔型不能小于等于芯棒直径!"); // return; //} if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == DialogResult.No) { return; } id = entity.MandrelId; string jsonStr = JSONFormat.Format(entity); int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.update", new object[] { jsonStr }, ob); if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; } else { MessageUtil.ShowWarning("修改成功!", entityGridMandrel); Query(); } } private void Delete() { UltraGridRow ugr = entityGridMandrel.ActiveRow; if (ugr == null) { MessageUtil.ShowWarning("请选择要删除的记录!", entityGridMandrel); return; } if (!CheckParams()) { return; } ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject; string jsonStr = JSONFormat.Format(entity); if (MessageUtil.ShowYesNoAndQuestion("是否删除?") == DialogResult.No) { return; } int count = ServerHelper.SetData("com.steering.pss.plnsaleord.processOrder.FrmBaseMandrelSpec.delete", new object[] { jsonStr }, ob); if (count == 0) { MessageUtil.ShowTips("服务端处理失败!"); return; } else { MessageUtil.ShowWarning("删除成功!", entityGridMandrel); Query(); } } private void txtPline2_ValueChanged(object sender, EventArgs e) { if (txtPline2.Value == null) { txtPassModel.Clear(); return; } BaseHelper.NitializeDropDownBox(txtPassModel, "com.steering.pss.plnsaleord.processOrder.FrmPlnPassmodel.initPassModel", new Object[] { txtPline2.Value.ToString() }, "PASS_NAME", "PASS_CODE", false, ob); } private void chcPline_CheckedChanged(object sender, EventArgs e) { if (chcPline.Checked) { txtPline1.ReadOnly = false; } else { txtPline1.ReadOnly = true; } } private void entityGridMandrel_AfterRowActivate(object sender, EventArgs e) { UltraGridRow ugr = entityGridMandrel.ActiveRow; if (ugr == null) { txtPline2.Value = ""; txtPassModel.Value = ""; //txtDimater.Value = entity.MandrelId; txtMemo.Value = ""; txtMinD.Value = 0.00; txtMinH.Value = 0.00; txtMaxD.Value = 0.00; txtMaxH.Value = 0.00; numLenSinger.Value = 0.00; return; } ComBaseMandrelSpecEntity entity = (ComBaseMandrelSpecEntity)ugr.ListObject; txtPline2.Value = entity.PlineCode; txtPassModel.Value = entity.PassCode; //txtDimater.Value = entity.MandrelId; txtMemo.Value = entity.Memo; txtMinD.Value = entity.MinD; txtMinH.Value = entity.MinH; txtMaxD.Value = entity.MaxD; txtMaxH.Value = entity.MaxH; if (entity.LenSingerBill.Equals("")) { numLenSinger.Value = 0; } else { numLenSinger.Value = entity.LenSingerBill; } } private void BaseMandrelSpec_Load(object sender, EventArgs e) { Init(); } } }