Exemplo n.º 1
0
        //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); }
        }
Exemplo n.º 2
0
 //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 = "";
         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)
         {
             //Display summary and detail data
             try {
                 SqlDataAdapter adapter = new SqlDataAdapter(USP_DETAIL, global::Argix.Finance.Settings.Default.SQLConnection);
                 adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
                 adapter.SelectCommand.Parameters.AddRange(new SqlParameter[] { new SqlParameter("@InvoiceNumber", invoice) });
                 adapter.TableMappings.Add("Table", TBL_DETAIL);
                 InvoiceDS detailDS = new InvoiceDS();
                 adapter.Fill(detailDS, TBL_DETAIL);
                 showSummary(detailDS);
                 showDetail(detailDS.ClientInvoiceWithStoreBLNumbersTable);
             }
             catch (Exception ex) { reportError(ex); }
         }
     }
     catch (Exception ex) { reportError(ex); }
 }