FrmReceiveAndDebtMgtNew.cs 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Infragistics.Win.UltraWinGrid;
  10. using System.IO;
  11. using System.Collections;
  12. using CoreFS.CA06;
  13. using Core.Mes.Client.Comm.Tool;
  14. namespace Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIFrm
  15. {
  16. public partial class FrmReceiveAndDebtMgtNew : FrmFundBase
  17. {
  18. public FrmReceiveAndDebtMgtNew()
  19. {
  20. InitializeComponent();
  21. }
  22. private DataSet ds_Group = new DataSet();
  23. private DataSet ds_Gm = new DataSet();
  24. private DataSet ds_Proce = new DataSet();
  25. private DataSet ds_Adjust = new DataSet();
  26. private DataSet ds_P_Gm = new DataSet();
  27. private DataSet ds_P_Group = new DataSet();
  28. private DataSet ds_P_Ggm= new DataSet();
  29. FundBLL.ValueList.PubValueList PubValueList = null;
  30. Infragistics.Win.ValueList listBuyercode = null;
  31. private Infragistics.Win.ValueList GetStsList()
  32. {
  33. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  34. lit.ValueListItems.Add("0", "未结转");
  35. lit.ValueListItems.Add("1", "已经结转");
  36. return lit;
  37. }
  38. private Infragistics.Win.ValueList GetMonthList()
  39. {
  40. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  41. string mon = "";
  42. string val = "";
  43. for (int i = 0; i < 12; i++)
  44. {
  45. mon = System.DateTime.Now.AddMonths(i).ToString("yyyyMM");
  46. lit.ValueListItems.Add(mon,mon);
  47. }
  48. return lit;
  49. }
  50. private void InitDs()
  51. {
  52. ds_Group = base.GetDataSetByColumnName(this.GetDataStruct()
  53. ,null,
  54. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  55. ds_Gm = base.GetDataSetByColumnName(this.GetDataStruct()
  56. , null,
  57. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  58. ds_Adjust = base.GetDataSetByColumnName(this.GetDataStructAdj()
  59. , null,
  60. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  61. ChangeAdjDsCaption();
  62. this.ultraGrid1.DataSource = ds_Group;
  63. this.ultraGrid2.DataSource = ds_Gm;
  64. this.ultraGrid5.DataSource = ds_Adjust;
  65. }
  66. private void ChangeAdjDsCaption()
  67. {
  68. try
  69. {
  70. ds_Adjust.Tables[0].Columns[PRE_MONEY].Caption = "金额(调整前)";
  71. ds_Adjust.Tables[0].Columns["MONEY"].Caption = "金额(调整后)";
  72. ds_Adjust.Tables[0].Columns["INOUTTIME"].Caption = "时间";
  73. }
  74. catch
  75. {
  76. }
  77. }
  78. private string[] HiddenColumns()
  79. {
  80. return new string[] { this.INVOICE_MONTH, this.INVOICE_ACCOUNT, "MONEY" };
  81. }
  82. private UltraGrid[] GetAllUltraGrid()
  83. {
  84. return new UltraGrid[] { this.ultraGrid1, this.ultraGrid2};
  85. }
  86. private void InitGrid()
  87. {
  88. foreach (UltraGrid ugs in GetAllUltraGrid())
  89. {
  90. try
  91. {
  92. ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellActivation = Activation.AllowEdit;
  93. ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellAppearance.BackColor = base.GetEditColor();
  94. ugs.DisplayLayout.Bands[0].Columns[this.PRE_MONEY].CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
  95. ugs.DisplayLayout.Bands[0].Columns[this.INMONEY].CellAppearance.BackColor = base.GetEditColor();
  96. ugs.DisplayLayout.Bands[0].Columns[this.INVOICE_MONEY].CellAppearance.BackColor = base.GetEditColor();
  97. ugs.DisplayLayout.Bands[0].Columns[this.INVOICE_STS].ValueList = GetStsList();
  98. }
  99. catch
  100. { }
  101. }
  102. }
  103. private void InitGridValue()
  104. {
  105. foreach (UltraGrid ugs in GetAllUltraGrid())
  106. {
  107. try
  108. {
  109. ugs.DisplayLayout.Bands[0].Columns[this.BUYERCODE].ValueList =
  110. PubValueList.GetCustomerInfo();
  111. }
  112. catch
  113. { }
  114. }
  115. try
  116. {
  117. this.ultraGrid5.DisplayLayout.Bands[0].Columns[this.BUYERCODE].ValueList =
  118. PubValueList.GetCustomerInfo();
  119. }
  120. catch
  121. { }
  122. }
  123. private void InitAllAccoutBook()
  124. {
  125. InitAllBool( this.dateTimePicker2.Value.ToString("yyyyMM"));
  126. }
  127. private void InitAllBool(string month)
  128. {
  129. string sql = @"
  130. declare
  131. v_invoimon varchar2(8) := '{0}';
  132. v_int integer := 0;
  133. begin
  134. for r_info in (select distinct a.sale_area_desc,
  135. a.stlmt_unit_no buyercode,
  136. a.sale_org_desc forecorpcode,
  137. fst_drawee_unit
  138. from slm_order_head a
  139. where a.sale_area_desc is not null
  140. and a.stlmt_unit_no is not null
  141. and fst_drawee_unit is not null) loop
  142. select count(1)
  143. into v_int
  144. from sel_fund_receive_account a
  145. where a.INVOICE_MONTH = v_invoimon
  146. and invoice_account = '国内贸易部'
  147. and balancesubject = r_info.forecorpcode
  148. and secondaccount = r_info.sale_area_desc
  149. and buyercode = r_info.buyercode;
  150. if (v_int = 0 and r_info.forecorpcode = '国内贸易部') then
  151. insert into sel_fund_receive_account
  152. (INVOICE_MONTH,
  153. invoice_account,
  154. balancesubject,
  155. secondaccount,
  156. buyercode)
  157. select v_invoimon,
  158. '国内贸易部',
  159. r_info.forecorpcode,
  160. r_info.sale_area_desc,
  161. r_info.buyercode
  162. from dual;
  163. end if;
  164. select count(1)
  165. into v_int
  166. from sel_fund_receive_account a
  167. where a.INVOICE_MONTH = v_invoimon
  168. and invoice_account = '国际贸易部'
  169. and balancesubject = r_info.forecorpcode
  170. and secondaccount = r_info.sale_area_desc
  171. and buyercode = r_info.buyercode;
  172. if (v_int = 0 and r_info.forecorpcode = '国际贸易部') then
  173. insert into sel_fund_receive_account
  174. (INVOICE_MONTH,
  175. invoice_account,
  176. balancesubject,
  177. secondaccount,
  178. buyercode)
  179. select v_invoimon,
  180. '国际贸易部',
  181. r_info.forecorpcode,
  182. r_info.sale_area_desc,
  183. r_info.buyercode
  184. from dual;
  185. end if;
  186. end loop;
  187. commit;
  188. end;
  189. ";
  190. sql = string.Format(sql,month);
  191. base.ExecuteNoReader(sql);
  192. }
  193. private void ChgGroupNextInvoiceAccount()
  194. {
  195. }
  196. private DataSet GetGmMoneyInOut(string balancesubject,string buyercode,string areacode,string inmonth)
  197. {
  198. DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
  199. new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
  200. string sqlConditon = string.Format(" and balancesubject = '{0}' ",balancesubject);
  201. sqlConditon += string.Format(" and secondaccount = '{0}' and money_deliver = '0' ", areacode);
  202. sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
  203. sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
  204. sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
  205. DataSet ds = GetMoneyInout(sqlConditon);
  206. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
  207. return dsDetail;
  208. }
  209. private DataSet GetGroupMoneyInOut(string balancesubject, string buyercode, string areacode, string inmonth)
  210. {
  211. DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
  212. new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
  213. string sqlConditon = string.Format(" and balancesubject = '{0}' ", balancesubject);
  214. sqlConditon += string.Format(" and secondaccount = '{0}' ", areacode);
  215. sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
  216. sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
  217. sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
  218. sqlConditon += " and money_deliver = '2' ";
  219. DataSet ds = GetMoneyInout(sqlConditon);
  220. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
  221. return dsDetail;
  222. }
  223. private DataSet GetProcMoneyInOut(string balancesubject, string buyercode, string areacode, string inmonth)
  224. {
  225. DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
  226. new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
  227. string sqlConditon = string.Format(" and balancesubject = '{0}' ", balancesubject);
  228. sqlConditon += string.Format(" and secondaccount = '{0}' ", areacode);
  229. sqlConditon += string.Format(" and buyercode = '{0}' ", buyercode);
  230. sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
  231. sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
  232. sqlConditon += " and money_deliver = '1' ";
  233. DataSet ds = GetMoneyInout(sqlConditon);
  234. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
  235. return dsDetail;
  236. }
  237. private DataSet GetProcAllMoneyInOut(string balancesubject, string inmonth)
  238. {
  239. DataSet dsDetail = base.GetDataSetByColumnName(GetTbColumn_SEL_FUND_CUST_FUNDINOUT(),
  240. new System.Collections.Hashtable(), base.GetFundColumnNameAndCaption());
  241. string sqlConditon = "";
  242. if (balancesubject == "钢贸")
  243. {
  244. sqlConditon = " and balancesubject = '钢贸公司' and money_deliver = '0' ";
  245. }
  246. else if (balancesubject == "国贸")
  247. {
  248. sqlConditon = " and balancesubject = '国际贸易部' and money_deliver = '0' ";
  249. }
  250. else if (balancesubject == "制造")
  251. {
  252. sqlConditon = " and balancesubject = '国内贸易部' and money_deliver = '1' ";
  253. }
  254. else if (balancesubject == "集团")
  255. {
  256. sqlConditon = " and balancesubject = '国内贸易部' and money_deliver = '2' ";
  257. }
  258. sqlConditon += string.Format(" and inouttime > to_date('{0}', 'yyyymm')", inmonth);
  259. sqlConditon += string.Format(" and inouttime <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
  260. DataSet ds = GetMoneyInout(sqlConditon);
  261. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref dsDetail, ds);
  262. return dsDetail;
  263. }
  264. private DataSet GetGmInvoicePact(string month,string buyercode,string forecode,string salearea)
  265. {
  266. DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
  267. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  268. DataSet dsData = GetGmInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  269. (month,buyercode,forecode,salearea);
  270. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
  271. return ds;
  272. }
  273. private DataSet GetGroupInvoicePact(string month, string buyercode, string forecode, string salearea)
  274. {
  275. DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
  276. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  277. DataSet dsData = GetGroupInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  278. (month, buyercode, forecode, salearea);
  279. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
  280. return ds;
  281. }
  282. private DataSet GetProcInvoicePact(string month, string buyercode, string forecode, string salearea)
  283. {
  284. DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
  285. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  286. DataSet dsData = GetProcInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  287. (month, buyercode, forecode, salearea);
  288. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
  289. return ds;
  290. }
  291. private DataSet GetProcAllInvoicePact(string balancesubject, string inmonth)
  292. {
  293. DataSet ds = base.GetDataSetByColumnName(this.GetInvoiceStruct(), null,
  294. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  295. string sql = GetQueryOrgInvoicePact();
  296. string sqlConditon = "";
  297. if (balancesubject == "钢贸")
  298. {
  299. sqlConditon = " and fst_drawee_unit = '120604' ";
  300. }
  301. else if (balancesubject == "国贸")
  302. {
  303. sqlConditon = " and fst_drawee_unit = '120605' ";
  304. }
  305. else if (balancesubject == "制造")
  306. {
  307. sqlConditon = " and fst_drawee_unit = '120606' ";
  308. }
  309. else if (balancesubject == "集团")
  310. {
  311. sqlConditon = " and fst_drawee_unit = '120603' ";
  312. }
  313. sqlConditon += string.Format(" and realinvoiceno_date_org <= last_day(to_date('{0}', 'yyyymm')) + 1", inmonth);
  314. sqlConditon += string.Format(" and realinvoiceno_date_org > to_date('{0}', 'yyyymm')", inmonth);
  315. sql = string.Format(sql, sqlConditon);
  316. DataSet dsData = base.ExecuteReader(sql);
  317. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref ds, dsData);
  318. return ds;
  319. }
  320. private DataSet GetGmInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  321. (string month,string buyercode,string forcode,string salearea)
  322. {
  323. string sql = GetQueryInvoicePact();
  324. string sqlCondition = "";
  325. sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
  326. sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
  327. sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
  328. sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
  329. sql = string.Format(sql,sqlCondition);
  330. DataSet ds = base.ExecuteReader(sql);
  331. return ds;
  332. }
  333. private DataSet GetGroupInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  334. (string month, string buyercode, string forcode, string salearea)
  335. {
  336. string sql = GetQueryInvoicePact();
  337. string sqlCondition = "";
  338. sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
  339. sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
  340. sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
  341. sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
  342. sqlCondition += string.Format(" and fst_drawee_unit = '{0}' ", "120603");
  343. sql = string.Format(sql, sqlCondition);
  344. DataSet ds = base.ExecuteReader(sql);
  345. return ds;
  346. }
  347. private DataSet GetProcInvoicePactByInvoiceMonthAndBuyercodeAndSaleAreaAndForeCode
  348. (string month, string buyercode, string forcode, string salearea)
  349. {
  350. string sql = GetQueryInvoicePact();
  351. string sqlCondition = "";
  352. sqlCondition += string.Format(" and invoice_month = '{0}' ", month);
  353. sqlCondition += string.Format(" and buyercode = '{0}' ", buyercode);
  354. sqlCondition += string.Format(" and forecorpcode = '{0}' ", forcode);
  355. sqlCondition += string.Format(" and sale_area_desc = '{0}' ", salearea);
  356. sqlCondition += string.Format(" and fst_drawee_unit = '{0}' ", "120606");
  357. sql = string.Format(sql, sqlCondition);
  358. DataSet ds = base.ExecuteReader(sql);
  359. return ds;
  360. }
  361. private string GetQueryInvoicePact()
  362. {
  363. string sql = @" select a.ord_no pactno,
  364. sum(a.weight) weight,
  365. sum(a.money) money,
  366. min(a.buyername) buyername,
  367. min(a.sale_area_desc) sale_area_desc,
  368. min(b.basename) fst_drawee_unit
  369. from slm_balanceinfo a
  370. left join com_base_info b
  371. on a.fst_drawee_unit = b.basecode
  372. and b.sortcode = '1206'
  373. where a.balancestatus = '3'
  374. {0}
  375. and a.realinvoiceno is not null
  376. group by a.ord_no ";
  377. return sql;
  378. }
  379. private string GetQueryOrgInvoicePact()
  380. {
  381. string sql = @" select a.ord_no pactno,
  382. sum(a.weight) weight,
  383. sum(a.money_org) money,
  384. min(a.buyername) buyername,
  385. min(a.sale_area_desc) sale_area_desc,
  386. min(b.basename) fst_drawee_unit
  387. from slm_balanceinfo a
  388. left join com_base_info b
  389. on a.fst_drawee_unit = b.basecode
  390. and b.sortcode = '1206'
  391. where a.balancestatus_org = '3'
  392. {0}
  393. and a.realinvoiceno_org is not null
  394. group by a.ord_no ";
  395. return sql;
  396. }
  397. private DataSet GetMoneyInout(string sqlCondition)
  398. {
  399. string sql = " select * from sel_fund_cust_fundinout a where 1 = 1 and isvalid = '1' {0}";
  400. sql = string.Format(sql,sqlCondition);
  401. return base.ExecuteReader(sql);
  402. }
  403. private void FrmReceiveAndDebtMgt_Load(object sender, EventArgs e)
  404. {
  405. this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
  406. this.dateTimePicker2.CustomFormat = "yyyyMM";
  407. if (this.dateTimePicker2.Value.Day >= 26)
  408. {
  409. this.dateTimePicker2.Value = this.dateTimePicker2.Value.AddMonths(1);
  410. }
  411. PubValueList = new Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.ValueList.PubValueList(this.ob);
  412. InitDs();
  413. InitGridValue();
  414. base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid2,ref this.ultraGrid5);
  415. InitGrid();
  416. InitAllAccoutBook();
  417. InitGmData();
  418. }
  419. private void InitGmData()
  420. {
  421. try
  422. {
  423. if (this.CustomInfo == "3")
  424. {
  425. for (int i = 0; i < this.ultraTabControl1.Tabs.Count; i++)
  426. {
  427. if (i == 1)
  428. {
  429. this.ultraTabControl1.Tabs[i].Visible = true;
  430. this.ultraTabControl1.Tabs[i].Selected = true;
  431. }
  432. else
  433. this.ultraTabControl1.Tabs[i].Visible = false;
  434. }
  435. }
  436. if (this.CustomInfo == "4")
  437. {
  438. for (int i = 0; i < this.ultraTabControl1.Tabs.Count; i++)
  439. {
  440. if (i == 1)
  441. {
  442. this.ultraTabControl1.Tabs[i].Visible = true;
  443. }
  444. else
  445. this.ultraTabControl1.Tabs[i].Visible = false;
  446. }
  447. this.ultraTabControl1.Tabs[4].Visible = true;
  448. }
  449. }
  450. catch
  451. { }
  452. }
  453. public override void Query()
  454. {
  455. QueryAll();
  456. }
  457. public override void Update()
  458. {
  459. UpdateAll();
  460. }
  461. public override void ImportTemplate()
  462. {
  463. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("导入模板", this.ultraGrid3);
  464. }
  465. public override void Import()
  466. {
  467. List<ArrayList> lists = null;
  468. var openFileDialog = new OpenFileDialog
  469. {
  470. Filter = "导入模板|*.xls;*.xlsx"
  471. };
  472. if (openFileDialog.ShowDialog() == DialogResult.OK)
  473. {
  474. lists = ReadExcelToPlnReqinfGpExcel(openFileDialog.FileName);
  475. }
  476. if (lists == null) return;
  477. if (lists.Count <= 0)
  478. {
  479. MessageBox.Show("Excel无数据");
  480. return;
  481. }
  482. System.Collections.ArrayList sqllist = new System.Collections.ArrayList();
  483. foreach (var list in lists)
  484. {
  485. string sql = @" UPDATE SEL_FUND_RECEIVE_ACCOUNT
  486. SET PRE_MONEY = '{0}'
  487. WHERE
  488. INVOICE_MONTH = '{1}'AND
  489. INVOICE_ACCOUNT = '{2}' AND
  490. BALANCESUBJECT = '{3}' AND
  491. SECONDACCOUNT = '{4}' AND
  492. BUYERCODE ='{5}' ";
  493. sql = string.Format(sql, list[6], list[0], list[1], list[2], list[3], list[4]);
  494. sqllist.Add(sql);
  495. }
  496. base.ExecuteNoReader(sqllist);
  497. this.QueryAll();
  498. }
  499. public List<ArrayList> ReadExcelToPlnReqinfGpExcel(string fileName)
  500. {
  501. //定义要返回的datatable对象
  502. List<ArrayList> plnReqinfGpExcels = new List<ArrayList>();
  503. try
  504. {
  505. if (!File.Exists(fileName))
  506. {
  507. return null;
  508. }
  509. //根据指定路径读取文件
  510. using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
  511. {
  512. //根据文件流创建excel数据结构
  513. NPOI.SS.UserModel.IWorkbook workbook = NPOI.SS.UserModel.WorkbookFactory.Create(fs);
  514. //IWorkbook workbook = new HSSFWorkbook(fs);
  515. for (int k = 0; k < workbook.NumberOfSheets; k++)
  516. {
  517. NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(k);
  518. if (sheet != null)
  519. {
  520. //最后一列的标号
  521. int rowCount = sheet.LastRowNum;
  522. for (int i = 1; i <= rowCount; ++i)
  523. {
  524. NPOI.SS.UserModel.IRow row = sheet.GetRow(i);
  525. if (row == null) continue; //没有数据的行默认是null    
  526. ArrayList arr = new ArrayList();
  527. arr.Add(row.Cells[0]);
  528. arr.Add(row.Cells[1]);
  529. arr.Add(row.Cells[2]);
  530. arr.Add(row.Cells[3]);
  531. arr.Add(row.Cells[4]);
  532. arr.Add(row.Cells[5]);
  533. arr.Add(row.Cells[6]);
  534. plnReqinfGpExcels.Add(arr);
  535. }
  536. }
  537. }
  538. }
  539. return plnReqinfGpExcels;
  540. }
  541. catch (Exception ex)
  542. {
  543. MessageBox.Show("EXCEL格式错误:" + ex.Message);
  544. return null;
  545. }
  546. }
  547. public override void Export()
  548. {
  549. switch (ultraTabControl1.ActiveTab.Text)
  550. {
  551. case "国内贸易部":
  552. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid1);
  553. break;
  554. case "国际贸易部":
  555. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid2);
  556. break;
  557. default:
  558. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel("账本信息", this.ultraGrid5);
  559. break;
  560. }
  561. }
  562. private void SelectAllRows( Infragistics.Win.UltraWinGrid.UltraGrid ugr )
  563. {
  564. if (ugr == null || ugr.Rows.Count == 0)
  565. return;
  566. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugs in ugr.Rows )
  567. {
  568. ugs.Selected = true;
  569. }
  570. }
  571. public override void Add()
  572. {
  573. if (Core.StlMes.Client.Sale.Util.MessageUtil.ShowYesNoAndTips("是否确认结转") == DialogResult.No)
  574. return;
  575. if (this.ultraTabControl1.SelectedTab.Index == 1)
  576. {
  577. SelectAllRows(this.ultraGrid2);
  578. }
  579. else if (this.ultraTabControl1.SelectedTab.Index == 0)
  580. {
  581. SelectAllRows(this.ultraGrid1);
  582. }
  583. string errMsg = "";
  584. AddAll(GetUgrs(), out errMsg);
  585. if (errMsg.Length == 0)
  586. {
  587. Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功");
  588. }
  589. else
  590. {
  591. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError(errMsg);
  592. }
  593. QueryAll();
  594. }
  595. /// <summary>
  596. /// 结转期初,钢贸
  597. /// </summary>
  598. private void AddAll( List< Infragistics.Win.UltraWinGrid.UltraGridRow > list,out string errMsg)
  599. {
  600. errMsg = "";
  601. if (list == null || list.Count == 0)
  602. return;
  603. string actName = "";
  604. string montht = "";
  605. System.Collections.ArrayList listt = new System.Collections.ArrayList();
  606. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in list)
  607. {
  608. string premonth = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  609. DateTime dt = DateTime.ParseExact(premonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
  610. if (dt > System.DateTime.Now.AddDays(-System.DateTime.Now.Day))
  611. {
  612. errMsg = "当月不能结转";
  613. return;
  614. }
  615. montht = premonth;
  616. string month = dt.AddMonths(1).ToString("yyyyMM");
  617. string invoiceacct = ugr.Cells[this.INVOICE_ACCOUNT].Value.ToString();
  618. actName = invoiceacct;
  619. string balancesubject = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  620. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  621. string secaccount = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  622. double premoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.PRE_MONEY].Value);
  623. double inmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.INMONEY].Value);
  624. double invmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.INVOICE_MONEY].Value);
  625. double lstmoney = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[this.LST_MONEY].Value);
  626. listt.AddRange(GetSqlInserAndUpdateNextAccountBook(month, premonth, invoiceacct, balancesubject
  627. ,buyercode,secaccount,premoney,inmoney,invmoney,lstmoney));
  628. }
  629. if (actName == "集团公司")
  630. {
  631. listt.AddRange(GetUpdateGroupInvoice(montht));
  632. }
  633. if (actName == "钢贸公司")
  634. {
  635. listt.AddRange(GetUpdateGmInvoice(montht));
  636. }
  637. if (actName == "制造公司")
  638. {
  639. listt.AddRange(GetUpdateProcInvoice(montht));
  640. }
  641. base.ExecuteNoReader(listt);
  642. }
  643. private System.Collections.ArrayList GetUpdateGroupInvoice(string invoiceMonth)
  644. {
  645. System.Collections.ArrayList list = new System.Collections.ArrayList();
  646. string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
  647. and realinvoiceno is not null and fst_drawee_unit = '120603' ";
  648. sql = string.Format(sql,invoiceMonth);
  649. string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
  650. and realinvoiceno is not null and fst_drawee_unit = '120603' ";
  651. sqlT = string.Format(sqlT, invoiceMonth);
  652. list.Add(sql);
  653. list.Add(sqlT);
  654. return list;
  655. }
  656. private System.Collections.ArrayList GetUpdateGmInvoice(string invoiceMonth)
  657. {
  658. System.Collections.ArrayList list = new System.Collections.ArrayList();
  659. string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
  660. and realinvoiceno is not null and forecorpcode = '钢贸公司' ";
  661. sql = string.Format(sql, invoiceMonth);
  662. string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
  663. and realinvoiceno is not null and forecorpcode = '钢贸公司' ";
  664. sqlT = string.Format(sqlT, invoiceMonth);
  665. list.Add(sql);
  666. list.Add(sqlT);
  667. return list;
  668. }
  669. private System.Collections.ArrayList GetUpdateProcInvoice(string invoiceMonth)
  670. {
  671. System.Collections.ArrayList list = new System.Collections.ArrayList();
  672. string sql = @" update Slm_Balanceinfo set invoice_sts = '1' where invoice_month = '{0}' and balancestatus = '3'
  673. and realinvoiceno is not null and fst_drawee_unit = '120606' ";
  674. sql = string.Format(sql, invoiceMonth);
  675. string sqlT = @" update Slm_Balance_Transmoney set invoice_sts = '1' where invoice_month = '{0}' and status_cd = '2'
  676. and realinvoiceno is not null and fst_drawee_unit = '120606' ";
  677. sqlT = string.Format(sqlT, invoiceMonth);
  678. list.Add(sql);
  679. list.Add(sqlT);
  680. return list;
  681. }
  682. private System.Collections.ArrayList GetSqlInserAndUpdateNextAccountBook(string month, string premonth, string invoiceacct, string balancesubject,
  683. string buyercode, string secaccount, double premoney, double inmoney, double invmoney, double lstmoney
  684. )
  685. {
  686. System.Collections.ArrayList list = new System.Collections.ArrayList();
  687. string sql = @" begin insert into sel_fund_receive_account t
  688. (invoice_month,invoice_account,balancesubject,buyercode,secondaccount)
  689. select
  690. '{0}','{1}','{2}','{3}','{4}' from dual ; commit;exception when others then null; end
  691. ";
  692. string sqlUpdate = @" update sel_fund_receive_account set PRE_MONEY = {0}
  693. where invoice_account = '{1}' and invoice_month = '{2}' and balancesubject = '{3}'
  694. and buyercode = '{4}' and secondaccount = '{5}' and INVOICE_STS = '0' ";
  695. string sqlUpdatethisMonth = @" update sel_fund_receive_account set INMONEY = {0},INVOICE_MONEY = {1},
  696. LST_MONEY = {2}
  697. where invoice_account = '{3}' and invoice_month = '{4}' and balancesubject = '{5}'
  698. and buyercode = '{6}' and secondaccount = '{7}' and INVOICE_STS = '0' ";
  699. string sqlUpdateSts = @" update sel_fund_receive_account set INVOICE_STS = '1'
  700. where invoice_account = '{0}' and invoice_month = '{1}' and balancesubject = '{2}'
  701. and buyercode = '{3}' and secondaccount = '{4}' ";
  702. sql = string.Format(sql, month, invoiceacct, balancesubject, buyercode, secaccount);
  703. sqlUpdate = string.Format(sqlUpdate, lstmoney, invoiceacct, month, balancesubject,buyercode,secaccount);
  704. sqlUpdatethisMonth = string.Format(sqlUpdatethisMonth, inmoney, invmoney, lstmoney,
  705. invoiceacct, premonth, balancesubject, buyercode, secaccount
  706. );
  707. sqlUpdateSts = string.Format(sqlUpdateSts, invoiceacct, premonth, balancesubject, buyercode, secaccount);
  708. list.Add(sql);
  709. list.Add(sqlUpdate);
  710. list.Add(sqlUpdatethisMonth);
  711. list.Add(sqlUpdateSts);
  712. return list;
  713. }
  714. private void QueryAdjust()
  715. {
  716. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  717. string sql = @"select INVOICE_MONTH,
  718. INVOICE_ACCOUNT,
  719. BALANCESUBJECT,
  720. SECONDACCOUNT,
  721. BUYERCODE,
  722. PRE_MONEY,
  723. MONEY,
  724. UPDATE_PERSON,
  725. UPDATE_DATE INOUTTIME,
  726. REMARK from sel_fund_receive_adjust_detail a where 1 = 1
  727. and pre_money <> money {0} order by update_date desc ";
  728. string sqlCondition = string.Format(" and invoice_month = '{0}' ",month);
  729. sql = string.Format(sql,sqlCondition);
  730. DataSet ds = base.ExecuteReader(sql);
  731. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Adjust, ds);
  732. }
  733. private void QueryAll()
  734. {
  735. if (this.ultraTabControl1.SelectedTab.Index == 1)
  736. {
  737. this.QueryGm();//国际贸易部
  738. }
  739. else if (this.ultraTabControl1.SelectedTab.Index == 0)
  740. {
  741. this.QueryGroup();//国内贸易部
  742. }
  743. QueryAdjust();
  744. }
  745. private List<Infragistics.Win.UltraWinGrid.UltraGridRow> GetUgrs()
  746. {
  747. List<Infragistics.Win.UltraWinGrid.UltraGridRow> ugrs = new List<UltraGridRow>();
  748. if (this.ultraTabControl1.SelectedTab.Index == 1)
  749. {
  750. if (this.ultraGrid2.Rows.Count == 0)
  751. return ugrs;
  752. this.ultraGrid2.UpdateData();
  753. if (this.ultraGrid2.ActiveRow != null)
  754. this.ultraGrid2.ActiveRow.Selected = true;
  755. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid2.Selected.Rows)
  756. {
  757. ugrs.Add(ugr);
  758. }
  759. }
  760. else if (this.ultraTabControl1.SelectedTab.Index == 0)
  761. {
  762. if (this.ultraGrid1.Rows.Count == 0)
  763. return ugrs;
  764. this.ultraGrid1.UpdateData();
  765. if (this.ultraGrid1.ActiveRow != null)
  766. this.ultraGrid1.ActiveRow.Selected = true;
  767. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  768. {
  769. ugrs.Add(ugr);
  770. }
  771. }
  772. return ugrs;
  773. }
  774. private void UpdateAll()
  775. {
  776. UpdatePremoney(GetUgrs());
  777. this.QueryAll();
  778. }
  779. private void UpdatePremoney(List<Infragistics.Win.UltraWinGrid.UltraGridRow> ugrs)
  780. {
  781. if (ugrs == null)
  782. return;
  783. if (ugrs.Count == 0)
  784. return;
  785. System.Collections.ArrayList list = new System.Collections.ArrayList();
  786. System.Collections.ArrayList listTemp = new System.Collections.ArrayList();
  787. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in ugrs)
  788. {
  789. if (ugr.Cells[this.INVOICE_STS].Value.ToString() == "1")
  790. {
  791. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("数据已经结转,不允许修改期初");
  792. return;
  793. }
  794. listTemp = GetUpdatePreMoney(
  795. Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble( ugr.Cells["MONEY"].Value),
  796. Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells[PRE_MONEY].Value),
  797. CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(),
  798. ugr.Cells[this.INVOICE_MONTH].Value.ToString(),
  799. ugr.Cells[this.INVOICE_ACCOUNT].Value.ToString(),
  800. ugr.Cells[this.BALANCESUBJECT].Value.ToString(),
  801. ugr.Cells[this.SECONDACCOUNT].Value.ToString(),
  802. ugr.Cells[this.BUYERCODE].Value.ToString(),
  803. ""
  804. );
  805. list.AddRange(listTemp);
  806. }
  807. base.ExecuteNoReader(list);
  808. // this.QueryAll();
  809. }
  810. //国际贸易部
  811. private void QueryGm()
  812. {
  813. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  814. string sql = GetGmSql(month);
  815. DataSet ds = base.ExecuteReader(sql);
  816. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Gm, ds);
  817. }
  818. //国内贸易部
  819. private void QueryGroup()
  820. {
  821. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  822. string sql = GetGroupSql(month);
  823. DataSet ds = base.ExecuteReader(sql);
  824. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Group, ds);
  825. }
  826. private void QueryProce()
  827. {
  828. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  829. string sql = this.GetproceSql(month);
  830. DataSet ds = base.ExecuteReader(sql);
  831. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_Proce, ds);
  832. }
  833. private void QueryProceAll()
  834. {
  835. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  836. string sql = this.GetProceAllSql(month);
  837. DataSet ds = base.ExecuteReader(sql);
  838. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.ds_P_Gm, ds);
  839. }
  840. private System.Collections.ArrayList GetUpdatePreMoney(double primoney, double money, string person, string month,
  841. string account,string balancesubj,string secondaccount,string buyercode,string adjusitremark
  842. )
  843. {
  844. string sql = @" update SEL_FUND_RECEIVE_ACCOUNT
  845. set PRE_MONEY = {0} ,UPDATE_PERSON = '{1}',UPDATE_DATE = sysdate
  846. where INVOICE_MONTH = '{2}' and INVOICE_ACCOUNT = '{3}'
  847. and BALANCESUBJECT = '{4}' and SECONDACCOUNT = '{5}'
  848. and BUYERCODE = '{6}'
  849. ";
  850. string sqlInsert = @" insert into SEL_FUND_RECEIVE_ADJUST_DETAIL (
  851. INVOICE_MONTH ,
  852. INVOICE_ACCOUNT ,
  853. BALANCESUBJECT ,
  854. SECONDACCOUNT ,
  855. BUYERCODE ,
  856. PRE_MONEY ,
  857. MONEY ,
  858. UPDATE_PERSON ,
  859. UPDATE_DATE ,
  860. REMARK ) values (
  861. '{0}',
  862. '{1}',
  863. '{2}',
  864. '{3}',
  865. '{4}',
  866. {5},
  867. {6},
  868. '{7}',
  869. sysdate,
  870. '{8}' )";
  871. sql = string.Format(sql,money,person,month,account,balancesubj,secondaccount,buyercode);
  872. sqlInsert = string.Format(sqlInsert, month, account, balancesubj, secondaccount, buyercode
  873. , primoney, money, person, adjusitremark
  874. );
  875. System.Collections.ArrayList list = new System.Collections.ArrayList();
  876. list.Add(sql);
  877. list.Add(sqlInsert);
  878. return list;
  879. }
  880. private string[] GetDataStruct()
  881. {
  882. return new string[]
  883. {
  884. INVOICE_MONTH,
  885. INVOICE_ACCOUNT,
  886. BALANCESUBJECT,
  887. SECONDACCOUNT,
  888. BUYERCODE,
  889. PRE_MONEY,
  890. INMONEY,
  891. INVOICE_MONEY,
  892. LST_MONEY,
  893. // INVOICE_PERSON,
  894. // INVOICE_DATE,
  895. // UPDATE_PERSON,
  896. // UPDATE_DATE,
  897. INVOICE_STS,
  898. "MONEY",
  899. "ACT_WEIGHT",
  900. "BALNCE_PRICE",
  901. "WEIGHT1",
  902. "MONEY1",
  903. "MONEY2"
  904. };
  905. }
  906. private string[] GetDataStructAdj()
  907. {
  908. return new string[]
  909. {
  910. INVOICE_MONTH,
  911. INVOICE_ACCOUNT,
  912. BALANCESUBJECT,
  913. SECONDACCOUNT,
  914. BUYERCODE,
  915. PRE_MONEY,
  916. "MONEY",
  917. "UPDATE_PERSON",
  918. "INOUTTIME"
  919. };
  920. }
  921. private string[] GetInvoiceStruct()
  922. {
  923. return new string[]
  924. {
  925. "PACTNO",
  926. "WEIGHT",
  927. "MONEY",
  928. "BUYERNAME",
  929. "SALE_AREA_DESC",
  930. "FST_DRAWEE_UNIT"
  931. };
  932. }
  933. public string[] GetTbColumn_SEL_FUND_CUST_FUNDINOUT()
  934. {
  935. return new string[]
  936. {
  937. "BUSISEQ",
  938. "BALANCESUBJECT",
  939. "SECONDACCOUNT",
  940. // "BUYERCODE",
  941. "INOUTMONEY",
  942. "INOUTTIME",
  943. "FUNDTYPE",
  944. "BILLNO",
  945. // "ISVALID",
  946. // "MONEY_DELIVER",
  947. // "PREBUYERCODE",
  948. "REMARK",
  949. "IMPORTOR",
  950. "IMPORTTIME",
  951. "AFFRIMPER",
  952. "AFFRIMDATE"
  953. };
  954. }
  955. private string INVOICE_MONTH = "INVOICE_MONTH";
  956. private string INVOICE_ACCOUNT = "INVOICE_ACCOUNT";
  957. private string BALANCESUBJECT = "BALANCESUBJECT";
  958. private string SECONDACCOUNT = "SECONDACCOUNT";
  959. private string BUYERCODE = "BUYERCODE";
  960. private string PRE_MONEY = "PRE_MONEY";
  961. private string INMONEY = "INMONEY";
  962. private string INVOICE_MONEY = "INVOICE_MONEY";
  963. private string LST_MONEY = "LST_MONEY";
  964. private string INVOICE_PERSON = "INVOICE_PERSON";
  965. private string INVOICE_DATE = "INVOICE_DATE";
  966. private string UPDATE_PERSON = "UPDATE_PERSON";
  967. private string UPDATE_DATE = "UPDATE_DATE";
  968. private string INVOICE_STS = "INVOICE_STS";
  969. private string GetQuerySqlByMonthAndAccountBook(string month,string accountBook)
  970. {
  971. string sqlStr = " select * from SEL_FUND_RECEIVE_ACCOUNT a where 1 = 1 {0}";
  972. string sqlCondition = string.Format(" and INVOICE_MONTH = '{0}' ",month);
  973. sqlCondition += string.Format(" and INVOICE_ACCOUNT = '{0}' ", accountBook);
  974. sqlStr = string.Format(sqlStr, sqlCondition);
  975. return sqlStr;
  976. }
  977. private string GetGmSql(string month)
  978. {
  979. string sql = @"
  980. select b.balancesubject,
  981. b.buyercode,
  982. b.secondaccount,
  983. nvl(b.pre_money, 0) pre_money,
  984. nvl(b.pre_money, 0) money,
  985. b.INVOICE_ACCOUNT,
  986. nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
  987. nvl(invoice_money, f.money) INVOICE_MONEY,
  988. nvl(lst_money, nvl(b.pre_money, 0) - nvl(c.inoutmoney, 0) + nvl( f.money,0) ) LST_MONEY,
  989. b.invoice_person,
  990. b.invoice_date,
  991. b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS
  992. from SEL_FUND_RECEIVE_ACCOUNT b
  993. left join (select sum(fu.inoutmoney) inoutmoney,
  994. fu.balancesubject,
  995. fu.buyercode,
  996. fu.secondaccount
  997. from sel_fund_cust_fundinout fu
  998. where fu.isvalid = '1'
  999. and fu.inouttime > to_date('{0}', 'yyyymm')
  1000. and fu.inouttime <=
  1001. last_day(to_date('{0}', 'yyyymm')) + 1
  1002. group by fu.balancesubject, fu.buyercode, fu.secondaccount) c on b.balancesubject =
  1003. c.balancesubject
  1004. and b.buyercode =
  1005. c.buyercode
  1006. and b.secondaccount =
  1007. c.secondaccount
  1008. left join (
  1009. select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
  1010. from (select sum(s.money) money,
  1011. s.buyercode,
  1012. s.sale_area_desc,
  1013. s.forecorpcode
  1014. from slm_balanceinfo s
  1015. where s.balancestatus = '3'
  1016. and s.realinvoiceno is not null
  1017. and s.forecorpcode = '国际贸易部'
  1018. and s.invoice_month = '{0}'
  1019. group by s.buyercode, s.sale_area_desc, s.forecorpcode
  1020. union all
  1021. select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
  1022. from slm_balance_transmoney b
  1023. join slm_order_head c on b.ord_pk = c.ord_pk
  1024. where 1 = 1
  1025. and b.status_cd = '2'
  1026. and b.tickettype = '应收'
  1027. and b.invoice_month = '{0}'
  1028. and b.realinvoiceno is not null
  1029. and b.forecorpname = '国际贸易部'
  1030. group by b.buyercode, c.sale_area_desc, b.forecorpname
  1031. ) s group by
  1032. s.buyercode, s.sale_area_desc,s.forecorpcode ) f on b.balancesubject =
  1033. f.forecorpcode
  1034. and b.buyercode =
  1035. f.buyercode
  1036. and b.secondaccount =
  1037. f.sale_area_desc
  1038. where 1 = 1
  1039. and b.balancesubject = '国际贸易部'
  1040. and b.invoice_account = '国际贸易部'
  1041. and b.invoice_month = '{0}'
  1042. ";
  1043. sql = string.Format(sql,month);
  1044. return sql;
  1045. }
  1046. private string GetGroupSql(string month)
  1047. {
  1048. string sql = @"
  1049. select b.balancesubject,
  1050. b.buyercode,
  1051. b.secondaccount,
  1052. nvl(b.pre_money, 0) pre_money,
  1053. nvl(b.pre_money, 0) money,
  1054. b.INVOICE_ACCOUNT,
  1055. nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
  1056. nvl(invoice_money, f.money) INVOICE_MONEY,
  1057. nvl(lst_money, nvl( b.pre_money, 0 ) + nvl( inmoney, nvl( c.inoutmoney, 0 ) ) - nvl(nvl( invoice_money, f.money ),0) ) LST_MONEY,
  1058. b.invoice_person,
  1059. b.invoice_date,
  1060. b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS
  1061. ,BILL.ACT_WEIGHT,BILL.BALNCE_PRICE, BALANCE.WEIGHT WEIGHT1,BALANCE.MONEY MONEY1,
  1062. nvl( b.pre_money, 0 ) + nvl( inmoney, nvl( c.inoutmoney, 0 ) ) -nvl( BILL.BALNCE_PRICE, 0 ) - nvl( BALANCE.MONEY, 0 ) - nvl( BALANCE2.MONEY, 0 ) MONEY2
  1063. from SEL_FUND_RECEIVE_ACCOUNT b
  1064. left join (select sum(c.inoutmoney) inoutmoney,
  1065. c.balancesubject,
  1066. c. buyercode,
  1067. c.secondaccount
  1068. from (
  1069. select sum(fu.inoutmoney) inoutmoney,
  1070. fu.balancesubject,
  1071. fu.buyercode,
  1072. fu.secondaccount
  1073. from sel_fund_cust_fundinout fu
  1074. where fu.isvalid = '1'
  1075. AND GET_FISCAL_MONTH1(fu.inouttime) = '{0}'
  1076. and busiseq not like '%-1'
  1077. and fu.balancesubject = '国内贸易部'
  1078. group by fu.balancesubject,
  1079. fu.buyercode,
  1080. fu.secondaccount
  1081. ) c
  1082. group by c.balancesubject, c.buyercode, c.secondaccount) c on b.balancesubject =
  1083. c.balancesubject
  1084. and b.buyercode =
  1085. c.buyercode
  1086. and b.secondaccount =
  1087. c.secondaccount
  1088. left join ( select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
  1089. from (select
  1090. CASE CONTAIN_TAX
  1091. WHEN '1' THEN
  1092. sum( s.money )
  1093. ELSE
  1094. ROUND(sum( s.money )* 1.13,3)
  1095. END money,
  1096. s.buyercode,
  1097. s.sale_area_desc,
  1098. s.forecorpcode
  1099. from slm_balanceinfo s
  1100. where s.balancestatus = '3'
  1101. and s.forecorpcode = '国内贸易部'
  1102. and s.FST_DRAWEE_UNIT = '120604'
  1103. and GET_FISCAL_MONTH1(s.INVOICEDATE) = '{0}'
  1104. group by CONTAIN_TAX,s.buyercode, s.sale_area_desc, s.forecorpcode
  1105. union all
  1106. select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
  1107. from slm_balance_transmoney b
  1108. join slm_order_head c on b.ord_pk = c.ord_pk
  1109. where 1 = 1
  1110. and b.status_cd = '2'
  1111. and b.tickettype = '应收'
  1112. and b.forecorpname = '国内贸易部'
  1113. and b.FST_DRAWEE_UNIT = '120604'
  1114. and GET_FISCAL_MONTH1(b.REG_DTIME) = '{0}'
  1115. group by b.buyercode, c.sale_area_desc, b.forecorpname) s
  1116. group by s.buyercode, s.sale_area_desc, s.forecorpcode ) f on b.balancesubject =
  1117. f.forecorpcode
  1118. and b.buyercode =
  1119. f.buyercode
  1120. and b.secondaccount =
  1121. f.sale_area_desc
  1122. LEFT JOIN (
  1123. SELECT
  1124. T.CUSTOMER_NO,T.SALE_ORG_DESC,T.MANAGEMENT_NAME,SUM(T1.ACT_COUNT) ACT_COUNT,SUM(T1.ACT_WEIGHT) ACT_WEIGHT,SUM(T1.SEND_NUM) SEND_NUM,
  1125. SUM(t2.BALNCE_PRICE * t1.ACT_WEIGHT) BALNCE_PRICE
  1126. FROM
  1127. YDM_ZC_BILL_M t
  1128. LEFT JOIN YDM_ZC_BILL_C T1 ON T.BILL_NO = T1.BILL_NO AND t.ORD_LN_PK = t1.ORD_LN_PK
  1129. LEFT JOIN SLM_ORDER_LINE t2 on t.ORD_LN_PK = t2.ORD_LN_PK
  1130. WHERE
  1131. T.BILL_STATUS IN ( '1', '2', '3' )
  1132. and FST_DRAWEE_UNIT = '120604'
  1133. AND NOT EXISTS (
  1134. SELECT 1 FROM SLM_BALANCEINFO WHERE (BALANCESTATUS = '3' OR BALANCESTATUS_ORG = '3')AND ASKPLAN_ID = T.BILL_NO
  1135. ) GROUP BY T.CUSTOMER_NO,T.SALE_ORG_DESC,T.MANAGEMENT_NAME
  1136. ) BILL ON BILL.CUSTOMER_NO =B.buyercode AND BILL.MANAGEMENT_NAME = B.SECONDACCOUNT AND BILL.SALE_ORG_DESC = B.INVOICE_ACCOUNT
  1137. LEFT JOIN (
  1138. SELECT
  1139. BUYERCODE,
  1140. FORECORPCODE,
  1141. SALE_AREA_DESC,
  1142. sum(WEIGHT) WEIGHT,
  1143. sum(MONEY) MONEY
  1144. FROM
  1145. SLM_BALANCEINFO T
  1146. WHERE
  1147. (
  1148. (
  1149. BALANCESTATUS IN ( '0', '1', '2' )
  1150. AND ISPRECLOSE = '是'
  1151. AND EXISTS ( SELECT 1 FROM YDM_ZC_BILL_M WHERE BILL_NO = T.ASKPLAN_ID AND BILL_STATUS = '4')
  1152. )
  1153. OR ( BALANCESTATUS IN ( '0', '1', '2' ) AND ISPRECLOSE = '否' )
  1154. )
  1155. and FST_DRAWEE_UNIT = '120604'
  1156. GROUP BY
  1157. BUYERCODE,
  1158. FORECORPCODE,
  1159. SALE_AREA_DESC
  1160. ) BALANCE ON BALANCE.BUYERCODE =B.buyercode AND BALANCE.FORECORPCODE = B.INVOICE_ACCOUNT AND BALANCE.SALE_AREA_DESC = B.SECONDACCOUNT
  1161. LEFT JOIN (
  1162. SELECT
  1163. BUYERCODE,
  1164. FORECORPCODE,
  1165. SALE_AREA_DESC,
  1166. sum( WEIGHT ) WEIGHT,
  1167. sum( MONEY ) MONEY
  1168. FROM
  1169. SLM_BALANCEINFO T
  1170. WHERE
  1171. GET_FISCAL_MONTH1 ( INVOICEDATE ) = '{0}' AND BALANCESTATUS = '3'
  1172. and FST_DRAWEE_UNIT = '120604'
  1173. AND EXISTS ( SELECT 1 FROM YDM_ZC_BILL_M WHERE BILL_STATUS IN ( '4', '5' ) AND BILL_NO = T.ASKPLAN_ID )
  1174. GROUP BY
  1175. BUYERCODE,
  1176. FORECORPCODE,
  1177. SALE_AREA_DESC
  1178. ) BALANCE2 ON BALANCE2.BUYERCODE = B.buyercode
  1179. AND BALANCE2.FORECORPCODE = B.INVOICE_ACCOUNT
  1180. AND BALANCE2.SALE_AREA_DESC = B.SECONDACCOUNT
  1181. where 1 = 1
  1182. and b.invoice_account = '国内贸易部'
  1183. and b.invoice_month = '{0}'
  1184. ";
  1185. if (!string.IsNullOrEmpty(_buyercode))
  1186. {
  1187. sql += " and b.buyercode = '" + _buyercode + "'";
  1188. }
  1189. sql = string.Format(sql, month, (int.Parse(month) - 1).ToString());
  1190. return sql;
  1191. }
  1192. private string GetproceSql(string month)
  1193. {
  1194. string sql = @"
  1195. select b.balancesubject,
  1196. b.buyercode,
  1197. b.secondaccount,
  1198. nvl(b.pre_money, 0) pre_money,
  1199. nvl(b.pre_money, 0) money,
  1200. b.INVOICE_ACCOUNT,
  1201. nvl(inmoney, nvl(c.inoutmoney, 0)) INMONEY,
  1202. nvl(invoice_money, f.money) INVOICE_MONEY,
  1203. nvl(lst_money, nvl(b.pre_money, 0) - nvl(c.inoutmoney, 0) + nvl( f.money,0) ) LST_MONEY,
  1204. b.invoice_person,
  1205. b.invoice_date,
  1206. b.invoice_date,b.invoice_month,b.invoice_account,b.INVOICE_STS
  1207. from SEL_FUND_RECEIVE_ACCOUNT b
  1208. left join (select sum(c.inoutmoney) inoutmoney,
  1209. c.balancesubject,
  1210. c. buyercode,
  1211. c.secondaccount
  1212. from (select sum(fu.inoutmoney) inoutmoney,
  1213. fu.balancesubject,
  1214. fu.buyercode buyercode,
  1215. fu.secondaccount
  1216. from sel_fund_cust_fundinout fu
  1217. where fu.isvalid = '1'
  1218. and fu.inouttime > to_date('{0}', 'yyyymm')
  1219. and fu.money_deliver = '1'
  1220. and fu.balancesubject = '国内贸易部'
  1221. -- and fu.buyercode = '1010101184'
  1222. -- and 1 = 2
  1223. and fu.inouttime <=
  1224. last_day(to_date('{0}', 'yyyymm')) + 1
  1225. group by fu.balancesubject,
  1226. fu.buyercode,
  1227. fu.secondaccount
  1228. ) c
  1229. group by c.balancesubject, c.buyercode, c.secondaccount) c on b.balancesubject =
  1230. c.balancesubject
  1231. and b.buyercode =
  1232. c.buyercode
  1233. and b.secondaccount =
  1234. c.secondaccount
  1235. left join ( select sum(s.money) money, s.buyercode, s.sale_area_desc, s.forecorpcode
  1236. from (select sum(s.money) money,
  1237. s.buyercode,
  1238. s.sale_area_desc,
  1239. s.forecorpcode
  1240. from slm_balanceinfo s
  1241. where s.balancestatus = '3'
  1242. and s.realinvoiceno is not null
  1243. and s.fst_drawee_unit = '120606'
  1244. and s.invoice_month = '{0}'
  1245. group by s.buyercode, s.sale_area_desc, s.forecorpcode
  1246. union all
  1247. select sum(b.money), b.buyercode, c.sale_area_desc, b.forecorpname
  1248. from slm_balance_transmoney b
  1249. join slm_order_head c on b.ord_pk = c.ord_pk
  1250. where 1 = 1
  1251. and b.status_cd = '2'
  1252. and b.tickettype = '应收'
  1253. and b.realinvoiceno is not null
  1254. and b.fst_drawee_unit = '120606'
  1255. and b.invoice_month = '{0}'
  1256. group by b.buyercode, c.sale_area_desc, b.forecorpname) s
  1257. group by s.buyercode, s.sale_area_desc, s.forecorpcode ) f on b.balancesubject =
  1258. f.forecorpcode
  1259. and b.buyercode =
  1260. f.buyercode
  1261. and b.secondaccount =
  1262. f.sale_area_desc
  1263. where 1 = 1
  1264. and b.invoice_account = '制造公司'
  1265. and b.invoice_month = '{0}'
  1266. ";
  1267. sql = string.Format(sql, month);
  1268. return sql;
  1269. }
  1270. private string GetProceAllSql(string month)
  1271. {
  1272. string sql = @"
  1273. select a.invoice_month,
  1274. a.invoice_account,
  1275. a.balancesubject,
  1276. a.secondaccount,
  1277. a.buyercode,
  1278. a.pre_money,
  1279. INMONEY,
  1280. invoice_money,
  1281. a.invoice_sts,
  1282. nvl(a.lst_money, nvl(pre_money,0) - nvl(INMONEY, 0) + nvl(invoice_money, 0)) lst_money
  1283. from (
  1284. select a.invoice_month,
  1285. a.invoice_account,
  1286. a.balancesubject,
  1287. a.secondaccount,
  1288. a.buyercode,
  1289. a.pre_money,
  1290. nvl(INMONEY,
  1291. case
  1292. when a.balancesubject = '钢贸' then
  1293. gm
  1294. when a.balancesubject = '国贸' then
  1295. gmx
  1296. when a.balancesubject = '集团' then
  1297. groupm
  1298. when a.balancesubject = '制造' then
  1299. prc
  1300. else
  1301. 0
  1302. end) INMONEY,
  1303. nvl(a.invoice_money,
  1304. case
  1305. when a.balancesubject = '钢贸' then
  1306. c.gmmoney1
  1307. when a.balancesubject = '国贸' then
  1308. c.gmxmoney
  1309. when a.balancesubject = '集团' then
  1310. c.groupm1
  1311. when a.balancesubject = '制造' then
  1312. c.procmoney
  1313. else
  1314. 0
  1315. end) invoice_money, a.invoice_sts,
  1316. a.lst_money
  1317. from sel_fund_receive_account a
  1318. left join (select sum(case
  1319. when a.balancesubject = '钢贸公司' and
  1320. a.money_deliver = '0' then
  1321. a.inoutmoney
  1322. else
  1323. 0
  1324. end) gm,
  1325. sum(case
  1326. when a.balancesubject = '国贸公司' and
  1327. a.money_deliver = '0' then
  1328. a.inoutmoney
  1329. else
  1330. 0
  1331. end) gmx,
  1332. sum(case
  1333. when a.balancesubject = '国内贸易部' and
  1334. a.money_deliver = '1' then
  1335. a.inoutmoney
  1336. else
  1337. 0
  1338. end) prc,
  1339. sum(case
  1340. when a.balancesubject = '国内贸易部' and
  1341. a.money_deliver = '2' then
  1342. 0
  1343. else
  1344. 0
  1345. end) groupm
  1346. from sel_fund_cust_fundinout a
  1347. where a.isvalid = '1' and inouttime > to_date('{0}', 'yyyymm') and inouttime <=
  1348. last_day(to_date('{0}', 'yyyymm')) + 1 ) t on 1 = 1
  1349. left join (select sum(case
  1350. when fst_drawee_unit = '120603' then
  1351. money
  1352. else
  1353. 0
  1354. end) groupm1,
  1355. sum(case
  1356. when fst_drawee_unit = '120604' then
  1357. money
  1358. else
  1359. 0
  1360. end) gmmoney1,
  1361. sum(case
  1362. when fst_drawee_unit = '120605' then
  1363. money
  1364. else
  1365. 0
  1366. end) gmxmoney,
  1367. sum(case
  1368. when fst_drawee_unit = '120606' then
  1369. money
  1370. else
  1371. 0
  1372. end) procmoney
  1373. from (select sum(s.money_org) money, fst_drawee_unit
  1374. from slm_balanceinfo s
  1375. where s.balancestatus_org = '3'
  1376. and s.realinvoiceno_org is not null
  1377. and s.invoice_month = '{0}'
  1378. group by fst_drawee_unit
  1379. union all
  1380. select sum(b.money), b.fst_drawee_unit
  1381. from slm_balance_transmoney b
  1382. join slm_order_head c on b.ord_pk = c.ord_pk
  1383. where 1 = 1
  1384. and b.tickettype = '应收'
  1385. and b.realinvoiceno_org is not null
  1386. and b.invoice_month = '{0}'
  1387. group by b.fst_drawee_unit)
  1388. ) c on 1 = 1
  1389. where a.invoice_month = '{0}'
  1390. and a.invoice_account = '制造全' ) a
  1391. ";
  1392. sql = string.Format(sql,month);
  1393. return sql;
  1394. }
  1395. private void ultraGrid2_ClickCell(object sender, ClickCellEventArgs e)
  1396. {
  1397. }
  1398. private void ultraGrid1_ClickCell(object sender, ClickCellEventArgs e)
  1399. {
  1400. }
  1401. private void ultraGrid3_ClickCell(object sender, ClickCellEventArgs e)
  1402. {
  1403. }
  1404. private void ultraGrid1_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  1405. {
  1406. if (e.Cell.Column.Key == INVOICE_MONEY)
  1407. {
  1408. return;
  1409. UltraGridRow ugr = e.Cell.Row;
  1410. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1411. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1412. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1413. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1414. DataSet ds = this.GetGroupInvoicePact(month, buyercode, fore, salearea);
  1415. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1416. bankfrm._Ds = ds;
  1417. bankfrm._FrmText = "合同查询";
  1418. bankfrm.ShowDialog();
  1419. }
  1420. if (e.Cell.Column.Key == this.INMONEY)
  1421. {
  1422. UltraGridRow ugr = e.Cell.Row;
  1423. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1424. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1425. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1426. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1427. DataSet ds = this.GetGroupMoneyInOut(fore, buyercode, salearea, month);
  1428. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1429. bankfrm._Ds = ds;
  1430. bankfrm._FrmText = "进出款查询";
  1431. bankfrm.ShowDialog();
  1432. }
  1433. }
  1434. private void ultraGrid2_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  1435. {
  1436. if (e.Cell.Column.Key == INVOICE_MONEY)
  1437. {
  1438. return;
  1439. UltraGridRow ugr = e.Cell.Row;
  1440. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1441. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1442. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1443. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1444. DataSet ds = this.GetGmInvoicePact(month, buyercode, fore, salearea);
  1445. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1446. bankfrm._Ds = ds;
  1447. bankfrm._FrmText = "合同查询";
  1448. bankfrm.ShowDialog();
  1449. }
  1450. if (e.Cell.Column.Key == this.INMONEY)
  1451. {
  1452. UltraGridRow ugr = e.Cell.Row;
  1453. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1454. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1455. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1456. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1457. DataSet ds = this.GetGmMoneyInOut(fore, buyercode, salearea, month);
  1458. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1459. bankfrm._Ds = ds;
  1460. bankfrm._FrmText = "进出款查询";
  1461. bankfrm.ShowDialog();
  1462. }
  1463. }
  1464. private void ultraGrid3_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  1465. {
  1466. if (e.Cell.Column.Key == INVOICE_MONEY)
  1467. {
  1468. return;
  1469. UltraGridRow ugr = e.Cell.Row;
  1470. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1471. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1472. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1473. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1474. DataSet ds = this.GetProcInvoicePact(month, buyercode, fore, salearea);
  1475. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1476. bankfrm._Ds = ds;
  1477. bankfrm._FrmText = "合同查询";
  1478. bankfrm.ShowDialog();
  1479. }
  1480. if (e.Cell.Column.Key == this.INMONEY)
  1481. {
  1482. UltraGridRow ugr = e.Cell.Row;
  1483. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1484. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1485. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1486. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1487. DataSet ds = this.GetProcMoneyInOut(fore, buyercode, salearea, month);
  1488. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1489. bankfrm._Ds = ds;
  1490. bankfrm._FrmText = "进出款查询";
  1491. bankfrm.ShowDialog();
  1492. }
  1493. }
  1494. private void ultraGrid4_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
  1495. {
  1496. if (e.Cell.Column.Key == INVOICE_MONEY)
  1497. {
  1498. return;
  1499. UltraGridRow ugr = e.Cell.Row;
  1500. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1501. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1502. DataSet ds = this.GetProcAllInvoicePact(fore, month);
  1503. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1504. bankfrm._Ds = ds;
  1505. bankfrm._FrmText = "合同查询";
  1506. bankfrm.ShowDialog();
  1507. }
  1508. if (e.Cell.Column.Key == this.INMONEY)
  1509. {
  1510. UltraGridRow ugr = e.Cell.Row;
  1511. string month = ugr.Cells[this.INVOICE_MONTH].Value.ToString();
  1512. string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString();
  1513. string salearea = ugr.Cells[this.SECONDACCOUNT].Value.ToString();
  1514. string fore = ugr.Cells[this.BALANCESUBJECT].Value.ToString();
  1515. if (fore == "集团")
  1516. return;
  1517. DataSet ds = this.GetProcAllMoneyInOut(fore, month);
  1518. FundUI.UIDlgBox.DlgBankFrm bankfrm = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgBankFrm();
  1519. bankfrm._Ds = ds;
  1520. bankfrm._FrmText = "进出款查询";
  1521. bankfrm.ShowDialog();
  1522. }
  1523. }
  1524. private string _buyercode = "";
  1525. private void button1_Click(object sender, EventArgs e)
  1526. {
  1527. UIDlgBox.DlgCustChoose custChoose = new Core.StlMes.Client.Sale.SaleFundMgt.FundUI.UIDlgBox.DlgCustChoose(this.ob);
  1528. custChoose.CustUse = "100202";
  1529. custChoose.SaleOrg = base.GetSaleOrg();
  1530. custChoose.ShowDialog();
  1531. if (custChoose.DialogResult == DialogResult.OK)
  1532. {
  1533. this.textBox1.Text = custChoose.customerName;
  1534. _buyercode = custChoose.customerNo;
  1535. this.Query();
  1536. }
  1537. }
  1538. }
  1539. }