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 Core.Mes.Client.Comm.Control; using System.Collections; using Core.StlMes.Client.YdmPipeManage; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.YdmPipeReport { public partial class FrmLeaderRpt : FrmBase { private Hashtable ShapeRelation = null; public FrmLeaderRpt() { this.IsLoadUserView = true; InitializeComponent(); } private void FrmLeaderRpt_Load(object sender, EventArgs e) { dtBathYear.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM")); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": //queryData(); queryDataB(); break; case "Export": exportData(); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void queryData() { string yearMothTim = ""; try { this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待 if (Constant.WaitingForm == null) { Constant.WaitingForm = new WaitingForm(); } Constant.WaitingForm.ShowToUser = true; Constant.WaitingForm.Show(); Constant.WaitingForm.Update(); yearMothTim = this.dtBathYear.Value.ToString("yyyyMM"); //本月期初 DataTable table1 = null; if (!this.GetOriginalLast(yearMothTim, out table1)) { } //本月入库量 DataTable table2 = null; if (!this.GetThisIn(yearMothTim, out table2)) { //return; } //本月出库量 DataTable table3 = null; if (!this.GetThisOut(yearMothTim, out table3)) { //return; } //实物库存 DataTable table4 = null; if (!this.GetThisMat(yearMothTim, out table4)) { } //销售账面库存 DataTable table5 = null; if (!this.GetThisXsMat(yearMothTim, out table5)) { } //财务账面库存(末次) DataTable table6 = null; if (!this.GetThisZmMat(yearMothTim, out table6)) { } //财务账面库存(首次) DataTable table7 = null; if (!this.GetThisZmMat1(yearMothTim, out table7)) { } //调差量 DataTable table8 = null; if(!this.GetAdjustWgt(yearMothTim,out table8)) { } DataTable table = new DataTable(); string[] strMergeColumns = new string[] { "BELONG_NAME" }; if (table1 != null) { table = table1.DefaultView.ToTable(true, strMergeColumns); } if(table2 != null) { table = table2.DefaultView.ToTable(true, strMergeColumns); } if (table3 != null) { table = table3.DefaultView.ToTable(true, strMergeColumns); } if (table4 != null) { table = table4.DefaultView.ToTable(true, strMergeColumns); } if (table5 != null) { table = table5.DefaultView.ToTable(true, strMergeColumns); } if (table6 != null) { table = table6.DefaultView.ToTable(true, strMergeColumns); } //if (table8 != null) //{ // table = table8.DefaultView.ToTable(true, strMergeColumns); //} if (table7 != null) { table = table7.DefaultView.ToTable(true, strMergeColumns); } if (table != null) { table.DefaultView.Sort = "BELONG_NAME"; table = table.DefaultView.ToTable(true, strMergeColumns); } else { return; } string strSort = "", strBelongName = ""; DataRow newrow; DataRow[] rows; this.dataTable1.Rows.Clear(); decimal dWgt = 0.0M, dThisIn_Month = 0.0M, dThisOut_Month = 0.00M, dThisMatWgt = 0.00M, dThisXsWgt = 0.00M, dThisCwWgt = 0.00M,dThisCwWgt1 = 0.0M,dThisAdjustWgt = 0.00M; string strRowFilters = ""; for (int i = 0; i < table.Rows.Count; i++) { newrow = this.dataTable1.NewRow(); strBelongName = Convert.ToString(table.Rows[i]["BELONG_NAME"]); strRowFilters = string.IsNullOrEmpty(strBelongName) ? " BELONG_NAME is null " : " BELONG_NAME = '" + strBelongName + "' "; try { table1.CaseSensitive = true; rows = table1.Select(strRowFilters); if (rows.Length > 0) { try { dWgt = decimal.Parse(Convert.ToString(rows[0]["ACT_WEIGHT"])); } catch { dWgt = 0.0M; } } else { dWgt = 0.0M; } } catch { dWgt = 0.0M; } try { table2.CaseSensitive = true; rows = table2.Select(strRowFilters); if (rows.Length > 0) { try { dThisIn_Month = decimal.Parse(Convert.ToString(rows[0]["RKWGT"])); } catch { dThisIn_Month = 0.0M; } } else { dThisIn_Month = 0.0M; } } catch { dThisIn_Month = 0.0M; } try { table3.CaseSensitive = true; rows = table3.Select(strRowFilters); if (rows.Length > 0) { try { dThisOut_Month = decimal.Parse(Convert.ToString(rows[0]["CKWGT"])); } catch { dThisOut_Month = 0.0M; } } else { dThisOut_Month = 0.0M; } } catch { dThisOut_Month = 0.0M; } try { table4.CaseSensitive = true; rows = table4.Select(strRowFilters); if (rows.Length > 0) { try { dThisMatWgt = decimal.Parse(Convert.ToString(rows[0]["SWWGT"])); } catch { dThisMatWgt = 0.0M; } } else { dThisMatWgt = 0.0M; } } catch { dThisMatWgt = 0.0M; } try { table5.CaseSensitive = true; rows = table5.Select(strRowFilters); if (rows.Length > 0) { try { dThisXsWgt = decimal.Parse(Convert.ToString(rows[0]["XSWGT"])); } catch { dThisXsWgt = 0.0M; } } else { dThisXsWgt = 0.0M; } } catch { dThisXsWgt = 0.0M; } try { table6.CaseSensitive = true; rows = table6.Select(strRowFilters); if (rows.Length > 0) { try { dThisCwWgt = decimal.Parse(Convert.ToString(rows[0]["CWWGT"])); } catch { dThisCwWgt = 0.0M; } } else { dThisCwWgt = 0.0M; } } catch { dThisCwWgt = 0.0M; } try { table7.CaseSensitive = true; rows = table7.Select(strRowFilters); if (rows.Length > 0) { try { dThisCwWgt1 = decimal.Parse(Convert.ToString(rows[0]["CWWGT1"])); } catch { dThisCwWgt1 = 0.0M; } } else { dThisCwWgt1 = 0.0M; } } catch { dThisCwWgt1 = 0.0M; } try { table8.CaseSensitive = true; rows = table8.Select(strRowFilters); if (rows.Length > 0) { try { dThisAdjustWgt = decimal.Parse(Convert.ToString(rows[0]["ADJUSTWGT"])); } catch { dThisAdjustWgt = 0.0M; } } else { dThisAdjustWgt = 0.0M; } } catch { dThisAdjustWgt = 0.0M; } newrow["BELONG_NAME"] = strBelongName; newrow["ACT_WEIGHT"] = Convert.ToString(dWgt).Trim(); newrow["RUWGT"] = Convert.ToString(dThisIn_Month).Trim(); newrow["CKWGT"] = Convert.ToString(dThisOut_Month).Trim(); newrow["SWWGT"] = Convert.ToString(dThisMatWgt).Trim(); newrow["XSWGT"] = Convert.ToString(dThisXsWgt).Trim(); newrow["CWWGT"] = Convert.ToString(dThisCwWgt).Trim(); newrow["CWWGT2"] = Convert.ToString(dThisCwWgt1).Trim(); newrow["ADJUSTWGT"] = Convert.ToString(dThisAdjustWgt).Trim(); try { if (ShapeRelation.Contains(strBelongName)) { strSort = ShapeRelation[strBelongName].ToString(); } else { strSort = ""; } } catch { strSort = ""; } this.dataSet1.Tables[0].Rows.Add(newrow); } this.SetStaticsInfo(); CommonMethod.SetGridSumArea(this.ultraGrid1); this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } catch (Exception e) { this.Cursor = Cursors.Default; Constant.WaitingForm.ShowToUser = false; Constant.WaitingForm.Close(); Constant.WaitingForm = null; } } /// /// 查询 /// private void queryDataB() { string yearMothTim = this.dtBathYear.Value.ToString("yyyyMM"); DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.doQueryData", new object[] { yearMothTim }, ob); GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true); 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("ACT_WEIGHT"); alist.Add("RUWGT"); alist.Add("CKWGT"); alist.Add("SWWGT"); alist.Add("XSWGT"); alist.Add("CWWGT"); alist.Add("CWWGT2"); alist.Add("ADJUSTWGT"); //CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true); CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true); } } catch { } } /// /// 调差量 /// /// /// /// private bool GetAdjustWgt(string yearMothTim,out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getAdjustWgt", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } /// /// 财务账面库存(首次) /// /// /// /// private bool GetThisZmMat1(string yearMothTim, out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisCwMat1", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } /// /// 财务账面库存(末次) /// /// /// /// private bool GetThisZmMat(string yearMothTim, out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisCwMat", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } /// /// 销售账面库存 /// /// /// /// private bool GetThisXsMat(string yearMothTim, out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisXsMat", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } /// /// 实物库存 /// /// /// /// private bool GetThisMat(string yearMothTim, out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisSwMat", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } //本期出库量 private bool GetThisOut(string yearMothTim,out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisOut", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } //本期入库量 private bool GetThisIn(string yearMothTim,out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getThisIn", new object[] { yearMothTim }, this.ob); if (ds != null && ds.Rows.Count > 0) { set.Tables.Add(ds); table = set.Tables[0]; return true; } return false; } //期初 private bool GetOriginalLast(string yearMothTim, out DataTable table) { table = null; DataSet set = new DataSet(); DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmLeaderRpt.getOriginalLast", new object[] { yearMothTim }, 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(this.ultraGrid1, "本月收发存结总汇"); } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { this.dtBathYear.Enabled = this.chkRegTime.Checked; } private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Override.DefaultRowHeight = 45; e.Layout.Override.RowSizing = RowSizing.Free; this.ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.Free; } } }