| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689 |
- 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 Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIFrm
- {
- public partial class FrmReceiveAndDebtMgt : FrmFundBase
- {
- public FrmReceiveAndDebtMgt()
- {
- InitializeComponent();
- }
- private DataSet ds_Group = new DataSet();
- private DataSet ds_Gm = new DataSet();
- private DataSet ds_Proce = new DataSet();
- private DataSet ds_Adjust = new DataSet();
- private DataSet ds_P_Gm = new DataSet();
- private DataSet ds_P_Group = new DataSet();
- private DataSet ds_P_Ggm= new DataSet();
- FundBLL.ValueList.PubValueList PubValueList = null;
- Infragistics.Win.ValueList listBuyercode = null;
- private Infragistics.Win.ValueList GetStsList()
- {
- Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
- lit.ValueListItems.Add("0", "未结转");
- lit.ValueListItems.Add("1", "已经结转");
- return lit;
- }
- private Infragistics.Win.ValueList GetMonthList()
- {
- Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
- string mon = "";
- string val = "";
- for (int i = 0; i < 12; i++)
- {
- mon = System.DateTime.Now.AddMonths(i).ToString("yyyyMM");
- lit.ValueListItems.Add(mon,mon);
- }
- return lit;
- }
- private void InitDs()
- {
- ds_Group = base.GetDataSetByColumnName(this.GetDataStruct()
- ,null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_Gm = base.GetDataSetByColumnName(this.GetDataStruct()
- , null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_Proce = base.GetDataSetByColumnName(this.GetDataStruct()
- , null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_P_Gm = base.GetDataSetByColumnName(this.GetDataStruct()
- , base.GetNumberColumnHs(),
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_P_Group = base.GetDataSetByColumnName(this.GetDataStruct()
- , null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_P_Ggm = base.GetDataSetByColumnName(this.GetDataStruct()
- , null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ds_Adjust = base.GetDataSetByColumnName(this.GetDataStructAdj()
- , null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- ChangeAdjDsCaption();
- this.ultraGrid1.DataSource = ds_Group;
- this.ultraGrid2.DataSource = ds_Gm;
- this.ultraGrid3.DataSource = ds_Proce;
- this.ultraGrid4.DataSource = ds_P_Gm;
- this.ultraGrid5.DataSource = ds_Adjust;
-
-
- }
- private void ChangeAdjDsCaption()
- {
- try
- {
- ds_Adjust.Tables[0].Columns[PRE_MONEY].Caption = "金额(调整前)";
- ds_Adjust.Tables[0].Columns["MONEY"].Caption = "金额(调整后)";
- ds_Adjust.Tables[0].Columns["INOUTTIME"].Caption = "时间";
- }
- catch
- {
- }
-
- }
- private string[] HiddenColumns()
- {
- return new string[] { this.INVOICE_MONTH, this.INVOICE_ACCOUNT, "MONEY" };
- }
- private void HiddelColumn()
- {
- foreach (UltraGrid ugs in GetAllUltraGrid())
- {
- try
- {
- foreach (string s in HiddenColumns())
- ugs.DisplayLayout.Bands[0].Columns[s].Hidden = true;
- }
- catch
- { }
- }
- this.ultraGrid4.DisplayLayout.Bands[0].Columns[this.SECONDACCOUNT].Hidden = true;
- this.ultraGrid4.DisplayLayout.Bands[0].Columns[this.BUYERCODE].Hidden = true;
- }
- private UltraGrid[] GetAllUltraGrid()
- {
- return new UltraGrid[] { this.ultraGrid1, this.ultraGrid2, this.ultraGrid3, this.ultraGrid4};
- }
- private void InitGrid()
- {
- foreach (UltraGrid ugs in GetAllUltraGrid())
- {
- try
- {
- ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellActivation = Activation.AllowEdit;
- ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellAppearance.BackColor = base.GetEditColor();
- ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
- ugs.DisplayLayout.Bands[0].Columns[this.INMONEY].CellAppearance.BackColor = base.GetEditColor();
- ugs.DisplayLayout.Bands[0].Columns[this.INVOICE_MONEY].CellAppearance.BackColor = base.GetEditColor();
- ugs.DisplayLayout.Bands[0].Columns[this.INVOICE_STS].ValueList = GetStsList();
- }
- catch
- { }
- }
- }
- private void InitGridValue()
- {
- foreach (UltraGrid ugs in GetAllUltraGrid())
- {
-
- try
- {
- ugs.DisplayLayout.Bands[0].Columns[this.BUYERCODE].ValueList =
- PubValueList.GetCustomerInfo();
- }
- catch
- { }
-
- }
- try
- {
- this.ultraGrid5.DisplayLayout.Bands[0].Columns[this.BUYERCODE].ValueList =
- PubValueList.GetCustomerInfo();
- }
- catch
- { }
-
- }
- private void InitAllAccoutBook()
- {
- InitAllBool( this.dateTimePicker2.Value.ToString("yyyyMM"));
-
- }
- private void InitAllBool(string month)
- {
- string sql = @"
- declare
- v_invoimon varchar2(8) := '{0}';
- v_int integer := 0;
- begin
- for r_info in (select distinct a.sale_area_desc,
- a.stlmt_unit_no buyercode,
- a.sale_org_desc forecorpcode,
- fst_drawee_unit
- from slm_order_head a
- where a.sale_org_desc <> '国际贸易部'
- and a.sale_area_desc is not null
- and a.stlmt_unit_no is not null
- and fst_drawee_unit is not null) loop
-
- select count(1)
- into v_int
- from sel_fund_receive_account a
- where a.INVOICE_MONTH = v_invoimon
- and invoice_account = '集团公司'
-
- and balancesubject = r_info.forecorpcode
- and secondaccount = r_info.sale_area_desc
- and buyercode = r_info.buyercode;
- if (v_int = 0 and r_info.forecorpcode = '国内贸易部') then
- insert into sel_fund_receive_account
- (INVOICE_MONTH,
- invoice_account,
- balancesubject,
- secondaccount,
- buyercode)
- select v_invoimon,
- '集团公司',
- r_info.forecorpcode,
- r_info.sale_area_desc,
- r_info.buyercode
- from dual;
- end if;
-
-
- select count(1)
- into v_int
- from sel_fund_receive_account a
- where a.INVOICE_MONTH = v_invoimon
- and invoice_account = '制造公司'
- and balancesubject = r_info.forecorpcode
- and secondaccount = r_info.sale_area_desc
- and buyercode = r_info.buyercode;
- if (v_int = 0) then
- insert into sel_fund_receive_account
- (INVOICE_MONTH,
- invoice_account,
- balancesubject,
- secondaccount,
- buyercode)
- select v_invoimon,
- '制造公司',
- r_info.forecorpcode,
- r_info.sale_area_desc,
- r_info.buyercode
- from dual;
- end if;
-
- end loop;
- commit;
- end;
- ";
- sql = string.Format(sql,month);
- base.ExecuteNoReader(sql);
- }
- private void ChgGroupNextInvoiceAccount()
- {
- }
-
- private DataSet GetGmMoneyInOut(string balancesubject,string buyercode,string areacode,string inmonth)
- {
- DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
- new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
- string sqlConditon = string.Format(" and balancesubject = '{0}' ",balancesubject);
- sqlConditon += string.Format(" and secondaccount = '{0}' and money_deliver = '0' ", areacode);
- sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
- sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
- DataSet ds = GetMoneyInout(sqlConditon);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
- return dsDetail;
- }
- private DataSet GetGroupMoneyInOut(string balancesubject, string buyercode, string areacode, string inmonth)
- {
- DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
- new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
- string sqlConditon = string.Format(" and balancesubject = '{0}' ", balancesubject);
- sqlConditon += string.Format(" and secondaccount = '{0}' ", areacode);
- sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
- sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
- sqlConditon += " and money_deliver = '2' ";
- DataSet ds = GetMoneyInout(sqlConditon);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
- return dsDetail;
- }
- private DataSet GetProcMoneyInOut(string balancesubject, string buyercode, string areacode, string inmonth)
- {
- DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
- new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
- string sqlConditon = string.Format(" and balancesubject = '{0}' ", balancesubject);
- sqlConditon += string.Format(" and secondaccount = '{0}' ", areacode);
- sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
- sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
- sqlConditon += " and money_deliver = '1' ";
- DataSet ds = GetMoneyInout(sqlConditon);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
- return dsDetail;
- }
- private DataSet GetProcAllMoneyInOut(string balancesubject, string inmonth)
- {
- DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
- new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
- string sqlConditon = "";
- if (balancesubject == "钢贸")
- {
- sqlConditon = " and balancesubject = '钢贸公司' and money_deliver = '0' ";
- }
- else if (balancesubject == "国贸")
- {
- sqlConditon = " and balancesubject = '国际贸易部' and money_deliver = '0' ";
- }
- else if (balancesubject == "制造")
- {
- sqlConditon = " and balancesubject = '国内贸易部' and money_deliver = '1' ";
- }
- else if (balancesubject == "集团")
- {
- sqlConditon = " and balancesubject = '国内贸易部' and money_deliver = '2' ";
- }
- sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
- sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
- DataSet ds = GetMoneyInout(sqlConditon);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
- return dsDetail;
- }
- private DataSet GetGmInvoicePact(string month,string buyercode,string forecode,string salearea)
- {
- DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- DataSet dsData = GetGmInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (month,buyercode,forecode,salearea);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
- return ds;
- }
- private DataSet GetGroupInvoicePact(string month, string buyercode, string forecode, string salearea)
- {
- DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- DataSet dsData = GetGroupInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (month, buyercode, forecode, salearea);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
- return ds;
- }
- private DataSet GetProcInvoicePact(string month, string buyercode, string forecode, string salearea)
- {
- DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- DataSet dsData = GetProcInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (month, buyercode, forecode, salearea);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
- return ds;
- }
- private DataSet GetProcAllInvoicePact(string balancesubject, string inmonth)
- {
- DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
- base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
- string sql = GetQueryOrgInvoicePact();
- string sqlConditon = "";
- if (balancesubject == "钢贸")
- {
- sqlConditon = " and fst_drawee_unit = '120604' ";
- }
- else if (balancesubject == "国贸")
- {
- sqlConditon = " and fst_drawee_unit = '120605' ";
- }
- else if (balancesubject == "制造")
- {
- sqlConditon = " and fst_drawee_unit = '120606' ";
- }
- else if (balancesubject == "集团")
- {
- sqlConditon = " and fst_drawee_unit = '120603' ";
- }
- sqlConditon += string.Format(" and realinvoiceno_date_org <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
- sqlConditon += string.Format(" and realinvoiceno_date_org > to_date('{0}', 'yyyymm')", inmonth);
- sql = string.Format(sql, sqlConditon);
- DataSet dsData = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
- return ds;
- }
- private DataSet GetGmInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (string month,string buyercode,string forcode,string salearea)
- {
- string sql = GetQueryInvoicePact();
- string sqlCondition = "";
- sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
-
- sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
- sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
- sql = string.Format(sql,sqlCondition);
- DataSet ds = base.ExecuteReader(sql);
- return ds;
- }
- private DataSet GetGroupInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (string month, string buyercode, string forcode, string salearea)
- {
- string sql = GetQueryInvoicePact();
- string sqlCondition = "";
- sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
- sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
- sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
- sqlCondition += string.Format(" and fst_drawee_unit = '{0}' ", "120603");
- sql = string.Format(sql, sqlCondition);
- DataSet ds = base.ExecuteReader(sql);
- return ds;
- }
- private DataSet GetProcInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
- (string month, string buyercode, string forcode, string salearea)
- {
- string sql = GetQueryInvoicePact();
- string sqlCondition = "";
- sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
- sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
- sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
- sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
- sqlCondition += string.Format(" and fst_drawee_unit = '{0}' ", "120606");
- sql = string.Format(sql, sqlCondition);
- DataSet ds = base.ExecuteReader(sql);
- return ds;
- }
- private string GetQueryInvoicePact()
- {
- string sql = @" select a.ord_no pactno,
- sum(a.weight) weight,
- sum(a.money) money,
- min(a.buyername) buyername,
- min(a.sale_area_desc) sale_area_desc,
- min(b.basename) fst_drawee_unit
- from slm_balanceinfo a
- left join com_base_info b
- on a.fst_drawee_unit = b.basecode
- and b.sortcode = '1206'
- where a.balancestatus = '3'
- {0}
- and a.realinvoiceno is not null
- group by a.ord_no ";
- return sql;
- }
- private string GetQueryOrgInvoicePact()
- {
- string sql = @" select a.ord_no pactno,
- sum(a.weight) weight,
- sum(a.money_org) money,
- min(a.buyername) buyername,
- min(a.sale_area_desc) sale_area_desc,
- min(b.basename) fst_drawee_unit
- from slm_balanceinfo a
- left join com_base_info b
- on a.fst_drawee_unit = b.basecode
- and b.sortcode = '1206'
- where a.balancestatus_org = '3'
- {0}
- and a.realinvoiceno_org is not null
- group by a.ord_no ";
- return sql;
- }
- private DataSet GetMoneyInout(string sqlCondition)
- {
- string sql = " select * from sel_fund_cust_fundinout a where 1 = 1 and isvalid = '1' {0}";
- sql = string.Format(sql,sqlCondition);
- return base.ExecuteReader(sql);
- }
- private void FrmReceiveAndDebtMgt_Load(object sender, EventArgs e)
- {
- this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
- this.dateTimePicker2.CustomFormat = "yyyyMM";
- PubValueList = new Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.ValueList.PubValueList(this.ob);
- InitDs();
- HiddelColumn();
-
- InitGridValue();
-
- base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid2, ref this.ultraGrid3,ref this.ultraGrid4,ref this.ultraGrid5);
- InitGrid();
- InitAllAccoutBook();
- InitGmData();
- }
- private void InitGmData()
- {
- try
- {
- if (this.CustomInfo == "3")
- {
- for (int i = 0; i < this.ultraTabControl1.Tabs.Count; i++)
- {
- if (i == 1)
- {
- this.ultraTabControl1.Tabs[i].Visible = true;
- this.ultraTabControl1.Tabs[i].Selected = true;
- }
- else
- this.ultraTabControl1.Tabs[i].Visible = false;
- }
- }
- if (this.CustomInfo == "4")
- {
- for (int i = 0; i < this.ultraTabControl1.Tabs.Count; i++)
- {
- if (i == 1)
- {
- this.ultraTabControl1.Tabs[i].Visible = true;
-
- }
- else
- this.ultraTabControl1.Tabs[i].Visible = false;
- }
- this.ultraTabControl1.Tabs[4].Visible = true;
- }
- }
- catch
- { }
- }
- public override void Query()
- {
- QueryAll();
-
- }
- public override void Update()
- {
- UpdateAll();
- }
- public override void Export()
- {
- switch (ultraTabControl1.ActiveTab.Text)
- {
- case "集团对外":
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid1);
- break;
- case "钢贸对外":
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid2);
- break;
- case "制造对外":
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid3);
- break;
- case "制造对内":
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid4);
- break;
- default:
- Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid5);
- break;
- }
-
- }
- private void SelectAllRows( Infragistics.Win.UltraWinGrid.UltraGrid ugr )
- {
- if (ugr == null || ugr.Rows.Count == 0)
- return;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugs in ugr.Rows )
- {
- ugs.Selected = true;
- }
- }
- public override void Add()
- {
- if (Core.StlMes.Client.Sale.Util.MessageUtil.ShowYesNoAndTips("是否确认结转") == DialogResult.No)
- return;
-
- if (this.ultraTabControl1.SelectedTab.Index == 1)
- {
- SelectAllRows(this.ultraGrid2);
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 0)
- {
- SelectAllRows(this.ultraGrid1);
-
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 2)
- {
- SelectAllRows(this.ultraGrid3);
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 3)
- {
- SelectAllRows(this.ultraGrid4);
- }
- string errMsg = "";
- AddAll(GetUgrs(), out errMsg);
- if (errMsg.Length == 0)
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功");
- }
- else
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(errMsg);
- }
- QueryAll();
-
- }
- /// <summary>
- /// 结转期初,钢贸
- /// </summary>
- private void AddAll( List< Infragistics.Win.UltraWinGrid.UltraGridRow > list,out string errMsg)
- {
- errMsg = "";
- if (list == null || list.Count == 0)
- return;
- string actName = "";
- string montht = "";
- System.Collections.ArrayList listt = new System.Collections.ArrayList();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in list)
- {
-
- string premonth = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- DateTime dt = DateTime.ParseExact(premonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
- if (dt > System.DateTime.Now.AddDays(-System.DateTime.Now.Day))
- {
- errMsg = "当月不能结转";
- return;
- }
- montht = premonth;
- string month = dt.AddMonths(1).ToString("yyyyMM");
- string invoiceacct = ugr.Cells[this.INVOICE_ACCOUNT].Value.ToString();
- actName = invoiceacct;
- string balancesubject = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string secaccount = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- double premoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.PRE_MONEY].Value);
- double inmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.INMONEY].Value);
- double invmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.INVOICE_MONEY].Value);
- double lstmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.LST_MONEY].Value);
- listt.AddRange(GetSqlInserAndUpdateNextAccountBook(month, premonth, invoiceacct, balancesubject
- ,buyercode,secaccount,premoney,inmoney,invmoney,lstmoney));
- }
- if (actName == "集团公司")
- {
- listt.AddRange(GetUpdateGroupInvoice(montht));
- }
- if (actName == "钢贸公司")
- {
- listt.AddRange(GetUpdateGmInvoice(montht));
- }
- if (actName == "制造公司")
- {
- listt.AddRange(GetUpdateProcInvoice(montht));
- }
- base.ExecuteNoReader(listt);
-
- }
- private System.Collections.ArrayList GetUpdateGroupInvoice(string invoiceMonth)
- {
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
- and realinvoiceno is not null and fst_drawee_unit = '120603' ";
- sql = string.Format(sql,invoiceMonth);
-
- string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
- and realinvoiceno is not null and fst_drawee_unit = '120603' ";
- sqlT = string.Format(sqlT, invoiceMonth);
- list.Add(sql);
- list.Add(sqlT);
- return list;
-
- }
- private System.Collections.ArrayList GetUpdateGmInvoice(string invoiceMonth)
- {
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
- and realinvoiceno is not null and forecorpcode = '钢贸公司' ";
- sql = string.Format(sql, invoiceMonth);
- string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
- and realinvoiceno is not null and forecorpcode = '钢贸公司' ";
- sqlT = string.Format(sqlT, invoiceMonth);
- list.Add(sql);
- list.Add(sqlT);
- return list;
- }
- private System.Collections.ArrayList GetUpdateProcInvoice(string invoiceMonth)
- {
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
- and realinvoiceno is not null and fst_drawee_unit = '120606' ";
- sql = string.Format(sql, invoiceMonth);
- string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
- and realinvoiceno is not null and fst_drawee_unit = '120606' ";
- sqlT = string.Format(sqlT, invoiceMonth);
- list.Add(sql);
- list.Add(sqlT);
- return list;
- }
- private System.Collections.ArrayList GetSqlInserAndUpdateNextAccountBook(string month, string premonth, string invoiceacct, string balancesubject,
- string buyercode, string secaccount, double premoney, double inmoney, double invmoney, double lstmoney
- )
- {
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- string sql = @" begin insert into sel_fund_receive_account t
- (invoice_month,invoice_account,balancesubject,buyercode,secondaccount)
- select
- '{0}','{1}','{2}','{3}','{4}' from dual ; commit;exception when others then null; end
- ";
- string sqlUpdate = @" update sel_fund_receive_account set PRE_MONEY = {0}
- where invoice_account = '{1}' and invoice_month = '{2}' and balancesubject = '{3}'
- and buyercode = '{4}' and secondaccount = '{5}' and INVOICE_STS = '0' ";
- string sqlUpdatethisMonth = @" update sel_fund_receive_account set INMONEY = {0},INVOICE_MONEY = {1},
- LST_MONEY = {2}
- where invoice_account = '{3}' and invoice_month = '{4}' and balancesubject = '{5}'
- and buyercode = '{6}' and secondaccount = '{7}' and INVOICE_STS = '0' ";
- string sqlUpdateSts = @" update sel_fund_receive_account set INVOICE_STS = '1'
- where invoice_account = '{0}' and invoice_month = '{1}' and balancesubject = '{2}'
- and buyercode = '{3}' and secondaccount = '{4}' ";
- sql = string.Format(sql, month, invoiceacct, balancesubject, buyercode, secaccount);
- sqlUpdate = string.Format(sqlUpdate, lstmoney, invoiceacct, month, balancesubject,buyercode,secaccount);
- sqlUpdatethisMonth = string.Format(sqlUpdatethisMonth, inmoney, invmoney, lstmoney,
- invoiceacct, premonth, balancesubject, buyercode, secaccount
- );
- sqlUpdateSts = string.Format(sqlUpdateSts, invoiceacct, premonth, balancesubject, buyercode, secaccount);
- list.Add(sql);
- list.Add(sqlUpdate);
- list.Add(sqlUpdatethisMonth);
- list.Add(sqlUpdateSts);
- return list;
- }
- private void QueryAdjust()
- {
- string month = this.dateTimePicker2.Value.ToString("yyyyMM");
- string sql = @"select INVOICE_MONTH,
- INVOICE_ACCOUNT,
- BALANCESUBJECT,
- SECONDACCOUNT,
- BUYERCODE,
- PRE_MONEY,
- MONEY,
- UPDATE_PERSON,
- UPDATE_DATE INOUTTIME,
- REMARK from sel_fund_receive_adjust_detail a where 1 = 1
- and pre_money <> money {0} order by update_date desc ";
- string sqlCondition = string.Format(" and invoice_month = '{0}' ",month);
- sql = string.Format(sql,sqlCondition);
- DataSet ds = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Adjust, ds);
- }
- private void QueryAll()
- {
- if (this.ultraTabControl1.SelectedTab.Index == 1)
- {
- this.QueryGm();
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 0)
- {
- this.QueryGroup();
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 2)
- {
- this.QueryProce();
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 3)
- {
- this.QueryProceAll();
- }
- QueryAdjust();
-
- }
- private List<Infragistics.Win.UltraWinGrid.UltraGridRow> GetUgrs()
- {
- List<Infragistics.Win.UltraWinGrid.UltraGridRow> ugrs = new List<UltraGridRow>();
- if (this.ultraTabControl1.SelectedTab.Index == 1)
- {
- if (this.ultraGrid2.Rows.Count == 0)
- return ugrs;
- this.ultraGrid2.UpdateData();
- if (this.ultraGrid2.ActiveRow != null)
- this.ultraGrid2.ActiveRow.Selected = true;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid2.Selected.Rows)
- {
- ugrs.Add(ugr);
- }
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 0)
- {
- if (this.ultraGrid1.Rows.Count == 0)
- return ugrs;
- this.ultraGrid1.UpdateData();
- if (this.ultraGrid1.ActiveRow != null)
- this.ultraGrid1.ActiveRow.Selected = true;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
- {
- ugrs.Add(ugr);
- }
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 2)
- {
- if (this.ultraGrid3.Rows.Count == 0)
- return ugrs;
- this.ultraGrid3.UpdateData();
- if (this.ultraGrid3.ActiveRow != null)
- this.ultraGrid3.ActiveRow.Selected = true;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid3.Selected.Rows)
- {
- ugrs.Add(ugr);
- }
- }
- else if (this.ultraTabControl1.SelectedTab.Index == 3)
- {
- if (this.ultraGrid4.Rows.Count == 0)
- return ugrs;
- this.ultraGrid4.UpdateData();
- if (this.ultraGrid4.ActiveRow != null)
- this.ultraGrid4.ActiveRow.Selected = true;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid4.Selected.Rows)
- {
- ugrs.Add(ugr);
- }
- }
- return ugrs;
- }
- private void UpdateAll()
- {
- UpdatePremoney(GetUgrs());
- this.QueryAll();
- }
- private void UpdatePremoney(List<Infragistics.Win.UltraWinGrid.UltraGridRow> ugrs)
- {
- if (ugrs == null)
- return;
- if (ugrs.Count == 0)
- return;
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- System.Collections.ArrayList listTemp = new System.Collections.ArrayList();
- foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ugrs)
- {
- if (ugr.Cells[this.INVOICE_STS].Value.ToString() == "1")
- {
- Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("数据已经结转,不允许修改期初");
- return;
- }
- listTemp = GetUpdatePreMoney(
- Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble( ugr.Cells["MONEY"].Value),
- Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[PRE_MONEY].Value),
- CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(),
- ugr.Cells[this.INVOICE_MONTH].Value.ToString(),
- ugr.Cells[this.INVOICE_ACCOUNT].Value.ToString(),
- ugr.Cells[this.BALANCESUBJECT].Value.ToString(),
- ugr.Cells[this.SECONDACCOUNT].Value.ToString(),
- ugr.Cells[this.BUYERCODE].Value.ToString(),
- ""
- );
- list.AddRange(listTemp);
- }
- base.ExecuteNoReader(list);
- // this.QueryAll();
- }
-
- private void QueryGm()
- {
- string month = this.dateTimePicker2.Value.ToString("yyyyMM");
- string sql = GetGmSql(month);
- DataSet ds = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Gm, ds);
- }
- private void QueryGroup()
- {
- string month = this.dateTimePicker2.Value.ToString("yyyyMM");
- string sql = GetGroupSql(month);
- DataSet ds = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Group, ds);
- }
- private void QueryProce()
- {
- string month = this.dateTimePicker2.Value.ToString("yyyyMM");
- string sql = this.GetproceSql(month);
- DataSet ds = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Proce, ds);
- }
- private void QueryProceAll()
- {
- string month = this.dateTimePicker2.Value.ToString("yyyyMM");
- string sql = this.GetProceAllSql(month);
- DataSet ds = base.ExecuteReader(sql);
- Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_P_Gm, ds);
- }
- private System.Collections.ArrayList GetUpdatePreMoney(double primoney, double money, string person, string month,
- string account,string balancesubj,string secondaccount,string buyercode,string adjusitremark
- )
- {
- string sql = @" update SEL_FUND_RECEIVE_ACCOUNT
- set PRE_MONEY = {0} ,UPDATE_PERSON = '{1}',UPDATE_DATE = sysdate
- where INVOICE_MONTH = '{2}' and INVOICE_ACCOUNT = '{3}'
- and BALANCESUBJECT = '{4}' and SECONDACCOUNT = '{5}'
- and BUYERCODE = '{6}'
- ";
- string sqlInsert = @" insert into SEL_FUND_RECEIVE_ADJUST_DETAIL (
- INVOICE_MONTH ,
- INVOICE_ACCOUNT ,
- BALANCESUBJECT ,
- SECONDACCOUNT ,
- BUYERCODE ,
- PRE_MONEY ,
- MONEY ,
- UPDATE_PERSON ,
- UPDATE_DATE ,
- REMARK ) values (
- '{0}',
- '{1}',
- '{2}',
- '{3}',
- '{4}',
- {5},
- {6},
- '{7}',
- sysdate,
- '{8}' )";
- sql = string.Format(sql,money,person,month,account,balancesubj,secondaccount,buyercode);
- sqlInsert = string.Format(sqlInsert, month, account, balancesubj, secondaccount, buyercode
- , primoney, money, person, adjusitremark
- );
- System.Collections.ArrayList list = new System.Collections.ArrayList();
- list.Add(sql);
- list.Add(sqlInsert);
- return list;
- }
-
- private string[] GetDataStruct()
- {
- return new string[]
- {
- INVOICE_MONTH,
- INVOICE_ACCOUNT,
- BALANCESUBJECT,
- SECONDACCOUNT,
- BUYERCODE,
- PRE_MONEY,
- INMONEY,
- INVOICE_MONEY,
- LST_MONEY,
- // INVOICE_PERSON,
- // INVOICE_DATE,
- // UPDATE_PERSON,
- // UPDATE_DATE,
- INVOICE_STS,
- "MONEY",
- ORDERNO
- };
- }
- private string[] GetDataStructAdj()
- {
- return new string[]
- {
- INVOICE_MONTH,
- INVOICE_ACCOUNT,
- BALANCESUBJECT,
- SECONDACCOUNT,
- BUYERCODE,
- PRE_MONEY,
- "MONEY",
- "UPDATE_PERSON",
- "INOUTTIME"
-
-
- };
- }
- private string[] GetInvoiceStruct()
- {
- return new string[]
- {
- "PACTNO",
- "WEIGHT",
- "MONEY",
- "BUYERNAME",
- "SALE_AREA_DESC",
- "FST_DRAWEE_UNIT"
- };
- }
- public string[] GetTbColumn_SEL_FUND_CUST_FUNDINOUT()
- {
- return new string[]
- {
- "BUSISEQ",
- "BALANCESUBJECT",
- "SECONDACCOUNT",
- // "BUYERCODE",
- "INOUTMONEY",
- "INOUTTIME",
- "FUNDTYPE",
- "BILLNO",
- // "ISVALID",
- // "MONEY_DELIVER",
- // "PREBUYERCODE",
- "REMARK",
- "IMPORTOR",
- "IMPORTTIME",
- "AFFRIMPER",
- "AFFRIMDATE"
- };
- }
-
- private string INVOICE_MONTH = "INVOICE_MONTH";
- private string INVOICE_ACCOUNT = "INVOICE_ACCOUNT";
- private string BALANCESUBJECT = "BALANCESUBJECT";
- private string SECONDACCOUNT = "SECONDACCOUNT";
- private string BUYERCODE = "BUYERCODE";
- private string PRE_MONEY = "PRE_MONEY";
- private string INMONEY = "INMONEY";
- private string INVOICE_MONEY = "INVOICE_MONEY";
- private string LST_MONEY = "LST_MONEY";
- private string INVOICE_PERSON = "INVOICE_PERSON";
- private string INVOICE_DATE = "INVOICE_DATE";
- private string UPDATE_PERSON = "UPDATE_PERSON";
- private string UPDATE_DATE = "UPDATE_DATE";
- private string INVOICE_STS = "INVOICE_STS";
- private string ORDERNO = "ORDERNO";
- private string GetQuerySqlByMonthAndAccountBook(string month,string accountBook)
- {
- string sqlStr = " select * from SEL_FUND_RECEIVE_ACCOUNT a where 1 = 1 {0}";
- string sqlCondition = string.Format(" and INVOICE_MONTH = '{0}' ",month);
- sqlCondition += string.Format(" and INVOICE_ACCOUNT = '{0}' ", accountBook);
- sqlStr = string.Format(sqlStr, sqlCondition);
- return sqlStr;
-
- }
- private string GetGmSql(string month)
- {
- string sql = @"
- select b.balancesubject,
- b.buyercode,
- b.secondaccount,
- nvl(b.pre_money, 0) pre_money,
- nvl(b.pre_money, 0) money,
- b.INVOICE_ACCOUNT,
- nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
- nvl(invoice_money, f.money) INVOICE_MONEY,
- nvl(lst_money, nvl(b.pre_money, 0) - nvl(c.inoutmoney, 0) + nvl( f.money,0) ) LST_MONEY,
- b.invoice_person,
- b.invoice_date,
- b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS
- from SEL_FUND_RECEIVE_ACCOUNT b
- left join (select sum(fu.inoutmoney) inoutmoney,
- fu.balancesubject,
- fu.buyercode,
- fu.secondaccount
- from sel_fund_cust_fundinout fu
- where fu.isvalid = '1'
- and money_deliver = '0'
- and fu.inouttime > to_date('{0}', 'yyyymm')
- and fu.inouttime <=
- last_day(to_date('{0}', 'yyyymm')) + 1
- group by fu.balancesubject, fu.buyercode, fu.secondaccount) c on b.balancesubject =
- c.balancesubject
- and b.buyercode =
- c.buyercode
- and b.secondaccount =
- c.secondaccount
- left join (
- select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
- from (select sum(s.money) money,
- s.buyercode,
- s.sale_area_desc,
- s.forecorpcode
- from slm_balanceinfo s
- where s.balancestatus = '3'
- and s.realinvoiceno is not null
- and s.forecorpcode = '钢贸公司'
-
- and s.invoice_month = '{0}'
- group by s.buyercode, s.sale_area_desc, s.forecorpcode
- union all
- select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
- from slm_balance_transmoney b
- join slm_order_head c on b.ord_pk = c.ord_pk
- where 1 = 1
- and b.status_cd = '2'
- and b.tickettype = '应收'
- and b.invoice_month = '{0}'
- and b.realinvoiceno is not null
- and b.forecorpname = '钢贸公司'
-
- group by b.buyercode, c.sale_area_desc, b.forecorpname
- ) s group by
- s.buyercode, s.sale_area_desc,s.forecorpcode ) f on b.balancesubject =
- f.forecorpcode
- and b.buyercode =
- f.buyercode
- and b.secondaccount =
- f.sale_area_desc
- where 1 = 1
- and b.balancesubject = '钢贸公司'
- and b.invoice_account = '钢贸公司'
- and b.invoice_month = '{0}'
- ";
- sql = string.Format(sql,month);
- return sql;
- }
- private string GetGroupSql(string month)
- {
- string sql = @"
- select b.balancesubject,
- b.buyercode,
- b.secondaccount,
- nvl(b.pre_money, 0) pre_money,
- nvl(b.pre_money, 0) money,
- b.INVOICE_ACCOUNT,
- nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
- nvl(invoice_money, f.money) INVOICE_MONEY,
- nvl(lst_money, nvl(b.pre_money, 0) - nvl(c.inoutmoney, 0) + nvl( f.money,0) ) LST_MONEY,
- b.invoice_person,
- b.invoice_date,
- b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS
- from SEL_FUND_RECEIVE_ACCOUNT b
- left join (select sum(c.inoutmoney) inoutmoney,
- c.balancesubject,
- c. buyercode,
- c.secondaccount
- from (select sum(fu.inoutmoney) inoutmoney,
- fu.balancesubject,
- fu.buyercode buyercode,
- fu.secondaccount
- from sel_fund_cust_fundinout fu
- where fu.isvalid = '1'
- and fu.inouttime > to_date('{0}', 'yyyymm')
- and fu.money_deliver = '2'
- and fu.balancesubject = '国内贸易部'
- -- and fu.buyercode = '1010101184'
- -- and 1 = 2
- and fu.inouttime <=
- last_day(to_date('{0}', 'yyyymm')) + 1
- group by fu.balancesubject,
- fu.buyercode,
- fu.secondaccount
- union all
- select sum(fu.inoutmoney) inoutmoney,
- fu.balancesubject,
- fu.buyercode,
- fu.secondaccount
- from sel_fund_cust_fundinout fu
- where fu.isvalid = '1'
- and fu.inouttime > to_date('{0}', 'yyyymm')
- and fu.money_deliver = '2'
- and busiseq not like '%-1'
- and fu.balancesubject = '国内贸易部'
- and fu.inouttime <=
- last_day(to_date('{0}', 'yyyymm')) + 1
- group by fu.balancesubject,
- fu.buyercode,
- fu.secondaccount
-
- ) c
- group by c.balancesubject, c.buyercode, c.secondaccount) c on b.balancesubject =
- c.balancesubject
- and b.buyercode =
- c.buyercode
- and b.secondaccount =
- c.secondaccount
- left join ( select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
- from (select sum(s.money) money,
- s.buyercode,
- s.sale_area_desc,
- s.forecorpcode
- from slm_balanceinfo s
- where s.balancestatus = '3'
- and s.realinvoiceno is not null
- and s.fst_drawee_unit = '120603'
- and s.invoice_month = '{0}'
- group by s.buyercode, s.sale_area_desc, s.forecorpcode
- union all
- select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
- from slm_balance_transmoney b
- join slm_order_head c on b.ord_pk = c.ord_pk
- where 1 = 1
- and b.status_cd = '2'
- and b.tickettype = '应收'
- and b.realinvoiceno is not null
- and b.fst_drawee_unit = '120603'
- and b.invoice_month = '{0}'
- group by b.buyercode, c.sale_area_desc, b.forecorpname) s
- group by s.buyercode, s.sale_area_desc, s.forecorpcode ) f on b.balancesubject =
- f.forecorpcode
- and b.buyercode =
- f.buyercode
- and b.secondaccount =
- f.sale_area_desc
- where 1 = 1
- and b.invoice_account = '集团公司'
- and b.invoice_month = '{0}'
- ";
- sql = string.Format(sql, month);
- return sql;
- }
- private string GetproceSql(string month)
- {
- string sql = @"
- select b.balancesubject,
- b.buyercode,
- b.secondaccount,
- nvl(b.pre_money, 0) pre_money,
- nvl(b.pre_money, 0) money,
- b.INVOICE_ACCOUNT,
- nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
- nvl(invoice_money, f.money) INVOICE_MONEY,
- nvl(lst_money, nvl(b.pre_money, 0) - nvl(c.inoutmoney, 0) + nvl( f.money,0) ) LST_MONEY,
- b.invoice_person,
- b.invoice_date,
- b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS,c.orderno
- from SEL_FUND_RECEIVE_ACCOUNT b
- left join (select sum(c.inoutmoney) inoutmoney,
- c.balancesubject,
- c. buyercode,
- c.secondaccount,
- c.orderno
- from (select sum(fu.inoutmoney) inoutmoney,
- fu.balancesubject,
- fu.buyercode buyercode,
- fu.secondaccount,
- fu.orderno
- from sel_fund_cust_fundinout fu
- where fu.isvalid = '1'
- and fu.inouttime > to_date('{0}', 'yyyymm')
- and fu.money_deliver = '1'
- and fu.balancesubject = '国内贸易部'
- -- and fu.buyercode = '1010101184'
- -- and 1 = 2
- and fu.inouttime <=
- last_day(to_date('{0}', 'yyyymm')) + 1
- group by fu.balancesubject,
- fu.buyercode,
- fu.secondaccount,
- fu.orderno
-
- ) c
- group by c.balancesubject, c.buyercode, c.secondaccount,c.orderno) c on b.balancesubject =
- c.balancesubject
- and b.buyercode =
- c.buyercode
- and b.secondaccount =
- c.secondaccount
- left join ( select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
- from (select sum(s.money) money,
- s.buyercode,
- s.sale_area_desc,
- s.forecorpcode
- from slm_balanceinfo s
- where s.balancestatus = '3'
- and s.realinvoiceno is not null
- and s.fst_drawee_unit = '120606'
- and s.invoice_month = '{0}'
- group by s.buyercode, s.sale_area_desc, s.forecorpcode
- union all
- select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
- from slm_balance_transmoney b
- join slm_order_head c on b.ord_pk = c.ord_pk
- where 1 = 1
- and b.status_cd = '2'
- and b.tickettype = '应收'
- and b.realinvoiceno is not null
- and b.fst_drawee_unit = '120606'
- and b.invoice_month = '{0}'
- group by b.buyercode, c.sale_area_desc, b.forecorpname) s
- group by s.buyercode, s.sale_area_desc, s.forecorpcode ) f on b.balancesubject =
- f.forecorpcode
- and b.buyercode =
- f.buyercode
- and b.secondaccount =
- f.sale_area_desc
- where 1 = 1
- and b.invoice_account = '制造公司'
- and b.invoice_month = '{0}'
- ";
- sql = string.Format(sql, month);
- return sql;
- }
- private string GetProceAllSql(string month)
- {
- string sql = @"
- select a.invoice_month,
- a.invoice_account,
- a.balancesubject,
- a.secondaccount,
- a.buyercode,
- a.pre_money,
- INMONEY,
- invoice_money,
- a.invoice_sts,
- nvl(a.lst_money, nvl(pre_money,0) - nvl(INMONEY, 0) + nvl(invoice_money, 0)) lst_money
- from (
- select a.invoice_month,
- a.invoice_account,
- a.balancesubject,
- a.secondaccount,
- a.buyercode,
- a.pre_money,
- nvl(INMONEY,
- case
- when a.balancesubject = '钢贸' then
- gm
- when a.balancesubject = '国贸' then
- gmx
- when a.balancesubject = '集团' then
- groupm
- when a.balancesubject = '制造' then
- prc
- else
- 0
- end) INMONEY,
-
- nvl(a.invoice_money,
- case
- when a.balancesubject = '钢贸' then
- c.gmmoney1
- when a.balancesubject = '国贸' then
- c.gmxmoney
- when a.balancesubject = '集团' then
- c.groupm1
- when a.balancesubject = '制造' then
- c.procmoney
- else
- 0
- end) invoice_money, a.invoice_sts,
- a.lst_money
- from sel_fund_receive_account a
- left join (select sum(case
- when a.balancesubject = '钢贸公司' and
- a.money_deliver = '0' then
- a.inoutmoney
- else
- 0
- end) gm,
- sum(case
- when a.balancesubject = '国贸公司' and
- a.money_deliver = '0' then
- a.inoutmoney
- else
- 0
- end) gmx,
- sum(case
- when a.balancesubject = '国内贸易部' and
- a.money_deliver = '1' then
- a.inoutmoney
- else
- 0
- end) prc,
- sum(case
- when a.balancesubject = '国内贸易部' and
- a.money_deliver = '2' then
- 0
- else
- 0
- end) groupm
- from sel_fund_cust_fundinout a
- where a.isvalid = '1' and inouttime > to_date('{0}', 'yyyymm') and inouttime <=
- last_day(to_date('{0}', 'yyyymm')) + 1 ) t on 1 = 1
- left join (select sum(case
- when fst_drawee_unit = '120603' then
- money
- else
- 0
- end) groupm1,
- sum(case
- when fst_drawee_unit = '120604' then
- money
- else
- 0
- end) gmmoney1,
- sum(case
- when fst_drawee_unit = '120605' then
- money
- else
- 0
- end) gmxmoney,
- sum(case
- when fst_drawee_unit = '120606' then
- money
- else
- 0
- end) procmoney
- from (select sum(s.money_org) money, fst_drawee_unit
- from slm_balanceinfo s
- where s.balancestatus_org = '3'
- and s.realinvoiceno_org is not null
-
- and s.invoice_month = '{0}'
- group by fst_drawee_unit
- union all
- select sum(b.money), b.fst_drawee_unit
- from slm_balance_transmoney b
- join slm_order_head c on b.ord_pk = c.ord_pk
- where 1 = 1
- and b.tickettype = '应收'
- and b.realinvoiceno_org is not null
- and b.invoice_month = '{0}'
- group by b.fst_drawee_unit)
-
-
- ) c on 1 = 1
- where a.invoice_month = '{0}'
- and a.invoice_account = '制造全' ) a
- ";
- sql = string.Format(sql,month);
- return sql;
- }
- private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
- {
-
- }
- private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
- {
-
- }
- private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)
- {
- }
- private void ultraGrid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
- {
- if (e.Cell.Column.Key == INVOICE_MONEY)
- {
- return;
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetGroupInvoicePact(month, buyercode, fore, salearea);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "合同查询";
- bankfrm.ShowDialog();
- }
- if (e.Cell.Column.Key == this.INMONEY)
- {
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetGroupMoneyInOut(fore, buyercode, salearea, month);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "进出款查询";
- bankfrm.ShowDialog();
- }
-
- }
- private void ultraGrid2_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
- {
- if (e.Cell.Column.Key == INVOICE_MONEY)
- {
- return;
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetGmInvoicePact(month, buyercode, fore, salearea);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "合同查询";
- bankfrm.ShowDialog();
- }
- if (e.Cell.Column.Key == this.INMONEY)
- {
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetGmMoneyInOut(fore, buyercode, salearea, month);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "进出款查询";
- bankfrm.ShowDialog();
- }
- }
- private void ultraGrid3_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
- {
-
- if (e.Cell.Column.Key == INVOICE_MONEY)
- {
- return;
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetProcInvoicePact(month, buyercode, fore, salearea);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "合同查询";
- bankfrm.ShowDialog();
- }
- if (e.Cell.Column.Key == this.INMONEY)
- {
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetProcMoneyInOut(fore, buyercode, salearea, month);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "进出款查询";
- bankfrm.ShowDialog();
- }
- }
- private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
- {
-
- }
- private void ultraGrid4_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
- {
- if (e.Cell.Column.Key == INVOICE_MONEY)
- {
- return;
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- DataSet ds = this.GetProcAllInvoicePact(fore, month);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "合同查询";
- bankfrm.ShowDialog();
- }
- if (e.Cell.Column.Key == this.INMONEY)
- {
- UltraGridRow ugr = e.Cell.Row;
- string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
- string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
- string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
- string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
- if (fore == "集团")
- return;
- DataSet ds = this.GetProcAllMoneyInOut(fore, month);
- FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
- bankfrm._Ds = ds;
- bankfrm._FrmText = "进出款查询";
- bankfrm.ShowDialog();
- }
- }
- }
- }
|