FrmSpecificationsBasicsNew2.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using CoreFS.CA06;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections.Generic;
  7. namespace Core.StlMes.Client.Qcm
  8. {
  9. public partial class FrmSpecificationsBasicsNew2 : FrmBaseQcm
  10. {
  11. private string _strSelectedGrid = "1";
  12. private string _parentSelectedFlag = "";
  13. private string _childSelectedFlag = "";
  14. private bool _isPopup = false;
  15. /// <summary>
  16. /// 是否是弹窗
  17. /// </summary>
  18. public bool IsPopup
  19. {
  20. get { return _isPopup; }
  21. set { _isPopup = value; }
  22. }
  23. private string _mscStyle = "";
  24. public string MscStyle
  25. {
  26. get { return _mscStyle; }
  27. set { _mscStyle = value; }
  28. }
  29. public FrmSpecificationsBasicsNew2()
  30. {
  31. InitializeComponent();
  32. ExceptionHelper.RegistException();
  33. }
  34. public void PopupLoad(OpeBase ob)
  35. {
  36. this.OnLoad(EventArgs.Empty);
  37. this.ob = ob;
  38. }
  39. private void FrmSpecificationsBasicsNew2_Load(object sender, EventArgs e)
  40. {
  41. QcmBaseInfo.Fill_SpecType(cmbBindType, false);
  42. _dtBaseQcm = new DtSpecificationsBasicsNew2(this);
  43. }
  44. public override void ToolBar_Click(object sender, string ToolbarKey)
  45. {
  46. base.ToolBar_Click(sender, ToolbarKey);
  47. switch (ToolbarKey)
  48. {
  49. case "Export":
  50. Export();
  51. break;
  52. }
  53. }
  54. protected override void BeginDoAction(ActionType actionType)
  55. {
  56. SetValueToCHK();
  57. }
  58. protected override void SuccessDoAction(ActionType actionType)
  59. {
  60. if (_parentSelectedFlag == "")
  61. {
  62. SetGridRowActiveWithKey(ultraGrid1, "SPEC_CODE", "CREATE_NAME", "CREATE_TIME");
  63. }
  64. else
  65. {
  66. SetGridRowActiveWithKey(ultraGrid1, "SPEC_CODE", _parentSelectedFlag);
  67. }
  68. if (_childSelectedFlag == "")
  69. {
  70. SetGridRowActiveWithKey(ultraGrid2, "ORDER_SPEC_CODE", "CREATE_NAME", "CREATE_TIME");
  71. }
  72. else
  73. {
  74. SetGridRowActiveWithKey(ultraGrid2, "ORDER_SPEC_CODE", _childSelectedFlag);
  75. }
  76. }
  77. private void SetValueToCHK()
  78. {
  79. _parentSelectedFlag = "";
  80. _childSelectedFlag = "";
  81. foreach (UltraGridRow row in ultraGrid1.Rows)
  82. {
  83. if (row.Cells["CHK"].Value.ToString() == "True")
  84. {
  85. string specCode = row.Cells["SPEC_CODE"].Value.ToString();
  86. if (specCode != "")
  87. {
  88. _parentSelectedFlag = specCode;
  89. }
  90. else
  91. {
  92. _parentSelectedFlag = "";
  93. }
  94. }
  95. }
  96. if (_parentSelectedFlag == "")
  97. {
  98. if (ultraGrid1.ActiveRow != null)
  99. {
  100. _parentSelectedFlag = ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString();
  101. }
  102. }
  103. foreach (UltraGridRow row in ultraGrid2.Rows)
  104. {
  105. if (row.Cells["CHK"].Value.ToString() == "True")
  106. {
  107. string orderSpecCode = row.Cells["ORDER_SPEC_CODE"].Value.ToString();
  108. if (orderSpecCode != "")
  109. {
  110. _childSelectedFlag = orderSpecCode;
  111. }
  112. else
  113. {
  114. _childSelectedFlag = "";
  115. }
  116. }
  117. }
  118. ultraGrid1.UpdateData();
  119. ultraGrid2.UpdateData();
  120. }
  121. private void Export()
  122. {
  123. if (_strSelectedGrid == "2")
  124. {
  125. GridHelper.ulGridToExcel(ultraGrid2, "规格管理从表");
  126. }
  127. else
  128. {
  129. GridHelper.ulGridToExcel(ultraGrid1, "规格管理主表");
  130. }
  131. }
  132. private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  133. {
  134. SetDeleteColor(e, "VALIDFLAG", "0");
  135. BandComboToGrid1(e.Row);
  136. ControlGrid1Edit(e);
  137. }
  138. public void BandComboToGrid1(UltraGridRow row)
  139. {
  140. row.Cells["MSC_STYLE"].EditorComponent = cmbBindType;
  141. }
  142. private void ultraGrid2_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  143. {
  144. SetDeleteColor(e, "VALIDFLAG", "0");
  145. ControlGrid2Edit(e);
  146. }
  147. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  148. {
  149. ultraGrid1.UpdateData();
  150. SpecTypeChange(e);
  151. ControlGridCheck(e);
  152. ultraGrid1.UpdateData();
  153. }
  154. private void ControlGridCheck(CellEventArgs e)
  155. {
  156. if (e.Cell.Column.Key == "CHK" && _isPopup == false)
  157. {
  158. UltraGridRow[] rows = GridHelper.GetRowsWithKey(ultraGrid1,
  159. new string[] { "CHK" }, new string[] { "True" });
  160. foreach (UltraGridRow row in rows)
  161. {
  162. if (row.Cells["CHK"] != e.Cell)
  163. {
  164. row.Cells["CHK"].Value = false;
  165. }
  166. }
  167. }
  168. }
  169. private void SpecTypeChange(CellEventArgs e)
  170. {
  171. if (e.Cell.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
  172. {
  173. string spec_Name = "";
  174. spec_Name += e.Cell.Row.Cells["DIMATER"].Value.ToString();
  175. if (spec_Name == "" || e.Cell.Row.Cells["HEIGHT"].Value.ToString() == "")
  176. {
  177. spec_Name += e.Cell.Row.Cells["HEIGHT"].Value.ToString();
  178. }
  179. else
  180. {
  181. spec_Name += "x" + e.Cell.Row.Cells["HEIGHT"].Value.ToString();
  182. }
  183. e.Cell.Row.Cells["SPEC_NAME"].Value = spec_Name;
  184. }
  185. else if (e.Cell.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
  186. {
  187. e.Cell.Row.Cells["SPEC_NAME"].Value = e.Cell.Row.Cells["DIMATER"].Value.ToString();
  188. e.Cell.Row.Cells["HEIGHT"].Value = "";
  189. }
  190. else
  191. {
  192. e.Cell.Row.Cells["DIMATER"].Value = "";
  193. e.Cell.Row.Cells["HEIGHT"].Value = "";
  194. }
  195. }
  196. private void ultraGrid2_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  197. {
  198. ultraGrid2.UpdateData();
  199. }
  200. private void ultraGrid2_AfterRowInsert(object sender, RowEventArgs e)
  201. {
  202. e.Row.Cells["SPEC_NAME"].Value = ultraGrid1.ActiveRow.Cells["SPEC_NAME"].Value;
  203. e.Row.Cells["SPEC_CODE"].Value = ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value;
  204. e.Row.Cells["ORDER_SPEC_DESC"].Value = ultraGrid1.ActiveRow.Cells["SPEC_NAME"].Value;
  205. }
  206. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  207. {
  208. }
  209. private void ControlGrid1Edit(InitializeRowEventArgs e)
  210. {
  211. List<string> listNoEdit = new List<string>();
  212. listNoEdit.Add("创建人");
  213. listNoEdit.Add("创建时间");
  214. listNoEdit.Add("修改人");
  215. listNoEdit.Add("修改时间");
  216. listNoEdit.Add("作废人");
  217. listNoEdit.Add("作废时间");
  218. listNoEdit.Add("有效状态");
  219. listNoEdit.Add("产品规格代码");
  220. List<string> listDrop = new List<string>();
  221. listDrop.Add("类型");
  222. ControlGridSelectEdit(e, listNoEdit, listDrop, "CHK");
  223. if (e.Row.Cells["CHK"].Value.ToString().ToUpper() == "TRUE")
  224. {
  225. if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
  226. {
  227. e.Row.Cells["DIMATER"].Activation = Activation.AllowEdit;
  228. e.Row.Cells["HEIGHT"].Activation = Activation.AllowEdit;
  229. e.Row.Cells["SPEC_NAME"].Activation = Activation.ActivateOnly;
  230. }
  231. else if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
  232. {
  233. e.Row.Cells["DIMATER"].Activation = Activation.AllowEdit;
  234. e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
  235. e.Row.Cells["SPEC_NAME"].Activation = Activation.ActivateOnly;
  236. }
  237. else
  238. {
  239. e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
  240. e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
  241. e.Row.Cells["SPEC_NAME"].Activation = Activation.AllowEdit;
  242. }
  243. }
  244. else
  245. {
  246. if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "A")
  247. {
  248. e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
  249. e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
  250. }
  251. else if (e.Row.Cells["MSC_STYLE"].Value.ToString() == "B")
  252. {
  253. e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
  254. e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
  255. }
  256. else
  257. {
  258. e.Row.Cells["DIMATER"].Activation = Activation.ActivateOnly;
  259. e.Row.Cells["HEIGHT"].Activation = Activation.ActivateOnly;
  260. }
  261. }
  262. }
  263. private void ControlGrid2Edit(InitializeRowEventArgs e)
  264. {
  265. List<string> listNoEdit = new List<string>();
  266. listNoEdit.Add("创建人");
  267. listNoEdit.Add("创建时间");
  268. listNoEdit.Add("修改人");
  269. listNoEdit.Add("修改时间");
  270. listNoEdit.Add("作废人");
  271. listNoEdit.Add("作废时间");
  272. listNoEdit.Add("有效标志");
  273. listNoEdit.Add("订货规格代码");
  274. ControlGridSelectEdit(e, listNoEdit, new List<string>(), "CHK");
  275. }
  276. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  277. {
  278. if (ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString() == "")
  279. {
  280. dataTable2.Clear();
  281. return;
  282. }
  283. _dtBaseQcm.DoQuery("Child");
  284. }
  285. private void ultraGrid2_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  286. {
  287. if (ultraGrid1.Rows.Count == 0 || ultraGrid1.ActiveRow.Cells["SPEC_CODE"].Value.ToString() == "")
  288. {
  289. e.Cancel = true;
  290. }
  291. }
  292. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  293. {
  294. _strSelectedGrid = "1";
  295. }
  296. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
  297. {
  298. _strSelectedGrid = "2";
  299. }
  300. }
  301. }