/// <summary> /// Opens the Search Invoices window. (And hides main window.) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MI_Search_Click(object sender, RoutedEventArgs e) { if (!editing) { try { winSearch = new wndSearch(); this.Hide(); winSearch.ShowDialog(); //check to see if an invoice was selected. (Negative number means //cancel was clicked on the winSearch if (winSearch.InvoiceID >= 0) { btnAddInvoice.IsEnabled = true; btnEditInvoice.IsEnabled = true; btnDeleteInvoice.IsEnabled = true; MyInvoice.invNum = winSearch.InvoiceID; MyInvoice.LoadFromDatabase(); dpDatePick.SelectedDate = MyInvoice.date; //dpDatePick.Text = MyInvoice.date.ToString(); lblTotalNum.Content = MyInvoice.totalCost.ToString(); lblIDnum.Content = MyInvoice.invNum; dgItems.ItemsSource = MyInvoice.itemList; dgItems.Items.Refresh(); } this.Show(); } catch (Exception ex) { HandleError("MainWindow.xaml.cs", "MI_Search_Click", ex.Message); } } else { //Show a label that explains "Save you work before going to Updating." MessageBox.Show("You must Save or Cancel before leaving this page.", "Something Happened", MessageBoxButton.OK, MessageBoxImage.Exclamation); //MessageBox.Show() } }
/// <summary> /// Constructor. Instantiates window objects and /// maximizes self. /// </summary> public MainWindow() { winSearch = new wndSearch(); winUpdate = new AddItems(); //At startup, shouldn't have an invoice selected. try { MyInvoice = new InvoiceCls(-1); InitializeComponent(); WindowState = WindowState.Maximized; LoadInvoice(); } catch (Exception ex) { HandleError("MainWindow.xaml.cs", "MainWindow", ex.Message); } //SetUpComboBoxes(); //Is there a current Invoice ID? //OpenCurrentInvoice(); //sets the combo boxes to the correct selections //sets the data grid and whatever else. Label. //Else, Delete isn't an option }