Exemple #1
0
        }     //end add/update click

        /// <summary>
        /// delete invoice button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteInvoice_Click(object sender, RoutedEventArgs e)
        {
            ///try catch block
            try
            {
                ///check to see what the message box is showing
                if (MessageBox.Show("Are you sure you want to delete Invoice Number: " + invoiceId + "?", "Delete Invoice?", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                    //do no stuff
                }
                else
                {
                    ///if that fails, do this
                    String sSQL = mydb.DeleteLineItems(invoiceId);
                    db.ExecuteNonQuery(sSQL);

                    sSQL = mydb.DeleteInvoice(invoiceId);
                    db.ExecuteNonQuery(sSQL);

                    //easiest way to reset all values is to open a new window.
                    MainWindow mw = new MainWindow();
                    mw.Show();
                    this.Close();
                }//end else
            }
            catch (Exception)
            {
                MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name);
            } //end catch
        }     //end delete