FrmMilStaOutput.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.ZGMil.Entity;
  5. using CoreFS.CA06;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. namespace Core.StlMes.Client.ZGMil.Report
  15. {
  16. public partial class FrmMilStaOutput : FrmBase
  17. {
  18. private string departm = "";
  19. private string plineCode = "";
  20. private string plineName = "";
  21. private string date = "";
  22. private string endDate = "";
  23. private string yearM = "";
  24. public FrmMilStaOutput()
  25. {
  26. InitializeComponent();
  27. this.IsLoadUserView = true;
  28. }
  29. private void FrmMilStaOutput_Load(object sender, EventArgs e)
  30. {
  31. dateTimePicker1.Value = DateTime.Parse(DateTime.Today.ToString());
  32. NativeMethodNew na = new NativeMethodNew(this.ob);
  33. departm = UserInfo.GetDepartment();
  34. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  35. plineName = getPlineName(plineCode);
  36. yearM = dateTimePicker1.Value.ToString("yyyy年MM月");
  37. }
  38. /// <summary>
  39. /// 重写基类方法
  40. /// </summary>
  41. /// <param name="sender"></param>
  42. /// <param name="ToolbarKey"></param>
  43. public override void ToolBar_Click(object sender, string ToolbarKey)
  44. {
  45. switch (ToolbarKey)
  46. {
  47. case "Query":
  48. doQuery();
  49. break;
  50. case "Export":
  51. ExportData();
  52. break;
  53. case "Print":
  54. PrintData();
  55. break;
  56. case "Close":
  57. this.Close();
  58. break;
  59. }
  60. }
  61. private void PrintData()
  62. {
  63. DateTime dtTarget = dateTimePicker1.Value;
  64. DateTime FirstDay = dtTarget.AddDays(-dtTarget.AddMonths(1).Day);
  65. DateTime LastDay = dtTarget.AddMonths(1).AddDays(-dtTarget.AddMonths(1).Day);
  66. date = FirstDay.ToString("yyyy-MM-dd 21:00:00");
  67. endDate = LastDay.ToString("yyyy-MM-dd 21:00:00");
  68. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilStaOutput.cpt&op=view&PLINE_CODE=" + getPlineCode() + "&date=" + date + "&endDate=" + endDate;
  69. FrmRepExcel fre = new FrmRepExcel(ob, strurl);
  70. fre.AutoSize = true;
  71. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  72. fre.WindowState = FormWindowState.Maximized;
  73. fre.Show();
  74. }
  75. private void doQuery()
  76. {
  77. if (ultraCheckEditor1.Checked)
  78. {
  79. DateTime dtTarget = dateTimePicker1.Value;
  80. DateTime FirstDay = dtTarget.AddDays(-dtTarget.AddMonths(1).Day);
  81. DateTime LastDay = dtTarget.AddMonths(1).AddDays(-dtTarget.AddMonths(1).Day);
  82. date = FirstDay.ToString("yyyy-MM-dd 21:00:00");
  83. endDate = LastDay.ToString("yyyy-MM-dd 21:00:00");
  84. }
  85. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.report.FrmMilDateStatistics.getMilStaOutput", new Object[] { date, endDate, getPlineCode() }, this.ob);
  86. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  87. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  88. }
  89. private void ExportData()
  90. {
  91. GridHelper.ulGridToExcel(ultraGrid1, "轧管部" + plineName + "产量报表");
  92. }
  93. /// <summary>
  94. /// 非250、258、168、460的产线代码都为空
  95. /// </summary>
  96. /// <returns></returns>
  97. private string getPlineCode()
  98. {
  99. if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017"))
  100. {
  101. return plineCode;
  102. }
  103. else
  104. {
  105. return "";
  106. }
  107. }
  108. /// <summary>
  109. /// 机组
  110. /// </summary>
  111. /// <param name="plineCode"></param>
  112. /// <returns></returns>
  113. private string getPlineName(string plineCode)
  114. {
  115. if (plineCode.Equals("C008"))
  116. {
  117. return "250机组";
  118. }
  119. else if(plineCode.Equals("C009"))
  120. {
  121. return "258机组";
  122. }else if(plineCode.Equals("C010"))
  123. {
  124. return "168机组";
  125. }else if(plineCode.Equals("C017"))
  126. {
  127. return "460机组";
  128. }else
  129. {
  130. return "";
  131. }
  132. }
  133. /// <summary>
  134. /// 查询条件
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void chkDate_CheckedChanged(object sender, EventArgs e)
  139. {
  140. if (ultraCheckEditor1.Checked) { dateTimePicker1.Enabled = true; } else { dateTimePicker1.Enabled = false; }
  141. }
  142. }
  143. }