Ejemplo n.º 1
0
        /// <summary>
        /// Insert data into Invoice DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNewInvoice_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Enable textboxes
                tbInvoiceNumber.IsEnabled = true;
                dpInvoiceDate.IsEnabled   = true;
                txtbxTotalCost.IsEnabled  = true;
                cmbInvoiceItem.IsEnabled  = true;
                cmbxItemsAdded.IsEnabled  = true;

                //Enable Save button
                btnSaveInvoice.IsEnabled = true;

                //Insert Current Date
                dpInvoiceDate.SelectedDate = DateTime.Today;
                ml.SaveInvoice(dpInvoiceDate.SelectedDate.Value.Date.ToShortDateString(), "0");

                //Generate a new Invoice ID
                newID = ml.GenerateInvoiceID();

                //Insert Invoice ID onto Page
                tbInvoiceNumber.Text = newID;

                //Set variable to Current InvoiceNum
                InvoiceNum = newID;
            }
            catch (Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  Save Invoice
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Save_Click(object sender, RoutedEventArgs e)
        {
            if (mn.CurrentInvoice.Items != null && mn.CurrentInvoice.Items.Count > 0)
            {
                mn.SaveInvoice();
                lbl_InvoiceNumber.Content = mn.CurrentInvoice.InvoiceNumber;

                Btn_Edit.Visibility   = Visibility.Visible;
                Btn_Save.Visibility   = Visibility.Hidden;
                Btn_Delete.Visibility = Visibility.Hidden;
                Btn_Cancel.Visibility = Visibility.Visible;

                dp_InvoiceDate.IsEnabled        = false;
                cb_InvoiceItems.IsEnabled       = false;
                btn_AddToInvoice.IsEnabled      = false;
                btn_RemoveFromInvoice.IsEnabled = false;
                Btn_Edit.IsEnabled = true;
            }
            else
            {
                MessageBox.Show("Items box cannot be empty!");
            }
        }