UIC020150.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.Diagnostics;
  11. using System.Collections;
  12. using Infragistics.Win.UltraWinGrid;
  13. namespace Core.LZMes.Client.UIC
  14. {
  15. public partial class UIC020150 : FrmBase
  16. {
  17. public UIC020150()
  18. {
  19. InitializeComponent();
  20. }
  21. public override void ToolBar_Click(object sender, string ToolbarKey)
  22. {
  23. switch (ToolbarKey)
  24. {
  25. case "Query":
  26. this.DoQuery();
  27. break;
  28. case "Export":
  29. this.DoExport();
  30. break;
  31. case "Exit":
  32. this.Close();
  33. break;
  34. }
  35. }
  36. private void DoExport()
  37. {
  38. try
  39. {
  40. if (this.ultraGrid1.Rows.Count == 0)
  41. {
  42. MessageBox.Show("没有可以导出的数据", "提示");
  43. return;
  44. }
  45. saveFileDialog1.FileName = "酸轧停扎时间" + DateTime.Today.ToShortDateString() + "_01";
  46. saveFileDialog1.Filter = "表格(*.xls)|*.xls";
  47. if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
  48. {
  49. string fName = this.saveFileDialog1.FileName;
  50. this.ultraGridExcelExporter1.Export(ultraGrid1, fName);
  51. Process.Start(fName);
  52. }
  53. }
  54. catch (Exception ex)
  55. {
  56. System.Diagnostics.Debug.WriteLine(ex.ToString());
  57. }
  58. }
  59. public void DoQuery()
  60. {
  61. try
  62. {
  63. ArrayList al = new ArrayList();
  64. al.Add("UIC020150_01.SELECT");
  65. al.Add(this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss").Trim());
  66. al.Add(this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd").Trim()+"999999");
  67. //查询详细停轧时间
  68. this.dataSet1.Tables[0].Clear();
  69. CoreClientParam ccp = new CoreClientParam();
  70. ccp.ServerName = "UIB.COM.ComDBQuery";
  71. ccp.MethodName = "doSimpleQuery";
  72. ccp.ServerParams = new object[] { al };
  73. ccp.SourceDataTable = this.dataSet1.Tables[0];
  74. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  75. if (this.ultraGrid1.Rows.Count > 0)
  76. {
  77. DateTime a;
  78. string b = "";
  79. foreach (UltraGridRow ugr in this.ultraGrid1.Rows)
  80. {
  81. b = ugr.Cells["TIMESTART"].Text.ToString();
  82. a = DateTime.Parse(b);
  83. if (a.Hour>=0 && a.Hour<8)
  84. {
  85. ugr.Cells["BC"].Value = "晚班";
  86. }
  87. else if (a.Hour >= 8 && a.Hour < 16)
  88. {
  89. ugr.Cells["BC"].Value = "早班";
  90. }
  91. else if (a.Hour >= 16 && a.Hour < 24)
  92. {
  93. ugr.Cells["BC"].Value = "中班";
  94. }
  95. }
  96. }
  97. this.ultraGrid1.Update();
  98. //停扎时间按班次统计
  99. this.dataSet1.Tables[1].Clear();
  100. string queryDate = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss").Trim();
  101. string queryDate1 = this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd").Trim() + "999999";
  102. if (queryDate.Substring(0, 6) != queryDate1.Substring(0, 6))
  103. {
  104. MessageBox.Show("请确保两个查询日期在同一月份", "错误");
  105. return;
  106. }
  107. string queryDate2 = "";//月累统计截止日期
  108. if (queryDate1.Substring(0, 6) == DateTime.Today.ToString("yyyyMM"))//查询日期为当月
  109. queryDate2 = DateTime.Today.ToString("yyyyMMdd");
  110. else
  111. {
  112. DateTime date = ultraDateTimeEditor2.DateTime;
  113. queryDate2 = date.AddDays(1 - date.Day).AddMonths(1).AddDays(-1).ToString("yyyyMMdd");
  114. }
  115. CoreClientParam ccp1 = new CoreClientParam();
  116. ccp1.ServerName = "UIC.UIC02.UIC020120";
  117. ccp1.MethodName = "query";
  118. ccp1.ServerParams = new object[] { queryDate, queryDate1, queryDate2 };
  119. ccp1.SourceDataTable = this.dataSet1.Tables[1];
  120. this.ExecuteQueryToDataTable(ccp1, CoreInvokeType.Internal);
  121. }
  122. catch (Exception ex)
  123. {
  124. System.Diagnostics.Debug.WriteLine(ex.ToString());
  125. }
  126. }
  127. private void label2_Click(object sender, EventArgs e)
  128. {
  129. }
  130. private void UIC020150_Load(object sender, EventArgs e)
  131. {
  132. }
  133. }
  134. }