| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531 |
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Server;
- using Core.Mes.Client.Comm.Tool;
- using Core.StlMes.Client.YdmPipeManage;
- using Core.StlMes.Client.YdmPipeManage.Tool;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using System;
- using System.Collections;
- 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.YdmPipeReport
- {
- public partial class FrmRunTimeRptZgNew : FrmBase
- {
- public FrmRunTimeRptZgNew()
- {
- InitializeComponent();
- }
- private string beglongCode = "";//部门ID
- private Hashtable ShapeRelation = null;
- private void FrmRunTimeRptZgNew_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();
- break;
- case "Export":
- exportData();
- break;
- case "insertTal":
- insertTal();
- break;
- case "cancelInsertTal":
- cancelInsertTal();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- private void queryData()
- {
- string yearMothTim = this.dtBathYear.Value.ToString("yyyyMM");
- DataTable table1 = null;
- DataTable table2 = null;
- DataTable table3 = null;
- string[] arr = BaseMethod.getPlineValid(this.ValidDataPurviewIds,this.ob);
- //beglongCode = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
- try
- {
- this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
- if (Constant.WaitingForm == null)
- {
- Constant.WaitingForm = new WaitingForm();
- }
- Constant.WaitingForm.ShowToUser = true;
- Constant.WaitingForm.Show();
- Constant.WaitingForm.Update();
- //上期期初
- if (!this.GetOriginalLastB(yearMothTim, out table1, arr))
- {
- }
- //本期入库量
- if (!this.GetThisInB(yearMothTim, out table2, arr))
- {
- //return;
- }
- //本期出库量
- if (!this.GetThisOutB(yearMothTim, out table3, arr))
- {
- //return;
- }
- DataTable table = new DataTable();
- string[] strMergeColumns = new string[] { "JUDGE_STOVE_NO","PLINE_NAME" };
- if (table1 != null)
- {
- 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));
- }
- }
- else
- {
- if (table2 != null)
- {
- table = table2.DefaultView.ToTable(true, strMergeColumns);
- if (table3 != null)
- {
- table.Merge(table3.DefaultView.ToTable(true, strMergeColumns));
- }
- }
- else
- {
- if (table3 != null)
- {
- table = table3.DefaultView.ToTable(true, strMergeColumns);
- }
- }
- }
- if (table != null)
- {
- table.DefaultView.Sort = "JUDGE_STOVE_NO,PLINE_NAME";
- table = table.DefaultView.ToTable(true, strMergeColumns);
- }
- else
- {
- return;
- }
- string strSort = "", strHeatNo = "",strPlineName = "";
- DataRow newrow;
- DataRow[] rows;
- this.dataTable1.Rows.Clear();
- decimal dWgt = 0.0M, dAjust = 0.0M;
- int dCount = 0;
- decimal dThisIn_Month = 0.0M, dThisOut_Month = 0.00M;
- int dThisIn_MonthCount = 0, dThisOut_MonthCount = 0;
- string strRowFilters = "";
- for (int i = 0; i < table.Rows.Count; i++)
- {
- newrow = this.dataTable1.NewRow();
- try
- {
- strHeatNo = Convert.ToString(table.Rows[i]["JUDGE_STOVE_NO"]);//炉号
- strPlineName = Convert.ToString(table.Rows[i]["PLINE_NAME"]);//产线
- strRowFilters = string.IsNullOrEmpty(strHeatNo) ? " JUDGE_STOVE_NO is null " : " JUDGE_STOVE_NO = '" + strHeatNo + "' ";
- strRowFilters += string.IsNullOrEmpty(strPlineName) ? " and PLINE_NAME is null " : " and PLINE_NAME = '" + strPlineName + "' ";
- try
- {
- table1.CaseSensitive = true;
- rows = table1.Select(strRowFilters);
- if (rows.Length > 0)
- {
- try
- {
- dWgt = decimal.Parse(Convert.ToString(rows[0]["WEIGHT"]));
- dCount = int.Parse(Convert.ToString(rows[0]["COUNT"]));
- }
- catch
- {
- dWgt = 0.0M;
- dCount = 0;
- }
- }
- else
- {
- dWgt = 0.0M;
- dCount = 0;
- }
- }
- catch
- {
- dWgt = 0.0M;
- dCount = 0;
- }
- try
- {
- table2.CaseSensitive = true;
- rows = table2.Select(strRowFilters);
- if (rows.Length > 0)
- {
- try
- {
- dThisIn_Month = decimal.Parse(Convert.ToString(rows[0]["WEIGHT_MONTH"]));
- dThisIn_MonthCount = int.Parse(Convert.ToString(rows[0]["WEIGHT_MONTHCOUNT"]));
- }
- catch
- {
- dThisIn_Month = 0.0M;
- dThisIn_MonthCount = 0;
- }
- }
- else
- {
- dThisIn_Month = 0.0M;
- dThisIn_MonthCount = 0;
- }
- }
- catch
- {
- dThisIn_Month = 0.0M;
- dThisIn_MonthCount = 0;
- }
- try
- {
- table3.CaseSensitive = true;
- rows = table3.Select(strRowFilters);
- if (rows.Length > 0)
- {
- try
- {
- dThisOut_Month = decimal.Parse(Convert.ToString(rows[0]["WEIGHT_MONTH"]));
- dThisOut_MonthCount = int.Parse(Convert.ToString(rows[0]["weight_monthcount"]));
- }
- catch
- {
- dThisOut_Month = 0.0M;
- dThisOut_MonthCount = 0;
- }
- }
- else
- {
- dThisOut_Month = 0.0M;
- dThisOut_MonthCount = 0;
- }
- }
- catch
- {
- dThisOut_Month = 0.0M;
- dThisOut_MonthCount = 0;
- }
- try
- {
- newrow["JUDGE_STOVE_NO"] = strHeatNo;
- newrow["PLINE_NAME"] = strPlineName;
- newrow["ORIGINAL_AMOUNT"] = Convert.ToString(dWgt).Trim();
- newrow["ORIGINAL_COUNT"] = Convert.ToString(dCount).Trim();
- newrow["MONTH_1"] = dThisIn_Month.ToString().Trim();
- newrow["MONTH_1COUNT"] = dThisIn_MonthCount.ToString().Trim();
- newrow["MONTH_2"] = dThisOut_Month.ToString().Trim();
- newrow["MONTH_2COUNT"] = dThisOut_MonthCount.ToString().Trim();
- newrow["END_AMOUNT"] = Convert.ToString(dWgt + dThisIn_Month - dThisOut_Month + dAjust).Trim();
- newrow["END_COUNT"] = Convert.ToString(dCount + dThisIn_MonthCount - dThisOut_MonthCount).Trim();
- newrow["AWEIGHT"] = Convert.ToString(dAjust).Trim();
- try
- {
- if (ShapeRelation!=null&&ShapeRelation.Contains(strHeatNo))
- {
- strSort = ShapeRelation[strHeatNo].ToString();
- }
- else
- {
- strSort = "";
- }
- }
- catch
- {
- strSort = "";
- }
- this.dataSet1.Tables[0].Rows.Add(newrow);
- }
- catch { }
- }
- catch { }
- }
- 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 insertTal()
- {
- string dtYear = this.dtBathYear.Value.ToString("yyyyMM");
- string dtNowTim = DateTime.Now.AddMonths(1).ToString("yyyyMM");
- //if (!this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM").Equals(dtNowTim))
- //{
- // MessageUtil.ShowTips("所选结转年月与当前所在月往后推一月不一致,请重新选择结转年月!");
- // return;
- //}
- UltraGridRow row = this.ultraGrid1.ActiveRow;
- if (row == null || row.Index < 0)
- {
- MessageUtil.ShowWarning("无库存信息,无法结转!");
- return;
- }
- string departId = ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob);
- DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRptZg.getIntalJZB", new object[] { dtNowTim, departId }, ob);
- if (int.Parse(ds.Rows[0][0].ToString()) > 0)
- {
- MessageUtil.ShowTips("已存在结转数据,不允许重复结转!");
- return;
- }
- ArrayList parm = new ArrayList();
- if (MessageUtil.ShowYesNoAndQuestion("是否结转期初数据?") == DialogResult.No) return;
- try
- {
- this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
- if (Constant.WaitingForm == null)
- {
- Constant.WaitingForm = new WaitingForm();
- }
- Constant.WaitingForm.ShowToUser = true;
- Constant.WaitingForm.Show();
- Constant.WaitingForm.Update();
- foreach (UltraGridRow uRow in ultraGrid1.Rows)
- {
- if (int.Parse(uRow.Cells["END_COUNT"].Value.ToString()) > 0)
- {
- ArrayList list = new ArrayList();
- list.Add(uRow.Cells["JUDGE_STOVE_NO"].Value.ToString());
- list.Add(uRow.Cells["END_COUNT"].Value.ToString());
- list.Add(uRow.Cells["END_AMOUNT"].Value.ToString());
- list.Add(this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM"));
- list.Add(this.UserInfo.GetUserName());
- parm.Add(list);
- }
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.ydm.Report.FrmRunTimeRptZgNew";
- ccp.MethodName = "insertInitalBelog";
- ccp.ServerParams = new object[] { parm, departId, dtYear };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("期初数据结转成功!"))
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- 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 cancelInsertTal()
- {
- string dtYear = this.dtBathYear.Value.ToString("yyyyMM");
- string dtYear2 = this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM");
- string dtNowTim = DateTime.Now.ToString("yyyyMM");
- if (!this.dtBathYear.Value.AddMonths(1).ToString("yyyyMM").Equals(dtNowTim))
- {
- MessageUtil.ShowTips("所选结转年月与当前所在月往后推一月不一致,请重新选择结转年月!");
- return;
- }
-
- ArrayList parm = new ArrayList();
- if (MessageUtil.ShowYesNoAndQuestion("是否撤销结转期初数据?") == DialogResult.No) return;
- try
- {
- this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
- if (Constant.WaitingForm == null)
- {
- Constant.WaitingForm = new WaitingForm();
- }
- Constant.WaitingForm.ShowToUser = true;
- Constant.WaitingForm.Show();
- Constant.WaitingForm.Update();
-
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.pss.ydm.Report.FrmRunTimeRptZgNew";
- ccp.MethodName = "cancelInsertTal";
- ccp.ServerParams = new object[] { dtYear, dtYear2 };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("撤销成功!"))
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- 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 bool GetOriginalLastB(string yearMothTim, out DataTable table, string[] belogCode)
- {
- table = null;
- DataSet set = new DataSet();
- DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRptZgNew.getOriginalLastB", new object[] { yearMothTim, belogCode }, this.ob);
- if (ds != null && ds.Rows.Count > 0)
- {
- set.Tables.Add(ds);
- table = set.Tables[0];
- return true;
- }
- return false;
- }
- //入库量
- private bool GetThisInB(string yearMothTim, out DataTable table, string[] belogCode)
- {
- table = null;
- DataSet set = new DataSet();
- DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRptZgNew.getThisInB", new object[] { yearMothTim, belogCode }, this.ob);
- if (ds != null && ds.Rows.Count > 0)
- {
- set.Tables.Add(ds);
- table = set.Tables[0];
- return true;
- }
- return false;
- }
- //本期出库量
- private bool GetThisOutB(string yearMothTim, out DataTable table, string[] belogCode)
- {
- table = null;
- DataSet set = new DataSet();
- DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.Report.FrmRunTimeRptZgNew.getThisOutB", new object[] { yearMothTim, belogCode }, 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(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("ORIGINAL_AMOUNT");
- alist.Add("ORIGINAL_COUNT");
- alist.Add("MONTH_1");
- alist.Add("MONTH_1COUNT");
- alist.Add("MONTH_2");
- alist.Add("MONTH_2COUNT");
- alist.Add("END_AMOUNT");
- alist.Add("END_COUNT");
- alist.Add("AWEIGHT");
- CommonMethod.SetStaticsInfoSum(ref this.ultraGrid1, alist, true);
- }
- }
- catch { }
- }
- }
- }
|