| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Threading;
- using System.Collections;
- using System.Reflection;
- using CoreFS.CA06;
- namespace Core.StlMes.Client.Sale.UI.Balance.BalanceAccount
- {
- public partial class FrmBalanceInvoceMgt : Core.StlMes.Client.Sale.Common.FrmStyleBase.FrmUIBase
- {
- public FrmBalanceInvoceMgt()
- {
- InitializeComponent();
- }
-
- private DataSet dsInvoice = new DataSet();
- private DataSet dsInvoiceDetail = null;
- private DataSet dsInvoiceSeq = new DataSet();
- private DataSet dsInvoiceList = new DataSet();
- private DataSet dsMnyCredit = new DataSet();
- private DataSet dsCreditResult = new DataSet();
- private void initDataSource()
- {
- dsInvoice = base.GetDataSetByColumnName(this.GetGrid1DataStruct(),
- null, GetColumnAndCaption());
- this.ultraGrid1.DataSource = dsInvoice;
- dsInvoiceSeq = base.GetDataSetByColumnName(this.GetGrid2DataStruct(),
- null, GetColumnAndCaption());
- this.ultraGrid2.DataSource = dsInvoiceSeq;
- dsInvoiceList = base.GetDataSetByColumnName(this.GetGrid3DataStruct(),
- null, GetColumnAndCaption());
- this.ultraGrid3.DataSource = dsInvoiceList;
- dsMnyCredit = base.GetDataSetByColumnName(this.GetGrid5DataStruct(),
- null, GetGrid5DataSetColumnCaption());
- this.ultraGrid5.DataSource = dsMnyCredit;
- dsCreditResult = base.GetDataSetByColumnName(this.GetGrid4DataStruct(),
- null, GetGrid5DataSetColumnCaption());
- this.ultraGrid4.DataSource = dsCreditResult;
- }
- private void HiddenColumn()
- {
- try
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["CUSTOMER_NO"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["SALE_AREA_NO"].Hidden = true;
- // this.ultraGrid1.DisplayLayout.Bands[0].Columns["FORECORPCODE"].Hidden = true;
-
- this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO].Hidden = true;
- this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO_SEQ].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUYERCODE"].Hidden = true;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["CREATE_DEPT"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["INVOICENO"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["INVOICENO_DATE"].Hidden = true;
-
-
-
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["FORECORPCODE"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["MONEY_TYPE"].Hidden = true;
- // this.ultraGrid5.DisplayLayout.Bands[0].Columns["MONEY"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["SUB_SEQ"].Hidden = true;
- this.ultraGrid5.DisplayLayout.Bands[0].Columns["BUYERCODE"].Hidden = true;
-
- }
- catch
- { }
-
- }
- private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo slmBalanceInfo = null;
- private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceMnysubt slmBalanceMnysubt = null;
- private void FrmBalanceInvoceMgt_Load(object sender, EventArgs e)
- {
- // this.dateTimePicker1.Value = System.DateTime.Now.AddMonths(-1);
- slmBalanceInfo = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo(this.ob);
- slmBalanceMnysubt = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceMnysubt(this.ob);
- initDataSource();
- base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid5, ref this.ultraGrid2, ref this.ultraGrid3, ref this.ultraGrid4);
- InitGrid();
- HiddenColumn();
-
- }
- protected override List<string> GetNumberColumn()
- {
- return new List<string>(new string[] {
- "SEND_NUM",
- "MONEY",
- "WEIGHT",
- "QUANTITY",
- "ACT_WGT",
- "OUTSTOCKMNY",
- "TRANSMNY",
- "PRICE",
- "PRICE_ORG",
- "MONEY_ORG",
- });
- }
- protected Hashtable GetGrid5DataSetColumnCaption()
- {
- Hashtable hs = new Hashtable();
- hs.Add("SUB_SEQ", "冲减单号");
- hs.Add("BUYERCODE", "冲减客户");
- hs.Add("FORECORPCODE", "销售组织");
- hs.Add("MONEY", "冲减金额");
- hs.Add("MONEY_TYPE", "冲减类型");
- hs.Add("MONEY_TYPE_DESC", "冲减类型");
- hs.Add("AFFRIM_NAME", "确认人");
- hs.Add("CREATE_DEPT", "创建部门");
- hs.Add("BUYERNAME", "冲减客户");
- hs.Add("AFFRIM_TIME", "确认时间");
- hs.Add("INVOICENO_DATE", "冲减时间");
-
- return hs;
- }
-
- private void QueryGridFine(string buyercode, string forecode)
- {
-
- try
- {
- DataSet ds = slmBalanceMnysubt.GetCanBeUsedSlmBalanceMnySubtByBuyerCodeAndForeCode(buyercode, forecode);
- Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMnyCredit, ds);
-
- }
- catch
- { }
-
- }
- private void QueryGridFour(string invoiceNO)
- {
- try
- {
- DataSet ds = slmBalanceMnysubt.GetSlmBalanceMnySubtByInvoiceNo(invoiceNO);
- Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsCreditResult, ds);
- }
- catch
- { }
- }
- private void InitGrid()
- {
- System.Drawing.Color color = System.Drawing.Color.FromArgb(255, 255, 128);
- try
- {
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellAppearance.BackColor = color;
-
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellAppearance.BackColor = color;
- // this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime;
- // this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- //this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].CellAppearance.BackColor = color;
- }
- catch
- {
- }
-
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- {
- this.Query();
- break;
- }
- case "RollInv":
- {
- this.RollBackInvoiceNo();
- break;
- }
- case "Exit":
- {
-
- this.Close();
- break;
- }
- case "Save":
- {
- this.SaveRealInvoiceNo();
- break;
- }
- case "PrintInvoice":
- {
- this.PrintInvoice();
- break;
- }
- case "Print":
- {
- PrintInvoicerpt();
- break;
- }
- case "Credit":
- {
- this.Credit();
- break;
- }
- case "Export":
- {
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel(this.Text, this.ultraGrid1);
- break;
- }
- case "AddTrans":
- {
- InvoiceSignalTransMoney();
- break;
- }
- }
- }
- public override void Update()
- {
- return;
- this.ultraGrid1.UpdateData();
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- ugr.Selected = true;
- string invoiceno = "";
- string realdate = "";
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugs in this.ultraGrid1.Selected.Rows)
- {
- invoiceno = ugs.Cells[this.INVOICENO].Value.ToString();
- DateTime dt = Convert.ToDateTime( ugr.Cells["REALINVOICENO_DATE"].Value);
- realdate = dt.ToString("yyyyMMddHHmmss");
-
- }
- }
- private void InvoiceSignalTransMoney()
- {
- DlgBox.DlgSelectInvoceTransMnyAndOutStockMny dlg
- = new Core.StlMes.Client.Sale.UI.Balance.DlgBox.DlgSelectInvoceTransMnyAndOutStockMny(this.ob);
- dlg.ShowDialog();
- ArrayList arpk = new ArrayList();
- string errMsg = "";
- if (dlg.DialogResult == DialogResult.OK)
- {
- arpk = dlg.Tranpk;
- if (arpk.Count == 0)
- return;
- this.slmBalanceInfo.MakeLastInvoiceForTransMnyAndOutStockMoney(arpk,
- CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
- if (errMsg.Length == 0)
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功");
- this.Query();
- }
- }
- }
- /// <summary>
- /// 冲减
- /// </summary>
- private void Credit()
- {
-
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugrc = null;
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- if (this.ultraGrid2.Rows.Count == 0)
- return;
- if (this.ultraGrid1.Rows.Count == 1)
- this.ultraGrid1.Rows[0].Activated = true;
- ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- Util.MessageUtil.ShowTips("请选择需要保存的行");
- return;
- }
- if (this.ultraGrid5.Rows.Count == 0)
- return;
- if (this.ultraGrid5.Rows.Count == 1)
- this.ultraGrid5.Rows[0].Activated = true;
- ugrc = this.ultraGrid5.ActiveRow;
- if (ugrc == null)
- {
- Util.MessageUtil.ShowTips("请选择待冲减的行");
- return;
- }
- string invoiceno = ugr.Cells["INVOICENO"].Value.ToString();
- // "WEIGHT",
- // "MONEY",
- double money = Util.ConverObject.ConvertToDouble( ugr.Cells["MONEY"].Value);
- double weight = Util.ConverObject.ConvertToDouble(ugr.Cells["WEIGHT"].Value);
- double creditMny = Util.ConverObject.ConvertToDouble(ugrc.Cells["MONEY"].Value);
-
- if (creditMny >= money)
- {
- Util.MessageUtil.ShowError("冲减金额必须小于货款");
- return;
- }
- if (weight == 0)
- {
- Util.MessageUtil.ShowError("只能冲减货款");
- return;
- }
- if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定冲减结算单?") == DialogResult.No) return;
- double dlivPrice = (money - creditMny) / weight;
- ArrayList list = new ArrayList();
- string[] str = null;
- string sub_seq = ugrc.Cells["SUB_SEQ"].Value.ToString();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrr in this.ultraGrid2.Rows)
- {
- double seqmoney = dlivPrice * Util.ConverObject.ConvertToDouble(ugrr.Cells["WEIGHT"].Value);
- str = new string[] { invoiceno, ugrr.Cells["INVOICENO_SEQ"].Value.ToString(), dlivPrice + "",
- seqmoney +"",sub_seq};
- list.Add(str);
- }
- string errMsg = "";
- this.slmBalanceInfo.Credit(list, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
- if (errMsg.Length == 0)
- {
- Util.MessageUtil.ShowTips("操作成功");
- }
- this.Query();
- }
- private void SaveRealInvoiceNo()
- {
- this.ultraGrid1.UpdateData();
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- {
- Util.MessageUtil.ShowTips("请选择需要保存的行");
- return;
- }
- if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON"].Value.ToString()))
- return;
- string invoiceno = ugr.Cells["INVOICENO"].Value.ToString();
- string realInvoiceNo = ugr.Cells["REALINVOICENO"].Value.ToString();
- //DateTime dt = Convert.ToDateTime( ugr.Cells["REALINVOICENO_DATE"].Value);
- //if (realInvoiceNo.Length == 0)
- // dt = Convert.ToDateTime(DBNull.Value);
-
- if (realInvoiceNo.Length > 30)
- {
- Util.MessageUtil.ShowTips("真实发票号长度不能超过30");
- return;
- }
- string errMsg = "";
- this.slmBalanceInfo.UpdateRealInvoiceNO(invoiceno, realInvoiceNo, CoreFS.SA06.CoreUserInfo.UserInfo
- .GetUserName(), out errMsg);
- if (errMsg.Length == 0)
- {
- Util.MessageUtil.ShowTips("保存成功");
- }
-
- }
- private void UpdateInvoiceLockStatus(string invoiceNO)
- {
- try
- {
- ArrayList arrayList = new ArrayList();
- string errMsg = "";
- arrayList = new ArrayList(new string[] { invoiceNO });
- slmBalanceInfo.UpdateInvoiceStatusToLocked(arrayList,
- CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
- }
- catch
- { }
-
- }
- private void PrintInvoicerpt()
- {
- string INVOICENO = "INVOICENO";
- string errMsg = "";
- List<string> list = new List<string>();
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- if (this.ultraGrid1.Rows.Count == 1)
- this.ultraGrid1.Rows[0].Selected = true;
- this.ultraGrid1.ActiveRow.Selected = true;
- String sqlCondition = "";
- double money = 0;
- string isGreaterThanZero = "0";
- // 打印包含货款和独立的出库费 or 运费,这里因为模板不一样不能一起连打
- money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(this.ultraGrid1.Selected.Rows[0].Cells["MONEY"].Value);
- if (money != 0)
- {
- isGreaterThanZero = "0";
- }
- else
- {
- isGreaterThanZero = "1";
- }
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
- {
- money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["MONEY"].Value);
- if (money != 0)
- {
- if (isGreaterThanZero == "1")
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印");
- return;
- }
- }
- else
- {
- if (isGreaterThanZero == "0")
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印");
- return;
- }
- }
- sqlCondition += "\'" + ugr.Cells[INVOICENO].Value.ToString() + "\'" + ",";
- list.Add(ugr.Cells[INVOICENO].Value.ToString());
- }
- string url = "";
- if (isGreaterThanZero == "0")
- {
- url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicket.cpt&__bypagesize__=false" + "&invoiceno=";
- }
- else
- {
- url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTransAndOutStockMny.cpt&__bypagesize__=false" + "&invoiceno=";
- }
- if ("120504".Equals(CustomInfo))
- {
- url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicketTH.cpt&__bypagesize__=false" + "&invoiceno=";
- }
- sqlCondition = sqlCondition.Substring(1, sqlCondition.Length - 1);
- sqlCondition = sqlCondition.Substring(0, sqlCondition.Length - 2);
- url = url + sqlCondition;
- Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel
- fBug = new Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel(this.ob, url);
- fBug.AutoSize = true;
- fBug.Text = "打印结算单";
- fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
- fBug.WindowState = FormWindowState.Maximized;
- fBug.Show();
- }
- private void PrintInvoice()
- {
-
- string INVOICENO = "INVOICENO";
- string errMsg = "";
- List<string> list = new List<string>();
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- if (this.ultraGrid1.Rows.Count == 1)
- this.ultraGrid1.Rows[0].Selected = true;
- this.ultraGrid1.ActiveRow.Selected = true;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
- {
- list.Add(ugr.Cells[INVOICENO].Value.ToString());
- }
- DlgInvoicePrint print = null;
- print = new DlgInvoicePrint(this.ob);
-
- print.listInvoiceNo = list;
- print.ShowDialog();
- if (print.DialogResult == DialogResult.OK)
- {
- ArrayList listi = new ArrayList(list);
- this.slmBalanceInfo.UpdateInvoiceStatusToLocked(listi,
- CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
- }
- }
- private Boolean IsCanBeUpdateWithDifferentPerson(string user)
- {
-
- if (user == CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName())
- {
- return true;
- }
- else
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("只允许操作本人票据");
- return false;
- }
-
- }
- private void RollBackInvoiceNo()
- {
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow;
- if (ugr == null)
- return;
- if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON"].Value.ToString()))
- return;
- if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定回退结算单?") == DialogResult.No) return;
- string invoinceno = ugr.Cells[this.INVOICENO].Value.ToString();
- string errMsg = "";
- this.slmBalanceInfo.RollBaskInvoiceNo(invoinceno, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
- if (errMsg.Length == 0)
- {
- ugr.Delete(false);
- }
- this.ultraGrid1.UpdateData();
- }
- private void ClearGrid()
- {
- this.dsInvoiceSeq.Clear();
- this.dsInvoiceList.Clear();
- }
- private void Query()
- {
- ClearGrid();
- dsInvoice.Clear();
- dsInvoiceDetail = null;
- dsInvoiceDetail = this.slmBalanceInfo.GetInvoiceSlmBalaneInfoByDateAndStatus(this.dateTimePicker1.Value,
- this.dateTimePicker2.Value, CustomInfo);
- dsInvoiceDetail = base.GetDataSetByFilterDeptId(dsInvoiceDetail);
- dsInvoiceDetail = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "INVOICE_STS", "0");
- //if ("120504".Equals(CustomInfo))
- // dsInvoiceDetail = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "supply_unit", CustomInfo);
- // dsInvoiceDetail = base.GetDataSetByFilterDeptId(dsInvoiceDetail);
- DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(dsInvoiceDetail, new List<string>(GetGroupByName()),
- new List<string>(GetShowName()), new List<string>(GetStaticName()));
- Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoice, ds);
-
- SetTransMoneyAndOutStockMoney();
- QueryTransMny();
-
- }
- private void QueryTransMny()
- {
- string sql = GetSqlForInvoice(this.dateTimePicker1.Value,
- this.dateTimePicker2.Value);
- DataSet ds = base.ExecuteReader(sql);
-
- //DataSet ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoney(this.dateTimePicker1.Value,
- // this.dateTimePicker2.Value);
- if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
- return;
- // ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "INVOICE_STS", "0");
- if (this.dsInvoice == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
- {
- }
- else
- {
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- DataSet dstemp = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter
- (dsInvoice, "INVOICENO", dr["INVOICENO"].ToString());
- try
- {
- if (dstemp.Tables[0].Rows.Count > 0)
- {
- dr.Delete();
- }
- }
- catch
- {
- }
- }
- }
- ds.AcceptChanges();
- ds.Tables[0].TableName = this.dsInvoice.Tables[0].TableName;
- this.dsInvoice.Merge(ds, false, System.Data.MissingSchemaAction.Ignore);
- this.dsInvoice.AcceptChanges();
- // ClearGrid();
- }
- private string GetSqlForInvoice(System.DateTime dtbegin,System.DateTime dtEnd)
- {
- string sql = @"select sum(case
- when a.money_type = '出库费' then
- a.money
- else
- 0
- end) OUTSTOCKMNY,
- sum(case
- when a.money_type = '运费' then
- a.money
- else
- 0
- end) TRANSMNY,
- max(money_type) money_type,
- sum(nvl(a.weight, 0)) weight,
- a.buyercode,
- a.buyername,
- a.inceptcorpcode,
- a.fst_drawee_unit,
- a.forecorpcode forecorpname,
- a.forecorpname forecorpcode,
- a.invoiceno,
- MAX(A.REALINVOICENO) REALINVOICENO,
- max(a.invoice_id) INVOICEPERSON,
- max(a.invoicedate) invoicedate,
- b.customer_nm,
- b.sale_area_desc,min(a.INVOICE_STS) INVOICE_STS
- from slm_balance_transmoney a
- join slm_order_head b on a.ord_pk = b.ord_pk
- where a.status_cd = '2'
- and a.invoiceno is not null and INVOICE_STS = '0'
- {0}
- group by a.buyercode,
- a.buyername,
- a.inceptcorpcode,
- a.fst_drawee_unit,
- a.forecorpcode,
- a.forecorpname,
- a.invoiceno,
- b.customer_nm,
- b.sale_area_desc
- ";
- string sqlCondition = Util.ConverObject.ConvertDateTimeValueToDbLanguage("INVOICEDATE", dtbegin, dtEnd);
- sql = string.Format(sql,sqlCondition);
- return sql;
- }
- private string GetSqlForInvoiceIncludTax(System.DateTime dtbegin, System.DateTime dtEnd)
- {
- string sql = @"select sum(case
- when a.money_type = '出库费' then
- a.weight * (decode(a.trans_type, '铁运', 23, 10))
- else
- 0
- end) OUTSTOCKMNY,
- sum(case
- when a.money_type = '运费' then
- a.money
- else
- 0
- end) TRANSMNY,
- max(money_type) money_type,
- sum(nvl(a.weight, 0)) weight,
- a.buyercode,
- a.buyername,
- a.inceptcorpcode,
- a.fst_drawee_unit,
- a.forecorpcode forecorpname,
- a.forecorpname forecorpcode,
- a.invoiceno,
- MAX(A.REALINVOICENO) REALINVOICENO,
- max(a.invoice_id) INVOICEPERSON,
- max(a.invoicedate) invoicedate,
- b.customer_nm,
- b.sale_area_desc
- from slm_balance_transmoney a
- join slm_order_head b on a.ord_pk = b.ord_pk
- where a.status_cd = '2'
- and a.invoiceno is not null
- {0}
- group by a.buyercode,
- a.buyername,
- a.inceptcorpcode,
- a.fst_drawee_unit,
- a.forecorpcode,
- a.forecorpname,
- a.invoiceno,
- b.customer_nm,
- b.sale_area_desc
- ";
- string sqlCondition = Util.ConverObject.ConvertDateTimeValueToDbLanguage("INVOICEDATE", dtbegin, dtEnd);
- sql = string.Format(sql, sqlCondition);
- return sql;
- }
- private void SetTransMoneyAndOutStockMoney()
- {
- DataSet ds = null;
- ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoneyAndOutStockMoney(this.dateTimePicker1.Value,
- this.dateTimePicker2.Value);
- //ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoneyAndOutStockMoneyIncludeTax(this.dateTimePicker1.Value,
- // this.dateTimePicker2.Value);
- if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
- return;
- if (this.dsInvoice == null || this.dsInvoice.Tables.Count == 0 || this.dsInvoice.Tables[0].Rows.Count == 0)
- return;
- ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "INVOICE_STS", "0");
- foreach (DataRow dri in this.dsInvoice.Tables[0].Rows)
- {
- try
- {
- DataRow[] drs = ds.Tables[0].Select(string.Format(" invoiceno = '{0}' ", dri[this.INVOICENO].ToString()));
- if (drs == null || drs.Length == 0)
- continue;
- foreach (DataRow drd in drs)
- {
- if (drd["MONEY_TYPE"].ToString() == "运费")
- {
- dri["TRANSMNY"] = drd["MONEY"];
- }
- if (drd["MONEY_TYPE"].ToString() == "出库费")
- {
- dri["OUTSTOCKMNY"] = drd["MONEY"];
- }
- }
- }
- catch
- { }
- }
-
- this.dsInvoice.AcceptChanges();
- ClearGrid();
- }
- private void QuryGrid2(string invoiceNo)
- {
- DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceNo);
- DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(ds2,
- new List<string>(this.GetGrid2GroupByCol()),
- new List<string>(this.GetGrid2ShowCol()),
- new List<string>(this.GetGrid2StaticCol()));
- Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceSeq, ds);
- }
- private void QueryGrid3(String invoiceno, string invoiceno_seq)
- {
- DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceno);
- DataSet ds3 = Util.UtilDataSet.GetDataSetWithRowFilter(ds2, this.INVOICENO_SEQ, invoiceno_seq);
- Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceList, ds3);
- }
- private string[] GetGroupByName()
- {
- return new string[]
- {
- "INVOICENO",
- "BUYERCODE",
- "BUYERNAME",
- "FORECORPCODE",
- "CUSTOMER_NO",
- "SALE_AREA_NO",
-
- };
- }
- private string[] GetShowName()
- {
- return new string[]
- {
- // "REMARK" ,
- "REALINVOICENO",
- "REALINVOICENO_ORG",
- "SALE_AREA_DESC",
- "CUSTOMER_NM","ISINVOICENOLOCKED", "INVOICEPERSON",
- "INVOICEDATE","FORECORPCODE","SUPPLY_UNIT_DESC"
- };
- }
- private string[] GetStaticName()
- {
- return new string[]
- {
- "WEIGHT",
- "MONEY"
- };
- }
- private string[] GetGrid1DataStruct()
- {
- return new string[]
- {
- "INVOICENO",
- "REALINVOICENO",
- // "REALINVOICENO_DATE",
- "REALINVOICENO_ORG",
- "BUYERCODE",
- "BUYERNAME",
- "WEIGHT",
- "MONEY",
- "TRANSMNY",
- "OUTSTOCKMNY",
- // "TRANSMONEYQC",
- //"TRANSMONEYSY1",
- //"TRANSMONETRAIN",
- // "HOISTINGFEE",
- // "ORD_NO",
- // "REMARK",
- "CUSTOMER_NO",
- "CUSTOMER_NM",
- "SALE_AREA_NO",
- "SALE_AREA_DESC",
- "FORECORPCODE",
- "INVOICEPERSON",
- "INVOICEDATE",
- "SUPPLY_UNIT_DESC"
- // "ISINVOICENOLOCKED"
- }
- ;
- }
- private Hashtable GetColumnAndCaption()
- {
- return StaticData.TbColumnAndCaption.GetColumnAndCaption();
- Hashtable hs = new Hashtable();
- hs.Add("WEIGHT", "重量");
- hs.Add("INVOICENO", "结算单号");
- hs.Add("FORECORPCODE", "子公司");
- hs.Add("SHIPNO", "船号");
- hs.Add("TRANSMONEYQC", "汽运费");
- hs.Add("TRANSMONEYSY1", "船运费");
- hs.Add("TRANSMONETRAIN", "火运费");
- hs.Add("HOISTINGFEE", "吊装费");
- hs.Add("PLY", "厚/直径/壁厚");
- hs.Add("WIDTH", "宽/外径");
- hs.Add("ORD_NO", "合同号");
- hs.Add("BUYERNAME", "结算单位名称");
- hs.Add("BUYERCODE", "结算单位编码");
- hs.Add("STATIONCODE", "到站");
- hs.Add("TRANSMNY", "运费");
- hs.Add("OUTSTOCKMNY", "出库费");
- hs.Add("SUPPLY_UNIT_DESC", "制造商");
-
- return hs;
- }
- protected override Hashtable GetGridColumnLength()
- {
- return StaticData.TbColumnAndCaption.GetDataSetColumnLength();
- Hashtable hs = new Hashtable();
- hs.Add("SHIPNO", 80);
- hs.Add("SHIPPRICE", 70);
- hs.Add("TRANSMONEYQC", 80);
- hs.Add("TRANSMONEYSY1", 70);
- hs.Add("TRANSMONETRAIN", 70);
- hs.Add("HOISTINGFEE", 70);
- hs.Add(this.INVOICENO, 150);
- hs.Add(this.BUYERCODE, 150);
- return hs;
- }
- private string[] GetGrid5DataStruct()
- {
- return new string[]
- {
-
- "SUB_SEQ" ,
- "BUYERCODE" ,
- "BUYERNAME" ,
- "FORECORPCODE" ,
- "MONEY" ,
- "MONEY_TYPE" ,
- "MONEY_TYPE_DESC" ,
- "REMARK" ,
- "STATUS_CD" ,
- "INVOICENO" ,
- "CREATE_NAME" ,
- "CREATE_TIME" ,
- "AFFRIM_NAME" ,
- "AFFRIM_TIME" ,
- "CREATE_DEPT",
- "INVOICENO_DATE"
- }
- ;
- }
- private string[] GetGrid4DataStruct()
- {
- return new string[]
- {
-
- "MONEY" ,
- "MONEY_TYPE_DESC" ,
- "REMARK" ,
- // "INVOICENO" ,
- "INVOICENO_DATE"
- }
- ;
- }
- private string[] GetGrid2DataStruct()
- {
- return new string[]
- {
- "INVOICENO",
- "INVOICENO_SEQ",
- "SPETKEY",
- "STEELCODEKEY",
- "PRICE",
- "WEIGHT",
- "MONEY"
- }
- ;
- }
- private string[] GetGrid2GroupByCol()
- {
- return new string[] { "INVOICENO", "INVOICENO_SEQ" };
- }
- private string[] GetGrid2ShowCol()
- {
- return GetGrid2DataStruct();
- }
- private string[] GetGrid2StaticCol()
- {
- return new string[] { "WEIGHT",
- "MONEY" };
- }
- private string[] GetGrid3DataStruct()
- {
- return new string[]
- {
- "ORD_NO",
- "SPETKEY",
- "STEELCODEKEY",
- "QUANTITY",
- "WEIGHT",
- "MONEY"
- // "TRAINWAGON",
- // "SHIPNO",
- // "DOCKCODE",
- // "STATIONCODE",
-
- }
- ;
- }
-
- private string BUYERCODE = "BUYERCODE";
- private string ORD_NO = "ORD_NO";
- private string ORD_SEQ = "ORD_SEQ";
- private string ORD_LN_DLY = "ORD_LN_DLY";
- private string ASKPLAN_ID = "ASKPLAN_ID";
- private string ASKPLAN_ID_SEQ = "ASKPLAN_ID_SEQ";
- private string SPETKEY = "SPETKEY";
- private string STEELCODEKEY = "STEELCODEKEY";
- private string MONEY = "MONEY";
- private string WEIGHT = "WEIGHT";
- private string PRICE = "PRICE";
- private string BALANCESTATUS = "BALANCESTATUS";
- private string ADJUSTPRICEREASON = "ADJUSTPRICEREASON";
- private string INVOICENO = "INVOICENO";
- private string INVOICENO_SEQ = "INVOICENO_SEQ";
-
-
- private string BALANCESTATUS_INIT = "0";
- private string BALANCESTATUS_AFFRIM = "1";
- private string BALANCESTATUS_INVOINCE = "2";
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
-
- }
- private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
- {
- if (this.ultraGrid2.Rows.Count == 0)
- return;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- if (this.ultraGrid2.Rows.Count == 1)
- ugr = this.ultraGrid2.Rows[0];
- else
- ugr = this.ultraGrid2.ActiveRow;
- string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
- string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString();
- this.QueryGrid3(invoiceno, invoicenoseq);
- }
- private void button3_Click(object sender, EventArgs e)
- {
- this.PrintInvoice();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- FrmBalanceInvoceMgtOrg org = new FrmBalanceInvoceMgtOrg();
- org.ShowDialog();
- }
- private void ultraGrid1_AfterRowActivate_1(object sender, EventArgs e)
- {
- this.dsMnyCredit.Clear();
- this.dsCreditResult.Clear();
- if (this.ultraGrid1.Rows.Count == 0)
- return;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- if (this.ultraGrid1.Rows.Count == 1)
- ugr = this.ultraGrid1.Rows[0];
- else
- ugr = this.ultraGrid1.ActiveRow;
- string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
- this.QuryGrid2(invoiceno);
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string forecode = ugr.Cells["FORECORPCODE"].Value.ToString();
- QueryGridFine(buyercode, forecode);
- QueryGridFour(invoiceno);
- }
- private void ultraGrid2_AfterRowActivate_1(object sender, EventArgs e)
- {
- if (this.ultraGrid2.Rows.Count == 0)
- return;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
- if (this.ultraGrid2.Rows.Count == 1)
- ugr = this.ultraGrid2.Rows[0];
- else
- ugr = this.ultraGrid2.ActiveRow;
- string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
- string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString();
- this.QueryGrid3(invoiceno, invoicenoseq);
- }
- }
- }
|