| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- 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 Core.StlMes.Client.SaleOrder.BLL;
- using CoreFS.CA06;
- using Core.Mes.Client.Comm.Tool;
- using Infragistics.Win.UltraWinEditors;
- using Core.StlMes.Client.Qcm;
- using Core.Mes.Client.Comm.Server;
- using Infragistics.Win.UltraWinGrid;
- using CoreFS.SA06;
- using Infragistics.Win;
- using Core.Mes.Client.Comm.Control;
- namespace Core.StlMes.Client.SaleOrder.Control
- {
- public partial class CraftOrdDesignStdWicCtrl : UserControl
- {
- private CraftOrdDesignStdWicBLL _designStdWicBLL;
- private CraftOrdDesignMscPlBLL _designMscPlBLL;
- private CraftOrdDesignMscPlPrcBLL _designMscPlPrcBLL;
- private OpeBase _ob;
- UltraComboEditor Wics = new UltraComboEditor();
- public CraftOrdDesignStdWicCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- _ob = ob;
- _designStdWicBLL = new CraftOrdDesignStdWicBLL(ob);
- _designMscPlBLL = new CraftOrdDesignMscPlBLL(ob);
- _designMscPlPrcBLL = new CraftOrdDesignMscPlPrcBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- LoadBaseData();
- }
- private void LoadBaseData()
- {
- UltraComboEditor ultraComPsc = new UltraComboEditor();
- UltraComboEditor ultraComProcess = new UltraComboEditor();
- UltraComboEditor ultraComJG = new UltraComboEditor();
- UltraComboEditor cmbProBigType = new UltraComboEditor();
- this.Controls.Add(ultraComPsc);
- this.Controls.Add(ultraComProcess);
- this.Controls.Add(ultraComJG);
- this.Controls.Add(cmbProBigType);
- ultraComPsc.Visible = false;
- ultraComProcess.Visible = false;
- ultraComJG.Visible = false;
- cmbProBigType.Visible = false;
- this.Controls.Add(Wics);
- Wics.Visible = false;
- //绑定数据源 产品规范描述
- QcmBaseCommon.InitDropUltraComEditor(ultraComPsc, "com.steering.pss.qcm.ComBaseQuery.getPsc", "PscDesc", _ob, false);
- //不可编辑
- UltraComboEditor cmbWtr = new UltraComboEditor();
- cmbWtr.DropDownListWidth = -1;
- this.Controls.Add(cmbWtr);
- cmbWtr.Visible = false;
- ClsBaseInfo.FillWtrExpress(cmbWtr, _ob, true);
- entityGrid1.DisplayLayout.Bands[0].Columns["Formula"].EditorComponent = cmbWtr;
- entityGrid1.DisplayLayout.Bands[0].Columns["Formula"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- QcmBaseQuery.NitializeProductBigType(cmbProBigType, false, _ob);
- ClsBaseInfo.SetComboItemHeight(cmbProBigType);
- }
-
- /// <summary>
- /// 查询质量设计水压
- /// </summary>
- /// <param name="designStdWicEntity"></param>
- public void Query(CraftOrdDesignStdWicEntity designStdWicEntity)
- {
- this.CraftOrdDesignStdWicEntityBindingSource.DataSource = _designStdWicBLL.Query(designStdWicEntity);
- }
- private string designKey = "";
- private string[] _parms;
- /// <summary>
- /// 查询质量设计水压
- /// </summary>
- /// <param name="designStdWicEntity"></param>
- public void QueryByDesignKeyWic(string[] parms)
- {
- designKey = parms[0];
- _parms = parms;
- var data = _designStdWicBLL.QueryByDesignKeyWic(parms);
- var list = data.Select(p => p.Wic).Distinct().ToList();
- if (list.Count > 1)
- {
- Wics.DataSource = data.Select(p => p.Wic).Distinct().ToList();
- QcmBaseQuery.BindColumn(Wics, "Wic", entityGrid1.DisplayLayout.Bands[0]);
- }
- this.CraftOrdDesignStdWicEntityBindingSource.DataSource = data;
- //UltraComboEditor cmb = new UltraComboEditor();
- foreach (var row in entityGrid1.Rows)
- {
- GridEdite(row);
- if (row.GetValue("CraftSource") == "0")
- {
- row.Cells["Chk"].Value = null;
- row.Cells["Chk"].Activation = Activation.ActivateOnly;
- row.Update();
- }
- //if (cmb.ValueList.FindString(row.GetValue("Wic")) == -1)
- //{
- // cmb.ValueList.ValueListItems.Add(row.GetValue("Wic"));
- //}
- }
- //cmb.DisplayStyle = EmbeddableElementDisplayStyle.WindowsVista;
- //entityGrid1.DisplayLayout.Bands[0].Columns["Wic"].EditorComponent = cmb;
- //entityGrid1.DisplayLayout.Bands[0].Columns["Wic"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
- }
- public void Clear()
- {
- this.CraftOrdDesignStdWicEntityBindingSource.Clear();
- }
- public void Save()
- {
- List<CraftOrdDesignStdWicEntity> parms = new List<CraftOrdDesignStdWicEntity>();
- var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- foreach (var row in rows)
- {
- var parm = EntityHelper.CopyEntity<CraftOrdDesignStdWicEntity>(row.ListObject);
- if (parm.MscPline == "")
- {
- MessageUtil.ShowWarning("请选择制程!");
- row.SetCellActive("MscPline");
- return;
- }
- //if (parm.ProcessDescC == "")
- //{
- // MessageUtil.ShowWarning("请选择二级工序!");
- // row.SetCellActive("ProcessDescC");
- // return;
- //}
- if (parm.Wic == "")
- {
- MessageUtil.ShowWarning("请选择水压索引码!");
- row.SetCellActive("Wic");
- return;
- }
- if (parm.PressureY == "" && parm.Pressure == "" && parm.Formula == "")
- {
- MessageUtil.ShowWarning("请输入试验压力或者试验压力公式");
- return;
- }
- string formula = parm.Formula.Replace("f", "1").Replace("YS", "1").Replace("TS", "1").Replace("D", "2").Replace("t", "1");
- if (!parm.Formula.Equals("") && formula.CompileFormula() == null)
- {
- MessageUtil.ShowWarning("公式不合法,请重新输入");
- return;
- }
- if (parm.SaveTime.Equals(""))
- {
- MessageUtil.ShowWarning("请输入保压时间");
- return;
- }
- if ((parm.Pressure != "" || parm.PressureY != "") && parm.Formula != "")
- {
- if (parm.GetMaxvalue == null && parm.GetMinvalue == null)
- {
- MessageUtil.ShowWarning("请选择取大值或取小值");
- return;
- }
- }
- parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
- parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- parm.SpeclFl = "2";
- parm.DesginKey = designKey;
- parms.Add(parm);
- }
- if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
- {
- return;
- }
- _designStdWicBLL.Save(parms);
- MessageUtil.ShowTips("保存成功!");
- QueryByDesignKeyWic(_parms);
- }
- public void Delete()
- {
- List<CraftOrdDesignStdWicEntity> parms = new List<CraftOrdDesignStdWicEntity>();
- var rows = entityGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
- foreach (var row in rows)
- {
- var parm = EntityHelper.CopyEntity<CraftOrdDesignStdWicEntity>(row.ListObject);
- parm.CreateName = CoreUserInfo.UserInfo.GetUserName();
- parm.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- parm.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- parm.SpeclFl = "2";
- parm.DesginKey = designKey;
- parms.Add(parm);
- }
- _designStdWicBLL.Delete(parms);
- }
- private void GridEdite(UltraGridRow row)
- {
- if (row.GetValue("Chk") == "True")
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.AllowEdit;
- }
- }
- }
- else
- {
- foreach (UltraGridCell cell in row.Cells)
- {
- if (cell.Column.Key == "Chk") continue;
- if (cell.Column.CellActivation == Activation.AllowEdit)
- {
- cell.Activation = Activation.ActivateOnly;
- }
- }
- }
- }
- private void entityGrid1_CellChange(object sender, CellEventArgs e)
- {
- entityGrid1.UpdateData();
- GridEdite(e.Cell.Row);
- if (e.Cell.Column.Key == "PressureY")
- {
- if (e.Cell.Value.ToString() != "")
- {
- //英制压力转公制压力系数为0.00689476
- e.Cell.Row.Cells["Pressure"].Value = Math.Round(double.Parse(e.Cell.Value.ToString()) * 0.00689476, 2);
- }
- else
- {
- e.Cell.Row.Cells["Pressure"].Value = 0;
- }
- }
- else if (e.Cell.Column.Key == "Pressure")
- {
- if (e.Cell.Value.ToString() != "")
- {
- if (double.Parse(e.Cell.Value.ToString()) > 6894.76)
- {
- MessageUtil.ShowWarning("公制压力上限为68900");
- e.Cell.Row.Cells["Pressure"].Value = 6894.76;
- }
- //公制压力转英制压力系数为14.5
- e.Cell.Row.Cells["PressureY"].Value = Math.Round(double.Parse(e.Cell.Value.ToString()) / 0.00689476, 2);
- }
- else
- {
- e.Cell.Row.Cells["PressureY"].Value = 0;
- }
- }
- }
- private void entityGrid1_AfterRowInsert(object sender, RowEventArgs e)
- {
- e.Row.Cells["GetMaxvalue"].Value = true;
- e.Row.Cells["GetMinvalue"].Value = false;
- e.Row.Cells["CraftSource"].Value = "1";
- e.Row.Cells["SpeclFl"].Value = "2";
- }
- private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
- {
- UltraGridRow row = entityGrid1.ActiveRow;
- string key = entityGrid1.ActiveCell.Column.Key;
- if (key == "MscPline")
- {
- DataTable dt = _designMscPlBLL.QueryMscPlineProcess(designKey);
- dt.Columns["MSC_PLINE"].Caption = "制程号";
- dt.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
- dt.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
- dt.Columns["PROCESS_DESC"].Caption = "工序";
- dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
- dt.Columns["WIC"].Caption = "水压内控索引码";
- DataTable dtNew = dt.Clone();
- foreach (DataRow dr in dt.Rows)
- {
- string[] wics = dr["WIC"].ToString().Split(',');
- foreach (string wic in wics)
- {
- DataRow drNew = dtNew.NewRow();
- drNew["MSC_PLINE"] = dr["MSC_PLINE"];
- drNew["WHOLE_BACKLOG"] = dr["WHOLE_BACKLOG"];
- drNew["WHOLE_BACKLOG_DESC"] = dr["WHOLE_BACKLOG_DESC"];
- drNew["PROCESS_DESC"] = dr["PROCESS_DESC"];
- drNew["PROCESS_DESC_C"] = dr["PROCESS_DESC_C"];
- drNew["PROCESS_CODE"] = dr["PROCESS_CODE"];
- drNew["PROCESS_CODE_C"] = dr["PROCESS_CODE_C"];
- drNew["WIC"] = wic.Trim();
- dtNew.Rows.Add(drNew);
- }
- }
- BaseInfoPopup popup = new BaseInfoPopup(dtNew, "MSC_PLINE", "CIC", "SIC", "DIC", "PIC", "GIC", "PROCESS_CODE", "PROCESS_CODE_C");
- GridHelper.RefreshAndAutoSize(popup.UltraGrid1);
- popup.LabelTextBox1.Caption = "制程号";
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("MscPline", popup.ChoicedRow.GetValue("MSC_PLINE"));
- row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
- row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
- row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
- row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
- row.SetValue("Wic", popup.ChoicedRow.GetValue("WIC"));
- }
- }
- else if (key == "ProcessDescC")
- {
- string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
- DataTable dt = _designMscPlPrcBLL.queryProcess(designKey, mscPline);
- dt.Columns["PROCESS_DESC"].Caption = "工序";
- dt.Columns["PROCESS_DESC_C"].Caption = "二级工序";
- BaseInfoPopup popup = new BaseInfoPopup(dt, "PROCESS_DESC_C", "PROCESS_CODE", "PROCESS_CODE_C");
- popup.LabelTextBox1.Caption = "二级工序";
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("ProcessDescC", popup.ChoicedRow.GetValue("PROCESS_DESC_C"));
- row.SetValue("ProcessCodeC", popup.ChoicedRow.GetValue("PROCESS_CODE_C"));
- row.SetValue("ProcessDesc", popup.ChoicedRow.GetValue("PROCESS_DESC"));
- row.SetValue("ProcessCode", popup.ChoicedRow.GetValue("PROCESS_CODE"));
- }
- }
- else if (key == "Wic")
- {
- string mscPline = entityGrid1.ActiveRow.GetValue("MscPline");
- string processCode = entityGrid1.ActiveRow.GetValue("ProcessCode");
- DataTable dt = _designMscPlPrcBLL.queryProcessNkIndex(designKey, mscPline, processCode);
- dt.Columns["WIC"].Caption = "水压内控索引码";
- BaseInfoPopup popup = new BaseInfoPopup(dt, "WIC", "PIC", "SIC", "DIC", "CIC", "GIC");
- popup.LabelTextBox1.Caption = "水压内控索引码";
- if (popup.ShowDialog() == DialogResult.OK)
- {
- row.SetValue("Wic", popup.ChoicedRow.GetValue("WIC"));
- }
- }
- }
- }
- }
|