コード例 #1
0
        /// <summary>
        /// Main Window Constructor
        /// </summary>
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;  //shut down application only when main window is closed

                //Initialize windows
                searchWindow = new wndSearch();
                editWindow   = new wndEdit();

                //Initialize Main Window objects and attributes
                queries        = new clsDBQueries();
                currentInvoice = new clsInvoice();
                selectedItems  = new List <clsItem>();
                currentTotal   = 0;
                currentInvoice = null;

                //Bind ComboBox to Items in database and datagrid to selectedItems
                cmbBoxItems.ItemsSource       = queries.GetItems();
                dtgrdInvoiceItems.ItemsSource = selectedItems;
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// Open Edit Window Logic
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Reset UI
                ResetInvoiceData();
                grpboxInvoice.IsEnabled = false;
                btnPanel.IsEnabled      = true;

                //Open Window
                Hide();
                editWindow.ShowDialog();
                Show();

                //Repopulate Item Combobox
                cmbBoxItems.ItemsSource = queries.GetItems();

                //Update Items on Currently Displayed Invoice
                if (currentInvoice != null)
                {
                    currentInvoice.Items = queries.GetInvoiceContents(currentInvoice.InvoiceNumber);
                }

                ResetInvoiceData();
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }