CraftOrdFdPicSmpFrm.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.SaleOrder.Dialog
  16. {
  17. public partial class CraftOrdFdPicSmpFrm : FrmBase
  18. {
  19. private string _ordLnPk = "";
  20. private string _mscPline = "";
  21. private string _processCode = "";
  22. public CraftOrdFdPicSmpFrm(string ordLnPk, string mscPline, string processCode, OpeBase ob)
  23. {
  24. InitializeComponent();
  25. _ordLnPk = ordLnPk;
  26. _mscPline = mscPline;
  27. _processCode = processCode;
  28. this.ob = ob;
  29. }
  30. private void Query()
  31. {
  32. try
  33. {
  34. this.Cursor = Cursors.WaitCursor;
  35. if (ultraTabControl1.ActiveTab.Index == 0)
  36. {
  37. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getPhyMinSample",
  38. new object[] { _ordLnPk, _mscPline, _processCode }, ob);
  39. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  40. ultraGrid1.DisplayLayout.Bands[0].Columns["ITEM_NAME_W"].Hidden = false;
  41. }
  42. else
  43. {
  44. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getPhyMinSpline",
  45. new object[] { _ordLnPk, _mscPline, _processCode }, ob);
  46. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  47. ultraGrid1.DisplayLayout.Bands[0].Columns["ITEM_NAME_W"].Hidden = true;
  48. }
  49. }
  50. finally
  51. {
  52. this.Cursor = Cursors.Default;
  53. }
  54. }
  55. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  56. {
  57. Query();
  58. }
  59. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  60. {
  61. try
  62. {
  63. this.Cursor = Cursors.WaitCursor;
  64. var mRow = ultraGrid1.ActiveRow;
  65. string phyCodeMin = mRow.GetValue("PHY_CODE_MIN");
  66. string stdCode = mRow.GetValue("STD_CODE");
  67. string steelCode = mRow.GetValue("STEELCODE");
  68. string produccode = mRow.GetValue("PRODUCCODE");
  69. string itemCodeF = mRow.GetValue("ITEM_CODE_F");
  70. string itemCodeC = mRow.GetValue("ITEM_CODE_C");
  71. string itemCodeW = mRow.GetValue("ITEM_CODE_W");
  72. if (ultraTabControl1.ActiveTab.Index == 0)
  73. {
  74. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.Query",
  75. new Object[] { phyCodeMin, stdCode, steelCode, produccode }, ob);
  76. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  77. DataTable dtSic = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getFdSampleSic",
  78. new Object[] { _ordLnPk, _mscPline, _processCode, phyCodeMin, itemCodeF, itemCodeC, itemCodeW }, ob);
  79. if (dtSic.Rows.Count != 0)
  80. {
  81. string sic = dtSic.Rows[0]["SIC"].ToString();
  82. foreach (var row in ultraGrid2.Rows)
  83. {
  84. if (row.GetValue("SIC") == sic)
  85. {
  86. row.Cells["CHK"].Value = true;
  87. row.Update();
  88. }
  89. }
  90. }
  91. }
  92. else
  93. {
  94. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseSplineDAL.Query2",
  95. new object[] { phyCodeMin, itemCodeF, itemCodeC, "", "" }, ob);
  96. GridHelper.CopyDataToDatatable(dt, dataTable3, true);
  97. DataTable dtEic = ServerHelper.GetData("com.steering.pss.sale.order.CraftOrdFdPic.getFdSampleEic",
  98. new Object[] { _ordLnPk, _mscPline, _processCode, phyCodeMin, itemCodeF, itemCodeC }, ob);
  99. if (dtEic.Rows.Count != 0)
  100. {
  101. string eic = dtEic.Rows[0]["EIC"].ToString();
  102. foreach (var row in ultraGrid3.Rows)
  103. {
  104. if (row.GetValue("EIC") == eic)
  105. {
  106. row.Cells["CHK"].Value = true;
  107. row.Update();
  108. }
  109. }
  110. }
  111. }
  112. }
  113. finally
  114. {
  115. this.Cursor = Cursors.Default;
  116. }
  117. }
  118. private void CraftOrdFdPicSmpFrm_Load(object sender, EventArgs e)
  119. {
  120. Query();
  121. ClsBaseInfo.FillComBaseInfo(ultraComboEditor2, "4081", ob, false);
  122. }
  123. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  124. {
  125. this.Cursor = Cursors.WaitCursor;
  126. string phyCodeMin = ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN");
  127. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CorePhySample.QueryStdRTest",
  128. new object[] { phyCodeMin }, ob);
  129. dt.Columns["STD_NAME_TEST"].Caption = "试验标准";
  130. dt.Columns["MEMO"].Caption = "备注";
  131. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_NAME_TEST", "STD_CODE_TEST");
  132. baseInfoPopup.LabelTextBox1.Caption = "试验标准";
  133. baseInfoPopup.Shown += new EventHandler((a, b) =>
  134. {
  135. var actRow = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  136. c => c.GetValue("STD_CODE_TEST") == ultraGrid1.ActiveRow.GetValue("STD_CODE_TEST")).FirstOrDefault();
  137. if (actRow != null)
  138. {
  139. actRow.Activate();
  140. }
  141. });
  142. this.Cursor = Cursors.Default;
  143. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  144. {
  145. UltraGridRow row = ultraGrid1.ActiveRow;
  146. row.SetValue("STD_NAME_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_NAME_TEST"));
  147. row.SetValue("STD_CODE_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_CODE_TEST"));
  148. row.Update();
  149. //foreach (var row in ultraGrid1.Rows)
  150. //{
  151. // if (row.GetValue("PHY_CODE_MIN") == ultraGrid1.ActiveRow.GetValue("PHY_CODE_MIN"))
  152. // {
  153. // row.SetValue("STD_NAME_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_NAME_TEST"));
  154. // row.SetValue("STD_CODE_TEST", baseInfoPopup.ChoicedRow.GetValue("STD_CODE_TEST"));
  155. // row.Update();
  156. // }
  157. //}
  158. }
  159. }
  160. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  161. {
  162. switch (e.Tool.Key)
  163. {
  164. case "关联":
  165. Save();
  166. break;
  167. case "取样要求维护":
  168. ShowSample();
  169. break;
  170. case "关闭":
  171. break;
  172. }
  173. }
  174. private void ShowSample()
  175. {
  176. UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  177. try
  178. {
  179. this.Cursor = Cursors.WaitCursor;
  180. string phyCodeMin = ugr.GetValue("PHY_CODE_MIN");
  181. string itemCodeF = ugr.GetValue("ITEM_CODE_F");
  182. string itemCodeC = ugr.GetValue("ITEM_CODE_C");
  183. string itemCodeW = ugr.GetValue("ITEM_CODE_W");
  184. FrmBaseSample fbs = new FrmBaseSample();
  185. fbs.Ob = ob; //ob对象
  186. fbs.CustomInfo = this.CustomInfo;
  187. fbs.Phycode = ugr.Cells["PHY_CODE_MIN"].Value.ToString(); //取样码
  188. fbs.Phydesc = ugr.Cells["PHY_NAME_MIN"].Value.ToString(); //取样码描述
  189. fbs.Stdcode = ugr.Cells["STD_CODE"].Value.ToString(); //标准代码
  190. fbs.Stddesc = ugr.Cells["STD_NAME"].Value.ToString(); //标准名称
  191. fbs.Load += new EventHandler((a, b) =>
  192. {
  193. this.Cursor = Cursors.Default;
  194. });
  195. fbs.ShowDialog();
  196. Query();
  197. var reActRow = ultraGrid1.Rows.Where(a=>a.GetValue("PHY_CODE_MIN") == phyCodeMin && a.GetValue("ITEM_CODE_F") == itemCodeF
  198. && a.GetValue("ITEM_CODE_C") == itemCodeC && a.GetValue("ITEM_CODE_W") == itemCodeW).FirstOrDefault();
  199. if (reActRow != null)
  200. {
  201. reActRow.Activate();
  202. }
  203. }
  204. finally
  205. {
  206. this.Cursor = Cursors.Default;
  207. }
  208. }
  209. private void Save()
  210. {
  211. if (ultraGrid1.ActiveRow == null) return;
  212. var mRow = ultraGrid1.ActiveRow;
  213. var rows = ultraGrid2.Rows.Where(a=>a.GetValue("CHK") == "True");
  214. var splineRows = ultraGrid3.Rows.Where(a=>a.GetValue("CHK") == "True");
  215. if (rows.Count() == 0)
  216. {
  217. MessageUtil.ShowWarning("请选择一条取样要求!");
  218. return;
  219. }
  220. else if (mRow.GetValue("STD_CODE_TEST") == "")
  221. {
  222. MessageUtil.ShowWarning("请选择试验标准!");
  223. return;
  224. }
  225. if (ultraTabControl1.ActiveTab.Index == 0)
  226. {
  227. if (rows.Count() > 1)
  228. {
  229. MessageUtil.ShowWarning("只能选择一条取样要求!");
  230. return;
  231. }
  232. }
  233. else
  234. {
  235. if (splineRows.Count() > 1)
  236. {
  237. MessageUtil.ShowWarning("只能选择一条试样要求!");
  238. return;
  239. }
  240. }
  241. if (MessageUtil.ShowYesNoAndQuestion("是否确认关联?") == System.Windows.Forms.DialogResult.No)
  242. {
  243. return;
  244. }
  245. if (ultraTabControl1.ActiveTab.Index == 0)
  246. {
  247. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.setSample",
  248. new object[]{ _ordLnPk, mRow.GetValue("PHY_CODE_MIN"), mRow.GetValue("ITEM_CODE_F"), mRow.GetValue("ITEM_CODE_C"),
  249. mRow.GetValue("ITEM_CODE_W"), _mscPline, _processCode, mRow.GetValue("STD_NAME_TEST"), mRow.GetValue("STD_CODE_TEST"),
  250. rows.FirstOrDefault().GetValue("SIC"), mRow.GetValue("COMMON") }, ob);
  251. }
  252. else
  253. {
  254. ServerHelper.SetData("com.steering.pss.sale.order.CraftOrdFdPic.setSpline",
  255. new object[]{ _ordLnPk, mRow.GetValue("PHY_CODE_MIN"), mRow.GetValue("ITEM_CODE_F"), mRow.GetValue("ITEM_CODE_C"),
  256. _mscPline, _processCode, mRow.GetValue("STD_NAME_TEST"), mRow.GetValue("STD_CODE_TEST"),
  257. splineRows.FirstOrDefault().GetValue("EIC") }, ob);
  258. }
  259. MessageUtil.ShowTips("关联成功!");
  260. }
  261. private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  262. {
  263. e.Cell.Row.Update();
  264. }
  265. private void ultraGrid3_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  266. {
  267. e.Cell.Row.Update();
  268. }
  269. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  270. {
  271. e.Cell.Row.Update();
  272. }
  273. }
  274. }