UIK020070.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Collections;
  9. using System.Windows.Forms;
  10. using CoreFS.CA06;
  11. using System.IO;
  12. using Microsoft.Office.Interop.Excel;
  13. using ET;
  14. using PrintSolution;
  15. namespace Core.LZMes.Client.UIK
  16. {
  17. public partial class UIK020070 : FrmBase
  18. {
  19. private int coil_no_index = -1;//冷轧卷在轧制计划的下标位置
  20. public UIK020070()
  21. {
  22. InitializeComponent();
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. this.DoQuery();
  30. break;
  31. case "Save":
  32. //this.DoSave();
  33. break;
  34. case "Exit":
  35. this.Close();
  36. break;
  37. case "Print":
  38. this.DoPrint();
  39. break;
  40. case "Export":
  41. this.DoExport();
  42. break;
  43. }
  44. }
  45. private void UIK020070_Load(object sender, EventArgs e)
  46. {
  47. CoreClientParam ccp = new CoreClientParam();
  48. ccp.ServerName = "UIK.UIK02.UIK020060";
  49. ccp.MethodName = "queryRollManaNo";
  50. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  51. ArrayList list = (ArrayList)(ccp.ReturnObject);
  52. if (list != null)
  53. {
  54. int listSize = list.Count;
  55. Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize];
  56. for (int i = 0; i < listSize; i++)
  57. {
  58. Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
  59. string[] param = (string[])list[i];
  60. item.DataValue = param[1];
  61. item.DisplayText = param[1]; ;
  62. valueListItems[i] = item;
  63. }
  64. this.ultraComboEditor1.Items.AddRange(valueListItems);
  65. }
  66. ArrayList list2 = (ArrayList)(ccp.ReturnObject);
  67. if (list2 != null)
  68. {
  69. int listSize = list2.Count;
  70. Infragistics.Win.ValueListItem[] valueListItems2 = new Infragistics.Win.ValueListItem[listSize];
  71. for (int i = 0; i < listSize; i++)
  72. {
  73. Infragistics.Win.ValueListItem item2 = new Infragistics.Win.ValueListItem();
  74. string[] param = (string[])list2[i];
  75. item2.DataValue = param[1];
  76. item2.DisplayText = param[1]; ;
  77. valueListItems2[i] = item2;
  78. }
  79. this.ultraComboEditor4.Items.AddRange(valueListItems2);
  80. }
  81. }
  82. private void DoExport()
  83. {
  84. try
  85. {
  86. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  87. {
  88. string fileName = this.saveFileDialog1.FileName;
  89. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SELECT_ITEM"].Hidden = true;
  90. // this.ultraGrid1.DisplayLayout.Bands[0].Columns["SEQ"].Hidden = true;
  91. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_WGT"].Hidden = true;
  92. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = true;
  93. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = true;
  94. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = true;
  95. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_LEN"].Hidden = true;
  96. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_INDIA"].Hidden = true;
  97. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_OUTDIA"].Hidden = true;
  98. this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_EXTSHAPE_REQ"].Hidden = true;
  99. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACID_PROD_PATH"].Hidden = true;
  100. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SM_CFNM"].Hidden = true;
  101. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = true;
  102. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_YN"].Hidden = true;
  103. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = true;
  104. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_FL"].Hidden = true;
  105. this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_COIL_LOAD_LOC"].Hidden = true;
  106. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = true;
  107. this.ultraGrid1.DisplayLayout.Bands[0].Columns["BZ"].Hidden = true;
  108. this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.None;
  109. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  110. System.Diagnostics.Process.Start(fileName);
  111. this.ultraGrid1.BeginUpdate();
  112. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SELECT_ITEM"].Hidden = false;
  113. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SEQ"].Hidden = false;
  114. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_WGT"].Hidden = false;
  115. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = false;
  116. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = false;
  117. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = false;
  118. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_LEN"].Hidden = false;
  119. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_INDIA"].Hidden = false;
  120. this.ultraGrid1.DisplayLayout.Bands[0].Columns["H_ORD_OUTDIA"].Hidden = false;
  121. this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_EXTSHAPE_REQ"].Hidden = false;
  122. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACID_PROD_PATH"].Hidden = false;
  123. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SM_CFNM"].Hidden = false;
  124. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = false;
  125. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_YN"].Hidden = false;
  126. this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = false;
  127. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_FL"].Hidden = false;
  128. this.ultraGrid1.DisplayLayout.Bands[0].Columns["C_COIL_LOAD_LOC"].Hidden = false;
  129. this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = false;
  130. this.ultraGrid1.DisplayLayout.Bands[0].Columns["BZ"].Hidden = false;
  131. this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ExtendLastColumn;
  132. this.ultraGrid1.EndUpdate();
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. MessageBox.Show(ex.ToString());
  138. }
  139. }
  140. private void DoPrint()
  141. {
  142. if (MessageBox.Show("您确认流程卡打印信息?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
  143. {
  144. if (coil_no_index >= 0)
  145. {
  146. string d_H_ORD_WTH = "";
  147. string d_H_ORD_THK = "";
  148. ArrayList param = new ArrayList();
  149. param.Add(this.ultraTextC_PIHAO.Text.Trim());
  150. param.Add(this.ultraTextpaihao.Text.Trim());
  151. param.Add(this.ultraTextH_COILNO.Text.Trim());
  152. d_H_ORD_WTH = this.ultraTextORD_THK.Text.Trim();
  153. d_H_ORD_THK = this.ultraTextORD_WTH.Text.Trim();
  154. param.Add(d_H_ORD_WTH + "*" + d_H_ORD_THK);
  155. param.Add(this.ultraTextH_WGT.Text.Trim());
  156. param.Add(this.ultraTextc_paihao.Text.Trim());
  157. string prodLine = ultraGrid1.Rows[coil_no_index].Cells["PROD_LINE"].Value.ToString().Trim();
  158. string Consignee =ultraGrid1.Rows[coil_no_index].Cells["SM_CFNM"].Value.ToString().Trim();
  159. if (Consignee == "中冶南方(新余)冷轧新材料技术有限公司")
  160. {
  161. param.Add("否");
  162. }
  163. else
  164. {
  165. param.Add("是");
  166. }
  167. if (prodLine == "L")
  168. {
  169. param.Add("否");
  170. param.Add("连退");
  171. param.Add("是");
  172. }
  173. else
  174. {
  175. param.Add("是");
  176. param.Add("酸轧成品");
  177. param.Add("否");
  178. }
  179. try
  180. {
  181. ExcelPrinter ePrinter = new ExcelPrinter("FlowCard.xml", param);
  182. ePrinter.PageSetup.IsCustom = true;
  183. ePrinter.PageSetup.TopMargin = 40;
  184. ePrinter.PageSetup.BottomMargin = 1;
  185. ePrinter.PageSetup.LeftMargin = 25;
  186. ePrinter.PageSetup.RightMargin = 0.5;
  187. ePrinter.Orientation = 1;//横向打印
  188. ePrinter.printExcel();
  189. }
  190. catch (Exception ex)
  191. {
  192. MessageBox.Show("打印失败,请关闭程序后重新操作!");
  193. return;
  194. }
  195. }
  196. else
  197. {
  198. MessageBox.Show("请选择打印钢卷!");
  199. return;
  200. }
  201. }
  202. }
  203. /// <summary>
  204. /// 查询酸轧计划
  205. /// </summary>
  206. private void DoQuery()
  207. {
  208. bool flag = false;
  209. string rollManaNo = this.ultraComboEditor1.Text.Trim();
  210. string rollManaNo2 = this.ultraComboEditor4.Text.Trim();
  211. string pFromDate = null == this.ultraDateTimeEditor1.Value ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
  212. string pToDate = null == this.ultraDateTimeEditor2.Value ? "" : this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");
  213. string mFromDate = null == this.ultraDateTimeEditor3.Value ? "" : this.ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd");
  214. string mToDate = null == this.ultraDateTimeEditor4.Value ? "" : this.ultraDateTimeEditor4.DateTime.ToString("yyyyMMdd");
  215. string ordNo = textBox3.Text.Trim();
  216. string ordSeq = textBox1.Text.Trim();
  217. if ("".Equals(rollManaNo) && "".Equals(ordNo) && "".Equals(rollManaNo2))
  218. {
  219. if ("".Equals(mFromDate) || "".Equals(mToDate) || (ultraDateTimeEditor4.DateTime - ultraDateTimeEditor3.DateTime).Days > 30)
  220. {
  221. if ("".Equals(pFromDate) || "".Equals(pToDate) || (ultraDateTimeEditor2.DateTime - ultraDateTimeEditor1.DateTime).Days > 30)
  222. {
  223. MessageBox.Show("请选择合适的查询条件后再进行查询操作,否则导致数据量过大!");
  224. return;
  225. }
  226. }
  227. }
  228. if (rollManaNo == "") flag = true;
  229. this.dataSet1.Tables[0].Clear();
  230. CoreClientParam ccp = new CoreClientParam();
  231. ccp.ServerName = "UIK.UIK02.UIK020060";
  232. ccp.MethodName = "queryRollPlan";
  233. ccp.ServerParams = new Object[] { rollManaNo,rollManaNo2, pFromDate, pToDate, mFromDate, mToDate, ordNo, ordSeq,flag };
  234. ccp.SourceDataTable = this.dataSet1.Tables[0];
  235. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  236. ///string x = this.ultraGrid1.Rows[0].Cells["SEQ"].Value.ToString();
  237. //this.ultraGrid1.as
  238. // this.ultraGrid1.DataSource = dataSet1.Tables[0];
  239. DataRowCollection drs = dataSet1.Tables[0].Rows;
  240. for (int i = 0; i < drs.Count; i++)
  241. {
  242. Color color = Color.FromArgb(255, 255, 255);
  243. string status = drs[i]["STATUS_CD"].ToString().Trim();
  244. double coilWth = double.Parse(drs[i]["COIL_WTH"].ToString().Trim());
  245. double ordWth = double.Parse(drs[i]["ORD_WTH"].ToString().Trim());
  246. string ingDecGrd = drs[i]["INGR_DEC_GRD"].ToString().Trim();
  247. if ("轧制吊销".Equals(status))
  248. {
  249. color = Color.FromArgb(255, 128, 128);
  250. }
  251. else if ("轧制进行".Equals(status))
  252. {
  253. color = Color.FromArgb(0, 192, 0);
  254. if (coilWth < ordWth)
  255. {
  256. color = Color.SandyBrown;
  257. }
  258. }
  259. else if ("轧制完成".Equals(status))
  260. {
  261. color = Color.FromArgb(192, 255, 192);
  262. }
  263. else if ("上料完成".Equals(status))
  264. {
  265. color = Color.FromArgb(192, 192, 255);
  266. }
  267. else if ("轧废".Equals(status))
  268. {
  269. color = Color.FromArgb(192, 192, 192);
  270. }
  271. else
  272. {
  273. if (!"合格".Equals(ingDecGrd))
  274. {
  275. color = Color.FromArgb(255, 204, 0);
  276. }
  277. else if (coilWth < ordWth)
  278. {
  279. color = Color.SandyBrown;
  280. }
  281. }
  282. ultraGrid1.Rows[i].Appearance.BackColor = color;
  283. }
  284. }
  285. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  286. {
  287. if (e.Cell.Column.Key == "SELECT_ITEM")
  288. {
  289. if (e.Cell.Text == "True")
  290. {
  291. string C_COILNO;
  292. C_COILNO = e.Cell.Row.Cells["OLD_SAMPL_NO"].Text.Trim();
  293. /*for循环控制单选*/
  294. int i = this.ultraGrid1.Rows.Count;
  295. for (int j = 0; j < i; j++)
  296. {
  297. if (this.ultraGrid1.Rows[j].Cells["OLD_SAMPL_NO"].Text != C_COILNO)
  298. {
  299. Infragistics.Win.UltraWinGrid.UltraGrid uGrid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender;
  300. coil_no_index = uGrid.ActiveRow.VisibleIndex;
  301. this.ultraGrid1.Rows[j].Cells["SELECT_ITEM"].Value = false;
  302. string cCoilNo = this.ultraGrid1.Rows[coil_no_index].Cells["OLD_SAMPL_NO"].Text.Trim();
  303. this.ultraTextC_PIHAO.Text = cCoilNo.Substring(0, cCoilNo.LastIndexOf('-'));
  304. this.ultraTextORD_WTH.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_WTH"].Text.Trim();
  305. this.ultraTextORD_THK.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_THK"].Text.Trim();
  306. this.ultraTextORD_FL.Text = this.ultraGrid1.Rows[coil_no_index].Cells["ORD_FL"].Text.Trim().Equals("1") ? "订单" : "";
  307. this.ultraTextACT_WTH.Text = this.ultraGrid1.Rows[coil_no_index].Cells["H_ORD_WTH"].Text.Trim();
  308. this.ultraTextACT_THK.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_THK"].Text.Trim();
  309. this.ultraTextH_COILNO.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_NO"].Text.Trim();
  310. this.ultraTextH_WGT.Text = this.ultraGrid1.Rows[coil_no_index].Cells["COIL_WGT"].Text.Trim();
  311. this.ultraTextpaihao.Text = this.ultraGrid1.Rows[coil_no_index].Cells["STL_GRD"].Text.Trim();
  312. this.ultraTextc_paihao.Text = this.ultraGrid1.Rows[coil_no_index].Cells["C_SPEC_STL_GRD"].Text.Trim();
  313. this.ultraTextEditor17.Text = this.ultraGrid1.Rows[coil_no_index].Cells["SM_CFNM"].Text.Trim();
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }