} //end populateInventory() /// <summary> /// If there is an invoice number, get the data from the database and populate the datatable and dataset. /// If there is not in invoice given, set up the table to be able to accept inventory items. /// </summary> /// <param name="invoiceId"></param> public void populateInvoice(String invoiceId) { ///try catch block to handle exceptions try { ///if statement to check invoice ID and populate invoice if (invoiceId != "") { ///sets delete invoice to enabled btnDeleteInvoice.IsEnabled = true; ///sets label with number lblInvoiceNumber.Content = invoiceId; ///creates a string to hold invoice id info String sQuery = mydb.SelectItemsOnInvoice(invoiceId); ///executes query dtInvoice = db.FillSqlDataTable(sQuery); ///populates grid dgInvoiceItems.ItemsSource = dtInvoice.DefaultView; ///creates a return variable int iRet = 0; ///creates a data set DataSet ds = new DataSet(); ///calls a sql method String sSQL = mydb.SelectInvoiceDateFromNum(invoiceId); ///places info in data set ds = db.ExecuteSQLStatement(sSQL, ref iRet); ///creates temp variable to hold info String date = ds.Tables[0].Rows[0][0].ToString(); ///takes care of the date format invoiceDatePicker.SelectedDate = DateTime.Parse(date); //pulls data from database //UPDATE INVOICE LABEL WITH INVOICEID - lblInvoiceId } else { ///if all the above fails, then do this btnDeleteInvoice.IsEnabled = false; //fields should be clear and ready for input. dtInvoice.Columns.Add("ItemDesc"); dtInvoice.Columns.Add("Cost"); ///populatse invoice items dgInvoiceItems.ItemsSource = dtInvoice.DefaultView; }//end else } catch (Exception) {///catch exceptions MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name); }//end catch }//end populateInvoice()