FrmBalanceInvoceMgt.cs 40 KB

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