ComBasePurchaseStdIdxCtrl.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using Core.StlMes.Client.Qcm.BLL;
  2. using Core.StlMes.Client.Qcm.model;
  3. using CoreFS.CA06;
  4. using CoreFS.SA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Windows.Forms;
  11. namespace Core.StlMes.Client.Qcm.Control
  12. {
  13. public partial class ComBasePurchaseStdIdxCtrl : UserControl
  14. {
  15. private CtrlMscChem _ctrlMscChem;
  16. private CtrlMscMaterial _ctrlMscMaterial;
  17. private CtrlMscTolerances _ctrlMscTolerances;
  18. private CtrlMSCDetection _ctrlMscDetection;
  19. private CtrlMscProductWater _ctrlMscWater;
  20. private CtrlMSCStdProcess _ctrlMscProcess;
  21. private ComBasePurchaseProviderCtrl _providerCtrl;
  22. private ComBasePurchaseStdIdxBLL _purchaseStdIdxBLL;
  23. private ComBasePurchaseRangeCtrl _purchaseRangeCtrl;
  24. public ComBasePurchaseStdIdxCtrl(System.Windows.Forms.Control container, OpeBase ob)
  25. {
  26. InitializeComponent();
  27. _purchaseStdIdxBLL = new ComBasePurchaseStdIdxBLL(ob);
  28. this.Dock = DockStyle.Fill;
  29. _ctrlMscChem = new CtrlMscChem(ultraTabPageControl1);
  30. _ctrlMscChem.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  31. _ctrlMscMaterial = new CtrlMscMaterial(ultraTabPageControl2);
  32. _ctrlMscMaterial.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  33. _ctrlMscMaterial.Grid.DisplayLayout.Bands[0].Columns["UnboundColumn1"].Hidden = true;
  34. _ctrlMscTolerances = new CtrlMscTolerances(ultraTabPageControl3);
  35. _ctrlMscTolerances.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  36. _ctrlMscDetection = new CtrlMSCDetection(ultraTabPageControl4);
  37. _ctrlMscDetection.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  38. _ctrlMscWater = new CtrlMscProductWater(ultraTabPageControl5);
  39. _ctrlMscWater.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  40. _ctrlMscWater.Grid.DisplayLayout.Bands[1].Columns["RatioMng"].Hidden = true;
  41. _ctrlMscProcess = new CtrlMSCStdProcess(ultraTabPageControl6);
  42. _ctrlMscProcess.Grid.BeforeRowInsert += Grid_BeforeRowInsert;
  43. _ctrlMscChem.ShowPurchaseGrid(ob);
  44. _ctrlMscMaterial.ShowPurchaseGrid(ob);
  45. _ctrlMscTolerances.ShowPurchaseGrid(ob);
  46. _ctrlMscDetection.ShowPurchaseGrid(ob);
  47. _ctrlMscWater.ShowPurchaseGrid(ob);
  48. _ctrlMscProcess.ShowPurchaseGrid(ob);
  49. _providerCtrl = new ComBasePurchaseProviderCtrl(splitContainer1.Panel1, ob);
  50. _providerCtrl.UltraGrid1.AfterRowActivate += UltraGrid1_AfterRowActivate;
  51. _purchaseRangeCtrl = new ComBasePurchaseRangeCtrl(splitContainer1.Panel2, ob);
  52. container.Controls.Add(this);
  53. }
  54. void UltraGrid1_AfterRowActivate(object sender, EventArgs e)
  55. {
  56. string suppCode = _providerCtrl.UltraGrid1.GetActiveRowValue("suppCode");
  57. _purchaseRangeCtrl.Query(suppCode);
  58. }
  59. void Grid_BeforeRowInsert(object sender, Infragistics.Win.UltraWinGrid.BeforeRowInsertEventArgs e)
  60. {
  61. e.Cancel = true;
  62. }
  63. public List<ComBasePurchaseStdIdxEntity> GetSaveParms()
  64. {
  65. IEnumerable<UltraGridRow> rows;
  66. List<ComBasePurchaseStdIdxEntity> saveParms = new List<ComBasePurchaseStdIdxEntity>();
  67. switch (ultraTabControl1.ActiveTab.Key)
  68. {
  69. case "CIC":
  70. rows = _ctrlMscChem.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  71. foreach (var row in rows)
  72. {
  73. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  74. purchaseStdIdx.StdIdx = row.GetValue("CIC");
  75. purchaseStdIdx.StdIdxType = "CIC";
  76. purchaseStdIdx.AgreementCode = agreementCode;
  77. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  78. saveParms.Add(purchaseStdIdx);
  79. }
  80. break;
  81. case "PIC":
  82. rows = _ctrlMscMaterial.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  83. foreach (var row in rows)
  84. {
  85. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  86. purchaseStdIdx.StdIdx = row.GetValue("PIC");
  87. purchaseStdIdx.StdIdxType = "PIC";
  88. purchaseStdIdx.AgreementCode = agreementCode;
  89. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  90. saveParms.Add(purchaseStdIdx);
  91. }
  92. break;
  93. case "SIC":
  94. rows = _ctrlMscTolerances.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  95. foreach (var row in rows)
  96. {
  97. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  98. purchaseStdIdx.StdIdx = row.GetValue("SIC");
  99. purchaseStdIdx.StdIdxType = "SIC";
  100. purchaseStdIdx.AgreementCode = agreementCode;
  101. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  102. saveParms.Add(purchaseStdIdx);
  103. }
  104. break;
  105. case "DIC":
  106. rows = _ctrlMscDetection.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  107. foreach (var row in rows)
  108. {
  109. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  110. purchaseStdIdx.StdIdx = row.GetValue("DIC");
  111. purchaseStdIdx.StdIdxType = "DIC";
  112. purchaseStdIdx.AgreementCode = agreementCode;
  113. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  114. saveParms.Add(purchaseStdIdx);
  115. }
  116. break;
  117. case "WIC":
  118. rows = _ctrlMscWater.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  119. foreach (var row in rows)
  120. {
  121. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  122. purchaseStdIdx.StdIdx = row.GetValue("WIC");
  123. purchaseStdIdx.StdIdxType = "WIC";
  124. purchaseStdIdx.AgreementCode = agreementCode;
  125. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  126. saveParms.Add(purchaseStdIdx);
  127. }
  128. break;
  129. case "GIC":
  130. rows = _ctrlMscProcess.Grid.Rows.Where(a => a.GetValue("CHC") == "True");
  131. foreach (var row in rows)
  132. {
  133. var purchaseStdIdx = new ComBasePurchaseStdIdxEntity();
  134. purchaseStdIdx.StdIdx = row.GetValue("GIC");
  135. purchaseStdIdx.StdIdxType = "GIC";
  136. purchaseStdIdx.AgreementCode = agreementCode;
  137. purchaseStdIdx.CreateName = CoreUserInfo.UserInfo.GetUserName();
  138. saveParms.Add(purchaseStdIdx);
  139. }
  140. break;
  141. case "SUPP":
  142. break;
  143. }
  144. return saveParms;
  145. }
  146. public List<ComBasePurchaseProviderEntity> GetProviderParms()
  147. {
  148. return _providerCtrl.GetSaveParms();
  149. }
  150. private string agreementCode = "";
  151. private string validflag = "";
  152. private string stdCodeNk = "";
  153. public void Query(string agreementCode, string stdCodeNk, string validflag)
  154. {
  155. this.agreementCode = agreementCode;
  156. this.validflag = validflag;
  157. this.stdCodeNk = stdCodeNk;
  158. if (ultraTabControl1.ActiveTab == null) return;
  159. switch (ultraTabControl1.ActiveTab.Key)
  160. {
  161. case "CIC":
  162. _ctrlMscChem.QueryPurchaseAgreement(stdCodeNk);
  163. SetGridChkCic();
  164. break;
  165. case "PIC":
  166. _ctrlMscMaterial.QueryPurchaseAgreement(stdCodeNk);
  167. SetGridChkPic();
  168. break;
  169. case "SIC":
  170. _ctrlMscTolerances.QueryPurchaseAgreement(stdCodeNk);
  171. SetGridChkSic();
  172. break;
  173. case "DIC":
  174. _ctrlMscDetection.QueryPurchaseAgreement(stdCodeNk);
  175. SetGridChkDic();
  176. break;
  177. case "WIC":
  178. _ctrlMscWater.QueryPurchaseAgreement(stdCodeNk);
  179. SetGridChkWic();
  180. break;
  181. case "GIC":
  182. _ctrlMscProcess.QueryPurchaseAgreement(stdCodeNk);
  183. SetGridChkGic();
  184. break;
  185. case "SUPP":
  186. _purchaseRangeCtrl.Clear();
  187. _providerCtrl.Query(agreementCode);
  188. break;
  189. }
  190. }
  191. public void Clear()
  192. {
  193. _ctrlMscChem.Clear();
  194. _ctrlMscMaterial.Clear();
  195. _ctrlMscDetection.Clear();
  196. _ctrlMscTolerances.Clear();
  197. _ctrlMscWater.Clear();
  198. _ctrlMscProcess.Clear();
  199. _providerCtrl.Clear();
  200. _purchaseRangeCtrl.Clear();
  201. agreementCode = "";
  202. }
  203. private void SetGridChkCic()
  204. {
  205. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "CIC");
  206. foreach (var row in _ctrlMscChem.Grid.Rows)
  207. {
  208. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  209. {
  210. if (stdIdx.StdIdx == row.GetValue("CIC"))
  211. {
  212. row.SetValue("CHC", "True");
  213. }
  214. }
  215. }
  216. _ctrlMscChem.Grid.UpdateData();
  217. }
  218. private void SetGridChkPic()
  219. {
  220. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "PIC");
  221. foreach (var row in _ctrlMscMaterial.Grid.Rows)
  222. {
  223. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  224. {
  225. if (stdIdx.StdIdx == row.GetValue("PIC"))
  226. {
  227. row.SetValue("CHC", "True");
  228. }
  229. }
  230. }
  231. _ctrlMscMaterial.Grid.UpdateData();
  232. }
  233. private void SetGridChkSic()
  234. {
  235. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "SIC");
  236. foreach (var row in _ctrlMscTolerances.Grid.Rows)
  237. {
  238. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  239. {
  240. if (stdIdx.StdIdx == row.GetValue("SIC"))
  241. {
  242. row.SetValue("CHC", "True");
  243. }
  244. }
  245. }
  246. _ctrlMscTolerances.Grid.UpdateData();
  247. }
  248. private void SetGridChkDic()
  249. {
  250. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "DIC");
  251. foreach (var row in _ctrlMscDetection.Grid.Rows)
  252. {
  253. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  254. {
  255. if (stdIdx.StdIdx == row.GetValue("DIC"))
  256. {
  257. row.SetValue("CHC", "True");
  258. }
  259. }
  260. }
  261. _ctrlMscDetection.Grid.UpdateData();
  262. }
  263. private void SetGridChkWic()
  264. {
  265. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "WIC");
  266. foreach (var row in _ctrlMscWater.Grid.Rows)
  267. {
  268. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  269. {
  270. if (stdIdx.StdIdx == row.GetValue("WIC"))
  271. {
  272. row.SetValue("CHC", "True");
  273. }
  274. }
  275. }
  276. _ctrlMscWater.Grid.UpdateData();
  277. }
  278. private void SetGridChkGic()
  279. {
  280. List<ComBasePurchaseStdIdxEntity> stdIdxs = _purchaseStdIdxBLL.Query(agreementCode, "GIC");
  281. foreach (var row in _ctrlMscProcess.Grid.Rows)
  282. {
  283. foreach (ComBasePurchaseStdIdxEntity stdIdx in stdIdxs)
  284. {
  285. if (stdIdx.StdIdx == row.GetValue("GIC"))
  286. {
  287. row.SetValue("CHC", "True");
  288. }
  289. }
  290. }
  291. _ctrlMscProcess.Grid.UpdateData();
  292. }
  293. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  294. {
  295. try
  296. {
  297. ((Form)this.TopLevelControl).Cursor = Cursors.WaitCursor;
  298. if (agreementCode == "") return;
  299. Query(agreementCode, stdCodeNk, validflag);
  300. }
  301. finally
  302. {
  303. ((Form)this.TopLevelControl).Cursor = Cursors.Default;
  304. }
  305. }
  306. }
  307. }