예제 #1
0
        private void ButtonEditCustomer_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            if (TextBoxCustomerEmail != null && TextBoxCustomerTelephone != null && TextBoxCustomerZip != null && TextBoxCustomerTown != null)
            {
                customer.CompanyName       = TextBoxCompanyName.Text;
                customer.CustomerEmail     = TextBoxCustomerEmail.Text;
                customer.CustomerAddress   = TextBoxCustomerAddress.Text;
                customer.CustomerTelephone = TextBoxCustomerTelephone.Text;
                customer.CustomerZip       = TextBoxCustomerZip.Text;
                customer.CustomerTown      = TextBoxCustomerTown.Text;

                customerRepository.EditCustomer(customer);

                wsd.LabelShowDialog.Content = "Kunden blev opdateret";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i opdateringen af kunden";
                wsd.ShowDialog();
            }
        }
예제 #2
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            RawProduct       rawProduct = new RawProduct();
            WindowShowDialog wsd        = new WindowShowDialog();

            rawProduct.RawProductName = TextBoxName.Text.ToString();

            if (double.TryParse(TextBoxWeight.Text, out double resultWeight) && TextBoxDateOfPurchase.SelectedDate != null)
            {
                rawProduct.RawProductWeight = double.Parse(TextBoxWeight.Text);
                rawProduct.DateOfPurchase   = DateTime.Parse(TextBoxDateOfPurchase.Text);

                rawProductRepository.AddRawProduct(rawProduct);

                wsd.LabelShowDialog.Content = "Råvaren blev tilføjet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Vægt' eller 'Indkøbsdato'";
                wsd.ShowDialog();
            }
        }
예제 #3
0
        private void ButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            product.ProductName = TextBoxName.Text.ToString();

            if (double.TryParse(TextBoxWeight.Text, out double resultWeight) && double.TryParse(TextBoxPrice.Text, out double resultPrice) && double.TryParse(TextBoxAmount.Text, out double resultAmount) && TextBoxDateOfPackaging.SelectedDate != null && TextBoxDateOfExpiration.SelectedDate != null)
            {
                product.ProductWeight    = double.Parse(TextBoxWeight.Text);
                product.ProductPrice     = double.Parse(TextBoxPrice.Text);
                product.ProductAmount    = double.Parse(TextBoxAmount.Text);
                product.DateOfPackaging  = DateTime.Parse(TextBoxDateOfPackaging.Text);
                product.DateOfExpiration = DateTime.Parse(TextBoxDateOfExpiration.Text);

                productRepository.EditProduct(product);

                wsd.LabelShowDialog.Content = "Varen blev opdateret";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i lidt af hvert xd";
                wsd.ShowDialog();
            }
        }
예제 #4
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            Product          product = new Product();
            WindowShowDialog wsd     = new WindowShowDialog();

            product.ProductName = TextBoxName.Text.ToString();

            if (double.TryParse(TextBoxWeightAfterLoss.Text, out double resultWeight) && double.TryParse(TextBoxPrice.Text, out double resultPrice) && double.TryParse(TextBoxAmount.Text, out double resultAmount) && TextBoxDateOfPackaging.SelectedDate != null && TextBoxDateOfExpiration.SelectedDate != null)
            {
                product.ProductWeight    = resultWeight;
                product.ProductPrice     = resultPrice;
                product.ProductAmount    = resultAmount;
                product.DateOfPackaging  = DateTime.Parse(TextBoxDateOfPackaging.Text);
                product.DateOfExpiration = DateTime.Parse(TextBoxDateOfExpiration.Text);

                productRepository.AddProduct(product);
                rawProduct.RawProductWeight -= double.Parse(TextBoxWeightAfterLoss.Text);
                rawProductRepository.EditRawProduct(rawProduct);
                wsd.LabelShowDialog.Content = "Varen blev tilføjet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Vægt' eller 'Indkøbsdato'";
                wsd.ShowDialog();
            }
        }
예제 #5
0
        private void ButtonCreateCustomer_Click(object sender, RoutedEventArgs e)
        {
            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            customer.CompanyName = TextBoxCompanyName.Text.ToString();

            if (TextBoxCustomerAddress != null && TextBoxCustomerTelephone != null && TextBoxCustomerZip != null && TextBoxCustomerTelephone != null && TextBoxCustomerEmail != null)
            {
                customer.CompanyName       = TextBoxCompanyName.Text;
                customer.CustomerEmail     = TextBoxCustomerEmail.Text;
                customer.CustomerAddress   = TextBoxCustomerAddress.Text;
                customer.CustomerTelephone = TextBoxCustomerTelephone.Text;
                customer.CustomerZip       = TextBoxCustomerZip.Text;
                customer.CustomerTown      = TextBoxCustomerTown.Text;

                customerRepository.AddCustomer(customer);
                wsd.LabelShowDialog.Content = "Kunden blev tilføjet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Muligvis tommefelter";
                wsd.ShowDialog();
            }
        }
예제 #6
0
        private void ButtonSearchOrdre_Click(object sender, RoutedEventArgs e)
        {
            Order order = new Order();

            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            if (double.TryParse(TextBoxOrderID.Text, out double resultOrderID) || (double.TryParse(TextBoxCustomer.Text, out double resultCustomer) || double.TryParse(TextBoxTotalPrice.Text, out double resultTotalPrice) || DatePickerDateOfPurchase.SelectedDate != null))
            {
                if (double.TryParse(TextBoxOrderID.Text, out resultOrderID) == false)
                {
                    order.OrderID = 0;
                }
                else
                {
                    order.OrderID = int.Parse(TextBoxOrderID.Text);
                }

                if (double.TryParse(TextBoxCustomer.Text, out resultCustomer) == false)
                {
                    order.Customer            = new Domain.Customer();
                    order.Customer.CustomerID = 0;
                }
                else
                {
                    order.Customer = customer.GetCustomer(int.Parse(TextBoxCustomer.Text));
                }

                if (double.TryParse(TextBoxTotalPrice.Text, out resultTotalPrice) == false)
                {
                    order.TotalPrice = 0;
                }
                else
                {
                    order.TotalPrice = double.Parse(TextBoxTotalPrice.Text);
                }

                if (DatePickerDateOfPurchase.SelectedDate == null)
                {
                    order.DateOfPurchase = new DateTime(1973, 1, 1, 12, 0, 0);
                }
                else
                {
                    order.DateOfPurchase = DateTime.Parse(DatePickerDateOfPurchase.Text);
                }

                eventSendList(orderRepository.DisplaySpecificOrders(order));
                this.Close();
            }

            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Order nummer', 'Kunde', 'Samlet pris' eller 'Pakke dato'";
                wsd.ShowDialog();
            }
        }
예제 #7
0
        private void ButtonSend_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            invoiceRepository.SendInvoice(invoice);

            wsd.LabelShowDialog.Content = "Ikke implementeret endnu!";
            wsd.ShowDialog();

            this.Close();
        }
예제 #8
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            if (double.TryParse(TextBoxTotalPrice.Text, out double resultTotalPrice) && TextBoxDateOfPurchase.SelectedDate != null && (RadioButtonIsOrder.IsChecked == true || RadioButtonIsOffer.IsChecked == true))
            {
                order.TotalPrice     = double.Parse(TextBoxTotalPrice.Text);
                order.DateOfPurchase = DateTime.Parse(TextBoxDateOfPurchase.Text);
                if (RadioButtonIsOrder.IsChecked == true)
                {
                    order.Active = true;
                }
                else if (RadioButtonIsOffer.IsChecked == true)
                {
                    order.Active = false;
                }
                int comboBoxNumber = ComboBoxOffers.SelectedIndex;
                if (comboBoxNumber == 0 || comboBoxNumber == -1)
                {
                    orderRepository.AddOrder(order);
                }
                else
                {
                    orderRepository.EditOrder(order);
                }

                for (int i = 0; i < orderlines.Count; i++)
                {
                    orderlines[i].OrderID = orderRepository.DisplayLastOrderID();
                    orderline.OrderID     = orderlines[i].OrderID;
                    orderline.Product     = orderlines[i].Product;
                    orderline.Amount      = orderlines[i].Amount;
                    orderlineRepository.AddOrderline(orderline);

                    if (order.Active == true)
                    {
                        product = orderline.Product;
                        product.ProductAmount -= orderline.Amount;
                        productRepository.EditProduct(product);
                    }
                }

                wsd.LabelShowDialog.Content = "Ordren blev tilføjet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl man";
                wsd.ShowDialog();
            }
        }
예제 #9
0
 private void ButtonDeleteOrder_Click(object sender, RoutedEventArgs e)
 {
     if (order != null)
     {
         WindowDeleteOrder weo = new WindowDeleteOrder(order);
         weo.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen ordre er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #10
0
 private void ButtonDeleteRawProduct_Click(object sender, RoutedEventArgs e)
 {
     if (rawProductID != 0)
     {
         WindowDeleteRawProduct wdrp = new WindowDeleteRawProduct(rawProductID, rawProductName);
         wdrp.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen råvare er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #11
0
 private void ButtonEditCustomer_Click(object sender, RoutedEventArgs e)
 {
     if (customerID != 0)
     {
         WindowEditCustomer wec = new WindowEditCustomer(customerID);
         wec.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen kunde er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #12
0
 private void ButtonDeleteProduct_Click(object sender, RoutedEventArgs e)
 {
     if (product != null)
     {
         WindowDeleteProduct wdp = new WindowDeleteProduct(product);
         wdp.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen vare er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #13
0
 private void ButtonDeleteCustomer_Click(object sender, RoutedEventArgs e)
 {
     if (customerID != 0)
     {
         WindowDeleteCustomer wdp = new WindowDeleteCustomer(customerID, companyName);
         wdp.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen kunde er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #14
0
 private void ButtonOK_Click(object sender, RoutedEventArgs e)
 {
     amount = double.Parse(TextBoxProductAmount.Text);
        
     if (amount <= product.ProductAmount)
     {
         eventSendProductAmount(amount, true);
         this.Close();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Så mange vare er der ikke på lager";
         wsd.ShowDialog();
     }
 }
예제 #15
0
        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            RawProduct       rawProduct = new RawProduct();
            WindowShowDialog wsd        = new WindowShowDialog();

            rawProduct.RawProductName = TextBoxName.Text.ToString();

            if (double.TryParse(TextBoxWeight.Text, out double resultWeight) || TextBoxDateOfPurchase.SelectedDate != null)
            {
                if (double.TryParse(TextBoxWeight.Text, out resultWeight) == false)
                {
                    rawProduct.RawProductWeight = 0;
                }
                else
                {
                    rawProduct.RawProductWeight = double.Parse(TextBoxWeight.Text);
                }
                if (TextBoxDateOfPurchase.SelectedDate == null)
                {
                    rawProduct.DateOfPurchase = new DateTime(1973, 1, 1, 12, 0, 0);
                }
                else
                {
                    rawProduct.DateOfPurchase = DateTime.Parse(TextBoxDateOfPurchase.Text);
                }

                eventSendList(rawProductRepository.DisplaySpecificRawProducts(rawProduct));

                this.Close();
            }
            else if (TextBoxWeight.Text == string.Empty || TextBoxDateOfPurchase.SelectedDate == null)
            {
                rawProduct.DateOfPurchase = new DateTime(1973, 1, 1, 12, 0, 0);

                eventSendList(rawProductRepository.DisplaySpecificRawProducts(rawProduct));

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Vægt' eller 'Indkøbsdato'";
                wsd.ShowDialog();
            }
        }
예제 #16
0
 private void ButtonMakeCreditNota_Click(object sender, RoutedEventArgs e)
 {
     if (invoice.CreditNota == true)
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Faktura er allerede lavet til en kreditnota!";
         wsd.ShowDialog();
     }
     else if (invoice.InvoiceID != 0)
     {
         WindowMakeCreditNota wec = new WindowMakeCreditNota(invoice);
         wec.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen faktura er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #17
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            invoice.CreditNota = true;
            List <Orderline> orderlines = orderlineRepository.DisplayOrderlines(invoice.Order);

            for (int i = 0; i < orderlines.Count; i++)
            {
                Product product = orderlines[i].Product;
                product.ProductAmount += orderlines[i].Amount;
                productRepository.EditProduct(product);
                orderlineRepository.DeleteOrderline(orderlines[i].OrderlineNumber);
            }
            invoiceRepository.EditInvoice(invoice);

            wsd.LabelShowDialog.Content = "Kreditnota blev dannet";
            wsd.ShowDialog();

            this.Close();
        }
예제 #18
0
 private void ButtonSendInvoice_Click(object sender, RoutedEventArgs e)
 {
     if (invoice.Send == true)
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Faktura er allerede sendt!";
         wsd.ShowDialog();
     }
     else if (invoice.InvoiceID != 0)
     {
         WindowSendInvoice wsi = new WindowSendInvoice(invoice);
         wsi.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen faktura er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #19
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            if (TextBoxCustomer.Text != "" && ComboBoxFormOfDelivery.SelectedIndex != -1 && ComboBoxFormOfPayment.SelectedIndex != -1 && TextBoxDateOfDelivery.SelectedDate != null)
            {
                invoice.DateOfDelivery = DateTime.Parse(TextBoxDateOfDelivery.Text);

                invoiceRepository.AddInvoice(invoice);

                wsd.LabelShowDialog.Content = "Faktura blev dannet";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl man";
                wsd.ShowDialog();
            }
        }
예제 #20
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            WindowShowDialog wsd = new WindowShowDialog();

            if (double.TryParse(TextBoxTotalPrice.Text, out double resultTotalPrice) && TextBoxDateOfPurchase.SelectedDate != null)
            {
                order.TotalPrice     = double.Parse(TextBoxTotalPrice.Text);
                order.DateOfPurchase = DateTime.Parse(TextBoxDateOfPurchase.Text);
                if (RadioButtonIsOrder.IsChecked == true)
                {
                    order.Active = true;
                }
                else if (RadioButtonIsOffer.IsChecked == true)
                {
                    order.Active = false;
                }
                orderRepository.EditOrder(order);

                for (int i = 0; i < orderlines.Count; i++)
                {
                    if (order.Active == true)
                    {
                        product = orderline.Product;
                        product.ProductAmount -= orderline.Amount;
                        productRepository.EditProduct(product);
                    }
                }

                wsd.LabelShowDialog.Content = "Ordren blev redigeret";
                wsd.ShowDialog();

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl man";
                wsd.ShowDialog();
            }
        }
예제 #21
0
 private void ButtonEditOrder_Click(object sender, RoutedEventArgs e)
 {
     invoiceRepository.DisplayInvoiceFromOrder(order.OrderID);
     if (invoiceRepository.DisplayInvoiceFromOrder(order.OrderID) == true)
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Der er allerede dannet en faktura på denne ordre!";
         wsd.ShowDialog();
     }
     else if (order != null)
     {
         WindowEditOrder weo = new WindowEditOrder(order);
         weo.ShowDialog();
         Update();
     }
     else
     {
         WindowShowDialog wsd = new WindowShowDialog();
         wsd.LabelShowDialog.Content = "Ingen ordre er valgt!";
         wsd.ShowDialog();
     }
 }
예제 #22
0
        private void ButtonSearchCustomer_Click(object sender, RoutedEventArgs e)
        {
            Domain.Customer  customer = new Domain.Customer();
            WindowShowDialog wsd      = new WindowShowDialog();

            if (TextBoxCompanyName != null || TextBoxCustomerEmail != null || TextBoxCustomerAddress != null || TextBoxCustomerTown != null || TextBoxCustomerZip != null || TextBoxCustomerTelephone != null)
            {
                customer.CompanyName       = TextBoxCompanyName.Text.ToString();
                customer.CustomerEmail     = TextBoxCustomerEmail.Text.ToString();
                customer.CustomerAddress   = TextBoxCustomerAddress.Text.ToString();
                customer.CustomerTown      = TextBoxCustomerTown.Text.ToString();
                customer.CustomerZip       = TextBoxCustomerZip.Text.ToString();
                customer.CustomerTelephone = TextBoxCustomerTelephone.Text.ToString();

                eventSendList(customerRepository.DisplaySpecificCustomers(customer));

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Firma navn', 'Adresse', 'By', 'Postnr' eller 'Telefon'";
                wsd.ShowDialog();
            }
        }
예제 #23
0
        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            Product          product = new Product();
            WindowShowDialog wsd     = new WindowShowDialog();

            if (double.TryParse(TextBoxWeight.Text, out double resultWeight) && double.TryParse(TextBoxPrice.Text, out double resultPrice) && double.TryParse(TextBoxAmount.Text, out double resultAmount) || TextBoxDateOfPackaging.SelectedDate != null || TextBoxDateOfExpiration != null)
            {
                if (TextBoxName.Text.ToString() == "Navn")
                {
                    product.ProductName = string.Empty;
                }
                else
                {
                    product.ProductName = TextBoxName.Text.ToString();
                }
                if (double.TryParse(TextBoxWeight.Text, out resultWeight) == false)
                {
                    product.ProductWeight = 0;
                }
                else
                {
                    product.ProductWeight = double.Parse(TextBoxWeight.Text);
                }
                if (double.TryParse(TextBoxPrice.Text, out resultPrice) == false)
                {
                    product.ProductPrice = 0;
                }
                else
                {
                    product.ProductPrice = double.Parse(TextBoxPrice.Text);
                }
                if (double.TryParse(TextBoxAmount.Text, out resultAmount) == false)
                {
                    product.ProductAmount = 0;
                }
                else
                {
                    product.ProductAmount = double.Parse(TextBoxAmount.Text);
                }
                if (TextBoxDateOfPackaging.SelectedDate == null)
                {
                    product.DateOfPackaging = new DateTime(1973, 1, 1, 12, 0, 0);
                }
                else
                {
                    product.DateOfPackaging = DateTime.Parse(TextBoxDateOfPackaging.Text);
                }
                if (TextBoxDateOfExpiration.SelectedDate == null)
                {
                    product.DateOfExpiration = new DateTime(1973, 1, 1, 12, 0, 0);
                }
                else
                {
                    product.DateOfExpiration = DateTime.Parse(TextBoxDateOfExpiration.Text);
                }

                eventSendList(productRepository.DisplaySpecificProducts(product));

                this.Close();
            }
            else if (TextBoxWeight.Text == string.Empty || TextBoxPrice.Text == string.Empty || TextBoxAmount.Text == string.Empty || TextBoxDateOfPackaging.SelectedDate == null || TextBoxDateOfExpiration == null)
            {
                product.DateOfPackaging  = new DateTime(1973, 1, 1, 12, 0, 0);
                product.DateOfExpiration = new DateTime(1973, 1, 1, 12, 0, 0);

                eventSendList(productRepository.DisplaySpecificProducts(product));

                this.Close();
            }
            else
            {
                wsd.LabelShowDialog.Content = "Der var en fejl i 'Vægt', 'Pris', 'Antal' 'Pakkedato' eller 'Udløbsdato'";
                wsd.ShowDialog();
            }
        }