FrmBalanceInvoceMgtOrgList.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  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. namespace Core.StlMes.Client.Sale.UI.Balance.BalanceAccount
  13. {
  14. public partial class FrmBalanceInvoceMgtOrgList : Core.StlMes.Client.Sale.Common.FrmStyleBase.FrmUIBase
  15. {
  16. public FrmBalanceInvoceMgtOrgList()
  17. {
  18. InitializeComponent();
  19. }
  20. private DataSet dsInvoice = new DataSet();
  21. private DataSet dsInvoiceDetail = null;
  22. private DataSet dsInvoiceSeq = new DataSet();
  23. private DataSet dsInvoiceList = new DataSet();
  24. private void initDataSource()
  25. {
  26. dsInvoice = base.GetDataSetByColumnName(this.GetGrid1DataStruct(),
  27. null, GetColumnAndCaption());
  28. this.ultraGrid1.DataSource = dsInvoice;
  29. dsInvoiceSeq = base.GetDataSetByColumnName(this.GetGrid2DataStruct(),
  30. null, GetColumnAndCaption());
  31. this.ultraGrid2.DataSource = dsInvoiceSeq;
  32. //dsInvoiceList = base.GetDataSetByColumnName(this.GetGrid3DataStruct(),
  33. //null, GetColumnAndCaption());
  34. //this.ultraGrid3.DataSource = dsInvoiceList;
  35. }
  36. private void HiddenColumn()
  37. {
  38. try
  39. {
  40. this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO].Hidden = true;
  41. this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO_SEQ].Hidden = true;
  42. this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].Hidden = true;
  43. }
  44. catch
  45. { }
  46. }
  47. protected override List<string> GetNumberColumn()
  48. {
  49. return new List<string>(new string[] {
  50. "SEND_NUM",
  51. "MONEY",
  52. "WEIGHT",
  53. "QUANTITY",
  54. "ACT_WGT",
  55. "OUTSTOCKMNY",
  56. "TRANSMNY",
  57. "PRICE",
  58. "PRICE_ORG",
  59. "MONEY_ORG",
  60. });
  61. }
  62. private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo slmBalanceInfo = null;
  63. private void FrmBalanceInvoceMgt_Load(object sender, EventArgs e)
  64. {
  65. // this.ultraExpandableGroupBox2.Visible = false;
  66. // this.dateTimePicker1.Value = System.DateTime.Now.AddMonths(-1);
  67. slmBalanceInfo = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo(this.ob);
  68. initDataSource();
  69. base.SetGridStyle(ref this.ultraGrid1,ref this.ultraGrid2);
  70. InitGrid();
  71. HiddenColumn();
  72. InitGridValue();
  73. }
  74. private void SaveRealInvoiceNo()
  75. {
  76. this.ultraGrid1.UpdateData();
  77. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  78. if (this.ultraGrid1.Rows.Count == 0)
  79. return;
  80. ugr = this.ultraGrid1.ActiveRow;
  81. if (ugr == null)
  82. {
  83. MessageBox.Show("请选择需要保存的行");
  84. return;
  85. }
  86. if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON_ORG"].Value.ToString()))
  87. return;
  88. string invoiceno = ugr.Cells["INVOICENO_ORG"].Value.ToString();
  89. string realInvoiceNo = ugr.Cells["REALINVOICENO_ORG"].Value.ToString();
  90. if (realInvoiceNo.Length > 30)
  91. {
  92. MessageBox.Show("发票号允许最大长度30");
  93. return;
  94. }
  95. string errMsg = "";
  96. this.slmBalanceInfo.UpdateRealInvoiceNoOrg(invoiceno, realInvoiceNo, CoreFS.SA06.CoreUserInfo.UserInfo
  97. .GetUserName(), out errMsg);
  98. if (errMsg.Length == 0)
  99. {
  100. MessageBox.Show("保存成功");
  101. }
  102. }
  103. private void InitGrid()
  104. {
  105. System.Drawing.Color color = System.Drawing.Color.FromArgb(255, 255, 128);
  106. try
  107. {
  108. this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  109. this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellAppearance.BackColor = base.GetEditColor();
  110. this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
  111. this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellAppearance.BackColor = base.GetEditColor();
  112. }
  113. catch
  114. {
  115. }
  116. }
  117. private void InitGridValue()
  118. {
  119. try
  120. {
  121. this.ultraGrid1.DisplayLayout.Bands[0].Columns["FST_DRAWEE_UNIT"].ValueList
  122. = GetFstDraWeeUnit();
  123. }
  124. catch
  125. {
  126. }
  127. }
  128. private Infragistics.Win.ValueList GetFstDraWeeUnit()
  129. {
  130. Infragistics.Win.ValueList lit = new Infragistics.Win.ValueList();
  131. lit.ValueListItems.Add("120601", "N/A");
  132. lit.ValueListItems.Add("120602", "/");
  133. lit.ValueListItems.Add("120603", "天津钢管集团股份有限公司");
  134. lit.ValueListItems.Add("120604", "天津钢管钢铁贸易有限公司");
  135. lit.ValueListItems.Add("120605", "天津钢管国际贸易有限公司");
  136. lit.ValueListItems.Add("120606", "合同结算单位");
  137. return lit;
  138. }
  139. public override void ToolBar_Click(object sender, string ToolbarKey)
  140. {
  141. switch (ToolbarKey)
  142. {
  143. case "Query":
  144. {
  145. this.Query();
  146. break;
  147. }
  148. case "RollInv":
  149. {
  150. this.RollBackInvoiceNo();
  151. break;
  152. }
  153. case "Exit":
  154. {
  155. this.Close();
  156. break;
  157. }
  158. case "Save":
  159. {
  160. this.SaveRealInvoiceNo();
  161. break;
  162. }
  163. case "PrintInvoice":
  164. {
  165. this.PrintInvoice();
  166. break;
  167. }
  168. case "Credit":
  169. {
  170. this.Credit();
  171. break;
  172. }
  173. case "Export":
  174. {
  175. Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel(this.Text, this.ultraGrid1);
  176. break;
  177. }
  178. case "AddTrans":
  179. {
  180. InvoiceSignalTransMoney();
  181. break;
  182. }
  183. case "PrintDetail":
  184. {
  185. PrintDetail();
  186. break;
  187. }
  188. }
  189. }
  190. private void QueryTransMny()
  191. {
  192. string sql = GetSqlForInvoice(this.dateTimePicker1.Value,
  193. this.dateTimePicker2.Value);
  194. DataSet ds = base.ExecuteReader(sql);
  195. //DataSet ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoney(this.dateTimePicker1.Value,
  196. // this.dateTimePicker2.Value);
  197. if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
  198. return;
  199. if (this.dsInvoice == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
  200. {
  201. }
  202. else
  203. {
  204. foreach (DataRow dr in ds.Tables[0].Rows)
  205. {
  206. DataSet dstemp = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter
  207. (dsInvoice, "INVOICENO_ORG", dr["INVOICENO_ORG"].ToString());
  208. try
  209. {
  210. if (dstemp.Tables[0].Rows.Count > 0)
  211. {
  212. dr.Delete();
  213. }
  214. }
  215. catch
  216. {
  217. }
  218. }
  219. }
  220. ds.AcceptChanges();
  221. ds.Tables[0].TableName = this.dsInvoice.Tables[0].TableName;
  222. this.dsInvoice.Merge(ds, false, System.Data.MissingSchemaAction.Ignore);
  223. this.dsInvoice.AcceptChanges();
  224. // ClearGrid();
  225. }
  226. private string GetSqlForInvoice(System.DateTime dtbegin, System.DateTime dtEnd)
  227. {
  228. string sql = @"
  229. select sum(case
  230. when a.money_type = '出库费' then
  231. a.money
  232. else
  233. 0
  234. end) OUTSTOCKMNY,
  235. sum(case
  236. when a.money_type = '运费' then
  237. a.money
  238. else
  239. 0
  240. end) TRANSMNY,
  241. max(money_type) money_type,
  242. sum(nvl(a.weight, 0)) weight,
  243. a.buyercode,
  244. a.buyername,
  245. a.inceptcorpcode,
  246. a.fst_drawee_unit,
  247. a.forecorpcode forecorpname,
  248. a.forecorpname forecorpcode,
  249. a.invoiceno_org,
  250. MAX(A.REALINVOICENO_ORG) REALINVOICENO_ORG,
  251. max(a.INVOICEPERSON_org) INVOICEPERSON_ORG,
  252. max(a.invoicedate_org) INVOICEDATE_ORG,
  253. b.customer_nm,
  254. b.sale_area_desc,min(a.Invoice_Sts) Invoice_Sts
  255. from slm_balance_transmoney a
  256. join slm_order_head b on a.ord_pk = b.ord_pk
  257. where 1=1 and a.Invoice_Sts = '0'
  258. and a.invoiceno_org is not null
  259. {0}
  260. group by a.buyercode,
  261. a.buyername,
  262. a.inceptcorpcode,
  263. a.fst_drawee_unit,
  264. a.forecorpcode,
  265. a.forecorpname,
  266. a.invoiceno_org,
  267. b.customer_nm,
  268. b.sale_area_desc
  269. ";
  270. string sqlCondition = Util.ConverObject.ConvertDateTimeValueToDbLanguage("invoicedate_org", dtbegin, dtEnd);
  271. sql = string.Format(sql, sqlCondition);
  272. return sql;
  273. }
  274. private void InvoiceSignalTransMoney()
  275. {
  276. DlgBox.DlgSelectInvoceTransMnyAndOutStockMny dlg
  277. = new Core.StlMes.Client.Sale.UI.Balance.DlgBox.DlgSelectInvoceTransMnyAndOutStockMny(this.ob);
  278. dlg._invocieFlag = "1";
  279. dlg.ShowDialog();
  280. ArrayList arpk = new ArrayList();
  281. string errMsg = "";
  282. if (dlg.DialogResult == DialogResult.OK)
  283. {
  284. arpk = dlg.Tranpk;
  285. if (arpk.Count == 0)
  286. return;
  287. this.slmBalanceInfo.MakeFirstInvoiceForTransMnyAndOutStockMoney(arpk,
  288. CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
  289. if (errMsg.Length == 0)
  290. {
  291. Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功");
  292. this.Query();
  293. }
  294. }
  295. }
  296. /// <summary>
  297. /// 冲减
  298. /// </summary>
  299. private void Credit()
  300. {
  301. //Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  302. //Infragistics.Win.UltraWinGrid.UltraGridRow ugrc = null;
  303. //if (this.ultraGrid1.Rows.Count == 0)
  304. // return;
  305. //if (this.ultraGrid2.Rows.Count == 0)
  306. // return;
  307. //if (this.ultraGrid1.Rows.Count == 1)
  308. // this.ultraGrid1.Rows[0].Activated = true;
  309. //ugr = this.ultraGrid1.ActiveRow;
  310. //if (ugr == null)
  311. //{
  312. // Util.MessageUtil.ShowTips("请选择需要保存的行");
  313. // return;
  314. //}
  315. //if (this.ultraGrid5.Rows.Count == 0)
  316. // return;
  317. //if (this.ultraGrid5.Rows.Count == 1)
  318. // this.ultraGrid5.Rows[0].Activated = true;
  319. //ugrc = this.ultraGrid5.ActiveRow;
  320. //if (ugrc == null)
  321. //{
  322. // Util.MessageUtil.ShowTips("请选择待冲减的行");
  323. // return;
  324. //}
  325. //string invoiceno = ugr.Cells["INVOICENO_ORG"].Value.ToString();
  326. //// "WEIGHT",
  327. //// "MONEY",
  328. //double money = Util.ConverObject.ConvertToDouble(ugr.Cells["MONEY_ORG"].Value);
  329. //double weight = Util.ConverObject.ConvertToDouble(ugr.Cells["WEIGHT"].Value);
  330. //double creditMny = Util.ConverObject.ConvertToDouble(ugrc.Cells["MONEY_ORG"].Value);
  331. //if (creditMny >= money)
  332. //{
  333. // Util.MessageUtil.ShowError("冲减金额必须小于货款");
  334. // return;
  335. //}
  336. //if (weight == 0)
  337. //{
  338. // Util.MessageUtil.ShowError("只能冲减货款");
  339. // return;
  340. //}
  341. //if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定冲减结算单?") == DialogResult.No) return;
  342. //double dlivPrice = (money - creditMny) / weight;
  343. //ArrayList list = new ArrayList();
  344. //string[] str = null;
  345. //string sub_seq = ugrc.Cells["SUB_SEQ"].Value.ToString();
  346. //foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrr in this.ultraGrid2.Rows)
  347. //{
  348. // double seqmoney = dlivPrice * Util.ConverObject.ConvertToDouble(ugrr.Cells["WEIGHT"].Value);
  349. // str = new string[] { invoiceno, ugrr.Cells["INVOICENO_SEQ_ORG"].Value.ToString(), dlivPrice + "",
  350. // seqmoney +"",sub_seq};
  351. // list.Add(str);
  352. //}
  353. //string errMsg = "";
  354. //this.slmBalanceInfo.Credit(list, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg);
  355. //if (errMsg.Length == 0)
  356. //{
  357. // Util.MessageUtil.ShowTips("操作成功");
  358. //}
  359. //this.Query();
  360. }
  361. private void Print()
  362. {
  363. string INVOICENO = "INVOICENO_ORG";
  364. string errMsg = "";
  365. List<string> list = new List<string>();
  366. if (this.ultraGrid1.Rows.Count == 0)
  367. return;
  368. if (this.ultraGrid1.Rows.Count == 1)
  369. this.ultraGrid1.Rows[0].Selected = true;
  370. this.ultraGrid1.ActiveRow.Selected = true;
  371. String sqlCondition = "";
  372. double money = 0;
  373. string isGreaterThanZero = "0";
  374. // 打印包含货款和独立的出库费 or 运费,这里因为模板不一样不能一起连打
  375. money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(this.ultraGrid1.Selected.Rows[0].Cells["MONEY_ORG"].Value);
  376. if (money != 0)
  377. {
  378. isGreaterThanZero = "0";
  379. }
  380. else
  381. {
  382. isGreaterThanZero = "1";
  383. }
  384. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  385. {
  386. money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["MONEY_ORG"].Value);
  387. if (money != 0)
  388. {
  389. if (isGreaterThanZero == "1")
  390. {
  391. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印");
  392. return;
  393. }
  394. }
  395. else
  396. {
  397. if (isGreaterThanZero == "0")
  398. {
  399. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印");
  400. return;
  401. }
  402. }
  403. sqlCondition += "\'" + ugr.Cells[INVOICENO].Value.ToString() + "\'" + ",";
  404. list.Add(ugr.Cells[INVOICENO].Value.ToString());
  405. }
  406. string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicketOrg.cpt&__bypagesize__=false" + "&invoiceno=";
  407. if (isGreaterThanZero == "1")
  408. {
  409. url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTransAndOutStockMnOrg.cpt&__bypagesize__=false" + "&invoiceno=";
  410. }
  411. sqlCondition = sqlCondition.Substring(1, sqlCondition.Length - 1);
  412. sqlCondition = sqlCondition.Substring(0, sqlCondition.Length - 2);
  413. url = url + sqlCondition;
  414. Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel
  415. fBug = new Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel(this.ob, url);
  416. fBug.AutoSize = true;
  417. fBug.Text = "打印结算单";
  418. fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  419. fBug.WindowState = FormWindowState.Maximized;
  420. fBug.Show();
  421. }
  422. private void PrintDetail()
  423. {
  424. string INVOICENO = "INVOICENO_ORG";
  425. string errMsg = "";
  426. List<string> list = new List<string>();
  427. if (this.ultraGrid1.Rows.Count == 0)
  428. return;
  429. if (this.ultraGrid1.Rows.Count == 1)
  430. this.ultraGrid1.Rows[0].Selected = true;
  431. this.ultraGrid1.ActiveRow.Selected = true;
  432. String sqlCondition = "";
  433. double money = 0;
  434. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  435. {
  436. sqlCondition += "\'" + ugr.Cells[INVOICENO].Value.ToString() + "\'" + ",";
  437. list.Add(ugr.Cells[INVOICENO].Value.ToString());
  438. }
  439. string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicketOrgAtta.cpt&__bypagesize__=false" + "&invoiceno=";
  440. sqlCondition = sqlCondition.Substring(1, sqlCondition.Length - 1);
  441. sqlCondition = sqlCondition.Substring(0, sqlCondition.Length - 2);
  442. url = url + sqlCondition;
  443. Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel
  444. fBug = new Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel(this.ob, url);
  445. fBug.AutoSize = true;
  446. fBug.Text = "打印结算单明细";
  447. fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  448. fBug.WindowState = FormWindowState.Maximized;
  449. fBug.Show();
  450. }
  451. private void PrintInvoice()
  452. {
  453. Print();
  454. return;
  455. string INVOICENO = "INVOICENO_ORG";
  456. List<string> list = new List<string>();
  457. if (this.ultraGrid1.Rows.Count == 0)
  458. return;
  459. if (this.ultraGrid1.Rows.Count == 1)
  460. this.ultraGrid1.Rows[0].Selected = true;
  461. this.ultraGrid1.ActiveRow.Selected = true;
  462. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  463. {
  464. list.Add(ugr.Cells[INVOICENO].Value.ToString());
  465. }
  466. DlgInvoicePrint print = null;
  467. print = new DlgInvoicePrint(this.ob);
  468. print.listInvoiceNo = list;
  469. print.isOrgInvoice = true;
  470. print.ShowDialog();
  471. }
  472. private DataSet GetTransMnyByInvoiceNo(string invoiceno)
  473. {
  474. string sql = @"select sum(a.money) money,sum(a.weight) weight,a.money_type,a.invoiceno_org
  475. from slm_balance_transmoney a where invoiceno_org = '{0}' and a.invoiceno_org is not null
  476. group by a.money_type,a.invoiceno_org";
  477. sql = string.Format(sql, invoiceno);
  478. DataSet ds = base.ExecuteReader(sql);
  479. return ds;
  480. }
  481. private void SetTransMoneyAndOutStockMoney()
  482. {
  483. if (this.dsInvoice == null || this.dsInvoice.Tables.Count == 0 || this.dsInvoice.Tables[0].Rows.Count == 0)
  484. return;
  485. foreach (DataRow dri in this.dsInvoice.Tables[0].Rows)
  486. {
  487. try
  488. {
  489. string invoiceno = dri[this.INVOICENO].ToString();
  490. DataSet ds = GetTransMnyByInvoiceNo(invoiceno);
  491. //DataSet ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoneyAndOutStockMoney(this.dateTimePicker1.Value,
  492. // this.dateTimePicker2.Value);
  493. if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
  494. continue;
  495. foreach (DataRow drd in ds.Tables[0].Rows)
  496. {
  497. if (drd["MONEY_TYPE"].ToString() == "运费")
  498. {
  499. dri["TRANSMNY"] = drd["MONEY"];
  500. }
  501. if (drd["MONEY_TYPE"].ToString() == "出库费")
  502. {
  503. dri["OUTSTOCKMNY"] = drd["MONEY"];
  504. }
  505. }
  506. }
  507. catch
  508. { }
  509. }
  510. this.dsInvoice.AcceptChanges();
  511. ClearGrid();
  512. }
  513. private Boolean IsCanBeUpdateWithDifferentPerson(string user)
  514. {
  515. if (user == CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName())
  516. {
  517. return true;
  518. }
  519. else
  520. {
  521. Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("只允许操作本人票据");
  522. return false;
  523. }
  524. }
  525. private void RollBackInvoiceNo()
  526. {
  527. if (this.ultraGrid1.Rows.Count == 0)
  528. return;
  529. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow;
  530. if (ugr == null)
  531. return;
  532. if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON_ORG"].Value.ToString()))
  533. return;
  534. string invoinceno = ugr.Cells[this.INVOICENO].Value.ToString();
  535. this.slmBalanceInfo.RollBaskInvoiceNoOrg(invoinceno, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName());
  536. ugr.Delete(false);
  537. this.ultraGrid1.UpdateData();
  538. }
  539. private string saleOrg_Corp = "120603";
  540. private string saleOrg_Gm = "120604";
  541. private string saleOrg_Gtm = "120605";
  542. private void Query()
  543. {
  544. dsInvoiceDetail = this.slmBalanceInfo.GeOrgtInvoiceSlmBalaneInfoByInvoiceBeginDateAndEndDate(this.dateTimePicker1.Value,
  545. this.dateTimePicker2.Value);
  546. //if (this.textBox3.Text.Length > 0)
  547. //{
  548. // dsInvoiceDetail = Util.UtilDataSet.GetDataSetWithRowFilterWithApproximateMatch(dsInvoiceDetail, "ORD_NO", this.textBox3.Text.Trim());
  549. //}
  550. // 只显示首次受票单位为国贸,钢贸,集团的数据
  551. try
  552. {
  553. dsInvoiceDetail = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "FST_DRAWEE_UNIT",
  554. new string[] { saleOrg_Corp, saleOrg_Gm, saleOrg_Gtm }
  555. );
  556. }
  557. catch
  558. { }
  559. dsInvoiceDetail = base.GetDataSetByFilterDeptId(dsInvoiceDetail);
  560. //if ("120504".Equals(CustomInfo))
  561. dsInvoiceDetail = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "supply_unit", CustomInfo);
  562. // 只显示未结转的
  563. dsInvoiceDetail = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "INVOICE_STS", "0");
  564. DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(dsInvoiceDetail, new List<string>(GetGroupByName()),
  565. new List<string>(GetShowName()), new List<string>(GetStaticName()));
  566. Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoice, ds);
  567. SetTransMoneyAndOutStockMoney();
  568. QueryTransMny();
  569. ClearGrid();
  570. }
  571. private void ClearGrid()
  572. {
  573. this.dsInvoiceSeq.Clear();
  574. this.dsInvoiceList.Clear();
  575. }
  576. private void QueryTransMny1()
  577. {
  578. DataSet ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoney(this.dateTimePicker1.Value,
  579. this.dateTimePicker2.Value);
  580. if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
  581. return;
  582. ds.Tables[0].TableName = this.dsInvoice.Tables[0].TableName;
  583. this.dsInvoice.Merge(ds);
  584. this.dsInvoice.AcceptChanges();
  585. }
  586. private void QuryGrid2(string invoiceNo)
  587. {
  588. DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceNo);
  589. DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(ds2,
  590. new List<string>(this.GetGrid2GroupByCol()),
  591. new List<string>(this.GetGrid2ShowCol()),
  592. new List<string>(this.GetGrid2StaticCol()));
  593. Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceSeq, ds);
  594. }
  595. private void QueryGrid3(String invoiceno, string invoiceno_seq)
  596. {
  597. DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceno);
  598. DataSet ds3 = Util.UtilDataSet.GetDataSetWithRowFilter(ds2, this.INVOICENO_SEQ, invoiceno_seq);
  599. Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceList, ds3);
  600. }
  601. private string[] GetGroupByName()
  602. {
  603. return new string[]
  604. {
  605. "INVOICENO_ORG",
  606. // "FST_DRAWEE_UNIT",
  607. // "BUYERNAME",
  608. "FORECORPCODE"
  609. // "ORD_NO"
  610. };
  611. }
  612. private string[] GetShowName()
  613. {
  614. return new string[]
  615. {
  616. //"REMARK" ,
  617. // "PRICE_ORG",
  618. "REALINVOICENO_ORG",
  619. "INVOICEPERSON_ORG",
  620. "INVOICEDATE_ORG",
  621. "FST_DRAWEE_UNIT","REALINVOICENO_DATE_ORG"
  622. };
  623. }
  624. private string[] GetStaticName()
  625. {
  626. return new string[]
  627. {
  628. "WEIGHT",
  629. "MONEY_ORG"
  630. };
  631. }
  632. private string[] GetGrid1DataStruct()
  633. {
  634. return new string[]
  635. {
  636. "INVOICENO_ORG",
  637. "REALINVOICENO_ORG",
  638. // "REALINVOICENO_DATE_ORG",
  639. "FST_DRAWEE_UNIT",
  640. // "REALINVOICENO",
  641. // "BUYERNAME",
  642. "WEIGHT",
  643. "MONEY_ORG",
  644. "TRANSMNY",
  645. "OUTSTOCKMNY",
  646. // "TRANSMONEYQC",
  647. //"TRANSMONEYSY1",
  648. //"TRANSMONETRAIN",
  649. // "HOISTINGFEE",
  650. // "ORD_NO",
  651. // "REMARK",
  652. "FORECORPCODE",
  653. "INVOICEPERSON_ORG",
  654. "INVOICEDATE_ORG"
  655. }
  656. ;
  657. }
  658. private Hashtable GetColumnAndCaption()
  659. {
  660. return StaticData.TbColumnAndCaption.GetColumnAndCaption();
  661. Hashtable hs = new Hashtable();
  662. hs.Add("WEIGHT", "重量");
  663. hs.Add("INVOICENO", "结算单号");
  664. hs.Add("FORECORPCODE", "子公司");
  665. hs.Add("SHIPNO", "船号");
  666. hs.Add("TRANSMONEYQC", "汽运费");
  667. hs.Add("TRANSMONEYSY1", "船运费");
  668. hs.Add("TRANSMONETRAIN", "火运费");
  669. hs.Add("HOISTINGFEE", "吊装费");
  670. hs.Add("PLY", "厚/直径/壁厚");
  671. hs.Add("WIDTH", "宽/外径");
  672. hs.Add("ORD_NO", "合同号");
  673. hs.Add("BUYERNAME", "结算单位名称");
  674. hs.Add("BUYERCODE", "结算单位名称");
  675. hs.Add("FST_DRAWEE_UNIT", "首次受票人");
  676. hs.Add("STATIONCODE", "到站");
  677. hs.Add("MONEY_ORG", "金额");
  678. hs.Add("PRICE_ORG", "单价");
  679. hs.Add("INVOICENO_ORG", "结算单号");
  680. hs.Add("INVOICENO_SEQ_ORG", "序号");
  681. hs.Add("INVOICEPERSON_ORG", "编单人");
  682. hs.Add("INVOICENO_SEQ_ORG", "编单时间");
  683. return hs;
  684. }
  685. protected override Hashtable GetGridColumnLength()
  686. {
  687. return StaticData.TbColumnAndCaption.GetDataSetColumnLength();
  688. }
  689. private string[] GetGrid5DataStruct()
  690. {
  691. return new string[]
  692. {
  693. "SUBTCT_TYP",
  694. "SUBTCT_MOD",
  695. "SUBTCT_MNY",
  696. "SUBTCT_DSP",
  697. "DCL_ID",
  698. "DCL_DTIME",
  699. "REV_ID",
  700. "REV_DTIME",
  701. "REV_DSP"
  702. }
  703. ;
  704. }
  705. private string[] GetGrid2DataStruct()
  706. {
  707. return new string[]
  708. {
  709. "INVOICENO_ORG",
  710. "INVOICENO_SEQ_ORG",
  711. "ORD_NO",
  712. "ORD_SEQ",
  713. "PRICE_ORG",
  714. "WEIGHT",
  715. "MONEY_ORG",
  716. "SPETKEY",
  717. "STEELCODEKEY",
  718. "CATEGORY",
  719. "SPEC_ABBSYMNAME",
  720. "STD_STYLE_DESC",
  721. "MODEL_DESC",
  722. "ASKPLAN_ID"
  723. }
  724. ;
  725. }
  726. private string[] GetGrid2GroupByCol()
  727. {
  728. return new string[] { "INVOICENO_ORG", "INVOICENO_SEQ_ORG", "ASKPLAN_ID" };
  729. }
  730. private string[] GetGrid2ShowCol()
  731. {
  732. return GetGrid2DataStruct();
  733. }
  734. private string[] GetGrid2StaticCol()
  735. {
  736. return new string[] { "WEIGHT",
  737. "MONEY_ORG" };
  738. }
  739. private string[] GetGrid3DataStruct()
  740. {
  741. return new string[]
  742. {
  743. "SPETKEY",
  744. "STEELCODEKEY",
  745. "QUANTITY",
  746. "WEIGHT",
  747. "MONEY_ORG",
  748. "TRAINWAGON",
  749. // "SHIPNO",
  750. // "DOCKCODE",
  751. "STATIONCODE",
  752. }
  753. ;
  754. }
  755. private string[] GetGrid4DataStruct()
  756. {
  757. return new string[]
  758. {
  759. "SUBTCT_TYP",
  760. "SUBTCT_MOD",
  761. "SUBTCT_MNY",
  762. "SUBTCT_DSP",
  763. "SUBTCT_TIME"
  764. }
  765. ;
  766. }
  767. private string BUYERCODE = "BUYERCODE";
  768. private string ORD_NO = "ORD_NO";
  769. private string ORD_SEQ = "ORD_SEQ";
  770. private string ORD_LN_DLY = "ORD_LN_DLY";
  771. private string ASKPLAN_ID = "ASKPLAN_ID";
  772. private string ASKPLAN_ID_SEQ = "ASKPLAN_ID_SEQ";
  773. private string SPETKEY = "SPETKEY";
  774. private string STEELCODEKEY = "STEELCODEKEY";
  775. private string MONEY = "MONEY_ORG";
  776. private string WEIGHT = "WEIGHT";
  777. private string PRICE = "PRICE_ORG";
  778. private string BALANCESTATUS = "BALANCESTATUS";
  779. private string ADJUSTPRICEREASON = "ADJUSTPRICEREASON";
  780. private string INVOICENO = "INVOICENO_ORG";
  781. private string INVOICENO_SEQ = "INVOICENO_SEQ_ORG";
  782. private string BALANCESTATUS_INIT = "0";
  783. private string BALANCESTATUS_AFFRIM = "1";
  784. private string BALANCESTATUS_INVOINCE = "2";
  785. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  786. {
  787. if (this.ultraGrid1.Rows.Count == 0)
  788. return;
  789. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  790. if (this.ultraGrid1.Rows.Count == 1)
  791. ugr = this.ultraGrid1.Rows[0];
  792. else
  793. ugr = this.ultraGrid1.ActiveRow;
  794. string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
  795. this.QuryGrid2(invoiceno);
  796. }
  797. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  798. {
  799. if (this.ultraGrid2.Rows.Count == 0)
  800. return;
  801. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  802. if (this.ultraGrid2.Rows.Count == 1)
  803. ugr = this.ultraGrid2.Rows[0];
  804. else
  805. ugr = this.ultraGrid2.ActiveRow;
  806. string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
  807. string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString();
  808. this.QueryGrid3(invoiceno, invoicenoseq);
  809. }
  810. private void button3_Click(object sender, EventArgs e)
  811. {
  812. this.PrintInvoice();
  813. }
  814. private void ultraGrid1_AfterRowActivate_1(object sender, EventArgs e)
  815. {
  816. if (this.ultraGrid1.Rows.Count == 0)
  817. return;
  818. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  819. if (this.ultraGrid1.Rows.Count == 1)
  820. ugr = this.ultraGrid1.Rows[0];
  821. else
  822. ugr = this.ultraGrid1.ActiveRow;
  823. string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
  824. this.QuryGrid2(invoiceno);
  825. }
  826. private void ultraGrid2_AfterRowActivate_1(object sender, EventArgs e)
  827. {
  828. if (this.ultraGrid2.Rows.Count == 0)
  829. return;
  830. Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null;
  831. if (this.ultraGrid2.Rows.Count == 1)
  832. ugr = this.ultraGrid2.Rows[0];
  833. else
  834. ugr = this.ultraGrid2.ActiveRow;
  835. string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString();
  836. string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString();
  837. this.QueryGrid3(invoiceno, invoicenoseq);
  838. }
  839. }
  840. }