| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.Qcm.BLL;
- using Core.StlMes.Client.Qcm.model;
- using CoreFS.CA06;
- using CoreFS.SA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace Core.StlMes.Client.Qcm.Control
- {
- public partial class ComBaseSplineCCtrl : UserControl
- {
- private ComBaseSplineCBLL _splineCBLL;
- private OpeBase _ob;
- public ComBaseSplineCCtrl(System.Windows.Forms.Control container, OpeBase ob)
- {
- InitializeComponent();
- this._ob = ob;
- _splineCBLL = new ComBaseSplineCBLL(ob);
- container.Controls.Add(this);
- this.Dock = DockStyle.Fill;
- this.BringToFront();
- EntityHelper.ShowGridCaption<ComBaseSplineCEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- }
- public void Query(string eic, string validflag)
- {
- comBaseSplineCEntityBindingSource.DataSource = _splineCBLL.Query(eic, validflag);
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Query2(string eic)
- {
- comBaseSplineCEntityBindingSource.DataSource = _splineCBLL.Query2(eic);
- foreach (var row in ultraGrid1.Rows)
- {
- GridEdite(row);
- }
- }
- public void Clear()
- {
- comBaseSplineCEntityBindingSource.Clear();
- }
- public void ClearDataSource()
- {
- this.comBaseSplineCEntityBindingSource.Clear();
- }
- public void Save()
- {
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
- .Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
- foreach (var row in rows)
- {
- row.CreateName = CoreUserInfo.UserInfo.GetUserName();
- row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- }
- _splineCBLL.Save(rows);
- }
- public List<ComBaseSplineCEntity2> GetSaveParms()
- {
- ultraGrid1.UpdateData();
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True");
- List<ComBaseSplineCEntity2> splineCEntitys = new List<ComBaseSplineCEntity2>();
- //.Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
- foreach (var row in rows)
- {
- ComBaseSplineCEntity2 splineCEntity = EntityHelper.CopyEntity<ComBaseSplineCEntity2>(row.ListObject);
- if (splineCEntity.MinDSign != "" && splineCEntity.MinD == "")
- {
- MessageUtil.ShowWarning("请输入外径下限值!");
- row.SetCellActive("MinD");
- return null;
- }
- else if (splineCEntity.MinDSign == "" && splineCEntity.MinD != "")
- {
- MessageUtil.ShowWarning("请选择外径下限符号!");
- row.SetCellActive("MinDSign");
- return null;
- }
- else if (splineCEntity.MaxDSign != "" && splineCEntity.MaxD == "")
- {
- MessageUtil.ShowWarning("请输入外径上限值!");
- row.SetCellActive("MaxD");
- return null;
- }
- else if (splineCEntity.MaxDSign == "" && splineCEntity.MaxD != "")
- {
- MessageUtil.ShowWarning("请选择外径上限符号!");
- row.SetCellActive("MaxDSign");
- return null;
- }
- else if (splineCEntity.MinHSign != "" && splineCEntity.MinH == "")
- {
- MessageUtil.ShowWarning("请输入壁厚下限值!");
- row.SetCellActive("MinH");
- return null;
- }
- else if (splineCEntity.MinHSign == "" && splineCEntity.MinH != "")
- {
- MessageUtil.ShowWarning("请选择壁厚下限符号!");
- row.SetCellActive("MinHSign");
- return null;
- }
- else if (splineCEntity.MaxHSign != "" && splineCEntity.MaxH == "")
- {
- MessageUtil.ShowWarning("请输入壁厚上限值!");
- row.SetCellActive("MaxH");
- return null;
- }
- else if (splineCEntity.MaxHSign == "" && splineCEntity.MaxH != "")
- {
- MessageUtil.ShowWarning("请选择壁厚上限符号!");
- row.SetCellActive("MaxHSign");
- return null;
- }
- else if (splineCEntity.MinDSign == "=" && splineCEntity.MaxDSign != "")
- {
- MessageUtil.ShowWarning("外径下限符号为等号时,不能存在外径上限符号和外径上限值!");
- row.SetCellActive("MaxDSign");
- return null;
- }
- else if (splineCEntity.MinHSign == "=" && splineCEntity.MaxHSign != "")
- {
- MessageUtil.ShowWarning("壁厚下限符号为等号时,不能存在壁厚上限符号和壁厚上限值!");
- row.SetCellActive("MaxHSign");
- return null;
- }
- else if (splineCEntity.MinD != "" && splineCEntity.MaxD != ""
- && decimal.Parse(splineCEntity.MinD) >= decimal.Parse(splineCEntity.MaxD))
- {
- MessageUtil.ShowWarning("外径下限值不能大于等于外径上限值!");
- row.SetCellActive("MinD");
- return null;
- }
- else if (splineCEntity.MinH != "" && splineCEntity.MaxH != ""
- && decimal.Parse(splineCEntity.MinH) >= decimal.Parse(splineCEntity.MaxH))
- {
- MessageUtil.ShowWarning("壁厚下限值不能大于等于壁厚上限值!");
- row.SetCellActive("MinH");
- return null;
- }
- else if (splineCEntity.Formula != "" || splineCEntity.MinF != "" || splineCEntity.MinFSign != ""
- || splineCEntity.MaxF != "" || splineCEntity.MaxFSign != "")
- {
- string formula = splineCEntity.Formula.Replace("t", "0.01").Replace("D", "0.01");
- string formula2 = splineCEntity.Formula.Replace("t", "10000").Replace("D", "10000");
- if (splineCEntity.Formula == "")
- {
- MessageUtil.ShowWarning("请输入公式!");
- row.SetCellActive("Formula");
- return null;
- }
- else if (formula.CompileFormula() == null && formula2.CompileFormula() == null)
- {
- MessageUtil.ShowWarning("输入的公式不合法!");
- row.SetCellActive("Formula");
- return null;
- }
- else if (splineCEntity.MinF == "" && splineCEntity.MinFSign != "")
- {
- MessageUtil.ShowWarning("请输入公式下限值!");
- row.SetCellActive("MinF");
- return null;
- }
- else if (splineCEntity.MinF != "" && splineCEntity.MinFSign == "")
- {
- MessageUtil.ShowWarning("请输入公式下限符号!");
- row.SetCellActive("MinFSign");
- return null;
- }
- else if (splineCEntity.MaxF == "" && splineCEntity.MaxFSign != "")
- {
- MessageUtil.ShowWarning("请输入公式上限值!");
- row.SetCellActive("MaxF");
- return null;
- }
- else if (splineCEntity.MaxF != "" && splineCEntity.MaxFSign == "")
- {
- MessageUtil.ShowWarning("请输入公式上限符号!");
- row.SetCellActive("MaxFSign");
- return null;
- }
- else if (splineCEntity.Formula != "" && splineCEntity.MinF == "" && splineCEntity.MinFSign == ""
- && splineCEntity.MaxF == "" && splineCEntity.MaxFSign == "")
- {
- MessageUtil.ShowWarning("请输入公式下限符号!");
- row.SetCellActive("MinFSign");
- return null;
- }
- }
- else if (splineCEntity.MinF != "" && splineCEntity.MaxF != ""
- && decimal.Parse(splineCEntity.MinF) >= decimal.Parse(splineCEntity.MaxF))
- {
- MessageUtil.ShowWarning("公式下限值不能大于等于公式上限值!");
- row.SetCellActive("MinF");
- return null;
- }
- var steelCodes = row.GetValue("SteelCodes").Split(';').ToArray();
- //var steelDescs = row.GetValue("SteelDescs").Split(';').ToArray();
- splineCEntity.SplineCRSteel = new List<ComBaseSplineCRSteelEntity>();
- for (int i = 0; i < steelCodes.Length; i++)
- {
- if (steelCodes[i] == "") continue;
- splineCEntity.SplineCRSteel.Add(new ComBaseSplineCRSteelEntity()
- {
- Steelcode = steelCodes[i],
- CreateName = CoreUserInfo.UserInfo.GetUserName()
- });
- }
- var productCodes = row.GetValue("ProductCodes").Split(';').ToArray();
- //var productDescs = row.GetValue("ProductDescs").Split(';').ToArray();
- splineCEntity.SplineCRProduct = new List<ComBaseSplineCRProductEntity>();
- for (int i = 0; i < productCodes.Length; i++)
- {
- if (productCodes[i] == "") continue;
- splineCEntity.SplineCRProduct.Add(new ComBaseSplineCRProductEntity()
- {
- Produccode = productCodes[i],
- CreateName = CoreUserInfo.UserInfo.GetUserName()
- });
- }
- var stdCodes = row.GetValue("StdCode").Split(';').ToArray();
- //var stdNames = row.GetValue("StdName").Split(';').ToArray();
- splineCEntity.SplineCRStd = new List<ComBaseSplineCRStdEntity>();
- for (int i = 0; i < stdCodes.Length; i++)
- {
- if (stdCodes[i] == "") continue;
- splineCEntity.SplineCRStd.Add(new ComBaseSplineCRStdEntity()
- {
- StdCode = stdCodes[i]
- });
- }
- var modelCodes = row.GetValue("ModelCodes").Split('|').ToArray();
- //var modelNames = row.GetValue("ModelDescs").Split('|').ToArray();
- splineCEntity.SplineCRModel = new List<ComBaseSplineCRModelEntity>();
- for (int i = 0; i < modelCodes.Length; i++)
- {
- if (modelCodes[i] == "") continue;
- splineCEntity.SplineCRModel.Add(new ComBaseSplineCRModelEntity()
- {
- ModelCode = modelCodes[i]
- });
- }
- splineCEntity.CreateName = CoreUserInfo.UserInfo.GetUserName();
- splineCEntity.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- splineCEntitys.Add(splineCEntity);
- }
- return splineCEntitys;
- }
- public void UpdateValidflag(string validflag)
- {
- var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True")
- .Select(a => EntityHelper.CopyEntity<ComBaseSplineCEntity>(a.ListObject)).ToList();
- foreach (var row in rows)
- {
- row.DeleteName = CoreUserInfo.UserInfo.GetUserName();
- row.UpdateName = CoreUserInfo.UserInfo.GetUserName();
- }
- _splineCBLL.UpdateValidflag(rows, validflag);
- }
- private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
- {
- e.Cell.Row.Update();
- GridEdite(e.Cell.Row);
- }
- 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 ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- var actRow = ultraGrid1.ActiveRow;
- if (ultraGrid1.ActiveCell.Column.Key == "StdName")
- {
- //this.Cursor = Cursors.WaitCursor;
- //ComBaseSplineCEntity splineCEntity = (ComBaseSplineCEntity)ultraGrid1.ActiveRow.ListObject;
- //DataTable dt = _splineCBLL.GetComBaseStd();
- //dt.Columns["STD_NAME"].Caption = "标准名称";
- //dt.Columns["STDSTYLE"].Caption = "标准类型";
- //BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME", "STD_CODE");
- //baseInfoPopup.LabelTextBox1.Caption = "标准名称";
- //baseInfoPopup.Shown += new EventHandler((c, d) =>
- //{
- // var row = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
- // a => a.GetValue("STD_CODE") == splineCEntity.StdCode).FirstOrDefault();
- // if (row != null)
- // {
- // row.Activate();
- // }
- //});
- //GridHelper.RefreshAndAutoSize(baseInfoPopup.UltraGrid1);
- //this.Cursor = Cursors.Default;
- //if (baseInfoPopup.ShowDialog() == DialogResult.OK)
- //{
- // ultraGrid1.ActiveRow.SetValue("StdCode", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
- // ultraGrid1.ActiveRow.SetValue("StdName", baseInfoPopup.ChoicedRow.GetValue("STD_NAME"));
- //}
- this.Cursor = Cursors.WaitCursor;
- ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "G", "X" }, actRow.GetValue("StdCode"), _ob);
- this.Cursor = Cursors.Default;
- if (baseStdChoice.ShowDialog() == DialogResult.OK)
- {
- actRow.SetValue("StdCode", baseStdChoice.ChoiceStdCodes);
- actRow.SetValue("StdName", baseStdChoice.ChoiceStdNames);
- }
- }
- else if (ultraGrid1.ActiveCell.Column.Key == "ProductDescs")
- {
- this.Cursor = Cursors.WaitCursor;
- PopupProductName popupProductName = new PopupProductName(actRow.GetValue("ProductCodes"), _ob);
- this.Cursor = Cursors.Default;
- if (popupProductName.ShowDialog() == DialogResult.OK)
- {
- actRow.SetValue("ProductCodes", popupProductName.ProductCodes);
- actRow.SetValue("ProductDescs", popupProductName.ProductNames);
- }
- }
- else if (ultraGrid1.ActiveCell.Column.Key == "SteelDescs")
- {
- FrmRepSteel frmRepSteel = new FrmRepSteel();
- frmRepSteel.Code = actRow.GetValue("SteelCodes");
- frmRepSteel.Ob1 = _ob;
- if (frmRepSteel.ShowDialog() == DialogResult.OK)
- {
- actRow.SetValue("SteelCodes", frmRepSteel.Code);
- actRow.SetValue("SteelDescs", frmRepSteel.Desc);
- }
- }
- else if (ultraGrid1.ActiveCell.Column.Key == "ModelDescs")
- {
- FrmModel frmModel = new FrmModel();
- frmModel.Code = actRow.GetValue("ModelCodes");
- frmModel.Desc = actRow.GetValue("ModelDescs");
- frmModel.FrmOb = _ob;
- if (frmModel.ShowDialog() == DialogResult.OK)
- {
- actRow.SetValue("ModelCodes", frmModel.Code);
- actRow.SetValue("ModelDescs", frmModel.Desc);
- }
- }
- }
- private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
- {
- if (e.Row.GetValue("Validflag") == "无效")
- {
- e.Row.Appearance.ForeColor = Color.Red;
- }
- }
- }
- }
|