コード例 #1
0
        /// <summary>
        /// This will delete an existing Invoice
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteInvoice_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                clsInvoice invoice    = (clsInvoice)dgInvoices.SelectedItem;
                string     invoiceNum = invoice.InvoiceNum.ToString();

                ml.DeleteLineItems(invoiceNum);
                ml.DeleteInvoice(invoiceNum);

                dgInvoices.ClearValue(ItemsControl.ItemsSourceProperty);

                //Populate DataGrid with Invoices
                List <clsInvoice> refresh = ml.GetAllInvoices();
                dgInvoices.ItemsSource = refresh;
                //disable Delete and Edit Buttons
                btnDeleteInvoice.IsEnabled = false;
                btnEditInvoice.IsEnabled   = false;
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// Data Grid on Selected Invoice
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgInvoices_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                clsInvoice invoice = (clsInvoice)dgInvoices.SelectedItem;
                //clsItems items = mainLogic.
                if (invoice != null)
                {
                    btnEditInvoice.IsEnabled   = true;
                    btnDeleteInvoice.IsEnabled = true;

                    tbInvoiceNumber.Text = invoice.InvoiceNum.ToString();
                    InvoiceNum           = invoice.InvoiceNum.ToString();
                    dpInvoiceDate.Text   = invoice.InvoiceDate;
                    txtbxTotalCost.Text  = "$ " + String.Format("{0:N2}", invoice.TotalCost.ToString());
                    total = invoice.TotalCost;
                }
            }
            catch (System.Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
コード例 #3
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);
            }
        }