using Core.Mes.Client.Comm.Tool; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System; using System.Data; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public delegate void DetectionStdSuccessHandler(object sender, DetectionStdEventArgs e); public partial class PopupComMSCStdDetection : FrmBase { private string _psc = ""; private string _useCode = ""; private string _msc = ""; private string _dimater = ""; private string _heigth = ""; private string _model = ""; public event DetectionStdSuccessHandler DetectionStdSuccessEvent; private FrmComMSCStdDetection _frmDetectionStd; private string closeAction = ""; public PopupComMSCStdDetection(string[] args, string exceptionMsg, OpeBase ob) { InitializeComponent(); ExceptionHelper.RegistException(); _psc = args[0]; _useCode = args[1]; _msc = args[2] == "" ? "1" : args[2]; _dimater = args[3]; _heigth = args[4]; _model = args[5]; this.ob = ob; ultraStatusBar1.Panels["ExMsg"].Text = exceptionMsg; _frmDetectionStd = new FrmComMSCStdDetection(); _frmDetectionStd.PopupLoad("1", ob); _frmDetectionStd.Msc = _msc; _frmDetectionStd.CodeJg = ""; this.panel5.Controls.Add(_frmDetectionStd.Panel1); this.panel5.Controls.Add(_frmDetectionStd.UltraGrid1); _frmDetectionStd.UltraGrid1.BringToFront(); InitComBoxData(); _frmDetectionStd.UltraGrid1.AfterRowInsert += new Infragistics.Win.UltraWinGrid.RowEventHandler(UltraGrid1_AfterRowInsert); _frmDetectionStd.ToolBar_Click(null, "Query"); } void UltraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { if (e.Row.HasParent()) return; e.Row.SetValue("MSC", _msc); DataTable dt = (DataTable)((UltraComboEditor)e.Row.Band.Columns["MSC"].EditorComponent).DataSource; DataRow[] drs = dt.Select("MSC = '" + _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]; } } private void InitComBoxData() { UltraComboEditor combo = (UltraComboEditor)_frmDetectionStd.UltraGrid1.DisplayLayout.Bands[0].Columns["MSC"].EditorComponent; DataTable dt = (DataTable)combo.DataSource; dt.DefaultView.RowFilter = "MSC = '" + _msc + "'"; } private void btnClose_Click(object sender, EventArgs e) { closeAction = "Ok"; IQueryable queryable = _frmDetectionStd.UltraGrid1.Rows.AsQueryable().Where("CHC = 'True'"); int selectCount = queryable.Count(); if (selectCount == 0) { MessageUtil.ShowWarning("请选择一条主记录!"); return; } UltraGridRow[] rows = queryable.ToArray(); string dic = rows[0].GetValue("DIC"); if (DetectionStdSuccessEvent != null) { DetectionStdEventArgs e2 = new DetectionStdEventArgs(); e2.Result = "1"; e2.Dic = dic; DetectionStdSuccessEvent.Invoke(this, e2); } this.DialogResult = DialogResult.OK; } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "查询": _frmDetectionStd.ToolBar_Click(null, "Query"); break; case "保存": _frmDetectionStd.ToolBar_Click(null, "Save"); break; case "作废": _frmDetectionStd.ToolBar_Click(null, "Delete"); break; case "恢复": _frmDetectionStd.ToolBar_Click(null, "Resume"); break; case "复制": _frmDetectionStd.ToolBar_Click(null, "Copy"); break; case "粘贴": _frmDetectionStd.ToolBar_Click(null, "Paste"); break; case "刷新": _frmDetectionStd.ToolBar_Click(null, "Refresh"); break; case "分组": _frmDetectionStd.ToolBar_Click(null, "Group"); break; case "取消分组": _frmDetectionStd.ToolBar_Click(null, "Cancel"); break; case "关闭": this.Close(); break; } } private void PopupComMSCStdDetection_FormClosing(object sender, FormClosingEventArgs e) { if (DetectionStdSuccessEvent != null && closeAction == "") { DetectionStdEventArgs e2 = new DetectionStdEventArgs(); e2.Result = "0"; DetectionStdSuccessEvent.Invoke(this, e2); } } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } public class DetectionStdEventArgs : EventArgs { private string _dic = ""; public string Dic { get { return _dic; } set { _dic = value; } } private string _result = ""; public string Result { get { return _result; } set { _result = value; } } } }