/// <summary>
 /// This method will open up the Search form to search the database for a particular invoice.
 /// </summary>
 /// <param name="sender">Search for Invoice menu item</param>
 /// <param name="e">Click</param>
 private void Btn_Click_Search(object sender, RoutedEventArgs e)
 {
     try
     {
         wndSearch wndSearch = new wndSearch(); //calls wndSearch form
         wndSearch.ShowDialog();
         //Display the new changes if any, .ie. if any new invoice was selected
         if (wndSearch.selected_Invoice != "")
         {
             string isInvoice = wndSearch.selected_Invoice;
             clsMain.setCost(0);               //Reset cost
             clsMain.loadInvoice(isInvoice);
             clsMain.setInvoiceNum(isInvoice); //Fixes a bug I ran into
             currInvoiceDataGrid.ItemsSource = clsMain.getData();
             DateTime d    = clsMain.getDate();
             string   data = d.ToString();
             datepicker.Text = data; //Puts invoice's date into the date picker
             deleteIvoiceButton.IsEnabled = true;
             newInvoiceButton.IsEnabled   = true;
             removeItembutton.IsEnabled   = false;
             saveBut.IsEnabled            = false;
             datepicker.IsEnabled         = false;
             editButton.IsEnabled         = true;
             addItemButton.IsEnabled      = false;
             itemsListcomboBox.IsEnabled  = false;
             InvoiceNoBox.Content         = clsMain.getInvoiceNum();
             orderTotalBox.Content        = "$" + clsMain.getTotalCost();
         }
     }
     catch (Exception ex)
     {
         CheckingErrors(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                        MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            wndSearch s = new wndSearch();

            s.Show();
            this.Close();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Search Invoices menu item click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchInvoices_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wndSearch wndSearch = new wndSearch();
                wndSearch.ShowDialog();
                if (MainWndwInvoice.InvoiceNum != null)
                {
                    var           DateTime = Convert.ToDateTime(MainWndwInvoice.InvoiceDate);
                    clsInvoices[] list     = new clsInvoices[1];

                    list[0] = MainWndwInvoice;

                    datePicker.SelectedDate = DateTime;

                    invoiceComboBox.SelectedItem = MainWndwInvoice.InvoiceNum;
                    invoiceComboBox.ItemsSource  = list;
                    dataGridList = mainLogic.PopulateLineItemsOnInvoiceNum(MainWndwInvoice.InvoiceNum);
                    invoiceDataGrid.ItemsSource = dataGridList;
                }
            }
            catch (Exception ex)
            {               //this is reflection
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Search Invoice button click
        /// sends user to new Search Window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchInvoice_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wndSearch Search = new wndSearch();
                Search.ShowDialog();

                //Must wait for Search Logic to fully incorporate this
                //but I think its pretty close.

                //return if nothing selected
                if (Search.searchLogic.SelectedInvoice == null)
                {
                    return;
                }

                mainLogic.CurrentInvoice = Search.searchLogic.SelectedInvoice;
                mainLogic.ResetSelectedInvoice();

                ItemListBox.IsEnabled      = true;
                DeleteInvoiceBtn.IsEnabled = true;
                EditInvoiceBtn.IsEnabled   = true;
                TotalLbl.Content           = "$" + mainLogic.CurrentInvoice.TotalCost.ToString("00.00");

                ItemListBox.ItemsSource = mainLogic.CurrentInvoice.InvoiceItems.ToList();
                TotalLbl.Content        = mainLogic.CurrentInvoice.TotalCost.ToString("00.00");
                InvoiceNumLbl.Content   = mainLogic.CurrentInvoice.InvoiceNumber;
                DateBox.Text            = mainLogic.CurrentInvoice.InvoiceDate;
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// OnClick handler for the MenuItem
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Event object</param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Show the search window as a dialog
                wndSearch wndSearch = new wndSearch();
                wndSearch.ShowDialog();

                //If they hit cancel then just return
                if (wndSearch.SL.SelectedInvoice == null)
                {
                    return;
                }

                //Alter the stack panel to be styled as active
                Style st = (Style)this.FindResource("StackPanelActive");
                InvoiceBtnStack.Style = st;

                //Toggle disabled status of ui elements
                ItemListMenu.IsEnabled = true;

                if (DateBox.IsEnabled)
                {
                    DateBox.IsEnabled = false;
                }

                if (NewInvoiceGrid.Visibility == Visibility.Visible)
                {
                    NewInvoiceGrid.Visibility = Visibility.Hidden;
                }

                DeleteInvoiceBtn.IsEnabled = true;
                EditInvoiceBtn.IsEnabled   = true;

                //Set the current invoice to be the selected invoice
                ML.CurrentInvoice = wndSearch.SL.SelectedInvoice;

                InvoiceDetailGrid.Visibility = Visibility.Visible;

                //If the item combobox's itemsource is not set, set it
                if (ItemCmb.ItemsSource == null)
                {
                    ItemCmb.ItemsSource = ML.Items;
                }

                //Set the itemsource for itemlist to be the selected invoice's items
                ItemList.ItemsSource = ML.CurrentInvoice._Items;

                //Set the labels to contain the selected invoice's information
                TotalLbl.Content      = ML.CurrentInvoice._Total.ToString();
                InvoiceNumLbl.Content = ML.CurrentInvoice._Num;
                DateBox.Text          = ML.CurrentInvoice._Date;
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Menu -> File -> Search - Opens "search" window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            //open "search" window.
            wndSearch searchWindow = new wndSearch();

            searchWindow.ShowDialog();

            this.Show();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Opens the search window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SearchForInvoice(object sender, RoutedEventArgs e)
 {
     try
     {
         search = new wndSearch(this);
         //App.Current.MainWindow = search;
         search.ShowDialog();
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " " + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Focuses the Search Window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchMenuItem_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
            wndSearch  wndSearch    = new wndSearch();
            clsInvoice selectedItem = wndSearch.ShowSearch();

            if (selectedItem != null)
            {
                var tempInvoice = mainLogic.invoices.FirstOrDefault(m => m.Id == selectedItem.Id);
                InvoiceSelectionComboBox.SelectedItem = tempInvoice;
            }

            this.Show();
        }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor for main window
 /// </summary>
 public wndMain()
 {
     try
     {
         InitializeComponent();
         Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
         windowItems               = new wndItems();
         windowSearch              = new wndSearch();
         mainLogic                 = new clsMainLogic();
         GridMain.DataContext      = mainLogic;
         ComboBoxItems.ItemsSource = mainLogic.Items;
     }
     catch (Exception ex)
     {
         HandleException(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Loads up the main Window
        /// </summary>
        public wndMain()
        {
            try
            {
                InitializeComponent();

                //allow application to close
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                //Instantiate Window Objects
                wndItemsForm  = new wndItems();
                wndSearchForm = new wndSearch();
                oMainLogic    = new clsMainLogic();
            }
            catch (Exception ex)
            {
                HandleError.handleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                        MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
 /// <summary>
 /// Search button click event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Search_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //open the search form
         wndSearch = new wndSearch();
         //Hide the menu
         this.Hide();
         //Show the search form
         wndSearch.ShowDialog();
         //Show the search form
         this.Show();
     }
     catch (Exception ex)
     {
         HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                     MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Load the search window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SearchHeader_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var search = new wndSearch();
         search.ShowDialog();
         //if the invoice value is not 0, that means the search window has an invoice selected
         if (search.selectedInvoiceId != 0)
         {
             //items may have changed, so refresh the combo box
             LoadItems();
             LoadInvoice(search.selectedInvoiceId);
         }
     }
     catch (Exception ex)
     {
         //This is the top level method so we want to handle the exception
         HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                     MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// menu control when search is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchTab_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SearchWindow = new wndSearch();  //initializes the SearchWindow


                this.Hide();
                SearchWindow.ShowDialog();
                this.Show();

                DeleteInvoice.IsEnabled = true;
                EditInvoice.IsEnabled   = true;
                MyList.Clear();
                AmountOfItems.Text    = "";
                ItemCostTextBox.Text  = "";
                cbItems.SelectedIndex = -1;
                DisableAllInput();
                SaveInvoice.IsEnabled = false;
                //check if it has been closed but nothing has been selected
                if (SearchWindow.SelectedInvoice != null)
                {
                    MyInvoice = SearchWindow.SelectedInvoice;

                    //adds all the items that are associated with the invoice into the data grid
                    foreach (var item in MainLogic.GetLineItems(MyInvoice.InvoiceID))
                    {
                        MyList.Add(item);
                    }
                }

                UpdateDisplays();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor for main window and application entry point.
        /// </summary>
        public MainWindow()
        {
            try
            {
                InitializeComponent();
                mainLogic = new clsMainLogic();
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;//close the application when the main window is closed
                //Maybe delete this line.
                MainWndwInvoice = new clsInvoices();

                dataGridList = new ObservableCollection <Item>();
                itemsWindow  = new wndItems();
                SearchWindow = new wndSearch();

                //this.Hide(); //temporary for austin's development
                //itemsWindow.Show(); //temporary for austin's development
            }
            catch (Exception ex)
            {               //this is reflection
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Click on Search Button and it will navigate you to the
        /// Search Window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void itemSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                searchWindow = new wndSearch();

                this.Hide();

                searchWindow.ShowDialog();
                int num;
                num = searchWindow.InvoiceNum;

                //find the invoice in the datagrid
                int i = 0;
                if (num != -1)
                {
                    foreach (var item in dgInvoices.Items)
                    {
                        clsInvoice invoice = (clsInvoice)item;
                        if (invoice.InvoiceNum == num)
                        {
                            break;
                        }
                        i++;
                    }

                    dgInvoices.SelectedIndex = i;
                }
                this.Show();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
        /// <summary>
        /// This click event will handle the openning and closing of the Search window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (searchWindow == null)
                {
                    searchWindow = new wndSearch(this);
                }
                this.Hide();
                searchWindow.ShowDialog();
                if (searchWindow != null)
                {
                    if (searchWindow.SelectedInvoiceNum != "")
                    {
                        //retrieve search selected.
                        selectedInvoice = Int32.Parse(searchWindow.SelectedInvoiceNum);

                        //get invoice from selected num
                        clsInvoice invoice = new clsInvoice();
                        invoice = clsMainSQL.getInvoice(selectedInvoice);
                        ObservableCollection <clsItem> tempList = invoice.getLineItemList();

                        //populate controls with invoice data for edit
                        tbInvoiceNumber.Text       = invoice.getInvoiceNumber().ToString();
                        dpInvoiceDate.DisplayDate  = DateTime.Parse(invoice.getInvoiceDate());
                        dpInvoiceDate.SelectedDate = DateTime.Parse(invoice.getInvoiceDate());

                        dgMain.Items.Clear();

                        foreach (clsItem item in tempList)
                        {
                            dgMain.Items.Add(item);
                            //lineItemList.Add(item);
                        }

                        double sum = 0;
                        foreach (clsItem item in tempList)
                        {
                            sum += double.Parse(item.sCost);
                        }
                        tbTotal.Content = "$" + sum.ToString();

                        //enable components
                        tbInvoiceNumber.IsEnabled  = false;
                        dpInvoiceDate.IsEnabled    = false;
                        btnAdd.IsEnabled           = false;
                        tbItemCost.IsEnabled       = false;
                        tbItemCost.IsReadOnly      = true;
                        cbLineItem.IsEnabled       = false;
                        btnAddItem.IsEnabled       = false;
                        btnRemoveItem.IsEnabled    = false;
                        btnSaveInvoice.IsEnabled   = false;
                        tbInvoiceNumber.IsReadOnly = true;
                        btnEdit.IsEnabled          = true;
                        btnDelete.IsEnabled        = true;
                        btnSearch.IsEnabled        = true; //
                        btnUpdate.IsEnabled        = true; //
                    }
                }
            }
            catch (System.Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }