using Core.Mes.Client.Comm.Control;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Tool;
using Core.StlMes.Client.Mcp.Control.Base;
using CoreFS.CA06;
using Infragistics.Win.UltraWinGrid;
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;
namespace Core.StlMes.Client.Mcp.Mch.Report
{
public partial class FrmStatistical : FrmBase
{
private string _plineCode = "";
//private string _startime = "";
//private string _endtime = "";
private string bc = "";
private string bz = "";
private int days = 0;
private string effic = "";
private string effic1 = "";
private string effic2 = "";
public FrmStatistical(string plineCode, OpeBase _ob)
{
InitializeComponent();
_plineCode = plineCode;
//_startime = startime;
//_endtime = endtime;
this.ob = _ob;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.statisticalControl1.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
this.statisticalControl2.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
this.statisticalControl3.Grid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
}
private void FrmStatistical_Load(object sender, EventArgs e)
{
dateDayTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
bc = this.UserInfo.GetUserOrder();
bz = this.UserInfo.GetUserGroup();
txtBc.Text = this.UserInfo.GetUserOrderText();
txtBz.Text = this.UserInfo.GetUserGroupText();
days = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
doOutlibrary();
}
private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case "Outlibrary"://查询
doOutlibrary();
break;
case "ClassPint"://班报打印
doClassPint();
break;
case "DayPrint"://日报打印
doDayPrint();
break;
case "MonthPrint"://月报打印
doMonthPrint();
break;
case "Close":
this.Close();
break;
default:
break;
}
}
private void doOutlibrary()
{
//月
string fistMonthD = "";
//string lastMonthD = "";
//日
string fistday = "";
//string lastday = "";
//DateTime t = DateTime.Parse(dateDayTime.Value.ToString());
//DateTime t1 = new DateTime(t.Year, t.Month, 1);
fistMonthD =dateDayTime.Value.ToString("yyyyMM");
fistday = dateDayTime.Value.ToString("yyyyMMdd");
//lastday = dateDayTime.Value.ToString("yyyyMMdd");
//查询当班生产实绩
DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchControlLog.doQueryActual", new object[] { fistday, bc, _plineCode }, this.ob);
if (dt != null && dt.Rows.Count > 0)
{
DataRow row = dt.Rows[0];
this.statisticalControl1.Value.JudgeStoveNo = row["JUDGE_STOVE_NO"].ToString();
this.statisticalControl1.Value.QualifiedNum = row["QUALIFIED_NUM"].ToString();
this.statisticalControl1.Value.QualifiedWt = row["QUALIFIED_WT"].ToString();
this.statisticalControl1.Value.Minutes = row["MINUTES"].ToString();
this.statisticalControl1.Value.AbaMinutes = row["ABSMINUTES"].ToString();
this.statisticalControl1.Value.SumMinutes = row["SUMMINUTES"].ToString();
double feizi = double.Parse(row["YOUMINUTES"].ToString()) - double.Parse(row["SUMMINUTES"].ToString());
double feimu = double.Parse(row["YOUMINUTES"].ToString());
if (feizi <= 0 || row["JUDGE_STOVE_NO"].ToString().Equals("0"))
{
effic = "0";
}
else
{
effic = ((feizi / feimu) * 100).ToString("f2");
}
this.statisticalControl1.Value.Effic = effic+"%";
this.statisticalControl1.UpdateData();
}
else
{
StatisticalClass result = new StatisticalClass();
this.statisticalControl1.Value = result;
}
//查询当天生产实绩
DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchControlLog.doQueryDayActual",
new object[] {fistday, _plineCode }, this.ob);
if (dt1 != null && dt1.Rows.Count > 0)
{
//if (!dt1.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0"))
//{
DataRow row1 = dt1.Rows[0];
this.statisticalControl2.Value.JudgeStoveNo = row1["JUDGE_STOVE_NO"].ToString();
this.statisticalControl2.Value.QualifiedNum = row1["QUALIFIED_NUM"].ToString();
this.statisticalControl2.Value.QualifiedWt = row1["QUALIFIED_WT"].ToString();
this.statisticalControl2.Value.Minutes = row1["MINUTES"].ToString();
this.statisticalControl2.Value.AbaMinutes = row1["ABSMINUTES"].ToString();
this.statisticalControl2.Value.SumMinutes = row1["SUMMINUTES"].ToString();
double feizi = double.Parse(row1["YOUMINUTES"].ToString()) - double.Parse(row1["SUMMINUTES"].ToString());
double feimu = double.Parse(row1["YOUMINUTES"].ToString());
if (feizi <= 0 || row1["JUDGE_STOVE_NO"].ToString().Equals("0"))
{
effic1 = "0";
}
else
{
effic1 = ((feizi / feimu) * 100).ToString("f2");
}
this.statisticalControl2.Value.Effic = effic1 + "%";
this.statisticalControl2.UpdateData();
//}
//else
//{
// StatisticalClass result = new StatisticalClass();
// this.statisticalControl2.Value = result;
//}
}
else
{
StatisticalClass result = new StatisticalClass();
this.statisticalControl2.Value = result;
}
//查询当月生产实绩
DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMchControlLog.doQueryMonthActual", new object[] { fistMonthD, _plineCode }, this.ob);
if (dt2 != null && dt2.Rows.Count > 0)
{
//if (!dt2.Rows[0]["JUDGE_STOVE_NO"].ToString().Equals("0"))
//{
DataRow row2 = dt2.Rows[0];
this.statisticalControl3.Value.JudgeStoveNo = row2["JUDGE_STOVE_NO"].ToString();
this.statisticalControl3.Value.QualifiedNum = row2["QUALIFIED_NUM"].ToString();
this.statisticalControl3.Value.QualifiedWt = row2["QUALIFIED_WT"].ToString();
this.statisticalControl3.Value.Minutes = row2["MINUTES"].ToString();
this.statisticalControl3.Value.AbaMinutes = row2["ABSMINUTES"].ToString();
this.statisticalControl3.Value.SumMinutes = row2["SUMMINUTES"].ToString();
double feizi = double.Parse(row2["YOUMINUTES"].ToString()) - double.Parse(row2["SUMMINUTES"].ToString());
double feimu = double.Parse(row2["YOUMINUTES"].ToString());
if (feizi <= 0 || row2["JUDGE_STOVE_NO"].ToString().Equals("0"))
{
effic2 = "0";
}
else
{
effic2 = ((feizi / feimu) * 100).ToString("f2");
}
this.statisticalControl3.Value.Effic = effic2 + "%";
this.statisticalControl3.UpdateData();
//}
//else
//{
// StatisticalClass result = new StatisticalClass();
// this.statisticalControl3.Value = result;
//}
}
else
{
StatisticalClass result = new StatisticalClass();
this.statisticalControl3.Value = result;
}
}
///
/// 班报打印
///
private void doClassPint()
{
doOutlibrary();
//日
string fistday = "";
//string lastday = "";
fistday = dateDayTime.Value.ToString("yyyyMMdd");
//lastday = dateDayTime.Value.ToString("yyyyMMdd");
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduClass.cpt&__bypagesize__=false&PROBC=" + bc + "&PLINECODE=" + _plineCode + "&p1=" + effic + "&startTim=" + fistday + "";
FrmRepExcel fre = new FrmRepExcel(this.ob, url);
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.Text = "调度班报统计";
fre.ShowDialog();
}
///
/// 日报打印
///
private void doDayPrint()
{
doOutlibrary();
//日
string fistday = "";
//string lastday = "";
fistday = dateDayTime.Value.ToString("yyyyMMdd");
//lastday = dateDayTime.Value.ToString("yyyyMMdd");
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduDay.cpt&__bypagesize__=false&PLINECODE=" + _plineCode + "&startTim=" + fistday + "&p1=" + effic1 + "";
FrmRepExcel fre = new FrmRepExcel(this.ob, url);
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.Text = "调度日报统计";
fre.ShowDialog();
}
///
/// 月报打印
///
private void doMonthPrint()
{
doOutlibrary();
//月
string fistMonthD = "";
//string lastMonthD = "";
//DateTime t = DateTime.Parse(dateDayTime.Value.ToString());
//DateTime t1 = new DateTime(t.Year, t.Month, 1);
//lastMonthD = DateTime.Parse(t.ToString("yyyy-MM-dd 21:06")).ToString("yyyyMMdd");
fistMonthD = dateDayTime.Value.ToString("yyyyMM");
string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepScheduMonth.cpt&__bypagesize__=false&PLINECODE=" + _plineCode + "&startTim=" + fistMonthD + "&p1=" + effic2 + "";
FrmRepExcel fre = new FrmRepExcel(this.ob, url);
fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
fre.Text = "调度月报统计";
fre.ShowDialog();
}
}
}