FrmReqRollMonth.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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.IO;
  11. using System.Globalization;
  12. namespace Core.StlMes.Client.PlnSaleOrd
  13. {
  14. public partial class FrmReqRollMonth : FrmBase
  15. {
  16. public FrmReqRollMonth()
  17. {
  18. InitializeComponent();
  19. }
  20. private void FrmReqRollMonth_Load(object sender, EventArgs e)
  21. {
  22. ReadLog();
  23. string rollMonth = this.ultraDateTimeRollMonth.DateTime.ToString("yyyy-MM");
  24. string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
  25. //string url = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
  26. this.webBrowser1.Url = new Uri(url);
  27. this.webBrowser1.ScriptErrorsSuppressed = true;//屏蔽脚本错误
  28. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
  29. //url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
  30. this.webBrowser2.Url = new Uri(url);
  31. this.webBrowser2.ScriptErrorsSuppressed = true;//屏蔽脚本错误
  32. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
  33. //url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
  34. this.webBrowser3.Url = new Uri(url);
  35. this.webBrowser3.ScriptErrorsSuppressed = true;//屏蔽脚本错误
  36. }
  37. /// <summary>
  38. /// 重写基类toolBar方法
  39. /// </summary>
  40. /// <param name="sender"></param>
  41. /// <param name="ToolbarKey"></param>
  42. public override void ToolBar_Click(object sender, string ToolbarKey)
  43. {
  44. switch (ToolbarKey)
  45. {
  46. case "Close":
  47. this.Close();
  48. break;
  49. }
  50. }
  51. private void ultraButtonQuery_Click(object sender, EventArgs e)
  52. {
  53. string rollMonth = this.ultraDateTimeRollMonth.DateTime.ToString("yyyy-MM");
  54. string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
  55. //string url = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
  56. this.webBrowser1.Url = new Uri(url);
  57. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
  58. //url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
  59. this.webBrowser2.Url = new Uri(url);
  60. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
  61. //url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
  62. this.webBrowser3.Url = new Uri(url);
  63. WriteLog(rollMonth);
  64. }
  65. /// <summary>
  66. /// 写入查询月份
  67. /// </summary>
  68. /// <param name="rollMonth">月份</param>
  69. private void WriteLog(string rollMonth)
  70. {
  71. string path = System.Windows.Forms.Application.StartupPath + "\\Tmp";
  72. string tempText = path + "\\RollMonth.txt";
  73. string w = rollMonth;
  74. if (!Directory.Exists(path))//检查目录是否存在
  75. {
  76. Directory.CreateDirectory(path);
  77. }
  78. if (!File.Exists(tempText))//检察文件是否存在
  79. {
  80. FileStream fs = new FileStream(tempText, FileMode.Create, FileAccess.Write);//创建写入文件s
  81. StreamWriter sw = new StreamWriter(fs);
  82. sw.Write(w);
  83. sw.Close();
  84. fs.Close();
  85. }
  86. else
  87. {
  88. FileStream fs = new FileStream(tempText, FileMode.Open, FileAccess.Write);
  89. StreamWriter sw = new StreamWriter(fs);
  90. fs.Seek(0, SeekOrigin.Begin);
  91. fs.SetLength(0); //清空txt文件
  92. sw.Write(w);
  93. sw.Close();
  94. fs.Close();
  95. }
  96. }
  97. /// <summary>
  98. /// 读取
  99. /// </summary>
  100. /// <returns></returns>
  101. private void ReadLog()
  102. {
  103. DateTime date = new DateTime();
  104. string path = System.Windows.Forms.Application.StartupPath + "\\Tmp";
  105. string tempText = path + "\\RollMonth.txt";
  106. if (!File.Exists(tempText))//检察文件是否存在
  107. {
  108. this.ultraDateTimeRollMonth.DateTime = DateTime.Now;
  109. return;
  110. }
  111. string rollMonth = System.IO.File.ReadAllText(tempText);
  112. if (!DateTime.TryParseExact(rollMonth, "yyyy-MM", null, DateTimeStyles.None, out date))
  113. {
  114. this.ultraDateTimeRollMonth.DateTime = DateTime.Now;
  115. }
  116. else
  117. {
  118. this.ultraDateTimeRollMonth.DateTime = date;
  119. }
  120. }
  121. }
  122. }