private void getInvDataBaseBtn_Click_1(object sender, EventArgs e) { //Clears the listbox on click to ensure no duplicate data listBox1.Items.Clear(); //Creates a new list of invoices from the Database invoicesDB = new List <Invoice>(); invoicesDB = DataAdapter.GetInvoice(); //Sorts the invoices list by Invoice ID so the info is in numeric order. invoicesDB = invoicesDB.OrderBy(inv => inv.InvoiceID).ToList(); //Adds each invoice from the database to the listbox foreach (Invoice invoice in invoicesDB) { listBox1.Items.Add("DB Invoice # " + invoice.InvoiceID); } }
//Gets the invoices from the database and populates the invoices list. private void Form1_Load(object sender, EventArgs e) { invoices = DataAdapter.GetInvoice(); dbInvoices = invoices.Count + 1; //Count number of invoices in database //tempInvoices = invoices.Count + 1; //MessageBox.Show("Number of invoice in database" + tempInvoices); //Increase tempInvoices number by 1 //tempInvoices += 1; //MessageBox.Show("NUmber of first invoice number" + tempInvoices); ////Writes some test info to the console to ensure it's being converted properly. //foreach (Invoice invoice in invoices) //{ // foreach (Package package in invoice.packages) // { // Console.WriteLine(package.ShipCompany); // } // Console.WriteLine(invoice.InvoiceID); //} }