Example #1
0
 private void AddToInvoiceButton_Click(object sender, RoutedEventArgs e)
 {
     foreach (Window window in Application.Current.Windows)
     {
         if (window.GetType() == typeof(NewInvoiceWindow))
         {
             this.invoiceWindow = (window as NewInvoiceWindow);
         }
     }
     invoiceItem = new InvoiceItem()
     {
         ItemId   = this.itemToAdd.Id,
         Item     = this.itemToAdd,
         Quantity = int.Parse(quantityBox.Text)
     };
     invoiceWindow.invoiceItems.Add(invoiceItem);
     // Connects to database -- `using` statement closes connection after
     //using (SQLiteConnection connection = new SQLiteConnection(App.databasePath))
     //{
     //    // Creates the InvoiceItem table. Will be ignored if table already exists.
     //    connection.CreateTable<InvoiceItem>();
     //    connection.Insert(invoiceItem);
     //}
     Close();
 }
Example #2
0
        public EditInvoiceItemWindow(InvoiceItem invoiceItem, NewInvoiceWindow newInvoiceWindow)
        {
            InitializeComponent();

            this.invoiceItem      = invoiceItem;
            this.newInvoiceWindow = newInvoiceWindow;
            this.DataContext      = this.invoiceItem;

            quantityBox.KeyDown           += QuantityBox_KeyDown;
            updateQuantityButton.Click    += UpdateQuantityButton_Click;
            deleteInvoiceItemButton.Click += DeleteInvoiceItemButton_Click;
        }