using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; using System.Collections; using System.Reflection; using CoreFS.CA06; namespace Core.StlMes.Client.Sale.UI.Balance.BalanceAccount { public partial class FrmBalanceInvoceMgt : Core.StlMes.Client.Sale.Common.FrmStyleBase.FrmUIBase { public FrmBalanceInvoceMgt() { InitializeComponent(); } private DataSet dsInvoice = new DataSet(); private DataSet dsInvoiceDetail = null; private DataSet dsInvoiceSeq = new DataSet(); private DataSet dsInvoiceList = new DataSet(); private DataSet dsMnyCredit = new DataSet(); private DataSet dsCreditResult = new DataSet(); private void initDataSource() { dsInvoice = base.GetDataSetByColumnName(this.GetGrid1DataStruct(), null, GetColumnAndCaption()); this.ultraGrid1.DataSource = dsInvoice; dsInvoiceSeq = base.GetDataSetByColumnName(this.GetGrid2DataStruct(), null, GetColumnAndCaption()); this.ultraGrid2.DataSource = dsInvoiceSeq; dsInvoiceList = base.GetDataSetByColumnName(this.GetGrid3DataStruct(), null, GetColumnAndCaption()); this.ultraGrid3.DataSource = dsInvoiceList; dsMnyCredit = base.GetDataSetByColumnName(this.GetGrid5DataStruct(), null, GetGrid5DataSetColumnCaption()); this.ultraGrid5.DataSource = dsMnyCredit; dsCreditResult = base.GetDataSetByColumnName(this.GetGrid4DataStruct(), null, GetGrid5DataSetColumnCaption()); this.ultraGrid4.DataSource = dsCreditResult; } private void HiddenColumn() { try { this.ultraGrid1.DisplayLayout.Bands[0].Columns["CUSTOMER_NO"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["SALE_AREA_NO"].Hidden = true; // this.ultraGrid1.DisplayLayout.Bands[0].Columns["FORECORPCODE"].Hidden = true; this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO].Hidden = true; this.ultraGrid2.DisplayLayout.Bands[0].Columns[this.INVOICENO_SEQ].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["BUYERCODE"].Hidden = true; this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["CREATE_DEPT"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["STATUS_CD"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["INVOICENO"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["INVOICENO_DATE"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["FORECORPCODE"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["MONEY_TYPE"].Hidden = true; // this.ultraGrid5.DisplayLayout.Bands[0].Columns["MONEY"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["SUB_SEQ"].Hidden = true; this.ultraGrid5.DisplayLayout.Bands[0].Columns["BUYERCODE"].Hidden = true; } catch { } } private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo slmBalanceInfo = null; private Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceMnysubt slmBalanceMnysubt = null; private void FrmBalanceInvoceMgt_Load(object sender, EventArgs e) { // this.dateTimePicker1.Value = System.DateTime.Now.AddMonths(-1); slmBalanceInfo = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceInfo(this.ob); slmBalanceMnysubt = new Core.StlMes.Client.Sale.BLL.SaleBusinessMgt.Balance.SlmBalanceMnysubt(this.ob); initDataSource(); base.SetGridStyle(ref this.ultraGrid1, ref this.ultraGrid5, ref this.ultraGrid2, ref this.ultraGrid3, ref this.ultraGrid4); InitGrid(); HiddenColumn(); } protected override List GetNumberColumn() { return new List(new string[] { "SEND_NUM", "MONEY", "WEIGHT", "QUANTITY", "ACT_WGT", "OUTSTOCKMNY", "TRANSMNY", "PRICE", "PRICE_ORG", "MONEY_ORG", }); } protected Hashtable GetGrid5DataSetColumnCaption() { Hashtable hs = new Hashtable(); hs.Add("SUB_SEQ", "冲减单号"); hs.Add("BUYERCODE", "冲减客户"); hs.Add("FORECORPCODE", "销售组织"); hs.Add("MONEY", "冲减金额"); hs.Add("MONEY_TYPE", "冲减类型"); hs.Add("MONEY_TYPE_DESC", "冲减类型"); hs.Add("AFFRIM_NAME", "确认人"); hs.Add("CREATE_DEPT", "创建部门"); hs.Add("BUYERNAME", "冲减客户"); hs.Add("AFFRIM_TIME", "确认时间"); hs.Add("INVOICENO_DATE", "冲减时间"); return hs; } private void QueryGridFine(string buyercode, string forecode) { try { DataSet ds = slmBalanceMnysubt.GetCanBeUsedSlmBalanceMnySubtByBuyerCodeAndForeCode(buyercode, forecode); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsMnyCredit, ds); } catch { } } private void QueryGridFour(string invoiceNO) { try { DataSet ds = slmBalanceMnysubt.GetSlmBalanceMnySubtByInvoiceNo(invoiceNO); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsCreditResult, ds); } catch { } } private void InitGrid() { System.Drawing.Color color = System.Drawing.Color.FromArgb(255, 255, 128); try { this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO"].CellAppearance.BackColor = color; this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_ORG"].CellAppearance.BackColor = color; // this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DateTime; // this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].CellActivation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit; //this.ultraGrid1.DisplayLayout.Bands[0].Columns["REALINVOICENO_DATE"].CellAppearance.BackColor = color; } catch { } } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": { this.Query(); break; } case "RollInv": { this.RollBackInvoiceNo(); break; } case "Exit": { this.Close(); break; } case "Save": { this.SaveRealInvoiceNo(); break; } case "PrintInvoice": { this.PrintInvoice(); break; } case "Print": { PrintInvoicerpt(); break; } case "Credit": { this.Credit(); break; } case "Export": { Core.StlMes.Client.Sale.Util.UtilUltraGrid.ExportGridDataToExcel(this.Text, this.ultraGrid1); break; } case "AddTrans": { InvoiceSignalTransMoney(); break; } } } public override void Update() { return; this.ultraGrid1.UpdateData(); if (this.ultraGrid1.Rows.Count == 0) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; ugr.Selected = true; string invoiceno = ""; string realdate = ""; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugs in this.ultraGrid1.Selected.Rows) { invoiceno = ugs.Cells[this.INVOICENO].Value.ToString(); DateTime dt = Convert.ToDateTime( ugr.Cells["REALINVOICENO_DATE"].Value); realdate = dt.ToString("yyyyMMddHHmmss"); } } private void InvoiceSignalTransMoney() { DlgBox.DlgSelectInvoceTransMnyAndOutStockMny dlg = new Core.StlMes.Client.Sale.UI.Balance.DlgBox.DlgSelectInvoceTransMnyAndOutStockMny(this.ob); dlg.ShowDialog(); ArrayList arpk = new ArrayList(); string errMsg = ""; if (dlg.DialogResult == DialogResult.OK) { arpk = dlg.Tranpk; if (arpk.Count == 0) return; this.slmBalanceInfo.MakeLastInvoiceForTransMnyAndOutStockMoney(arpk, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length == 0) { Core.StlMes.Client.Sale.Util.MessageUtil.ShowTips("操作成功"); this.Query(); } } } /// /// 冲减 /// private void Credit() { Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; Infragistics.Win.UltraWinGrid.UltraGridRow ugrc = null; if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid2.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) this.ultraGrid1.Rows[0].Activated = true; ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { Util.MessageUtil.ShowTips("请选择需要保存的行"); return; } if (this.ultraGrid5.Rows.Count == 0) return; if (this.ultraGrid5.Rows.Count == 1) this.ultraGrid5.Rows[0].Activated = true; ugrc = this.ultraGrid5.ActiveRow; if (ugrc == null) { Util.MessageUtil.ShowTips("请选择待冲减的行"); return; } string invoiceno = ugr.Cells["INVOICENO"].Value.ToString(); // "WEIGHT", // "MONEY", double money = Util.ConverObject.ConvertToDouble( ugr.Cells["MONEY"].Value); double weight = Util.ConverObject.ConvertToDouble(ugr.Cells["WEIGHT"].Value); double creditMny = Util.ConverObject.ConvertToDouble(ugrc.Cells["MONEY"].Value); if (creditMny >= money) { Util.MessageUtil.ShowError("冲减金额必须小于货款"); return; } if (weight == 0) { Util.MessageUtil.ShowError("只能冲减货款"); return; } if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定冲减结算单?") == DialogResult.No) return; double dlivPrice = (money - creditMny) / weight; ArrayList list = new ArrayList(); string[] str = null; string sub_seq = ugrc.Cells["SUB_SEQ"].Value.ToString(); foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugrr in this.ultraGrid2.Rows) { double seqmoney = dlivPrice * Util.ConverObject.ConvertToDouble(ugrr.Cells["WEIGHT"].Value); str = new string[] { invoiceno, ugrr.Cells["INVOICENO_SEQ"].Value.ToString(), dlivPrice + "", seqmoney +"",sub_seq}; list.Add(str); } string errMsg = ""; this.slmBalanceInfo.Credit(list, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length == 0) { Util.MessageUtil.ShowTips("操作成功"); } this.Query(); } private void SaveRealInvoiceNo() { this.ultraGrid1.UpdateData(); Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 0) return; ugr = this.ultraGrid1.ActiveRow; if (ugr == null) { Util.MessageUtil.ShowTips("请选择需要保存的行"); return; } if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON"].Value.ToString())) return; string invoiceno = ugr.Cells["INVOICENO"].Value.ToString(); string realInvoiceNo = ugr.Cells["REALINVOICENO"].Value.ToString(); //DateTime dt = Convert.ToDateTime( ugr.Cells["REALINVOICENO_DATE"].Value); //if (realInvoiceNo.Length == 0) // dt = Convert.ToDateTime(DBNull.Value); if (realInvoiceNo.Length > 30) { Util.MessageUtil.ShowTips("真实发票号长度不能超过30"); return; } string errMsg = ""; this.slmBalanceInfo.UpdateRealInvoiceNO(invoiceno, realInvoiceNo, CoreFS.SA06.CoreUserInfo.UserInfo .GetUserName(), out errMsg); if (errMsg.Length == 0) { Util.MessageUtil.ShowTips("保存成功"); } } private void UpdateInvoiceLockStatus(string invoiceNO) { try { ArrayList arrayList = new ArrayList(); string errMsg = ""; arrayList = new ArrayList(new string[] { invoiceNO }); slmBalanceInfo.UpdateInvoiceStatusToLocked(arrayList, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); } catch { } } private void PrintInvoicerpt() { string INVOICENO = "INVOICENO"; string errMsg = ""; List list = new List(); if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) this.ultraGrid1.Rows[0].Selected = true; this.ultraGrid1.ActiveRow.Selected = true; String sqlCondition = ""; double money = 0; string isGreaterThanZero = "0"; // 打印包含货款和独立的出库费 or 运费,这里因为模板不一样不能一起连打 money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(this.ultraGrid1.Selected.Rows[0].Cells["MONEY"].Value); if (money != 0) { isGreaterThanZero = "0"; } else { isGreaterThanZero = "1"; } foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows) { money = Core.StlMes.Client.Sale.Util.ConverObject.ConvertToDouble(ugr.Cells["MONEY"].Value); if (money != 0) { if (isGreaterThanZero == "1") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印"); return; } } else { if (isGreaterThanZero == "0") { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("单独运费和出库费不能和货款票一起打印"); return; } } sqlCondition += "\'" + ugr.Cells[INVOICENO].Value.ToString() + "\'" + ","; list.Add(ugr.Cells[INVOICENO].Value.ToString()); } string url = ""; if (isGreaterThanZero == "0") { url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicket.cpt&__bypagesize__=false" + "&invoiceno="; } else { url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTransAndOutStockMny.cpt&__bypagesize__=false" + "&invoiceno="; } if ("120504".Equals(CustomInfo)) { url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepInvoiceTicketTH.cpt&__bypagesize__=false" + "&invoiceno="; } sqlCondition = sqlCondition.Substring(1, sqlCondition.Length - 1); sqlCondition = sqlCondition.Substring(0, sqlCondition.Length - 2); url = url + sqlCondition; Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel fBug = new Core.StlMes.Client.SaleOrder.ReviewForm.FrmOrderRepExcel(this.ob, url); fBug.AutoSize = true; fBug.Text = "打印结算单"; fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); fBug.WindowState = FormWindowState.Maximized; fBug.Show(); } private void PrintInvoice() { string INVOICENO = "INVOICENO"; string errMsg = ""; List list = new List(); if (this.ultraGrid1.Rows.Count == 0) return; if (this.ultraGrid1.Rows.Count == 1) this.ultraGrid1.Rows[0].Selected = true; this.ultraGrid1.ActiveRow.Selected = true; foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows) { list.Add(ugr.Cells[INVOICENO].Value.ToString()); } DlgInvoicePrint print = null; print = new DlgInvoicePrint(this.ob); print.listInvoiceNo = list; print.ShowDialog(); if (print.DialogResult == DialogResult.OK) { ArrayList listi = new ArrayList(list); this.slmBalanceInfo.UpdateInvoiceStatusToLocked(listi, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); } } private Boolean IsCanBeUpdateWithDifferentPerson(string user) { if (user == CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName()) { return true; } else { Core.StlMes.Client.Sale.Util.MessageUtil.ShowError("只允许操作本人票据"); return false; } } private void RollBackInvoiceNo() { if (this.ultraGrid1.Rows.Count == 0) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = this.ultraGrid1.ActiveRow; if (ugr == null) return; if (!IsCanBeUpdateWithDifferentPerson(ugr.Cells["INVOICEPERSON"].Value.ToString())) return; if (Util.MessageUtil.ShowYesNoAndQuestion("是否确定回退结算单?") == DialogResult.No) return; string invoinceno = ugr.Cells[this.INVOICENO].Value.ToString(); string errMsg = ""; this.slmBalanceInfo.RollBaskInvoiceNo(invoinceno, CoreFS.SA06.CoreUserInfo.UserInfo.GetUserName(), out errMsg); if (errMsg.Length == 0) { ugr.Delete(false); } this.ultraGrid1.UpdateData(); } private void ClearGrid() { this.dsInvoiceSeq.Clear(); this.dsInvoiceList.Clear(); } private void Query() { ClearGrid(); dsInvoice.Clear(); dsInvoiceDetail = null; dsInvoiceDetail = this.slmBalanceInfo.GetInvoiceSlmBalaneInfoByDateAndStatus(this.dateTimePicker1.Value, this.dateTimePicker2.Value, CustomInfo); dsInvoiceDetail = base.GetDataSetByFilterDeptId(dsInvoiceDetail); dsInvoiceDetail = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "INVOICE_STS", "0"); //if ("120504".Equals(CustomInfo)) // dsInvoiceDetail = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, "supply_unit", CustomInfo); // dsInvoiceDetail = base.GetDataSetByFilterDeptId(dsInvoiceDetail); DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(dsInvoiceDetail, new List(GetGroupByName()), new List(GetShowName()), new List(GetStaticName())); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoice, ds); SetTransMoneyAndOutStockMoney(); QueryTransMny(); } private void QueryTransMny() { string sql = GetSqlForInvoice(this.dateTimePicker1.Value, this.dateTimePicker2.Value); DataSet ds = base.ExecuteReader(sql); //DataSet ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoney(this.dateTimePicker1.Value, // this.dateTimePicker2.Value); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) return; // ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "INVOICE_STS", "0"); if (this.dsInvoice == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { } else { foreach (DataRow dr in ds.Tables[0].Rows) { DataSet dstemp = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter (dsInvoice, "INVOICENO", dr["INVOICENO"].ToString()); try { if (dstemp.Tables[0].Rows.Count > 0) { dr.Delete(); } } catch { } } } ds.AcceptChanges(); ds.Tables[0].TableName = this.dsInvoice.Tables[0].TableName; this.dsInvoice.Merge(ds, false, System.Data.MissingSchemaAction.Ignore); this.dsInvoice.AcceptChanges(); // ClearGrid(); } private string GetSqlForInvoice(System.DateTime dtbegin,System.DateTime dtEnd) { string sql = @"select sum(case when a.money_type = '出库费' then a.money else 0 end) OUTSTOCKMNY, sum(case when a.money_type = '运费' then a.money else 0 end) TRANSMNY, max(money_type) money_type, sum(nvl(a.weight, 0)) weight, a.buyercode, a.buyername, a.inceptcorpcode, a.fst_drawee_unit, a.forecorpcode forecorpname, a.forecorpname forecorpcode, a.invoiceno, MAX(A.REALINVOICENO) REALINVOICENO, max(a.invoice_id) INVOICEPERSON, max(a.invoicedate) invoicedate, b.customer_nm, b.sale_area_desc,min(a.INVOICE_STS) INVOICE_STS from slm_balance_transmoney a join slm_order_head b on a.ord_pk = b.ord_pk where a.status_cd = '2' and a.invoiceno is not null and INVOICE_STS = '0' {0} group by a.buyercode, a.buyername, a.inceptcorpcode, a.fst_drawee_unit, a.forecorpcode, a.forecorpname, a.invoiceno, b.customer_nm, b.sale_area_desc "; string sqlCondition = Util.ConverObject.ConvertDateTimeValueToDbLanguage("INVOICEDATE", dtbegin, dtEnd); sql = string.Format(sql,sqlCondition); return sql; } private string GetSqlForInvoiceIncludTax(System.DateTime dtbegin, System.DateTime dtEnd) { string sql = @"select sum(case when a.money_type = '出库费' then a.weight * (decode(a.trans_type, '铁运', 23, 10)) else 0 end) OUTSTOCKMNY, sum(case when a.money_type = '运费' then a.money else 0 end) TRANSMNY, max(money_type) money_type, sum(nvl(a.weight, 0)) weight, a.buyercode, a.buyername, a.inceptcorpcode, a.fst_drawee_unit, a.forecorpcode forecorpname, a.forecorpname forecorpcode, a.invoiceno, MAX(A.REALINVOICENO) REALINVOICENO, max(a.invoice_id) INVOICEPERSON, max(a.invoicedate) invoicedate, b.customer_nm, b.sale_area_desc from slm_balance_transmoney a join slm_order_head b on a.ord_pk = b.ord_pk where a.status_cd = '2' and a.invoiceno is not null {0} group by a.buyercode, a.buyername, a.inceptcorpcode, a.fst_drawee_unit, a.forecorpcode, a.forecorpname, a.invoiceno, b.customer_nm, b.sale_area_desc "; string sqlCondition = Util.ConverObject.ConvertDateTimeValueToDbLanguage("INVOICEDATE", dtbegin, dtEnd); sql = string.Format(sql, sqlCondition); return sql; } private void SetTransMoneyAndOutStockMoney() { DataSet ds = null; ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoneyAndOutStockMoney(this.dateTimePicker1.Value, this.dateTimePicker2.Value); //ds = this.slmBalanceInfo.GetInvoiceSlmBalanceTransMoneyAndOutStockMoneyIncludeTax(this.dateTimePicker1.Value, // this.dateTimePicker2.Value); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) return; if (this.dsInvoice == null || this.dsInvoice.Tables.Count == 0 || this.dsInvoice.Tables[0].Rows.Count == 0) return; ds = Core.StlMes.Client.Sale.Util.UtilDataSet.GetDataSetWithRowFilter(ds, "INVOICE_STS", "0"); foreach (DataRow dri in this.dsInvoice.Tables[0].Rows) { try { DataRow[] drs = ds.Tables[0].Select(string.Format(" invoiceno = '{0}' ", dri[this.INVOICENO].ToString())); if (drs == null || drs.Length == 0) continue; foreach (DataRow drd in drs) { if (drd["MONEY_TYPE"].ToString() == "运费") { dri["TRANSMNY"] = drd["MONEY"]; } if (drd["MONEY_TYPE"].ToString() == "出库费") { dri["OUTSTOCKMNY"] = drd["MONEY"]; } } } catch { } } this.dsInvoice.AcceptChanges(); ClearGrid(); } private void QuryGrid2(string invoiceNo) { DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceNo); DataSet ds = Util.UtilDataSet.GetDateSetByGroupColumnAndStaticsColumnName(ds2, new List(this.GetGrid2GroupByCol()), new List(this.GetGrid2ShowCol()), new List(this.GetGrid2StaticCol())); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceSeq, ds); } private void QueryGrid3(String invoiceno, string invoiceno_seq) { DataSet ds2 = Util.UtilDataSet.GetDataSetWithRowFilter(dsInvoiceDetail, this.INVOICENO, invoiceno); DataSet ds3 = Util.UtilDataSet.GetDataSetWithRowFilter(ds2, this.INVOICENO_SEQ, invoiceno_seq); Util.UtilDataSet.SetDataSetByMergeSameColumnName(ref this.dsInvoiceList, ds3); } private string[] GetGroupByName() { return new string[] { "INVOICENO", "BUYERCODE", "BUYERNAME", "FORECORPCODE", "CUSTOMER_NO", "SALE_AREA_NO", }; } private string[] GetShowName() { return new string[] { // "REMARK" , "REALINVOICENO", "REALINVOICENO_ORG", "SALE_AREA_DESC", "CUSTOMER_NM","ISINVOICENOLOCKED", "INVOICEPERSON", "INVOICEDATE","FORECORPCODE","SUPPLY_UNIT_DESC" }; } private string[] GetStaticName() { return new string[] { "WEIGHT", "MONEY" }; } private string[] GetGrid1DataStruct() { return new string[] { "INVOICENO", "REALINVOICENO", // "REALINVOICENO_DATE", "REALINVOICENO_ORG", "BUYERCODE", "BUYERNAME", "WEIGHT", "MONEY", "TRANSMNY", "OUTSTOCKMNY", // "TRANSMONEYQC", //"TRANSMONEYSY1", //"TRANSMONETRAIN", // "HOISTINGFEE", // "ORD_NO", // "REMARK", "CUSTOMER_NO", "CUSTOMER_NM", "SALE_AREA_NO", "SALE_AREA_DESC", "FORECORPCODE", "INVOICEPERSON", "INVOICEDATE", "SUPPLY_UNIT_DESC" // "ISINVOICENOLOCKED" } ; } private Hashtable GetColumnAndCaption() { return StaticData.TbColumnAndCaption.GetColumnAndCaption(); Hashtable hs = new Hashtable(); hs.Add("WEIGHT", "重量"); hs.Add("INVOICENO", "结算单号"); hs.Add("FORECORPCODE", "子公司"); hs.Add("SHIPNO", "船号"); hs.Add("TRANSMONEYQC", "汽运费"); hs.Add("TRANSMONEYSY1", "船运费"); hs.Add("TRANSMONETRAIN", "火运费"); hs.Add("HOISTINGFEE", "吊装费"); hs.Add("PLY", "厚/直径/壁厚"); hs.Add("WIDTH", "宽/外径"); hs.Add("ORD_NO", "合同号"); hs.Add("BUYERNAME", "结算单位名称"); hs.Add("BUYERCODE", "结算单位编码"); hs.Add("STATIONCODE", "到站"); hs.Add("TRANSMNY", "运费"); hs.Add("OUTSTOCKMNY", "出库费"); hs.Add("SUPPLY_UNIT_DESC", "制造商"); return hs; } protected override Hashtable GetGridColumnLength() { return StaticData.TbColumnAndCaption.GetDataSetColumnLength(); Hashtable hs = new Hashtable(); hs.Add("SHIPNO", 80); hs.Add("SHIPPRICE", 70); hs.Add("TRANSMONEYQC", 80); hs.Add("TRANSMONEYSY1", 70); hs.Add("TRANSMONETRAIN", 70); hs.Add("HOISTINGFEE", 70); hs.Add(this.INVOICENO, 150); hs.Add(this.BUYERCODE, 150); return hs; } private string[] GetGrid5DataStruct() { return new string[] { "SUB_SEQ" , "BUYERCODE" , "BUYERNAME" , "FORECORPCODE" , "MONEY" , "MONEY_TYPE" , "MONEY_TYPE_DESC" , "REMARK" , "STATUS_CD" , "INVOICENO" , "CREATE_NAME" , "CREATE_TIME" , "AFFRIM_NAME" , "AFFRIM_TIME" , "CREATE_DEPT", "INVOICENO_DATE" } ; } private string[] GetGrid4DataStruct() { return new string[] { "MONEY" , "MONEY_TYPE_DESC" , "REMARK" , // "INVOICENO" , "INVOICENO_DATE" } ; } private string[] GetGrid2DataStruct() { return new string[] { "INVOICENO", "INVOICENO_SEQ", "SPETKEY", "STEELCODEKEY", "PRICE", "WEIGHT", "MONEY" } ; } private string[] GetGrid2GroupByCol() { return new string[] { "INVOICENO", "INVOICENO_SEQ" }; } private string[] GetGrid2ShowCol() { return GetGrid2DataStruct(); } private string[] GetGrid2StaticCol() { return new string[] { "WEIGHT", "MONEY" }; } private string[] GetGrid3DataStruct() { return new string[] { "ORD_NO", "SPETKEY", "STEELCODEKEY", "QUANTITY", "WEIGHT", "MONEY" // "TRAINWAGON", // "SHIPNO", // "DOCKCODE", // "STATIONCODE", } ; } private string BUYERCODE = "BUYERCODE"; private string ORD_NO = "ORD_NO"; private string ORD_SEQ = "ORD_SEQ"; private string ORD_LN_DLY = "ORD_LN_DLY"; private string ASKPLAN_ID = "ASKPLAN_ID"; private string ASKPLAN_ID_SEQ = "ASKPLAN_ID_SEQ"; private string SPETKEY = "SPETKEY"; private string STEELCODEKEY = "STEELCODEKEY"; private string MONEY = "MONEY"; private string WEIGHT = "WEIGHT"; private string PRICE = "PRICE"; private string BALANCESTATUS = "BALANCESTATUS"; private string ADJUSTPRICEREASON = "ADJUSTPRICEREASON"; private string INVOICENO = "INVOICENO"; private string INVOICENO_SEQ = "INVOICENO_SEQ"; private string BALANCESTATUS_INIT = "0"; private string BALANCESTATUS_AFFRIM = "1"; private string BALANCESTATUS_INVOINCE = "2"; private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { } private void ultraGrid2_AfterRowActivate(object sender, EventArgs e) { if (this.ultraGrid2.Rows.Count == 0) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid2.Rows.Count == 1) ugr = this.ultraGrid2.Rows[0]; else ugr = this.ultraGrid2.ActiveRow; string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString(); string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString(); this.QueryGrid3(invoiceno, invoicenoseq); } private void button3_Click(object sender, EventArgs e) { this.PrintInvoice(); } private void button1_Click(object sender, EventArgs e) { } private void button1_Click_1(object sender, EventArgs e) { FrmBalanceInvoceMgtOrg org = new FrmBalanceInvoceMgtOrg(); org.ShowDialog(); } private void ultraGrid1_AfterRowActivate_1(object sender, EventArgs e) { this.dsMnyCredit.Clear(); this.dsCreditResult.Clear(); if (this.ultraGrid1.Rows.Count == 0) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid1.Rows.Count == 1) ugr = this.ultraGrid1.Rows[0]; else ugr = this.ultraGrid1.ActiveRow; string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString(); this.QuryGrid2(invoiceno); string buyercode = ugr.Cells[this.BUYERCODE].Value.ToString(); string forecode = ugr.Cells["FORECORPCODE"].Value.ToString(); QueryGridFine(buyercode, forecode); QueryGridFour(invoiceno); } private void ultraGrid2_AfterRowActivate_1(object sender, EventArgs e) { if (this.ultraGrid2.Rows.Count == 0) return; Infragistics.Win.UltraWinGrid.UltraGridRow ugr = null; if (this.ultraGrid2.Rows.Count == 1) ugr = this.ultraGrid2.Rows[0]; else ugr = this.ultraGrid2.ActiveRow; string invoiceno = ugr.Cells[this.INVOICENO].Value.ToString(); string invoicenoseq = ugr.Cells[this.INVOICENO_SEQ].Value.ToString(); this.QueryGrid3(invoiceno, invoicenoseq); } } }