ComBaseSplineFrm.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Qcm.Control;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using System;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Qcm
  12. {
  13. public partial class ComBaseSplineFrm : FrmBase
  14. {
  15. private ComBaseSplineCtrl _splineCtrl;
  16. private ComBaseSplineCCtrl _splineCCtrl;
  17. public ComBaseSplineFrm()
  18. {
  19. InitializeComponent();
  20. }
  21. private string flag = "";
  22. public ComBaseSplineFrm(OpeBase ob, string phyNameMin, string flag)
  23. : this()
  24. {
  25. this.ob = ob;
  26. this.flag = flag;
  27. ultraToolbarsManager1.Visible = true;
  28. labelTextBox1.Checked = true;
  29. labelTextBox1.Text = phyNameMin;
  30. }
  31. private void ComBaseSplineFrm_Load(object sender, EventArgs e)
  32. {
  33. _splineCtrl = new ComBaseSplineCtrl(ultraGroupBox1, ob);
  34. _splineCtrl.BringToFront();
  35. GridHelper.HidenColumns(_splineCtrl.UltraGrid1.DisplayLayout.Bands[0], "Chk2", "Chk3");
  36. _splineCtrl.UltraGrid1.AfterRowActivate += _splineCtrl_AfterRowActivate;
  37. _splineCCtrl = new ComBaseSplineCCtrl(ultraGroupBox2, ob);
  38. _splineCCtrl.UltraGrid1.BeforeRowInsert += _splineCCtrl_BeforeRowInsert;
  39. _splineCCtrl.UltraGrid1.AfterRowInsert += _splineCCtrl_AfterRowInsert;
  40. _splineCCtrl.BringToFront();
  41. LoadData();
  42. if (flag != "")
  43. {
  44. Query();
  45. }
  46. }
  47. private void LoadData()
  48. {
  49. ClsBaseInfo.FillComBaseInfo(labelComboBox1.ComboBox, "4081", ob, true);
  50. }
  51. void _splineCCtrl_BeforeRowInsert(object sender, Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs e)
  52. {
  53. if (_splineCtrl.UltraGrid1.ActiveRow == null)
  54. {
  55. e.Cancel = true;
  56. return;
  57. }
  58. ComBaseSplineEntity splineEntity = (ComBaseSplineEntity)_splineCtrl.UltraGrid1.ActiveRow.ListObject;
  59. if (splineEntity.Validflag == "")
  60. {
  61. e.Cancel = true;
  62. return;
  63. }
  64. }
  65. void _splineCCtrl_AfterRowInsert(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e)
  66. {
  67. ComBaseSplineEntity splineEntity = (ComBaseSplineEntity)_splineCtrl.UltraGrid1.ActiveRow.ListObject;
  68. ComBaseSplineCEntity splineCEntity = (ComBaseSplineCEntity)e.Row.ListObject;
  69. splineCEntity.Eic = splineEntity.Eic;
  70. splineCEntity.PhyCodeMin = splineEntity.PhyCodeMin;
  71. splineCEntity.PhyNameMin = splineEntity.PhyNameMin;
  72. }
  73. void _splineCtrl_AfterRowActivate(object sender, EventArgs e)
  74. {
  75. try
  76. {
  77. this.Cursor = Cursors.WaitCursor;
  78. ComBaseSplineEntity splineEntity = (ComBaseSplineEntity)_splineCtrl.UltraGrid1.ActiveRow.ListObject;
  79. string validflag = labelCheckBox1.Checked ? "0" : "1";
  80. _splineCCtrl.Query(splineEntity.Eic, validflag);
  81. }
  82. finally
  83. {
  84. this.Cursor = Cursors.Default;
  85. }
  86. }
  87. public override void ToolBar_Click(object sender, string ToolbarKey)
  88. {
  89. base.ToolBar_Click(sender, ToolbarKey);
  90. switch (ToolbarKey)
  91. {
  92. case "Query":
  93. Query();
  94. break;
  95. case "Save":
  96. Save();
  97. break;
  98. case "Delete":
  99. Delete();
  100. break;
  101. case "Resume":
  102. Resume();
  103. break;
  104. case "CopyStd":
  105. CopyStd();
  106. break;
  107. case "Export":
  108. Export();
  109. break;
  110. case "Close":
  111. this.Close();
  112. break;
  113. }
  114. }
  115. private void CopyStd()
  116. {
  117. ComBaseSplineCopyStdFrm copyStdFrm = new ComBaseSplineCopyStdFrm(ob);
  118. string oldStdName = "";
  119. string oldStdCode = "";
  120. string newStdName = "";
  121. string newStdCode = "";
  122. if (copyStdFrm.ShowDialog() == DialogResult.OK)
  123. {
  124. oldStdName = copyStdFrm.OldStdName;
  125. oldStdCode = copyStdFrm.OldStdCode;
  126. newStdName = copyStdFrm.NewStdName;
  127. newStdCode = copyStdFrm.NewStdCode;
  128. }
  129. else
  130. {
  131. return;
  132. }
  133. ServerHelper.SetData("com.steering.pss.qcm.DAL.ComBaseSplineCDAL.CopyStd", new object[] { oldStdCode, newStdCode, newStdName }, ob);
  134. MessageUtil.ShowTips("保存成功");
  135. }
  136. private void Export()
  137. {
  138. GridHelper.ulGridToExcel(_splineCtrl.UltraGrid1, "试样码主信息");
  139. }
  140. private void Query()
  141. {
  142. try
  143. {
  144. this.Cursor = Cursors.WaitCursor;
  145. string phyNameMin = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : "";
  146. string sampleStyle = labelComboBox1.Checked ? labelComboBox1.SelecteValue.ToString2() : "";
  147. string validflag = labelCheckBox1.Checked ? "0" : "1";
  148. string seamArea = labelComboBox2.Checked ? labelComboBox2.SelecteValue.ToString2() : "";
  149. _splineCCtrl.Clear();
  150. _splineCtrl.Query(phyNameMin, sampleStyle, validflag, seamArea);
  151. }
  152. finally
  153. {
  154. this.Cursor = Cursors.Default;
  155. }
  156. }
  157. private void Save()
  158. {
  159. int chkCnt = _splineCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count() +
  160. _splineCCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count();
  161. if (chkCnt == 0)
  162. {
  163. MessageUtil.ShowWarning("请选择记录保存!");
  164. return;
  165. }
  166. var splineCEntitys = _splineCCtrl.GetSaveParms();
  167. if (splineCEntitys == null) return;
  168. bool result = _splineCtrl.Save(splineCEntitys);
  169. if (result)
  170. {
  171. MessageUtil.ShowTips("保存成功!");
  172. _splineCtrl_AfterRowActivate(null, null);
  173. }
  174. }
  175. private void Delete()
  176. {
  177. int splineCnt = _splineCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count();
  178. int spineCCnt = _splineCCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count();
  179. if ((splineCnt + spineCCnt) == 0)
  180. {
  181. MessageUtil.ShowWarning("请选择记录!");
  182. return;
  183. }
  184. if (MessageUtil.ShowYesNoAndQuestion("是否确认作废选择的记录?") == System.Windows.Forms.DialogResult.No)
  185. {
  186. return;
  187. }
  188. if (splineCnt > 0)
  189. {
  190. _splineCtrl.UpdateValidflag("0");
  191. }
  192. else
  193. {
  194. _splineCCtrl.UpdateValidflag("0");
  195. }
  196. MessageUtil.ShowTips("作废成功!");
  197. Query();
  198. //_splineCtrl_AfterRowActivate(null, null);
  199. }
  200. private void Resume()
  201. {
  202. int chkCnt = _splineCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count() +
  203. _splineCCtrl.UltraGrid1.Rows.AsQueryable().Where(a => a.GetValue("Chk") == "True").Count();
  204. if (chkCnt == 0)
  205. {
  206. MessageUtil.ShowWarning("请选择记录!");
  207. return;
  208. }
  209. if (MessageUtil.ShowYesNoAndQuestion("是否确认恢复选择的记录?") == System.Windows.Forms.DialogResult.No)
  210. {
  211. return;
  212. }
  213. _splineCtrl.UpdateValidflag("1");
  214. _splineCCtrl.UpdateValidflag("1");
  215. MessageUtil.ShowTips("恢复成功!");
  216. Query();
  217. //_splineCtrl_AfterRowActivate(null, null);
  218. }
  219. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  220. {
  221. switch (e.Tool.Key)
  222. {
  223. case "查询":
  224. Query();
  225. break;
  226. case "保存":
  227. Save();
  228. break;
  229. case "作废":
  230. Delete();
  231. break;
  232. case "恢复":
  233. Resume();
  234. break;
  235. case "关闭":
  236. this.Close();
  237. break;
  238. }
  239. }
  240. }
  241. }