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.Collections;
using Core.Mes.Client.Comm.Tool;
using Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
using Core.StlMes.Client.YdmPipeManage.Tool;
namespace Core.StlMes.Client.YdmPipeReport
{
public partial class rptSendClosing : FrmBase
{
public rptSendClosing()
{
this.IsLoadUserView = true;
InitializeComponent();
}
private void rptSendClosing_Load(object sender, EventArgs e)
{
//StatTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM") + "-01" + " 00:00:00");
//endTime.Value = DateTime.Today.AddDays(1).AddSeconds(-1);
DateTime d1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
this.StartTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM"));
}
private Hashtable ShapeRelation = null;
string[] arr = null;
///
/// 重写基类方法
///
///
///
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
QueryData();
break;
case "Export":
ExportData();
break;
case "Close":
this.Close();
break;
}
}
///
/// 查询
///
private void QueryData()
{
//if (this.StatTime.Value > this.endTime.Value)
//{
// MessageUtil.ShowTips("起始日期不能大于结束日期!");
// this.endTime.Focus();
// return;
//}
string bathYear = this.StartTime.Value.ToString("yyyyMM");
string strDateFrom = "";
string strDateTo = "";
string beglogCode = this.ComBeglog.Value.ToString2();
arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
string[] strMergeColumns = new string[] { "BILL_NO", "JUDGE_STOVE_NO", "BATCH_NO", "BATCH_GROUD_NO", "PRODUCNAME", "STD_STYLE_DESC", "STEELNAME", "SPEC_NAME", "MODEL_DESC" };
//出库实单量
DataTable table1 = null;
if (!this.GetSOutWgt(strDateFrom, strDateTo, bathYear, out table1))
{
return;
}
//出库虚单量
DataTable table2 = null;
if (!this.GetXOutWgt(strDateFrom, strDateTo, bathYear, out table2))
{
}
//已结算实单量
DataTable table3 = null;
if (!this.GetSClosingWgt(strDateFrom, strDateTo, bathYear, out table3))
{
}
//已结算虚单量
DataTable table4 = null;
if (!this.GetXClosingWgt(strDateFrom, strDateTo, bathYear, out table4))
{
}
//实时未结算量
DataTable table5 = null;
if (!this.GetRealNoClosingWgt(strDateFrom, strDateTo, bathYear, out table5))
{
}
//票据未对齐
DataTable table6 = null;
if (!this.GetReaggedWgt(strDateFrom, strDateTo, bathYear, out table6))
{
}
DataTable table = table1.DefaultView.ToTable(true, strMergeColumns);
if (table2 != null)
{
table.Merge(table2.DefaultView.ToTable(true, strMergeColumns));
}
if (table3 != null)
{
table.Merge(table3.DefaultView.ToTable(true, strMergeColumns));
}
if (table4 != null)
{
table.Merge(table4.DefaultView.ToTable(true, strMergeColumns));
}
if (table5 != null)
{
table.Merge(table5.DefaultView.ToTable(true, strMergeColumns));
}
if(table6 != null)
{
table.Merge(table6.DefaultView.ToTable(true, strMergeColumns));
}
table.DefaultView.Sort = "BILL_NO,JUDGE_STOVE_NO,BATCH_NO,BATCH_GROUD_NO,PRODUCNAME,STD_STYLE_DESC,STEELNAME,SPEC_NAME,MODEL_DESC";
table = table.DefaultView.ToTable(true, strMergeColumns);
string strSort = "", strBillNo = "", strJudgeNo = "", strBatchNo = "",strGroupNo = "",strPro = "",strStyle = "",strSte = "",strSpec = "",strMode = "" ;
DataRow newrow;
DataRow[] rows;
this.dataTable1.Rows.Clear();
int dSOutCount = 0, dXOutCount = 0, dSdClosingCount = 0, dXdClosingCount = 0, dNoClosingCount = 0, dReaggedCount = 0, dCzCount = 0;
decimal dSOutWgt = 0.0M, dXOutWgt = 0.0M, dSdClosingWgt = 0.0M, dXdClosingWgt = 0.0M, dNoClosingWgt = 0.0M, dReaggedWgt = 0.0M,dCzWgt = 0.0M;
string strRowFilters = "";
for (int i = 0; i < table.Rows.Count; i++)
{
newrow = this.dataTable1.NewRow();
try
{
strBillNo = Convert.ToString(table.Rows[i]["BILL_NO"]);//提单号
strJudgeNo = Convert.ToString(table.Rows[i]["JUDGE_STOVE_NO"]);
strBatchNo = Convert.ToString(table.Rows[i]["BATCH_NO"]);
strGroupNo = Convert.ToString(table.Rows[i]["BATCH_GROUD_NO"]);
strPro = Convert.ToString(table.Rows[i]["PRODUCNAME"]);
strStyle = Convert.ToString(table.Rows[i]["STD_STYLE_DESC"]);
strSte = Convert.ToString(table.Rows[i]["STEELNAME"]);
strSpec = Convert.ToString(table.Rows[i]["SPEC_NAME"]);
strMode = Convert.ToString(table.Rows[i]["MODEL_DESC"]);
strRowFilters = string.IsNullOrEmpty(strBillNo) ? " BILL_NO is null " : " BILL_NO = '" + strBillNo + "' ";
strRowFilters += string.IsNullOrEmpty(strJudgeNo) ? " and JUDGE_STOVE_NO is null " : " and JUDGE_STOVE_NO = '" + strJudgeNo + "' ";
strRowFilters += string.IsNullOrEmpty(strBatchNo) ? " and BATCH_NO is null " : " and BATCH_NO = '" + strBatchNo + "' ";
strRowFilters += string.IsNullOrEmpty(strGroupNo) ? " and BATCH_GROUD_NO is null " : " and BATCH_GROUD_NO = '" + strGroupNo + "' ";
strRowFilters += string.IsNullOrEmpty(strPro) ? " and PRODUCNAME is null " : " and PRODUCNAME = '" + strPro + "' ";
strRowFilters += string.IsNullOrEmpty(strStyle) ? " and STD_STYLE_DESC is null " : " and STD_STYLE_DESC = '" + strStyle + "' ";
strRowFilters += string.IsNullOrEmpty(strSte) ? " and STEELNAME is null " : " and STEELNAME = '" + strSte + "' ";
strRowFilters += string.IsNullOrEmpty(strSpec) ? " and SPEC_NAME is null " : " and SPEC_NAME = '" + strSpec + "' ";
strRowFilters += string.IsNullOrEmpty(strMode) ? " and MODEL_DESC is null " : " and MODEL_DESC = '" + strMode + "' ";
try
{
table1.CaseSensitive = true;
rows = table1.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dSOutCount = int.Parse(Convert.ToString(rows[0]["SOUTCOUNT"]));
dSOutWgt = decimal.Parse(Convert.ToString(rows[0]["SOUTWEIGHT"]));
}
catch
{
dSOutCount = 0;
dSOutWgt = 0.0M;
}
}
else
{
dSOutCount = 0;
dSOutWgt = 0.0M;
}
}
catch
{
dSOutCount = 0;
dSOutWgt = 0.0M;
}
try
{
table2.CaseSensitive = true;
rows = table2.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dXOutCount = int.Parse(Convert.ToString(rows[0]["XOUTCOUNT"]));
dXOutWgt = decimal.Parse(Convert.ToString(rows[0]["XOUTWEIGHT"]));
}
catch
{
dXOutCount = 0;
dXOutWgt = 0.0M;
}
}
else
{
dXOutCount = 0;
dXOutWgt = 0.0M;
}
}
catch
{
dXOutCount = 0;
dXOutWgt = 0.0M;
}
try
{
table3.CaseSensitive = true;
rows = table3.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dSdClosingCount = int.Parse(Convert.ToString(rows[0]["SCLOSINGCOUNT"]));
dSdClosingWgt = decimal.Parse(Convert.ToString(rows[0]["SCLOSINGWEIGHT"]));
}
catch
{
dSdClosingCount = 0;
dSdClosingWgt = 0.0M;
}
}
else
{
dSdClosingCount = 0;
dSdClosingWgt = 0.0M;
}
}
catch
{
dSdClosingCount = 0;
dSdClosingWgt = 0.0M;
}
try
{
table4.CaseSensitive = true;
rows = table4.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dXdClosingCount = int.Parse(Convert.ToString(rows[0]["XCLOSINGCOUNT"]));
dXdClosingWgt = decimal.Parse(Convert.ToString(rows[0]["XCLOSINGWEIGHT"]));
}
catch
{
dXdClosingCount = 0;
dXdClosingWgt = 0.0M;
}
}
else
{
dXdClosingCount = 0;
dXdClosingWgt = 0.0M;
}
}
catch
{
dXdClosingCount = 0;
dXdClosingWgt = 0.0M;
}
try
{
table5.CaseSensitive = true;
rows = table5.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dNoClosingCount = int.Parse(Convert.ToString(rows[0]["TIMEPOINTCOUNT"]));
dNoClosingWgt = decimal.Parse(Convert.ToString(rows[0]["TIMEPOINTWEIGHT"]));
}
catch
{
dNoClosingCount = 0;
dNoClosingWgt = 0.0M;
}
}
else
{
dNoClosingCount = 0;
dNoClosingWgt = 0.0M;
}
}
catch
{
dNoClosingCount = 0;
dNoClosingWgt = 0.0M;
}
try
{
table6.CaseSensitive = true;
rows = table6.Select(strRowFilters);
if (rows.Length > 0)
{
try
{
dReaggedCount = int.Parse(Convert.ToString(rows[0]["RAGGEDCOUNT"]));
dReaggedWgt = decimal.Parse(Convert.ToString(rows[0]["RAGGEDWEIGHT"]));
}
catch
{
dReaggedCount = 0;
dReaggedWgt = 0.0M;
}
}
else
{
dReaggedCount = 0;
dReaggedWgt = 0.0M;
}
}
catch
{
dReaggedCount = 0;
dReaggedWgt = 0.0M;
}
try
{
newrow["BILL_NO"] = strBillNo;
newrow["JUDGE_STOVE_NO"] = strJudgeNo;
newrow["BATCH_NO"] = strBatchNo;
newrow["BATCH_GROUD_NO"] = strGroupNo;
newrow["PRODUCNAME"] = strPro;
newrow["STD_STYLE_DESC"] = strStyle;
newrow["STEELNAME"] = strSte;
newrow["SPEC_NAME"] = strSpec;
newrow["MODEL_DESC"] = strMode;
newrow["SOUTCOUNT"] = dSOutCount.ToString();
newrow["SOUTWEIGHT"] = dSOutWgt.ToString();
newrow["XOUTCOUNT"] = dXOutCount.ToString();
newrow["XOUTWEIGHT"] = dXOutWgt.ToString();
newrow["SCLOSINGCOUNT"] = dSdClosingCount.ToString();
newrow["SCLOSINGWEIGHT"] = dSdClosingWgt.ToString();
newrow["XCLOSINGCOUNT"] = dXdClosingCount.ToString();
newrow["XCLOSINGWEIGHT"] = dXdClosingWgt.ToString();
//newrow["TIMEPOINTCOUNT"] = Convert.ToString(dSOutCount + dXOutCount - dSdClosingCount - dXdClosingCount).Trim();
//newrow["TIMEPOINTWEIGHT"] = Convert.ToString(dSOutWgt + dXOutWgt - dSdClosingWgt - dXdClosingWgt).Trim();
newrow["REALTIMECOUNT"] = dNoClosingCount.ToString();
newrow["REALTIMEWEIGHT"] = dNoClosingWgt.ToString();
newrow["RAGGEDCOUNT"] = dReaggedCount.ToString();
newrow["RAGGEDWEIGHT"] = dReaggedWgt.ToString();
newrow["DIFCOUNT"] = Convert.ToString(dSOutCount + dXOutCount - dReaggedCount - dSdClosingCount - dXdClosingCount - dNoClosingCount).Trim();
newrow["DIFWEIGHT"] = Convert.ToString(dSOutWgt + dXOutWgt - dReaggedWgt - dSdClosingWgt - dXdClosingWgt - dNoClosingWgt).Trim();
try
{
if (ShapeRelation.Contains(strBillNo))
{
strSort = ShapeRelation[strBillNo].ToString();
}
else
{
strSort = "";
}
}
catch
{
strSort = "";
}
//newrow["PRODUCT_SORT"] = strSort;
this.dataSet1.Tables[0].Rows.Add(newrow);
}
catch { }
}
catch { }
}
this.SetStaticsInfo();
CommonMethod.SetGridSumArea(this.ultraGrid1);
}
private void SetStaticsInfo()
{
try
{
if (this.ultraGrid1.Rows.Count == 0)
{
this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
}
else
{
ArrayList alist = new ArrayList();
alist.Add("SOUTCOUNT");
alist.Add("SOUTWEIGHT");
alist.Add("XOUTCOUNT");
alist.Add("XOUTWEIGHT");
alist.Add("SCLOSINGCOUNT");
alist.Add("SCLOSINGWEIGHT");
alist.Add("XCLOSINGCOUNT");
alist.Add("XCLOSINGWEIGHT");
//alist.Add("TIMEPOINTCOUNT");
//alist.Add("TIMEPOINTWEIGHT");
alist.Add("REALTIMECOUNT");
alist.Add("REALTIMEWEIGHT");
alist.Add("DIFCOUNT");
alist.Add("DIFWEIGHT");
alist.Add("RAGGEDCOUNT");
alist.Add("RAGGEDWEIGHT");
CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
}
}
catch { }
}
///
/// 票据未对齐
///
///
///
///
///
private bool GetReaggedWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getReaggedWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 实时未结算
///
///
///
///
///
private bool GetRealNoClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getRealNoClosingWgt", new object[] { strDateFrom, strDateTo,beglogCode,arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 已结算虚单量
///
///
///
///
///
private bool GetXClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getXClosingWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 已结算实单量
///
///
///
///
///
private bool GetSClosingWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getSClosingWgt", new object[] { strDateFrom, strDateTo ,beglogCode,arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 出库虚单量
///
///
///
///
///
private bool GetXOutWgt(string strDateFrom, string strDateTo, string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getXOutWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 出库实单量
///
///
///
///
///
private bool GetSOutWgt(string strDateFrom, string strDateTo,string beglogCode, out DataTable table)
{
table = null;
DataSet set = new DataSet();
DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmrptSendClosing.getSOutWgt", new object[] { strDateFrom, strDateTo,beglogCode, arr }, this.ob);
if (ds != null && ds.Rows.Count > 0)
{
set.Tables.Add(ds);
table = set.Tables[0];
return true;
}
return false;
}
///
/// 导出
///
private void ExportData()
{
GridHelper.ulGridToExcel(ultraGrid1, "出库结算汇总");
}
}
}