PopupComMSCStdDetection.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using Core.Mes.Client.Comm.Tool;
  2. using CoreFS.CA06;
  3. using Infragistics.Win.UltraWinEditors;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Windows.Forms;
  9. namespace Core.StlMes.Client.Qcm
  10. {
  11. public delegate void DetectionStdSuccessHandler(object sender, DetectionStdEventArgs e);
  12. public partial class PopupComMSCStdDetection : FrmBase
  13. {
  14. private string _psc = "";
  15. private string _useCode = "";
  16. private string _msc = "";
  17. private string _dimater = "";
  18. private string _heigth = "";
  19. private string _model = "";
  20. public event DetectionStdSuccessHandler DetectionStdSuccessEvent;
  21. private FrmComMSCStdDetection _frmDetectionStd;
  22. private string closeAction = "";
  23. public PopupComMSCStdDetection(string[] args, string exceptionMsg, OpeBase ob)
  24. {
  25. InitializeComponent();
  26. ExceptionHelper.RegistException();
  27. _psc = args[0];
  28. _useCode = args[1];
  29. _msc = args[2] == "" ? "1" : args[2];
  30. _dimater = args[3];
  31. _heigth = args[4];
  32. _model = args[5];
  33. this.ob = ob;
  34. ultraStatusBar1.Panels["ExMsg"].Text = exceptionMsg;
  35. _frmDetectionStd = new FrmComMSCStdDetection();
  36. _frmDetectionStd.PopupLoad("1", ob);
  37. _frmDetectionStd.Msc = _msc;
  38. _frmDetectionStd.CodeJg = "";
  39. this.panel5.Controls.Add(_frmDetectionStd.Panel1);
  40. this.panel5.Controls.Add(_frmDetectionStd.UltraGrid1);
  41. _frmDetectionStd.UltraGrid1.BringToFront();
  42. InitComBoxData();
  43. _frmDetectionStd.UltraGrid1.AfterRowInsert += new Infragistics.Win.UltraWinGrid.RowEventHandler(UltraGrid1_AfterRowInsert);
  44. _frmDetectionStd.ToolBar_Click(null, "Query");
  45. }
  46. void UltraGrid1_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  47. {
  48. if (e.Row.HasParent()) return;
  49. e.Row.SetValue("MSC", _msc);
  50. DataTable dt = (DataTable)((UltraComboEditor)e.Row.Band.Columns["MSC"].EditorComponent).DataSource;
  51. DataRow[] drs = dt.Select("MSC = '" + _msc + "'");
  52. if (drs.Length > 0)
  53. {
  54. e.Row.Cells["PSC"].Value = drs[0][2];
  55. e.Row.Cells["PSC_DESC"].Value = drs[0][3];
  56. e.Row.Cells["PRODUCNAME"].Value = drs[0][4];
  57. if (e.Row.Cells.Exists("STD_NAME_B"))
  58. {
  59. e.Row.Cells["STD_NAME_B"].Value = drs[0][5];
  60. }
  61. else
  62. {
  63. e.Row.Cells["STD_NAME"].Value = drs[0][5];
  64. }
  65. e.Row.Cells["STEELNAME"].Value = drs[0][6];
  66. e.Row.Cells["STD_STYLE_DESC"].Value = drs[0][7];
  67. e.Row.Cells["STDSTYLE"].Value = drs[0][8];
  68. }
  69. }
  70. private void InitComBoxData()
  71. {
  72. UltraComboEditor combo = (UltraComboEditor)_frmDetectionStd.UltraGrid1.DisplayLayout.Bands[0].Columns["MSC"].EditorComponent;
  73. DataTable dt = (DataTable)combo.DataSource;
  74. dt.DefaultView.RowFilter = "MSC = '" + _msc + "'";
  75. }
  76. private void btnClose_Click(object sender, EventArgs e)
  77. {
  78. closeAction = "Ok";
  79. IQueryable<UltraGridRow> queryable = _frmDetectionStd.UltraGrid1.Rows.AsQueryable().Where("CHC = 'True'");
  80. int selectCount = queryable.Count();
  81. if (selectCount == 0)
  82. {
  83. MessageUtil.ShowWarning("请选择一条主记录!");
  84. return;
  85. }
  86. UltraGridRow[] rows = queryable.ToArray();
  87. string dic = rows[0].GetValue("DIC");
  88. if (DetectionStdSuccessEvent != null)
  89. {
  90. DetectionStdEventArgs e2 = new DetectionStdEventArgs();
  91. e2.Result = "1";
  92. e2.Dic = dic;
  93. DetectionStdSuccessEvent.Invoke(this, e2);
  94. }
  95. this.DialogResult = DialogResult.OK;
  96. }
  97. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  98. {
  99. switch (e.Tool.Key)
  100. {
  101. case "查询":
  102. _frmDetectionStd.ToolBar_Click(null, "Query");
  103. break;
  104. case "保存":
  105. _frmDetectionStd.ToolBar_Click(null, "Save");
  106. break;
  107. case "作废":
  108. _frmDetectionStd.ToolBar_Click(null, "Delete");
  109. break;
  110. case "恢复":
  111. _frmDetectionStd.ToolBar_Click(null, "Resume");
  112. break;
  113. case "复制":
  114. _frmDetectionStd.ToolBar_Click(null, "Copy");
  115. break;
  116. case "粘贴":
  117. _frmDetectionStd.ToolBar_Click(null, "Paste");
  118. break;
  119. case "刷新":
  120. _frmDetectionStd.ToolBar_Click(null, "Refresh");
  121. break;
  122. case "分组":
  123. _frmDetectionStd.ToolBar_Click(null, "Group");
  124. break;
  125. case "取消分组":
  126. _frmDetectionStd.ToolBar_Click(null, "Cancel");
  127. break;
  128. case "关闭":
  129. this.Close();
  130. break;
  131. }
  132. }
  133. private void PopupComMSCStdDetection_FormClosing(object sender, FormClosingEventArgs e)
  134. {
  135. if (DetectionStdSuccessEvent != null && closeAction == "")
  136. {
  137. DetectionStdEventArgs e2 = new DetectionStdEventArgs();
  138. e2.Result = "0";
  139. DetectionStdSuccessEvent.Invoke(this, e2);
  140. }
  141. }
  142. private void btnCancel_Click(object sender, EventArgs e)
  143. {
  144. this.Close();
  145. }
  146. }
  147. public class DetectionStdEventArgs : EventArgs
  148. {
  149. private string _dic = "";
  150. public string Dic
  151. {
  152. get { return _dic; }
  153. set { _dic = value; }
  154. }
  155. private string _result = "";
  156. public string Result
  157. {
  158. get { return _result; }
  159. set { _result = value; }
  160. }
  161. }
  162. }