FrmCLReport.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.Windows.Forms;
  9. using CoreFS.CA06;
  10. using System.Collections;
  11. using Infragistics.Win.UltraWinGrid;
  12. namespace Core.LgMes.Client.lgIntegrationQuery
  13. {
  14. public partial class FrmCLReport : FrmBase
  15. {
  16. public FrmCLReport()
  17. {
  18. InitializeComponent();
  19. }
  20. private void FrmCLReport_Load(object sender, EventArgs e)
  21. {
  22. this.ultraComboEditor1.SelectedIndex = 0;
  23. this.ultraComboEditor3.SelectedIndex = 0;
  24. this.ultraComboEditor2.SelectedIndex = 0;
  25. }
  26. /// <summary>
  27. /// 操作方法 查询
  28. /// </summary>
  29. private void DoQuery()
  30. {
  31. try
  32. {
  33. if (this.DelToDateTo.DateTime.Date.Subtract(this.DelToDateFrom.DateTime.Date).Days > 180)
  34. {
  35. MessageBox.Show("查询时间不可超过6个月。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  36. return;
  37. }
  38. if (this.DelToDateFrom.DateTime > this.DelToDateTo.DateTime)
  39. {
  40. MessageBox.Show("查询起始时间不能大于结束时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  41. return;
  42. }
  43. string strErr = "";
  44. this.dataSet1.Tables[0].Clear();
  45. string DelToDateFrom = Convert.ToString(this.DelToDateFrom.DateTime.ToString("yyyyMMdd"));
  46. string DelToDateTo = Convert.ToString(this.DelToDateTo.DateTime.ToString("yyyyMMdd"));
  47. string prcd = this.ultraComboEditor4.Text.ToString();
  48. DateTime t1 = DateTime.ParseExact(DelToDateFrom, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
  49. DateTime t2 = DateTime.ParseExact(DelToDateTo, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
  50. System.TimeSpan t3 = t2 - t1; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  51. double getDay = t3.TotalDays; //将这个天数转换成天数, 返回值是double类型的(其实不必转换,因为t3默认就是天数) 得到:
  52. if (getDay > 30)
  53. {
  54. MessageBox.Show("查询周期过长,是否继续查询?");
  55. }
  56. string sqlCondition = "1=1 AND (T1.MATRL_END_CAUSE_CD IS NULL OR T1.MATRL_END_CAUSE_CD != '4')";
  57. if (this.ultraComboEditor1.Text.ToString() == "已申报") //是否申报
  58. {
  59. sqlCondition += " AND T1.REPORT_TIME IS NOT NULL ";
  60. }
  61. else if (this.ultraComboEditor1.Text.ToString() == "未申报")
  62. {
  63. sqlCondition += " AND T1.REPORT_TIME IS NULL ";
  64. }
  65. if (this.ultraComboEditor2.Text.ToString() == "切割时间")
  66. {
  67. sqlCondition += " AND T1.SLAB_CUT_DTIME BETWEEN " + DelToDateFrom + "000000" + " AND " + DelToDateTo + "999999" + "";
  68. }
  69. else if (this.ultraComboEditor2.Text.ToString() == "申报时间")
  70. {
  71. sqlCondition += " AND T1.REPORT_REGTIME BETWEEN " + DelToDateFrom + "000000" + " AND " + DelToDateTo + "999999" + "";
  72. }
  73. else //出库时间
  74. {
  75. sqlCondition += " AND T1.SMS_YARD_EXT_DTIME BETWEEN " + DelToDateFrom + "000000" + " AND " + DelToDateTo + "999999" + "";
  76. }
  77. if (!string.IsNullOrEmpty(this.textOrdNO.Text))
  78. {
  79. sqlCondition += " AND T1.SLAB_NO LIKE '%" + Convert.ToString(this.textOrdNO.Text) + "%' ";
  80. }
  81. if (!string.IsNullOrEmpty(this.ultraComboEditor4.Text.Trim()) && this.ultraComboEditor4.Text.Trim() != "全部")
  82. {
  83. sqlCondition += " AND T1.PROC_CD = '" + this.ultraComboEditor4.Text.Trim() + "'";
  84. }
  85. ArrayList arry1 = new ArrayList();
  86. ArrayList sqlList = new ArrayList();
  87. arry1.Add("FrmCLReport.Select");//此ID为XML文件ID
  88. sqlList.Add(sqlCondition);
  89. //调用服务端方法
  90. CoreClientParam CCP_JJBQuery = new CoreClientParam();
  91. DataTable dt = new DataTable();
  92. CCP_JJBQuery.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
  93. CCP_JJBQuery.MethodName = "doQuery";
  94. CCP_JJBQuery.ServerParams = new object[] { arry1, sqlList };
  95. CCP_JJBQuery.SourceDataTable = dt;//dataSet1.Tables[0];
  96. this.ExecuteQueryToDataTable(CCP_JJBQuery, CoreInvokeType.Internal);
  97. if (dt != null && dt.Rows.Count > 0)
  98. {
  99. this.dataTable1.Rows.Clear();
  100. DataRow dr;
  101. for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
  102. {
  103. dr = this.dataTable1.NewRow();
  104. for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
  105. {
  106. if (this.dataTable1.Columns.Contains(dt.Columns[jCol].ColumnName))
  107. {
  108. dr[dt.Columns[jCol].ColumnName] = dt.Rows[iRow][jCol];
  109. }
  110. }
  111. this.dataTable1.Rows.Add(dr);
  112. }
  113. }
  114. //this.dataSet1.data = dt;
  115. //System.Diagnostics.Debug.WriteLine(this.dataSet1.Tables[0].ToString());
  116. this.Docount();
  117. }
  118. catch (Exception EX)
  119. {
  120. MessageBox.Show(EX.ToString());
  121. }
  122. }
  123. private void Docount()
  124. {
  125. int coilCount = 0;
  126. double actWgtSum = 0;
  127. double thrWgtSum = 0;
  128. string status = "", zl2 = "", zl3 = "";
  129. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ultraGrid1.Rows)
  130. {
  131. double actWgt = 0;
  132. double thrWgt = 0;
  133. bool ifhide = ugr.HiddenResolved;
  134. if (ifhide == false)
  135. {
  136. try
  137. {
  138. Color color = Color.SandyBrown;
  139. status = ugr.Cells["REPORTFLAG"].Value.ToString().Trim();
  140. if ("未申报".Equals(status))
  141. {
  142. color = Color.White;
  143. }
  144. else if ("已申报".Equals(status))
  145. {
  146. color = Color.FromArgb(255, 128, 128);
  147. }
  148. ugr.Appearance.BackColor = color;
  149. zl2 = Convert.ToString(ugr.Cells["THR_WGT"].Text.ToString());
  150. if (zl2 == "") zl2 = "0";
  151. zl3 = Convert.ToString(ugr.Cells["SLAB_WGT"].Text.ToString());
  152. if (zl3 == "") zl3 = "0";
  153. thrWgt = double.Parse(zl2);
  154. actWgt = double.Parse(zl3);
  155. thrWgtSum += thrWgt;
  156. actWgtSum += actWgt;
  157. coilCount = coilCount + 1;
  158. }
  159. catch (Exception e)
  160. {
  161. }
  162. }
  163. }
  164. this.textBox1.Text = coilCount.ToString();
  165. this.textBox2.Text = (Math.Round(thrWgtSum, 3)).ToString();
  166. this.textBox3.Text = (Math.Round(actWgtSum, 3)).ToString();
  167. // this.ultraGrid1.DisplayLayout.Bands[0].Summaries.
  168. }
  169. private void DoSave()
  170. {
  171. try
  172. {
  173. string strQueryFlag = "Y";
  174. this.ultraGrid1.UpdateData();
  175. ArrayList list = new ArrayList();
  176. string[] param = null;
  177. CoreClientParam ccp = new CoreClientParam();
  178. ccp.ServerName = "Core.LgMes.Server.lgIntegrationQuery.PerformanceLog";
  179. string regid = this.UserInfo.GetUserName();
  180. string bc = this.UserInfo.GetUserOrderText();
  181. string reporttime = Convert.ToString(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMM"));
  182. DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
  183. for (int i = 0; i < selectedRows.Length; i++)
  184. {
  185. param = new string[3];
  186. string slab_no = Convert.ToString(selectedRows[i]["SLAB_NO"]);
  187. param[0] = slab_no;//板坯号
  188. param[1] = reporttime;//申报时间
  189. param[2] = bc;//班次
  190. list.Add(param);
  191. }
  192. if (MessageBox.Show("确定将所选定板坯申报至" + reporttime + "?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  193. return;
  194. ccp.MethodName = "reportslab";
  195. ccp.ServerParams = new Object[] { regid, list };
  196. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  197. if (strQueryFlag == "Y")
  198. {
  199. this.DoQuery();
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. System.Diagnostics.Debug.WriteLine(ex.ToString());
  205. }
  206. }
  207. private void DoCancel()
  208. {
  209. try
  210. {
  211. string strQueryFlag = "Y";
  212. this.ultraGrid1.UpdateData();
  213. ArrayList list = new ArrayList();
  214. string[] param = null;
  215. CoreClientParam ccp = new CoreClientParam();
  216. ccp.ServerName = "Core.LgMes.Server.lgIntegrationQuery.PerformanceLog";
  217. string regid = this.UserInfo.GetUserID();
  218. string reporttime = Convert.ToString(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMM"));
  219. DataRow[] selectedRows = dataSet1.Tables[0].Select("CHK ='True'");
  220. for (int i = 0; i < selectedRows.Length; i++)
  221. {
  222. param = new string[1];
  223. string slab_no = Convert.ToString(selectedRows[i]["SLAB_NO"]);
  224. param[0] = slab_no;//板坯号
  225. list.Add(param);
  226. }
  227. if (MessageBox.Show("确定取消所选板坯申报?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
  228. return;
  229. ccp.MethodName = "cancelreportslab";
  230. ccp.ServerParams = new Object[] { regid, list };
  231. this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  232. if (strQueryFlag == "Y")
  233. {
  234. this.DoQuery();
  235. }
  236. }
  237. catch (Exception ex)
  238. {
  239. System.Diagnostics.Debug.WriteLine(ex.ToString());
  240. }
  241. }
  242. private void DoExport()
  243. {
  244. try
  245. {
  246. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  247. {
  248. string fileName = this.saveFileDialog1.FileName;
  249. ultraGridExcelExporter1.Export(ultraGrid1, fileName);
  250. //System.Diagnostics.Process.Start(fileName);
  251. }
  252. }
  253. catch (Exception EX)
  254. {
  255. MessageBox.Show(EX.ToString());
  256. }
  257. }
  258. /// <summary>
  259. /// 事件方法:
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. #region "EVENT 事件"
  264. private void UIN060310_Load(object sender, EventArgs e)
  265. {
  266. // init();
  267. }
  268. public override void ToolBar_Click(object sender, string ToolbarKey)
  269. {
  270. switch (ToolbarKey)
  271. {
  272. case "Query":
  273. this.DoQuery();
  274. break;
  275. case "Save":
  276. this.DoSave();
  277. break;
  278. case "Export":
  279. this.DoExport();
  280. break;
  281. case "cancel":
  282. this.DoCancel();
  283. break;
  284. case "Exit":
  285. this.Close();
  286. break;
  287. }
  288. }
  289. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  290. {
  291. try
  292. {
  293. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  294. {
  295. if (ugr.HiddenResolved == false)//只处理过滤之后的数据
  296. {
  297. ugr.Cells["CHK"].Value = this.checkBox1.Checked;
  298. ugr.Update();
  299. }
  300. }
  301. }
  302. catch (Exception ex)
  303. {
  304. System.Diagnostics.Debug.WriteLine(ex.ToString());
  305. }
  306. }
  307. #endregion
  308. private void ultraComboEditor3_ValueChanged(object sender, EventArgs e)
  309. {
  310. try
  311. {
  312. this.ultraGrid1.DisplayLayout.Bands[0].ColumnFilters.ClearAllFilters();
  313. if (ultraComboEditor3.Text == "在库")
  314. ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["SLAB_STAT"].FilterConditions.Add(Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Like, "在*");
  315. else if (ultraComboEditor3.Text == "出库")
  316. ultraGrid1.DisplayLayout.Bands[0].ColumnFilters["SLAB_STAT"].FilterConditions.Add(Infragistics.Win.UltraWinGrid.FilterComparisionOperator.Like, "出*");
  317. this.Docount();
  318. }
  319. catch (Exception ex)
  320. {
  321. MessageBox.Show(ex.Message);
  322. }
  323. }
  324. private void ultraGrid1_FilterRow(object sender, Infragistics.Win.UltraWinGrid.FilterRowEventArgs e)
  325. {
  326. //this.Docount();
  327. //List<UltraGridRow> rows = this.ultraGrid1.Rows.Where(p => p.IsFilteredOut == false).ToList();//选择过滤后数据的代码
  328. }
  329. private void ultraGrid1_AfterRowFilterChanged(object sender, Infragistics.Win.UltraWinGrid.AfterRowFilterChangedEventArgs e)
  330. {
  331. this.Docount();
  332. }
  333. }
  334. }