FrmInvoiceAccountMgt.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Threading;
  9. using System.Collections;
  10. using System.Reflection;
  11. using CoreFS.CA06;
  12. using Infragistics.Win.UltraWinGrid;
  13. namespace Core.StlMes.Client.Sale.UI.Balance.Report
  14. {
  15. public partial class FrmInvoiceAccountMgt : Core.StlMes.Client.Sale.Common.FrmStyleBase.FrmUIBase
  16. {
  17. public FrmInvoiceAccountMgt()
  18. {
  19. InitializeComponent();
  20. }
  21. private DataSet _dsGroup = new DataSet();
  22. private DataSet _dsGm = new DataSet();
  23. private DataSet _dsProc = new DataSet();
  24. private DataSet _dsProcFist = new DataSet();
  25. private DataSet _dsSale = new DataSet();
  26. private DataSet _dsOutSale = new DataSet();
  27. private void InitDataSource()
  28. {
  29. _dsGroup = base.GetDataSetByColumnName(this.GetBalanceMainColumn()
  30. , null,
  31. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  32. _dsGm = base.GetDataSetByColumnName(this.GetBalanceMainColumn()
  33. , null,
  34. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  35. _dsProc = base.GetDataSetByColumnName(this.GetBalanceMainColumn()
  36. , null,
  37. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  38. _dsProcFist = base.GetDataSetByColumnName(this.GetBalanceMainColumnOrg()
  39. , null,
  40. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  41. _dsSale = base.GetDataSetByColumnName(this.GetBalanceMainColumn()
  42. , null,
  43. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  44. _dsOutSale = base.GetDataSetByColumnName(this.GetBalanceMainColumnOrg()
  45. , null,
  46. base.ConvertListStringArrayToHashTable(base.GetDataStructCaption()));
  47. this.ultraGrid1.DataSource = _dsGroup;
  48. this.ultraGrid2.DataSource = _dsGm;
  49. this.ultraGrid3.DataSource = _dsProc;
  50. this.ultraGrid4.DataSource = _dsProcFist;
  51. this.ultraGrid5.DataSource = _dsSale;
  52. this.ultraGrid6.DataSource = _dsOutSale;
  53. }
  54. private Infragistics.Win.UltraWinGrid.UltraGrid[] GetAllUltraGrid()
  55. {
  56. return new Infragistics.Win.UltraWinGrid.UltraGrid[]
  57. {this.ultraGrid1,this.ultraGrid2,this.ultraGrid3,this.ultraGrid4,this.ultraGrid5,this.ultraGrid6};
  58. }
  59. private string INVOICE_MONTH = "INVOICE_MONTH";
  60. private string FST_DRAWEE_UNIT = "FST_DRAWEE_UNIT";
  61. private string CONTAIN_TAX = "CONTAIN_TAX";
  62. private string ASKPLAN_ID = "ASKPLAN_ID";
  63. private void InitGridValue()
  64. {
  65. foreach (Infragistics.Win.UltraWinGrid.UltraGrid ugr in GetAllUltraGrid())
  66. {
  67. try
  68. {
  69. ugr.DisplayLayout.Bands[0].Columns[this.FST_DRAWEE_UNIT].ValueList = GetFst_Drawee_unit();
  70. }
  71. catch { }
  72. try
  73. {
  74. ugr.DisplayLayout.Bands[0].Columns[this.CONTAIN_TAX].ValueList = GetAgenCyFlList();
  75. }
  76. catch { }
  77. try
  78. {
  79. ugr.DisplayLayout.Bands[0].Columns[this.INVOICE_MONTH].ValueList = this.GetMonthList();
  80. }
  81. catch { }
  82. }
  83. }
  84. private void InitEditCell()
  85. {
  86. foreach (Infragistics.Win.UltraWinGrid.UltraGrid ugr in GetAllUltraGrid())
  87. {
  88. try
  89. {
  90. ugr.DisplayLayout.Bands[0].Columns[this.INVOICE_MONTH].CellActivation = Activation.AllowEdit;
  91. ugr.DisplayLayout.Bands[0].Columns[this.INVOICE_MONTH].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  92. ugr.DisplayLayout.Bands[0].Columns[this.INVOICE_MONTH].CellAppearance.BackColor = base.GetEditColor();
  93. }
  94. catch { }
  95. }
  96. }
  97. private Infragistics.Win.ValueList GetMonthList()
  98. {
  99. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  100. string mon = "";
  101. string val = "";
  102. for (int i = 0; i < 12; i++)
  103. {
  104. mon = System.DateTime.Now.AddMonths(-i).ToString("yyyyMM");
  105. lit.ValueListItems.Add(mon, mon);
  106. }
  107. return lit;
  108. }
  109. private Infragistics.Win.ValueList GetAgenCyFlList()
  110. {
  111. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  112. lit.ValueListItems.Add("0", "否");
  113. lit.ValueListItems.Add("1", "是");
  114. return lit;
  115. }
  116. private Infragistics.Win.ValueList GetFst_Drawee_unit()
  117. {
  118. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  119. lit.ValueListItems.Add("120601", "N/A");
  120. lit.ValueListItems.Add("120602", "/");
  121. lit.ValueListItems.Add("120603", "天津钢管集团股份有限公司");
  122. lit.ValueListItems.Add("120604", "天津钢管钢铁贸易有限公司");
  123. lit.ValueListItems.Add("120605", "天津钢管国际经济贸易有限公司");
  124. lit.ValueListItems.Add("120606", "合同结算单位");
  125. lit.ValueListItems.Add("120607", "江苏天淮钢管有限公司");
  126. lit.ValueListItems.Add("120608", "天津钢管制造有限公司");
  127. return lit;
  128. }
  129. private void FrmInvoiceAccountMgt_Load(object sender, EventArgs e)
  130. {
  131. this.dateTimePicker2.Format = DateTimePickerFormat.Custom;
  132. this.dateTimePicker2.CustomFormat = "yyyyMM";
  133. InitDataSource();
  134. InitGridValue();
  135. base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid2, ref this.ultraGrid3,ref this.ultraGrid4,
  136. ref this.ultraGrid5, ref this.ultraGrid6);
  137. InitEditCell();
  138. InitGmFrm();
  139. }
  140. private void InitGmFrm()
  141. {
  142. if (this.CustomInfo == "4")
  143. {
  144. for( int i = 0; i < this.ultraTabControl2.Tabs.Count; i ++)
  145. {
  146. this.ultraTabControl2.Tabs[i].Visible = false;
  147. this.ultraTabControl2.Tabs[1].Visible = true;
  148. }
  149. }
  150. }
  151. public override void Query()
  152. {
  153. if (this.ultraTabControl2.SelectedTab.Index == 1)
  154. {
  155. this.QueryGm();
  156. }
  157. else if (this.ultraTabControl2.SelectedTab.Index == 0)
  158. {
  159. this.QueryGroup();
  160. }
  161. else if (this.ultraTabControl2.SelectedTab.Index == 2)
  162. {
  163. this.QueryProc();
  164. }
  165. else if (this.ultraTabControl2.SelectedTab.Index == 3)
  166. {
  167. this.QueryProcIn();
  168. }
  169. else if (this.ultraTabControl2.SelectedTab.Index == 4)
  170. {
  171. this.QuerySale();
  172. }
  173. else if (this.ultraTabControl2.SelectedTab.Index == 5)
  174. {
  175. this.QueryOutSale();
  176. }
  177. }
  178. private List<Infragistics.Win.UltraWinGrid.UltraGridRow> GetUgrs()
  179. {
  180. List<Infragistics.Win.UltraWinGrid.UltraGridRow> ugrs = new List<UltraGridRow>();
  181. if (this.ultraTabControl2.SelectedTab.Index == 1)
  182. {
  183. if (this.ultraGrid2.Rows.Count == 0)
  184. return ugrs;
  185. this.ultraGrid2.UpdateData();
  186. if (this.ultraGrid2.ActiveRow != null)
  187. this.ultraGrid2.ActiveRow.Selected = true;
  188. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid2.Selected.Rows)
  189. {
  190. ugrs.Add(ugr);
  191. }
  192. }
  193. else if (this.ultraTabControl2.SelectedTab.Index == 0)
  194. {
  195. if (this.ultraGrid1.Rows.Count == 0)
  196. return ugrs;
  197. this.ultraGrid1.UpdateData();
  198. if (this.ultraGrid1.ActiveRow != null)
  199. this.ultraGrid1.ActiveRow.Selected = true;
  200. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  201. {
  202. ugrs.Add(ugr);
  203. }
  204. }
  205. else if (this.ultraTabControl2.SelectedTab.Index == 2)
  206. {
  207. if (this.ultraGrid3.Rows.Count == 0)
  208. return ugrs;
  209. this.ultraGrid3.UpdateData();
  210. if (this.ultraGrid3.ActiveRow != null)
  211. this.ultraGrid3.ActiveRow.Selected = true;
  212. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid3.Selected.Rows)
  213. {
  214. ugrs.Add(ugr);
  215. }
  216. }
  217. else if (this.ultraTabControl2.SelectedTab.Index == 3)
  218. {
  219. if (this.ultraGrid4.Rows.Count == 0)
  220. return ugrs;
  221. this.ultraGrid4.UpdateData();
  222. if (this.ultraGrid4.ActiveRow != null)
  223. this.ultraGrid4.ActiveRow.Selected = true;
  224. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid4.Selected.Rows)
  225. {
  226. ugrs.Add(ugr);
  227. }
  228. }
  229. else if (this.ultraTabControl2.SelectedTab.Index == 4)
  230. {
  231. if (this.ultraGrid5.Rows.Count == 0)
  232. return ugrs;
  233. this.ultraGrid5.UpdateData();
  234. if (this.ultraGrid5.ActiveRow != null)
  235. this.ultraGrid5.ActiveRow.Selected = true;
  236. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid5.Selected.Rows)
  237. {
  238. ugrs.Add(ugr);
  239. }
  240. }
  241. else if (this.ultraTabControl2.SelectedTab.Index == 5)
  242. {
  243. if (this.ultraGrid6.Rows.Count == 0)
  244. return ugrs;
  245. this.ultraGrid6.UpdateData();
  246. if (this.ultraGrid6.ActiveRow != null)
  247. this.ultraGrid6.ActiveRow.Selected = true;
  248. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid6.Selected.Rows)
  249. {
  250. ugrs.Add(ugr);
  251. }
  252. }
  253. return ugrs;
  254. }
  255. public override void Update()
  256. {
  257. UpdateInvoiceMonth();
  258. }
  259. private void UpdateInvoiceMonth()
  260. {
  261. List<Infragistics.Win.UltraWinGrid.UltraGridRow> list = this.GetUgrs();
  262. if (list.Count == 0)
  263. return;
  264. string sql = " update Slm_Balanceinfo a set a.invoice_month = '{0}' where askplan_id = '{1}' and invoice_sts = '0' ";
  265. string sqlt = " update SLM_BALANCE_TRANSMONEY a set a.invoice_month = '{0}' where askplan_id = '{1}' and invoice_sts = '0' ";
  266. ArrayList lists = new ArrayList();
  267. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in list)
  268. {
  269. sql = string.Format(sql,ugr.Cells[this.INVOICE_MONTH].Value.ToString(),ugr.Cells[this.ASKPLAN_ID].Value.ToString());
  270. sqlt = string.Format(sqlt, ugr.Cells[this.INVOICE_MONTH].Value.ToString(), ugr.Cells[this.ASKPLAN_ID].Value.ToString());
  271. if (!(ugr.Cells["MONEY_TYPE"].Value.ToString() == "货款"))
  272. {
  273. lists.Add(sqlt);
  274. }
  275. else
  276. lists.Add(sql);
  277. }
  278. base.ExecuteNoReader(lists);
  279. Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功");
  280. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in list)
  281. {
  282. ugr.Delete();
  283. }
  284. }
  285. private void QueryGroup()
  286. {
  287. string sqlcondition = "";
  288. sqlcondition += " and fst_drawee_unit = '120603' ";
  289. sqlcondition += " and balancestatus = '3' and realinvoiceno is not null ";
  290. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  291. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  292. string sql = GetSqlMain(sqlcondition);
  293. DataSet ds = base.ExecuteReader(sql);
  294. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsGroup,ds);
  295. string sqlTransConditjon = " and fst_drawee_unit = '120603' ";
  296. sqlTransConditjon += " and realinvoiceno is not null ";
  297. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  298. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  299. DataSet dsTrans = base.ExecuteReader(sqltran);
  300. try
  301. {
  302. dsTrans.Tables[0].TableName = this._dsGroup.Tables[0].TableName;
  303. this._dsGroup.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  304. }
  305. catch
  306. {
  307. }
  308. }
  309. private void QueryGm()
  310. {
  311. string sqlcondition = "";
  312. sqlcondition += " and forecorpcode = '钢贸公司' ";
  313. sqlcondition += " and balancestatus = '3' and realinvoiceno is not null ";
  314. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  315. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  316. string sql = GetSqlMain(sqlcondition);
  317. DataSet ds = base.ExecuteReader(sql);
  318. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsGm, ds);
  319. string sqlTransConditjon = " and forecorpname = '钢贸公司' ";
  320. sqlTransConditjon += " and realinvoiceno is not null ";
  321. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  322. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  323. DataSet dsTrans = base.ExecuteReader(sqltran);
  324. try
  325. {
  326. dsTrans.Tables[0].TableName = this._dsGm.Tables[0].TableName;
  327. this._dsGm.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  328. }
  329. catch
  330. {
  331. }
  332. }
  333. private void QueryProc()
  334. {
  335. string sqlcondition = "";
  336. sqlcondition += " and fst_drawee_unit = '120606' ";
  337. sqlcondition += " and balancestatus = '3' and realinvoiceno is not null ";
  338. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  339. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  340. string sql = GetSqlMain(sqlcondition);
  341. DataSet ds = base.ExecuteReader(sql);
  342. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsProc, ds);
  343. string sqlTransConditjon = " and fst_drawee_unit = '120606' ";
  344. sqlTransConditjon += " and realinvoiceno is not null ";
  345. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  346. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  347. DataSet dsTrans = base.ExecuteReader(sqltran);
  348. try
  349. {
  350. dsTrans.Tables[0].TableName = this._dsProc.Tables[0].TableName;
  351. this._dsProc.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  352. }
  353. catch
  354. {
  355. }
  356. }
  357. private void QueryProcIn()
  358. {
  359. string sqlcondition = "";
  360. sqlcondition += " and balancestatus_org = '3' and REALINVOICENO_ORG is not null ";
  361. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  362. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  363. string sql = GetSqlMain(sqlcondition);
  364. DataSet ds = base.ExecuteReader(sql);
  365. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsProcFist, ds);
  366. string sqlTransConditjon = " ";
  367. sqlTransConditjon += " and realinvoiceno_org is not null ";
  368. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  369. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  370. DataSet dsTrans = base.ExecuteReader(sqltran);
  371. try
  372. {
  373. dsTrans.Tables[0].TableName = this._dsProcFist.Tables[0].TableName;
  374. this._dsProcFist.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  375. }
  376. catch
  377. {
  378. }
  379. }
  380. private void QuerySale()
  381. {
  382. string sqlcondition = "";
  383. sqlcondition += " and balancestatus = '3' and realinvoiceno is not null and forecorpcode = '销售公司' ";
  384. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  385. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  386. string sql = GetSqlMain(sqlcondition);
  387. DataSet ds = base.ExecuteReader(sql);
  388. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsSale, ds);
  389. string sqlTransConditjon = " and forecorpname = '销售公司' ";
  390. sqlTransConditjon += " and realinvoiceno is not null ";
  391. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  392. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  393. DataSet dsTrans = base.ExecuteReader(sqltran);
  394. try
  395. {
  396. dsTrans.Tables[0].TableName = this._dsSale.Tables[0].TableName;
  397. this._dsSale.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  398. }
  399. catch
  400. {
  401. }
  402. }
  403. private void QueryOutSale()
  404. {
  405. string sqlcondition = "";
  406. sqlcondition += " and balancestatus_org = '3' and REALINVOICENO_ORG is not null and forecorpcode = '国贸公司' ";
  407. string month = this.dateTimePicker2.Value.ToString("yyyyMM");
  408. sqlcondition += string.Format(" and invoice_month = '{0}' ", month);
  409. string sql = GetSqlMain(sqlcondition);
  410. DataSet ds = base.ExecuteReader(sql);
  411. Core.StlMes.Client.Sale.Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref _dsOutSale, ds);
  412. string sqlTransConditjon = " and forecorpname = '国贸公司' ";
  413. sqlTransConditjon += " and realinvoiceno_org is not null ";
  414. sqlTransConditjon += string.Format(" and invoice_month = '{0}' ", month);
  415. string sqltran = GetBalanceTransMoney(sqlTransConditjon);
  416. DataSet dsTrans = base.ExecuteReader(sqltran);
  417. try
  418. {
  419. dsTrans.Tables[0].TableName = this._dsOutSale.Tables[0].TableName;
  420. this._dsOutSale.Merge(dsTrans, false, System.Data.MissingSchemaAction.Ignore);
  421. }
  422. catch
  423. {
  424. }
  425. }
  426. private string GetSqlMain(string sqlCondition)
  427. {
  428. string sql = @" select a.*,
  429. b.batchno,
  430. b.pno,
  431. b.wgt ACT_WEIGHT,
  432. b.qty ACT_COUNT,
  433. send_num1 INOUTMONEY,
  434. round(a.price * nvl(b.wgt, b.send_num1), 5) TOTALMONEY,
  435. round(a.price_org * nvl(b.wgt, b.send_num1), 5) LEAVEMONEY,'货款' MONEY_TYPE
  436. from Slm_Balanceinfo a
  437. join (select *
  438. from (select row_number() over(partition by a.ord_no, a.ord_seq, a.ord_ln_dly, a.askplan_id, a.askplan_id_seq, a.steelcodekey, a.spetkey, a.batch_no order by a.ord_no, a.ord_seq, a.ord_ln_dly, a.askplan_id, a.askplan_id_seq, a.steelcodekey, a.spetkey, a.batch_no) rn,
  439. sum(a.act_wgt) over(partition by a.ord_no, a.ord_seq, a.ord_ln_dly, a.askplan_id, a.askplan_id_seq, a.steelcodekey, a.spetkey, a.batch_no) wgt,
  440. sum(a.PRD_QTY) over(partition by a.ord_no, a.ord_seq, a.ord_ln_dly, a.askplan_id, a.askplan_id_seq, a.steelcodekey, a.spetkey, a.batch_no) qty,
  441. sum(a.send_num) over(partition by a.ord_no, a.ord_seq, a.ord_ln_dly, a.askplan_id, a.askplan_id_seq, a.steelcodekey, a.spetkey, a.batch_no) send_num1,
  442. a.ord_no,
  443. a.ord_seq,
  444. a.ord_ln_dly,
  445. a.askplan_id,
  446. a.askplan_id_seq,
  447. a.steelcodekey,
  448. a.spetkey,
  449. substr(a.batch_no, 1, instr(batch_no, '/', 1) - 1) batchno,
  450. substr(a.batch_no, instr(batch_no, '/', 1) + 1) pno
  451. from Slm_Balancedetail_All a)
  452. where rn = 1) b on a.ord_no = b.ord_no
  453. and a.ord_seq = b.ord_seq
  454. and a.ord_ln_dly = b.ord_ln_dly
  455. and a.askplan_id = b.askplan_id
  456. and a.askplan_id_seq = b.askplan_id_seq
  457. and a.steelcodekey = b.steelcodekey
  458. and a.spetkey = b.spetkey
  459. where 1 = 1 {0} ";
  460. sql = string.Format(sql, sqlCondition);
  461. return sql;
  462. }
  463. private string GetBalanceTransMoney(string sqlCondition)
  464. {
  465. string sql = @"
  466. select a.askplan_id,
  467. a.listnumber,
  468. a.buyercode,
  469. a.buyername,
  470. min(INVOICE_MONTH) INVOICE_MONTH,
  471. min(realinvoiceno) realinvoiceno,
  472. min(INVOICE_ID) INVOICEPERSON,
  473. min(a.order_no) ORD_NO,
  474. min(a.order_seq) ORD_SEQ,
  475. a.forecorpname forecorpcode,
  476. a.fst_drawee_unit,
  477. a.inceptcorpcode,
  478. a.trans_type TRANS_TYPE_NAME,
  479. a.tickettype,
  480. a.MONEY_TYPE,
  481. sum(a.money) TOTALMONEY,
  482. sum(a.weight) ACT_WEIGHT,
  483. min(a.reg_id) reg_id,
  484. min(a.reg_dtime) reg_dtime,
  485. min(b.sale_area_desc) sale_area_desc,
  486. min(b.create_dept) create_dept,
  487. min(b.create_name) create_name,min(INCEPTCORPCODE) INCEPTCORPCODE,
  488. min(b.customer_nm) CUSTOMER_NM,min(a.REALINVOICE_DATE) REALINVOICENO_DATE
  489. from Slm_Balance_Transmoney a
  490. join (select min(b.create_dept) create_dept,
  491. min(b.create_name) create_name,min(b.customer_nm) customer_nm,
  492. min(b.sale_area_desc) sale_area_desc,
  493. bill_no
  494. from ydm_zc_bill_m m
  495. join slm_order_head b on m.ord_pk = b.ord_pk
  496. group by bill_no) b on a.askplan_id = b.bill_no
  497. where 1=1
  498. {0}
  499. and a.tickettype = '应收'
  500. group by a.askplan_id,
  501. a.listnumber,
  502. a.buyercode,
  503. a.buyername,
  504. a.ord_pk,
  505. a.ord_ln_pk,
  506. a.ord_ln_dly_pk,
  507. a.forecorpcode,
  508. a.forecorpname,
  509. a.fst_drawee_unit,
  510. a.inceptcorpcode,
  511. a.trans_type,
  512. a.tickettype,
  513. a.money_type
  514. ";
  515. sql = string.Format(sql, sqlCondition);
  516. return sql;
  517. }
  518. protected override Hashtable GetDataSetColumnCaption()
  519. {
  520. Hashtable hs = new Hashtable();
  521. hs.Add("INOUTMONEY", "实发数");
  522. hs.Add("LEAVEMONEY", "金额");
  523. return hs;
  524. }
  525. private string[] GetBalanceMainColumn()
  526. {
  527. return new string[]
  528. {
  529. "INVOICE_MONTH",
  530. "MONEY_TYPE",
  531. "SALE_AREA_DESC",
  532. "FORECORPCODE",
  533. "BUYERNAME",
  534. "FST_DRAWEE_UNIT",
  535. "ASKPLAN_ID",
  536. "ORD_NO",
  537. "ORD_SEQ",
  538. "ORD_LN_DLY",
  539. "BATCHNO",
  540. "PNO",
  541. "STEELCODEKEY",
  542. "PACTINDEX",
  543. "SPETKEY",
  544. "INOUTMONEY",
  545. "ORDER_UNIT",
  546. "ACT_COUNT",
  547. "ACT_WEIGHT",
  548. "PRICE",
  549. "TOTALMONEY",
  550. "INVOICEPERSON",
  551. "REALINVOICENO",
  552. "REALINVOICENO_DATE",
  553. "CONTAIN_TAX",
  554. "CATEGORY",
  555. "SPEC_ABBSYMNAME",
  556. "STD_STYLE_DESC",
  557. "MODEL_DESC",
  558. "INCEPTCORPCODE",
  559. "CUSTOMER_NM"
  560. };
  561. }
  562. private string[] GetBalanceMainColumnOrg()
  563. {
  564. return new string[]
  565. {
  566. "SALE_AREA_DESC",
  567. "FORECORPCODE",
  568. "BUYERNAME",
  569. "FST_DRAWEE_UNIT",
  570. "ASKPLAN_ID",
  571. "ORD_NO",
  572. "ORD_SEQ",
  573. "ORD_LN_DLY",
  574. "BATCHNO",
  575. "PNO",
  576. "STEELCODEKEY",
  577. "PACTINDEX",
  578. "SPETKEY",
  579. "INOUTMONEY",
  580. "ORDER_UNIT",
  581. "ACT_COUNT",
  582. "ACT_WEIGHT",
  583. "REALINVOICENO_DATE_ORG",
  584. "PRICE_ORG",
  585. "LEAVEMONEY",
  586. "REALINVOICENO_ORG",
  587. "CONTAIN_TAX",
  588. "CATEGORY",
  589. "SPEC_ABBSYMNAME",
  590. "STD_STYLE_DESC",
  591. "MODEL_DESC",
  592. "INCEPTCORPCODE",
  593. "CUSTOMER_NM"
  594. };
  595. }
  596. }
  597. }