using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;
using System.IO;
using System.Globalization;
namespace Core.StlMes.Client.PlnSaleOrd
{
public partial class FrmReqRollMonth : FrmBase
{
public FrmReqRollMonth()
{
InitializeComponent();
}
private void FrmReqRollMonth_Load(object sender, EventArgs e)
{
ReadLog();
string rollMonth = this.ultraDateTimeRollMonth.DateTime.ToString("yyyy-MM");
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
//string url = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser1.Url = new Uri(url);
this.webBrowser1.ScriptErrorsSuppressed = true;//屏蔽脚本错误
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
//url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser2.Url = new Uri(url);
this.webBrowser2.ScriptErrorsSuppressed = true;//屏蔽脚本错误
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
//url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser3.Url = new Uri(url);
this.webBrowser3.ScriptErrorsSuppressed = true;//屏蔽脚本错误
}
///
/// 重写基类toolBar方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Close":
this.Close();
break;
}
}
private void ultraButtonQuery_Click(object sender, EventArgs e)
{
string rollMonth = this.ultraDateTimeRollMonth.DateTime.ToString("yyyy-MM");
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
//string url = "http://localhost:8075/webroot/decision/view/report?viewlet=RepPlnproduceSort.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser1.Url = new Uri(url);
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
//url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnPrdcls.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser2.Url = new Uri(url);
url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
//url = "http://localhost:8075/webroot/decision/view/report?viewlet=ReqPlnOutbilletfl.cpt&op=view&dateRollMonth=" + rollMonth;
this.webBrowser3.Url = new Uri(url);
WriteLog(rollMonth);
}
///
/// 写入查询月份
///
/// 月份
private void WriteLog(string rollMonth)
{
string path = System.Windows.Forms.Application.StartupPath + "\\Tmp";
string tempText = path + "\\RollMonth.txt";
string w = rollMonth;
if (!Directory.Exists(path))//检查目录是否存在
{
Directory.CreateDirectory(path);
}
if (!File.Exists(tempText))//检察文件是否存在
{
FileStream fs = new FileStream(tempText, FileMode.Create, FileAccess.Write);//创建写入文件s
StreamWriter sw = new StreamWriter(fs);
sw.Write(w);
sw.Close();
fs.Close();
}
else
{
FileStream fs = new FileStream(tempText, FileMode.Open, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
fs.Seek(0, SeekOrigin.Begin);
fs.SetLength(0); //清空txt文件
sw.Write(w);
sw.Close();
fs.Close();
}
}
///
/// 读取
///
///
private void ReadLog()
{
DateTime date = new DateTime();
string path = System.Windows.Forms.Application.StartupPath + "\\Tmp";
string tempText = path + "\\RollMonth.txt";
if (!File.Exists(tempText))//检察文件是否存在
{
this.ultraDateTimeRollMonth.DateTime = DateTime.Now;
return;
}
string rollMonth = System.IO.File.ReadAllText(tempText);
if (!DateTime.TryParseExact(rollMonth, "yyyy-MM", null, DateTimeStyles.None, out date))
{
this.ultraDateTimeRollMonth.DateTime = DateTime.Now;
}
else
{
this.ultraDateTimeRollMonth.DateTime = date;
}
}
}
}