//Interface private void ThisWorkbook_Startup(object sender, System.EventArgs e) { //Event handler for workbook startup event try { System.IntPtr p = GetCommandLine(); string cmd = System.Runtime.InteropServices.Marshal.PtrToStringAuto(p); string clid = "", invoice = ""; //L15427 if (cmd != null) { string query = cmd.Substring(cmd.IndexOf('?') + 1); string[] args = query.Split('&'); if (args.Length > 0) { clid = args[0].Substring(args[0].IndexOf("=") + 1).Trim(); } if (args.Length > 1) { invoice = args[1].Substring(args[1].IndexOf("=") + 1).Trim(); } } DialogResult result = DialogResult.OK; if (invoice.Length == 0) { dlgInvoice dlg = new dlgInvoice(); result = dlg.ShowDialog(); invoice = dlg.InvoiceNumber; } if (result == DialogResult.OK) { //Get shipments and shipment details SqlDataAdapter adapter = new SqlDataAdapter(USP_SHIPMENT, global::Argix.Finance.Settings.Default.SQLConnection); adapter.SelectCommand.CommandType = CommandType.StoredProcedure; adapter.SelectCommand.Parameters.AddRange(new SqlParameter[] { new SqlParameter("@InvoiceNumber", invoice) }); InvoiceDS ds = new InvoiceDS(); adapter.Fill(ds, TBL_SHIPMENT); adapter.SelectCommand.CommandText = USP_DETAIL; adapter.Fill(ds, TBL_DETAIL); adapter.SelectCommand.CommandText = USP_TOTALS; adapter.Fill(ds, TBL_TOTALS); int rows = ROW0_DETAIL; createInvoiceHeader(invoice, ds.InvoiceTotalTable[0]); for (int i = 0; i < ds.InvoiceShipmentTable.Rows.Count; i++) { //Show each shipment rows = rows + createInvoiceBodyShipments(ds.InvoiceShipmentTable[i], rows); //Show details for each shipment InvoiceDS _ds = new InvoiceDS(); _ds.Merge(ds.InvoiceDetailTable.Select("ShipmentNumber='" + ds.InvoiceShipmentTable[i].ShipmentNumber + "'")); rows = rows + createInvoiceBodyDetails(_ds, rows); rows++; //Add break } createInvoiceTotals(ds.InvoiceTotalTable[0], rows); } } catch (Exception ex) { reportError(ex); } }
private void OnFormLoad(object sender, EventArgs e) { //Event handler for form load event this.Cursor = Cursors.WaitCursor; try { //Get client list SqlDataAdapter adapter = new SqlDataAdapter(USP_CLIENT, global::Argix.Finance.Settings.Default.SQLConnection); adapter.SelectCommand.CommandType = CommandType.StoredProcedure; adapter.TableMappings.Add("Table", TBL_CLIENT); DataSet _ds = new DataSet(); adapter.Fill(_ds, TBL_CLIENT); InvoiceDS ds = new InvoiceDS(); string clientID = global::Argix.Finance.Settings.Default.ClientID; if (clientID.Length > 0) { ds.Merge(_ds.Tables[TBL_CLIENT].Select("DivisionNumber = '01' AND (" + clientID + ")")); } else { ds.Merge(_ds); } this.mInvoiceDS.Merge(ds); if (this.cboClient.Items.Count > 0) { if (clientID.Length > 0) { this.cboClient.SelectedValue = clientID; } else { this.cboClient.SelectedIndex = 0; } } OnClientSelected(null, EventArgs.Empty); this.cboClient.Enabled = this.cboClient.Items.Count > 0; } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }
public Invoices GetClientInvoices(string clientNumber, string clientDivision, string startDate) { //Get a list of clients invoices filtered for a specific division Invoices invoices = null; try { invoices = new Invoices(); DataSet ds = fillDataset(USP_INVOICES, TBL_INVOICES, new object[] { clientNumber, clientDivision, startDate }); if (ds.Tables[TBL_INVOICES].Rows.Count > 0) { InvoiceDS __invoices = new InvoiceDS(); __invoices.Merge(ds); string filter = getInvoiceFilter(clientNumber); InvoiceDS _invoices = new InvoiceDS(); _invoices.Merge(__invoices.ClientInvoiceTable.Select(filter, "InvoiceNumber ASC")); System.Xml.XmlNode node = InvoicingConfig.Document.DocumentElement.SelectSingleNode("//client[@number='" + clientNumber + "']"); if (node != null) { System.Xml.XmlNode inv = node.SelectSingleNode("invoices"); if (inv != null) { for (int i = 0; i < _invoices.ClientInvoiceTable.Rows.Count; i++) { string invoiceType = _invoices.ClientInvoiceTable[i].InvoiceTypeCode.Trim(); if (inv.Attributes[invoiceType] != null) { _invoices.ClientInvoiceTable[i].InvoiceTypeTarget = inv.Attributes[invoiceType].Value; } Invoice invoice = new Invoice(_invoices.ClientInvoiceTable[i]); invoices.Add(invoice); } } } } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected exception creating client invoice list.", ex); } return(invoices); }