| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Collections;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Infragistics.Win.UltraWinGrid;
- using Infragistics.Win;
- using SaleBusiness = Core.StlMes.Client.Sale.BLL.SaleBusinessMgt;
- namespace Core.StlMes.Client.Sale.UI.Balance.BalanceAccount
- {
- public partial class DlgInvoicePrint : Form
- {
- private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo slmBalanceInfo = null;
- public DlgInvoicePrint(CoreFS.CA06.OpeBase ob)
- {
- this._ob = ob;
- InitializeComponent();
- }
- private CoreFS.CA06.OpeBase _ob = null;
- public List<string> listInvoiceNo = null;
- public Boolean isOrgInvoice = false;
- private int _RowCount = 0;
- private void DlgInvoicePrint_Load(object sender, EventArgs e)
- {
- this.MaximizeBox = false;
- this.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False;
- this.ultraGrid1.DisplayLayout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.None;
- slmBalanceInfo = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo(this._ob);
- if (!isOrgInvoice)
- this.InitData();
- else
- this.InitDataOrg();
- }
- /// <summary>
- /// 设置首次结算单位
- /// </summary>
- /// <returns></returns>
- private Hashtable GetFST_DRAWEE_UNIT()
- {
- Hashtable hs = new Hashtable();
- //天津钢管集团股份有限公司
- hs.Add("120603", new CompanyAddressAndTaxNum("天津钢管集团股份有限公司", " ", " ", " "));
- hs.Add("120604", new CompanyAddressAndTaxNum("天津钢管钢铁贸易有限公司", " ", " ", " "));
- hs.Add("120605", new CompanyAddressAndTaxNum("天津钢管国际贸易有限公司", " ", " ", " "));
- hs.Add("120606", new CompanyAddressAndTaxNum("天津钢管制造有限公司", " ", " ", " "));
- return hs;
- }
- class CompanyAddressAndTaxNum
- {
- private string _BUYERNAME = "";
- private string _TAXNO = "";
- private string _ADDRESS = "";
- private string _ACCOUNT = "";
- public CompanyAddressAndTaxNum(string buyername, string taxno, string address, string account)
- {
- this._BUYERNAME = buyername;
- this._TAXNO = taxno;
- this._ADDRESS = address;
- this._ACCOUNT = account;
- }
- public string BUYERNAME
- {
- get
- {
- return this._BUYERNAME;
- }
- set
- {
- this._BUYERNAME = value;
- }
- }
- public string TAXNO
- {
- get
- {
- return this._TAXNO;
- }
- set
- {
- this._TAXNO = value;
- }
- }
- public string ADDRESS
- {
- get
- {
- return this._ADDRESS;
- }
- set
- {
- this._ADDRESS = value;
- }
- }
- public string ACCOUNT
- {
- get
- {
- return this._ACCOUNT;
- }
- set
- {
- this._ACCOUNT = value;
- }
- }
- }
- private void InitDataOrg()
- {
- string INVOICENOZ = "INVOICENOZ";
- string INVOICENO = "INVOICENO";
- string firstInviceCmp = "FST_DRAWEE_UNIT";
- string firstInviceCmpValue = "";
- DataSet ds = this.slmBalanceInfo.GetInvoicedSlmBalanceInfoByListInvoiceNoOrg(listInvoiceNo);
- if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
- return;
- Hashtable hsCmp = GetFST_DRAWEE_UNIT();
- Hashtable hs = new Hashtable();
- Hashtable hsdetail = new Hashtable();
- System.Collections.Generic.List<DataRow> listrow = new System.Collections.Generic.List<DataRow>();
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- // string invoiceno = dr[INVOICENO].ToString();
- if (dr[firstInviceCmp].ToString() == "120603" || dr[firstInviceCmp].ToString() == "120604" || dr[firstInviceCmp].ToString() == "120605")
- {
- string invoicenoz = dr[INVOICENOZ].ToString();
- if (hs.ContainsKey(invoicenoz))
- {
- listrow = (List<DataRow>)hs[invoicenoz];
- hs.Remove(invoicenoz);
- }
- else
- {
- listrow = new List<DataRow>();
- }
- if (!listrow.Contains(dr))
- {
- listrow.Add(dr);
- }
- hs.Add(invoicenoz, listrow);
- }
- }
- Hashtable hsrows = new Hashtable();
- foreach (string s in hs.Keys)
- {
- listrow = (List<DataRow>)hs[s];
- DataRow ugrP = listrow[0];
- int rowIndex = 0;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugrN = null; //新行
- DataRow ugrC = null;
- for (int j = 0; j < listrow.Count; j++)
- {
- if (j == 8) rowIndex = 0;
- ugrC = listrow[j];
- if (rowIndex == 0)
- {
- ugrN = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
- for (int k = 0; k < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; k++)
- {
- ugrN.Cells[k].Value = this.ultraGrid1.DisplayLayout.Bands[0].Columns[k].DefaultCellValue;
- }
- // 首次受票人
- firstInviceCmpValue = ugrP[firstInviceCmp].ToString();
- // UnboundColumn36 buyername
- //UnboundColumn37 taxno
- // UnboundColumn38 address and phone
- // UnboundColumn39 bank account
-
- CompanyAddressAndTaxNum cmp = (CompanyAddressAndTaxNum)hsCmp["120606"];
- ugrN.Cells["UnboundColumn36"].Value = cmp.BUYERNAME;
- ugrN.Cells["UnboundColumn37"].Value = cmp.TAXNO;
- ugrN.Cells["UnboundColumn38"].Value = cmp.ADDRESS;
- ugrN.Cells["UnboundColumn39"].Value = cmp.ACCOUNT;
- if (hsCmp.Contains(ugrP["BUYERCODE"].ToString()))
- {
- CompanyAddressAndTaxNum cmp1 = (CompanyAddressAndTaxNum)hsCmp[ugrP["BUYERCODE"].ToString()];
- ugrN.Cells[2].Value = cmp1.BUYERNAME;
- ugrN.Cells[3].Value = cmp1.TAXNO;
- ugrN.Cells[4].Value = cmp1.ADDRESS;
- ugrN.Cells[5].Value = cmp1.ACCOUNT;
-
- }
- ugrN.Cells[0].Value = ugrC["INVOICENO"].ToString().Split('.')[0];
- ugrN.Cells[1].Value = System.DateTime.Today.ToShortDateString();
- // ugrN.Cells[2].Value = ugrP["BUYERNAME"];
- // ugrN.Cells[3].Value = ugrP["TAXNO"];
- // ugrN.Cells[4].Value = ugrP["ADDRESS"];
- // ugrN.Cells[5].Value = ugrP["ACCOUNT"];
- ugrN.Cells[74].Value = ugrC["AUDITINGPERSON"];
- ugrN.Cells[75].Value = ugrC["INVOICEPERSON"];
- ugrN.Cells[72].Value = ugrC["REMARK"];
- }
- ugrN.Cells[6 + 8 * rowIndex].Value = ugrC["CATEGORY"] + " " + ugrC["STEELCODE"];
- ugrN.Cells[7 + 8 * rowIndex].Value = ugrC["SPEC"];
- ugrN.Cells[8 + 8 * rowIndex].Value = "吨";
- ugrN.Cells[9 + 8 * rowIndex].Value = ugrC["WEIGHT"];
- ugrN.Cells[10 + 8 * rowIndex].Value = ugrC["PRICE"];
- ugrN.Cells[11 + 8 * rowIndex].Value = ugrC["MONEY"].ToString();
- // ugrN.Cells[11 + 8 * rowIndex].Value = System.Math.Round(GetNoNullDec(ugrC["MONEY"]) / 1.16, 2);
- // ugrN.Cells[12 + 8 * rowIndex].Value = "17%";
- // ugrN.Cells[13 + 8 * rowIndex].Value = ugrC["TAXMONEY"];
- if (rowIndex == 7 || j == listrow.Count - 1)
- {
- double fl1 = GetTotalMoney(ugrN);
- double fl2 = 0;
- double fl3 = fl1 + fl2;
- ugrN.Cells["UnboundColumn26"].Value = "¥" + Convert.ToString(fl1);
- // ugrN.Cells["UnboundColumn28"].Value = "¥" + Convert.ToString(fl2);
- ugrN.Cells[70].Value = "¥" + Util.ConverObject.ConvertNumberToChinese(Convert.ToString((int)(Math.Round(fl3 * 100))));
- ugrN.Cells[71].Value = "¥" + Convert.ToString(fl3);
- ugrN.Cells["UnboundColumn24"].Value = this.GetTotalWeight(ugrN);
- }
- rowIndex++;
- }
- }
- this.ultraGrid1.UpdateData();
- _RowCount = this.ultraGrid1.Rows.Count;
- if (this.ultraGrid1.Rows.Count > 0) this.ultraGrid1.Rows[0].Activate();
- this.ultraMaskedEdit2.InputMask = string.Format(@"nnn \o\f\ \{0}", _RowCount.ToString());
- this.ultraMaskedEdit2.Text = string.Format("1 of {0}", _RowCount.ToString());
- }
- private void InitData()
- {
- string INVOICENOZ = "INVOICENOZ";
- string INVOICENO = "INVOICENO";
- string firstInviceCmp = "FST_DRAWEE_UNIT";
- string firstInviceCmpValue = "";
- DataSet ds = this.slmBalanceInfo.GetInvoicedSlmBalanceInfoByListInvoiceNo(listInvoiceNo);
- if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
- return;
- Hashtable hsCmp = GetFST_DRAWEE_UNIT();
- Hashtable hs = new Hashtable();
- Hashtable hsdetail = new Hashtable();
- System.Collections.Generic.List<DataRow> listrow = new System.Collections.Generic.List<DataRow>();
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- // string invoiceno = dr[INVOICENO].ToString();
- string invoicenoz = dr[INVOICENOZ].ToString();
- if (hs.ContainsKey(invoicenoz))
- {
- listrow = (List<DataRow>)hs[invoicenoz];
- hs.Remove(invoicenoz);
- }
- else
- {
- listrow = new List<DataRow>();
- }
- if (!listrow.Contains(dr))
- {
- listrow.Add(dr);
- }
- hs.Add(invoicenoz, listrow);
- }
- Hashtable hsrows = new Hashtable();
- foreach (string s in hs.Keys)
- {
- listrow = (List<DataRow>)hs[s];
- DataRow ugrP = listrow[0];
- int rowIndex = 0;
- Infragistics.Win.UltraWinGrid.UltraGridRow ugrN = null; //新行
- DataRow ugrC = null;
- for (int j = 0; j < listrow.Count; j++)
- {
- if (j == 8) rowIndex = 0;
- ugrC = listrow[j];
- if (rowIndex == 0)
- {
- ugrN = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
- for (int k = 0; k < this.ultraGrid1.DisplayLayout.Bands[0].Columns.Count; k++)
- {
- ugrN.Cells[k].Value = this.ultraGrid1.DisplayLayout.Bands[0].Columns[k].DefaultCellValue;
- }
- // 首次受票人
- firstInviceCmpValue = ugrP[firstInviceCmp].ToString();
- // UnboundColumn36 buyername
- //UnboundColumn37 taxno
- // UnboundColumn38 address and phone
- // UnboundColumn39 bank account
- if (hsCmp.ContainsKey(firstInviceCmpValue))
- {
- CompanyAddressAndTaxNum cmp = (CompanyAddressAndTaxNum)hsCmp[firstInviceCmpValue];
- ugrN.Cells["UnboundColumn36"].Value = cmp.BUYERNAME;
- ugrN.Cells["UnboundColumn37"].Value = cmp.TAXNO;
- ugrN.Cells["UnboundColumn38"].Value = cmp.ADDRESS;
- ugrN.Cells["UnboundColumn39"].Value = cmp.ACCOUNT;
- }
- else
- {
- continue;
- }
- ugrN.Cells[0].Value = ugrC["INVOICENO"].ToString().Split('.')[0];
- ugrN.Cells[1].Value = System.DateTime.Today.ToShortDateString();
- ugrN.Cells[2].Value = ugrP["BUYERNAME"];
- ugrN.Cells[3].Value = ugrP["TAXNO"];
- ugrN.Cells[4].Value = ugrP["ADDRESS"];
- ugrN.Cells[5].Value = ugrP["ACCOUNT"];
- ugrN.Cells[74].Value = ugrC["AUDITINGPERSON"];
- ugrN.Cells[75].Value = ugrC["INVOICEPERSON"];
- ugrN.Cells[72].Value = ugrC["REMARK"];
- }
- ugrN.Cells[6 + 8 * rowIndex].Value = ugrC["CATEGORY"] + " " + ugrC["STEELCODE"];
- ugrN.Cells[7 + 8 * rowIndex].Value = ugrC["SPEC"];
- ugrN.Cells[8 + 8 * rowIndex].Value = "吨";
- ugrN.Cells[9 + 8 * rowIndex].Value = ugrC["WEIGHT"];
- ugrN.Cells[10 + 8 * rowIndex].Value = ugrC["PRICE"];
- // ugrN.Cells[11 + 8 * rowIndex].Value = System.Math.Round(GetNoNullDec(ugrC["MONEY"]) / 1.16, 2);
- ugrN.Cells[11 + 8 * rowIndex].Value = ugrC["MONEY"].ToString();
- // ugrN.Cells[12 + 8 * rowIndex].Value = "17%";
- // ugrN.Cells[13 + 8 * rowIndex].Value = ugrC["TAXMONEY"];
- if (rowIndex == 7 || j == listrow.Count - 1)
- {
- double fl1 = GetTotalMoney(ugrN);
- // float fl2 = GetTotalTax(fl1);
- double fl2 = 0;
- double fl3 = fl1 + fl2;
- ugrN.Cells["UnboundColumn26"].Value = "¥" + Convert.ToString(fl1);
- // ugrN.Cells["UnboundColumn28"].Value = "¥" + Convert.ToString(fl2);
- ugrN.Cells[70].Value = "¥" + Util.ConverObject.ConvertNumberToChinese(Convert.ToString((int)(Math.Round(fl3 * 100))));
- ugrN.Cells[71].Value = "¥" + Convert.ToString(fl3);
- ugrN.Cells["UnboundColumn24"].Value = this.GetTotalWeight(ugrN);
- }
- rowIndex++;
- }
- }
- this.ultraGrid1.UpdateData();
- _RowCount = this.ultraGrid1.Rows.Count;
- if (this.ultraGrid1.Rows.Count > 0) this.ultraGrid1.Rows[0].Activate();
- this.ultraMaskedEdit2.InputMask = string.Format(@"nnn \o\f\ \{0}", _RowCount.ToString());
- this.ultraMaskedEdit2.Text = string.Format("1 of {0}", _RowCount.ToString());
- }
- private float GetNoNullDec(object obj)
- {
- if (obj == null || obj == DBNull.Value) return 0;
- try
- {
- return Convert.ToSingle(obj);
- }
- catch
- {
- return 0;
- }
- }
- private double GetTotalMoney(Infragistics.Win.UltraWinGrid.UltraGridRow ugr)
- {
- double fl = 0;
- double fl1 = 0;
- for (int i = 0; i < 8; i++)
- {
- if (ugr.Cells[11 + 8 * i].Value == null) continue;
- try
- {
- fl1 = Convert.ToDouble(ugr.Cells[11 + 8 * i].Value);
- }
- catch
- {
- fl1 = 0;
- }
- fl += fl1;
- }
- return fl;
- }
- private float GetTotalWeight(Infragistics.Win.UltraWinGrid.UltraGridRow ugr)
- {
- float fl = 0;
- float fl1 = 0;
- for (int i = 0; i < 8; i++)
- {
- if (ugr.Cells[11 + 8 * i].Value == null) continue;
- try
- {
- fl1 = Convert.ToSingle(ugr.Cells[9 + 8 * i].Value);
- }
- catch
- {
- fl1 = 0;
- }
- fl += fl1;
- }
- return fl;
- }
- private float GetTotalTax(float fl)
- {
- float fl1 = (float)0.13;
- fl = fl * fl1;
- return fl;
- }
- private void Init()
- {
- Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
- ugr.Cells["UnboundColumn5"].Value = "开票日期";
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.OK;
- this.ultraPrintPreviewDialog1.ShowDialog();
- }
- private void ultraMaskedEdit2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- int min = (int)this.ultraMaskedEdit2.MinValue;
- int max = (int)this.ultraMaskedEdit2.MaxValue;
- int newValue = min;
- EditorWithMask maskEdit = e.Button.Editor as EditorWithMask;
- try
- {
- string maskText = maskEdit.GetText(Infragistics.Win.UltraWinMaskedEdit.MaskMode.Raw);
- if (!Convert.IsDBNull(maskText))
- newValue = int.Parse(maskText);
- }
- catch { }
- switch (e.Button.Key)
- {
- case "First":
- newValue = min;
- break;
- case "Last":
- newValue = max;
- break;
- case "Next":
- newValue++;
- break;
- case "Previous":
- newValue--;
- break;
- }
- if (newValue < 1)
- newValue = 1;
- else if (newValue > _RowCount)
- newValue = _RowCount;
- e.Button.Editor.Value = newValue;
- this.ultraGrid1.Rows[newValue - 1].Activate();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- Util.UtilUltraGrid.ExportGridDataToExcel(this.Text, this.ultraGrid1);
- }
- }
- }
|