using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class CtrlMscRBlSpec : UserControl { private OpeBase _ob; public OpeBase Ob { get { return _ob; } set { _ob = value; } } private IQueryable _queryableRows; public IQueryable QueryableRows { get { return _queryableRows; } set { _queryableRows = value; } } private ComMscRBlSpecEntity _queryCondition; public ComMscRBlSpecEntity QueryCondition { get { return _queryCondition; } set { _queryCondition = value; } } private DtMscRBlSpec _dtMscRBlSpec; private UltraComboEditor _cmbSpec; public UltraComboEditor CmbSpec { get { return _cmbSpec; } set { _cmbSpec = value; } } public CtrlMscRBlSpec(System.Windows.Forms.Control container, OpeBase ob) { InitializeComponent(); _ob = ob; container.Controls.Add(this); _queryableRows = ultraGrid1.Rows.AsQueryable().Where("Chk = 'True'"); _dtMscRBlSpec = new DtMscRBlSpec(this); this.Dock = DockStyle.Fill; InitUi(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); _cmbSpec.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend; } private void InitUi() { _cmbSpec = new UltraComboEditor(); _cmbSpec.Visible = false; _cmbSpec.DropDownListWidth = -1; QcmBaseQuery.NitializeSpec(_cmbSpec, "C", false, _ob); this.Controls.Add(_cmbSpec); ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].EditorComponent = _cmbSpec; ultraGrid1.DisplayLayout.Bands[0].Columns["SpecCode"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); } public void Query(ComMscRBlSpecEntity queryCondition) { _queryCondition = queryCondition; _dtMscRBlSpec.DoQuery("Get"); } public void QueryHead(ComMscRBlSpecEntity queryCondition) { _queryCondition = queryCondition; _dtMscRBlSpec.DoQuery("GetHead"); } public void Save() { _dtMscRBlSpec.DoAction(ActionType.Save); } public void Delete() { _dtMscRBlSpec.DoAction(ActionType.Delete); } public void Resume() { _dtMscRBlSpec.DoAction(ActionType.Resume); } public void Clear() { mscRBlSpecSrc.Clear(); } private void ultraGrid1_CellChange(object sender, CellEventArgs e) { ultraGrid1.UpdateData(); ControlUltraGrid1Edit(e.Cell.Row); } public void ControlUltraGrid1Edit(UltraGridRow row) { if (row.Band.Columns["Chk"].Hidden == false) { if (row.GetValue("Chk") == "True") { row.Cells["SpecCode"].Activation = Activation.AllowEdit; row.Cells["MinD"].Activation = Activation.AllowEdit; row.Cells["MaxD"].Activation = Activation.AllowEdit; row.Cells["MinH"].Activation = Activation.AllowEdit; row.Cells["MaxH"].Activation = Activation.AllowEdit; row.Cells["Memo"].Activation = Activation.AllowEdit; } else { row.Cells["SpecCode"].Activation = Activation.ActivateOnly; row.Cells["MinD"].Activation = Activation.ActivateOnly; row.Cells["MaxD"].Activation = Activation.ActivateOnly; row.Cells["MinH"].Activation = Activation.ActivateOnly; row.Cells["MaxH"].Activation = Activation.ActivateOnly; row.Cells["Memo"].Activation = Activation.ActivateOnly; } } } public void SetInvalidColor(UltraGridRow row) { if (row.GetValue("Validflag") == "0") { row.Appearance.ForeColor = Color.Red; } else { row.Appearance.ForeColor = Color.Black; } } private void ultraTextEditor8_EditorButtonClick(object sender, EditorButtonEventArgs e) { if (ultraGrid1.ActiveCell.Column.Key == "SpecName") { string specs = ultraGrid1.GetActiveRowValue("SPECCODE"); PopupSpecificationsBasics popup = new PopupSpecificationsBasics(specs, _ob); DialogResult result = popup.ShowDialog(); if (result == DialogResult.OK) { string specCodes = ""; string specDescs = ""; foreach (string[] strs in popup.ChoiceSpecs) { if (specCodes == "") { specCodes += strs[0]; specDescs += strs[1]; } else { specCodes += ";" + strs[0]; specDescs += ";" + strs[1]; } } ultraGrid1.ActiveRow.Cells["specCode"].Value = specCodes; ultraGrid1.ActiveRow.Cells["specName"].Value = specDescs; } } else if (ultraGrid1.ActiveCell.Column.Key == "ModelDesc") { UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow; FrmModel frms = new FrmModel(); frms.Desc = row.Cells["ModelDesc"].Value.ToString(); frms.FrmOb = _ob; frms.ShowDialog(); row.Cells["ModelCode"].Value = frms.Code; row.Cells["ModelDesc"].Value = frms.Desc; } ultraGrid1.ActiveRow.Update(); } private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e) { e.Row.Cells["MinD"].Value = null; e.Row.Cells["MaxD"].Value = null; e.Row.Cells["MinH"].Value = null; e.Row.Cells["MaxH"].Value = null; } } }