/// <summary> /// MainWindow() - Constructor /// </summary> public wndMain() { //loads window wndMain InitializeComponent(); //To close application - to be included in all WPF applications - makes sure other windows close and the objects that have been instantiated will be cleared from memory. Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; //instantiate MainLogic object so that we can use methods from the clsMainLogic class MainLogic = new clsMainLogic(); //instantiate newLstInvoice object so that we can pass our list from MainLogic.lstInvoice into newLstInvoice newLstInvoice = new List <clsInvoice>(); newLstLineItems = new List <clsLineItems>(); newLstItemDesc = new List <clsItemDesc>(); //get the lstInvoice from MainLogic and pass it into our new list called newLstInvoice newLstInvoice = MainLogic.GetInvoice(); //bind the data from our new list onto our datagrid called dataGridView dataGridView1.ItemsSource = newLstInvoice; /*need to add button columns*/ create_btn.IsEnabled = false; edit_btn.IsEnabled = false; }
/// <summary> /// Deletes selected item from data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void delete_btn_Click(object sender, RoutedEventArgs e) { if (dataGridView1.SelectedIndex < newLstInvoice.Count && dataGridView1.SelectedItem != null) { //create and instanitate a new Invoice object clsInvoice Invoice = new clsInvoice(); //set the new object called Invoice to the selected item in the datagrid called dataGridView Invoice = (clsInvoice)dataGridView1.SelectedItem; bIsDeleting = true; //delete the Line item at the current selected item. MainLogic.DeleteLineItemSQL(Invoice.iInvoiceNum); //delete the Invoice at the current selected item. MainLogic.DeleteInvoiceSQL(Invoice.iInvoiceNum); //set the new list called newLstInvoice to get the lstInvoice that will return the data in the dataset. newLstInvoice = MainLogic.GetInvoice(); //bind the data from our new list into the datagrid called dataGridView dataGridView1.ItemsSource = newLstInvoice; bIsDeleting = false; //commits changes to database. MainLogic.ds.AcceptChanges(); //refresh items in the datagrid called dataGridView dataGridView1.Items.Refresh(); } }
public void UploadInvoice(int iInvoiceNum) { //wndSearch Search = new wndSearch(); if (bAddItem != true)//delete { /**************************************Testing - needs to go in another method and called in the constructor - when search sends InvoiceNum, call this**************************************/ items_cbo.IsEnabled = false; addItem_button.IsEnabled = false; create_btn.Visibility = Visibility.Hidden; editInvoice_btn.Visibility = Visibility.Visible; deleteInvoice_btn.Visibility = Visibility.Visible; //items_cbo.IsEnabled = true; //addItem_button.IsEnabled = true; MainLogic.GetInvoice(iInvoiceNum); //move thees to the constructor and pass in the InvoiceNum from "search" call these after the search screen selects the items. . . newLstItemDesc = MainLogic.GetInvoiceItemDesc(iInvoiceNum); //move thees to the constructor and pass in the InvoiceNum from "search" dataGridView1.ItemsSource = newLstItemDesc; invoiceNum_txtbox.Text = MainLogic.lstInvoice[0].iInvoiceNum.ToString(); invoiceData_txtbox.Text = MainLogic.lstInvoice[0].sInvoiceDate.ToString(); invoiceCost_txtbox.Text = "$" + MainLogic.lstInvoice[0].sTotalCost.ToString(); MainLogic.GetItemDesc(); for (int i = 0; i < MainLogic.lstItemDesc.Count; i++) { items_cbo.Items.Add(MainLogic.lstItemDesc[i].sItemDesc); } /**************************************Testing - needs to go in another method and called in the constructor - when search sends InvoiceNum, call this**************************************/ } }