| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- 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 = "";
- /// <summary>
- /// 创建人
- /// </summary>
- public string CreName
- {
- get { return creName; }
- set { creName = value; }
- }
- /// <summary>
- /// 芯棒编码
- /// </summary>
- private string mandrelId = "";
- /// <summary>
- /// 芯棒编码
- /// </summary>
- public string MandrelId
- {
- get { return mandrelId; }
- set { mandrelId = value; }
- }
- /// <summary>
- /// 芯棒直径
- /// </summary>
- private string mandDimater = "";
- /// <summary>
- /// 芯棒直径
- /// </summary>
- 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;
- }
- /// <summary>
- /// 初始化
- /// </summary>
- 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<ComBaseMandrelSpecEntity> listSource = EntityHelper.GetData<ComBaseMandrelSpecEntity>
- ("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();
- }
- }
- }
|