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 CoreFS.SA06; using Infragistics.Win.UltraWinGrid; using Core.StlMes.Client.Qcm; using Core.StlMes.Client.SaleOrder.Dialog; using Core.Mes.Client.Comm.Control; namespace Core.StlMes.Client.SaleOrder.Control { public partial class CraftFileLv2CCtrl : UserControl { private CraftFileLv2CBLL _craftFileLv2CBLL; private OpeBase _ob; public CraftFileLv2CCtrl(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); _ob = ob; _craftFileLv2CBLL = new CraftFileLv2CBLL(ob); container.Controls.Add(this); this.Dock = DockStyle.Fill; EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } private string _fileLv2Pk; private string _validflag; public void Query(string fileLv2Pk, string validflag) { _fileLv2Pk = fileLv2Pk; _validflag = validflag; var dataSource = _craftFileLv2CBLL.Query(fileLv2Pk, validflag); craftFileLv2CEntityBindingSource.DataSource = dataSource; foreach (var row in ultraGrid1.Rows) { GridEdite(row); if (row.GetValue("VALIDFLAG") == "无效") { row.Appearance.ForeColor = Color.Red; } } } public void Clear() { craftFileLv2CEntityBindingSource.Clear(); } public List GetSaveParms() { ultraGrid1.UpdateData(); var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True"); var parms = new List(); foreach (var row in rows) { var craftFileLv2C = EntityHelper.CopyEntity(row.ListObject); if (craftFileLv2C.Gradecode == "" && craftFileLv2C.MaxDSign == "" && craftFileLv2C.MaxHSign == "" && craftFileLv2C.MinDSign == "" && craftFileLv2C.MinHSign == "" && craftFileLv2C.ModelCode == "" && craftFileLv2C.Produccode == "" && craftFileLv2C.StdCode == "" && craftFileLv2C.Steelcode == "" && craftFileLv2C.CraftNo == "") { MessageUtil.ShowWarning("请至少输入一种适用条件"); row.Activate(); return null; } if (craftFileLv2C.MinDSign != "" && craftFileLv2C.MinD == "") { MessageUtil.ShowWarning("请输入外径下限值!"); row.SetCellActive("MinD"); return null; } else if (craftFileLv2C.MinDSign == "" && craftFileLv2C.MinD != "") { MessageUtil.ShowWarning("请选择外径下限符号!"); row.SetCellActive("MinDSign"); return null; } else if (craftFileLv2C.MaxHSign != "" && craftFileLv2C.MaxH == "") { MessageUtil.ShowWarning("请输入壁厚上限值!"); row.SetCellActive("MaxH"); return null; } else if (craftFileLv2C.MaxHSign == "" && craftFileLv2C.MaxH != "") { MessageUtil.ShowWarning("请选择壁厚上限符号!"); row.SetCellActive("MaxHSign"); return null; } else if (craftFileLv2C.MinHSign != "" && craftFileLv2C.MinH == "") { MessageUtil.ShowWarning("请输入壁厚下限值!"); row.SetCellActive("MinH"); return null; } else if (craftFileLv2C.MinHSign == "" && craftFileLv2C.MinH != "") { MessageUtil.ShowWarning("请选择壁厚下限符号!"); row.SetCellActive("MinHSign"); return null; } else if (craftFileLv2C.MaxHSign != "" && craftFileLv2C.MaxH == "") { MessageUtil.ShowWarning("请输入壁厚上限值!"); row.SetCellActive("MaxH"); return null; } else if (craftFileLv2C.MaxHSign == "" && craftFileLv2C.MaxH != "") { MessageUtil.ShowWarning("请选择壁厚上限符号!"); row.SetCellActive("MaxHSign"); return null; } else if (craftFileLv2C.MinD != "" && craftFileLv2C.MaxD != "" && decimal.Parse(craftFileLv2C.MinD) > decimal.Parse(craftFileLv2C.MaxD)) { MessageUtil.ShowWarning("外径下限值不能大于外径上限值!"); row.SetCellActive("MinD"); return null; } else if (craftFileLv2C.MinH != "" && craftFileLv2C.MaxH != "" && decimal.Parse(craftFileLv2C.MinH) > decimal.Parse(craftFileLv2C.MaxH)) { MessageUtil.ShowWarning("壁厚下限值不能大于壁厚上限值!"); row.SetCellActive("MinH"); return null; } craftFileLv2C.CreateName = CoreUserInfo.UserInfo.GetUserName(); craftFileLv2C.UpdateName = CoreUserInfo.UserInfo.GetUserName(); parms.Add(craftFileLv2C); } return parms; } public List GetUpdateValidflagParms() { ultraGrid1.UpdateData(); var rows = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True"); var parms = new List(); string pk = ""; foreach (var row in rows) { var craftFileLv2C = EntityHelper.CopyEntity(row.ListObject); craftFileLv2C.CreateName = CoreUserInfo.UserInfo.GetUserName(); craftFileLv2C.UpdateName = CoreUserInfo.UserInfo.GetUserName(); parms.Add(craftFileLv2C); pk = craftFileLv2C.Pk; } return parms; } public void Relocate(string pk) { Query(_fileLv2Pk, _validflag); var row = ultraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Pk") == pk).FirstOrDefault(); if (row != null) { row.Activate(); } } 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; } } } ultraGrid1.UpdateData(); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { e.Cell.Row.Update(); GridEdite(e.Cell.Row); } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { switch (ultraGrid1.ActiveCell.Column.Key) { case "CraftNo": CraftOrdDesignFilePopup popup = new CraftOrdDesignFilePopup(null, "ChoiceCraftNo", _ob); popup.IsMultiChoice = true; GridHelper.SetExcludeColumnsActive(popup.UltraGrid1.DisplayLayout.Bands[0], "CHK"); popup.CraftNos = ultraGrid1.ActiveRow.GetValue("CraftNo"); if (popup.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("CraftNo", popup.CraftNos); } break; case "Producname": string producCodes = ultraGrid1.ActiveRow.GetValue("Produccode"); PopupProductName popupProduct = new PopupProductName(producCodes, _ob); if (popupProduct.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("Produccode", popupProduct.ProductCodes); ultraGrid1.ActiveRow.SetValue("Producname", popupProduct.ProductNames); } break; case "Steelname": string steelCodes = ultraGrid1.ActiveRow.GetValue("Steelcode"); FrmRepSteel frmRepSteel = new FrmRepSteel(); frmRepSteel.Ob1 = _ob; frmRepSteel.Code = steelCodes; if (frmRepSteel.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("Steelcode", frmRepSteel.Code); ultraGrid1.ActiveRow.SetValue("Steelname", frmRepSteel.Desc); } break; case "StdName": string stdCodes = ultraGrid1.ActiveRow.GetValue("StdCode"); ComBaseStdChoice baseStdChoice = new ComBaseStdChoice(new string[] { "G", "X" }, stdCodes, _ob); if (baseStdChoice.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("StdCode", baseStdChoice.ChoiceStdCodes); ultraGrid1.ActiveRow.SetValue("StdName", baseStdChoice.ChoiceStdNames); } break; case "Gradename": string gradeNames = ultraGrid1.ActiveRow.GetValue("Gradename"); FrmGradeChoice gradeChoice = new FrmGradeChoice(gradeNames, _ob); if (gradeChoice.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("Gradecode", gradeChoice.GradeCodes); ultraGrid1.ActiveRow.SetValue("Gradename", gradeChoice.GradeNames); } break; case "ModelDesc": string modelDescs = ultraGrid1.ActiveRow.GetValue("ModelDesc"); FrmModel frmModel = new FrmModel(); frmModel.FrmOb = _ob; frmModel.Desc = modelDescs; if(frmModel.ShowDialog() == DialogResult.OK) { ultraGrid1.ActiveRow.SetValue("ModelCode", frmModel.Code); ultraGrid1.ActiveRow.SetValue("ModelDesc", frmModel.Desc); } break; } } } }