PopupComMSCPlineRSpec.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. using Core.Mes.Client.Comm.Server;
  2. using Core.Mes.Client.Comm.Tool;
  3. using CoreFS.CA06;
  4. using System;
  5. using System.Data;
  6. using System.Windows.Forms;
  7. namespace Core.StlMes.Client.Qcm
  8. {
  9. public delegate void PlineRSpecSucessHandler(object sender, PlineRSpecArgs e);
  10. public partial class PopupComMSCPlineRSpec : FrmBase
  11. {
  12. public event PlineRSpecSucessHandler PlineRSpecSucessEvent;
  13. private FrmComMSCPlineRSpec _frm;
  14. private string _process = "";
  15. private string _dimater = "";
  16. private string _height = "";
  17. private string _specCode = "";
  18. private string closeAction = "";
  19. /// <summary>
  20. /// 弹窗构造函数
  21. /// </summary>
  22. /// <param name="args">输入参数</param>
  23. public PopupComMSCPlineRSpec(string[] args, string exceptionMsg, OpeBase ob)
  24. {
  25. InitializeComponent();
  26. ExceptionHelper.RegistException();
  27. string str = args[0];
  28. string[] strs = str.Split(',');
  29. _process = strs[0].Trim();
  30. _dimater = strs[1].Trim();
  31. _height = strs[2].Trim();
  32. _specCode = strs[3].Trim();
  33. this.ob = ob;
  34. ultraStatusBar1.Panels["ExMsg"].Text = exceptionMsg;
  35. _frm = new FrmComMSCPlineRSpec();
  36. _frm.PopupLoad("", ob);
  37. this.panel5.Controls.Add(_frm.UltraPanel1);
  38. this.panel5.Controls.Add(_frm.UltraExpandableGroupBox1);
  39. this.panel5.Controls.Add(_frm.UltraGrid1);
  40. _frm.UltraGrid1.BringToFront();
  41. SetDefaltCondition();
  42. _frm.ToolBar_Click(null, "Query");
  43. }
  44. private void SetDefaltCondition()
  45. {
  46. _frm.MscPlines = GetMscPlines();
  47. //_frm.SpecCode = _specCode;
  48. _frm.Dimater = _dimater;
  49. _frm.Height1 = _height;
  50. DataTable dt = (DataTable)_frm.UltraComProLine.DataSource;
  51. dt.DefaultView.RowFilter = "ID IN (" + _frm.MscPlines + ")";
  52. //_frm.UltraComboEditor1.Value = _specCode;
  53. //_frm.UltraComboEditor1.ReadOnly = true;
  54. }
  55. private string GetMscPlines()
  56. {
  57. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComMSCPlineRSpec.getMscPlines",
  58. new object[] { _process }, ob);
  59. string mscPlines = _frm.MscPlines;
  60. foreach (DataRow dr in dt.Rows)
  61. {
  62. mscPlines += ", '" + dr["PLINE_CODE"].ToString() + "'";
  63. }
  64. return mscPlines;
  65. }
  66. private void btnClose_Click(object sender, EventArgs e)
  67. {
  68. closeAction = "Ok";
  69. if (PlineRSpecSucessEvent != null)
  70. {
  71. if (_frm.UltraGrid1.ActiveRow == null)
  72. {
  73. MessageUtil.ShowWarning("请维护一条生产产线适用规格!");
  74. return;
  75. }
  76. PlineRSpecArgs e2 = new PlineRSpecArgs();
  77. e2.Result = "1";
  78. PlineRSpecSucessEvent(this, e2);
  79. }
  80. this.DialogResult = DialogResult.OK;
  81. }
  82. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  83. {
  84. switch (e.Tool.Key)
  85. {
  86. case "查询":
  87. _frm.ToolBar_Click(null, "Query");
  88. break;
  89. case "新增":
  90. //if (CheckData() == false) return;
  91. _frm.ToolBar_Click(null, "Add");
  92. break;
  93. case "修改":
  94. //if (CheckData() == false) return;
  95. _frm.ToolBar_Click(null, "Update");
  96. break;
  97. case "作废":
  98. _frm.ToolBar_Click(null, "Delete");
  99. break;
  100. case "恢复":
  101. _frm.ToolBar_Click(null, "Resume");
  102. break;
  103. case "刷新":
  104. _frm.ToolBar_Click(null, "Refresh");
  105. break;
  106. case "关闭":
  107. this.Close();
  108. break;
  109. }
  110. }
  111. private bool CheckData()
  112. {
  113. double dimaterMin = double.Parse(_frm.UltraTextEditor1.Value.ToString() == "" ? "0" : _frm.UltraTextEditor1.Value.ToString());
  114. double dimaterMax = double.Parse(_frm.UltraTextEditor2.Value.ToString() == "" ? "0" : _frm.UltraTextEditor2.Value.ToString());
  115. double heightMin = double.Parse(_frm.UltraTextEditor3.Value.ToString() == "" ? "0" : _frm.UltraTextEditor3.Value.ToString());
  116. double heightMax = double.Parse(_frm.UltraTextEditor4.Value.ToString() == "" ? "0" : _frm.UltraTextEditor4.Value.ToString());
  117. if (_frm.UltraTextEditor1.Value != null && dimaterMin > double.Parse(_dimater == "" ? "0" : _dimater))
  118. {
  119. MessageUtil.ShowWarning("外径最小值不能大于指定的外径[" + (_dimater == "" ? "0" : _dimater) + "]");
  120. return false;
  121. }
  122. if (_frm.UltraTextEditor2.Value != null && dimaterMax < double.Parse(_dimater == "" ? "0" : _dimater))
  123. {
  124. MessageUtil.ShowWarning("外径最大值不能小于指定的外径[" + (_dimater == "" ? "0" : _dimater) + "]");
  125. return false;
  126. }
  127. if (_frm.UltraTextEditor3.Value != null && heightMin > double.Parse(_height == "" ? "0" : _height))
  128. {
  129. MessageUtil.ShowWarning("壁厚最小值不能大于指定的壁厚[" + (_height == "" ? "0" : _height) + "]");
  130. return false;
  131. }
  132. if (_frm.UltraTextEditor4.Value != null && heightMax < double.Parse(_height == "" ? "0" : _height))
  133. {
  134. MessageUtil.ShowWarning("壁厚最大值不能小于指定的壁厚[" + (_height == "" ? "0" : _height) + "]");
  135. return false;
  136. }
  137. return true;
  138. }
  139. private void PopupComMSCPlineRSpec_FormClosing(object sender, FormClosingEventArgs e)
  140. {
  141. if (PlineRSpecSucessEvent != null && closeAction == "")
  142. {
  143. PlineRSpecArgs e2 = new PlineRSpecArgs();
  144. e2.Result = "0";
  145. PlineRSpecSucessEvent(this, e2);
  146. }
  147. }
  148. private void btnCancel_Click(object sender, EventArgs e)
  149. {
  150. this.Close();
  151. }
  152. }
  153. public class PlineRSpecArgs : EventArgs
  154. {
  155. private string _result = "";
  156. public string Result
  157. {
  158. get { return _result; }
  159. set { _result = value; }
  160. }
  161. }
  162. }