using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Data; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class CtrlMSCDetection : UserControl { public FrmComMSCStdDetection _frmDetectionStd; private bool isLoaded = false; private string _customInfo; public event BeforeRowInsertEventHandler BeforeRowInsert; public OpeBase Ob { get { return _frmDetectionStd.ob; } set { _frmDetectionStd.ob = value; } } public UltraGrid Grid { get { return _frmDetectionStd.UltraGrid1; } } public DataTable DetectionDataTable1 { get { return _frmDetectionStd.DataTable1; } } public DataTable DetectionDataTable2 { get { return _frmDetectionStd.DataTable2; } } public bool IsQueryValidData { get { return _frmDetectionStd.UltraCheckValid.Checked; } set { _frmDetectionStd.UltraCheckValid.Checked = value; } } public CtrlMSCDetection(System.Windows.Forms.Control container) { InitializeComponent(); this.Dock = DockStyle.Fill; _frmDetectionStd = new FrmComMSCStdDetection(); _frmDetectionStd.UltraGrid1.BeforeRowInsert += new BeforeRowInsertEventHandler(UltraGrid1_BeforeRowInsert); _frmDetectionStd.UltraGrid1.AfterRowInsert += new Infragistics.Win.UltraWinGrid.RowEventHandler(UltraGrid1_AfterRowInsert); this.Controls.Add(_frmDetectionStd.UltraGrid1); container.Controls.Add(this); this.BringToFront(); } public void ShowGrid(string msc, OpeBase ob) { if (isLoaded == false) { _frmDetectionStd.Msc = msc; _frmDetectionStd.PopupLoad("1", ob); _customInfo = "1"; isLoaded = true; } else { if (_frmDetectionStd.Msc != "" && _frmDetectionStd.Msc != msc) { _frmDetectionStd.Msc = msc; this.RefreshData(); } } } /// /// 显示以标准为查询条件的内控标准 /// public void ShowStdGrid(string stdCode, string stdCodeSNk, string stdStyleSNk, string isNkEdite, string produccodeNk, string steelcodeNk, string processCode, OpeBase ob) { if (isLoaded == false) { //_frmChemStd = new FrmChemStandard(); //_frmChemStd.Msc = msc; _frmDetectionStd.StdCode = stdCode; _frmDetectionStd.ProduccodeNk = produccodeNk; _frmDetectionStd.SteelcodeNk = steelcodeNk; _frmDetectionStd.StdCodesNk = stdCodeSNk; _frmDetectionStd.StdStylesNk = stdStyleSNk; _frmDetectionStd.IsNkEdite = isNkEdite; _frmDetectionStd.ProcessCode = processCode; _frmDetectionStd.PopupLoad("2", ob); _customInfo = "2"; isLoaded = true; } else { if (_frmDetectionStd.StdCode != "" && _frmDetectionStd.StdCode != stdCode) { _frmDetectionStd.StdCode = stdCode; _frmDetectionStd.ProduccodeNk = produccodeNk; _frmDetectionStd.SteelcodeNk = steelcodeNk; _frmDetectionStd.StdCodesNk = stdCodeSNk; _frmDetectionStd.StdStylesNk = stdStyleSNk; _frmDetectionStd.IsNkEdite = isNkEdite; _frmDetectionStd.ProcessCode = processCode; //this.RefreshData(); _frmDetectionStd.PopupRefresh(); } } } public void ShowPurchaseGrid(OpeBase ob) { if (isLoaded) { _frmDetectionStd.PopupRefresh(); } else { _frmDetectionStd.PopupLoad("2", ob); isLoaded = true; } } public void Query(string msc, string codeJg) { _frmDetectionStd.Msc = msc; _frmDetectionStd.CodeJg = codeJg; _frmDetectionStd.ToolBar_Click(null, "Query"); } public void QueryStd(string stdCode, string modelCode) { _frmDetectionStd.StdCode = stdCode; _frmDetectionStd.ModelCode = modelCode; _frmDetectionStd.ToolBar_Click(null, "Query"); } public void QueryPurchaseAgreement(string stdCodeNk) { _frmDetectionStd.QueryPurchaseAgreement(stdCodeNk); } public void Save() { _frmDetectionStd.ToolBar_Click(null, "Save"); } public void Delete() { _frmDetectionStd.ToolBar_Click(null, "Delete"); } public void Resume() { _frmDetectionStd.ToolBar_Click(null, "Resume"); } public void Copy() { _frmDetectionStd.ToolBar_Click(null, "Copy"); } public void Paste() { _frmDetectionStd.ToolBar_Click(null, "Paste"); } public void RefreshData() { _frmDetectionStd.ToolBar_Click(null, "Refresh"); } public void Group() { _frmDetectionStd.ToolBar_Click(null, "Group"); } public void CancelGroup() { _frmDetectionStd.ToolBar_Click(null, "Cancel"); } public void Clear() { _frmDetectionStd.DataTable2.Clear(); _frmDetectionStd.DataTable1.Clear(); } public void ExpandFirstRow() { if (_frmDetectionStd.UltraGrid1.Rows.Count > 0) { _frmDetectionStd.UltraGrid1.Rows[0].ExpandAll(); } } private void UltraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { if (e.Row.HasParent()) return; if (_customInfo == "1") { e.Row.SetValue("MSC", _frmDetectionStd.Msc); DataTable dt = (DataTable)((UltraComboEditor)e.Row.Band.Columns["MSC"].EditorComponent).DataSource; DataRow[] drs = dt.Select("MSC = '" + _frmDetectionStd.Msc + "'"); if (drs.Length > 0) { e.Row.Cells["PSC"].Value = drs[0][2]; e.Row.Cells["PSC_DESC"].Value = drs[0][3]; e.Row.Cells["PRODUCNAME"].Value = drs[0][4]; if (e.Row.Cells.Exists("STD_NAME_B")) { e.Row.Cells["STD_NAME_B"].Value = drs[0][5]; } else { e.Row.Cells["STD_NAME"].Value = drs[0][5]; } e.Row.Cells["STEELNAME"].Value = drs[0][6]; e.Row.Cells["STD_STYLE_DESC"].Value = drs[0][7]; e.Row.Cells["STDSTYLE"].Value = drs[0][8]; } } else if (_customInfo == "2") { e.Row.Cells["STD_CODE_NK"].Value = _frmDetectionStd.StdCode; DataTable dt = (DataTable)((UltraComboEditor)e.Row.Band.Columns["STD_CODE_NK"].EditorComponent).DataSource; DataRow[] drs = dt.Select("STD_CODE = '" + _frmDetectionStd.StdCode + "'"); if (drs.Length > 0) { e.Row.Cells["STD_NAME_NK"].Value = drs[0][1]; e.Row.Cells["STDSTYLE"].Value = drs[0][2]; } } } private void UltraGrid1_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e) { if (BeforeRowInsert != null) { BeforeRowInsert(sender, e); } } } }