| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656 |
- 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;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- 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 { }
- }
- /// <summary>
- /// 调差量
- /// </summary>
- /// <param name="yearMothTim"></param>
- /// <param name="table"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 财务账面库存(首次)
- /// </summary>
- /// <param name="yearMothTim"></param>
- /// <param name="table6"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 财务账面库存(末次)
- /// </summary>
- /// <param name="yearMothTim"></param>
- /// <param name="table6"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 销售账面库存
- /// </summary>
- /// <param name="yearMothTim"></param>
- /// <param name="table5"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 实物库存
- /// </summary>
- /// <param name="yearMothTim"></param>
- /// <param name="table4"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 导出
- /// </summary>
- 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;
- }
- }
- }
|