示例#1
0
        private void OnSaveInvoiceButtonAction(object sender, RoutedEventArgs e)
        {
            bool isNumberEmpty   = service.ValidateNumberTextField(numberTextField, numberErrorLabel);
            bool isCustomerEmpty = service.ValidateCustomerButton(addCustomerButton, customerErrorLabel);
            bool isProductEmpty  = service.ValidateProductButton(listProductsButton, productErrorLabel);

            if (!isNumberEmpty && !isCustomerEmpty && !isProductEmpty)
            {
                invoice.Number   = numberTextField.Text;
                invoice.Date     = datePicker.SelectedDate == null ? DateTime.Now : datePicker.SelectedDate.Value;
                invoice.Deadline = deadlinePicker.SelectedDate == null ? DateTime.Now : deadlinePicker.SelectedDate.Value;
                invoice.Customer = customer;
                invoice.Comment  = commentTextField.Text;
                invoice.Status   = Status.NOT_SENT;

                invoice.InvoiceProducts = new List <InvoiceProduct>();


                foreach (Product product in products)
                {
                    InvoiceProduct ip = new InvoiceProduct();
                    ip.Invoice = invoice;
                    ip.Product = product;

                    invoice.InvoiceProducts.Add(ip);
                }

                repository.AddInvoice(invoice, context, isUpdateFlag);
                invoiceWindow.RefreshInvoiceGridData();
                Close();
            }
        }
示例#2
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();
            }
        }
示例#3
0
        public async Task <IActionResult> AddInvoice(InvoiceData iData)
        {
            User user = await _auth.GetUser(this.User.Identity.Name);

            Permissions permissions = await _auth.GetPermissions(user.Id);

            if (permissions.AddInvoice == false)
            {
                return(Unauthorized());
            }

            if (ModelState.IsValid)
            {
                var invoiceToCreate = new Invoice
                {
                    InvoiceDate   = iData.InvoiceDate,
                    OutgoingInv   = iData.OutgoingInv,
                    AmountPaid    = iData.AmountPaid,
                    Tax           = iData.Tax,
                    Discount      = iData.Discount,
                    InvoiceCustID = iData.InvoiceCustID
                };

                //var invoiceToCreate = _mapper.Map<Invoice>(iData);

                var createdInvoice = await _Irepo.AddInvoice(invoiceToCreate);

                lastInvoice.username      = this.User.Identity.Name;
                lastInvoice.lastInvoiceId = createdInvoice.Id;

                return(StatusCode(201));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
示例#4
0
 public ActionResult AddInvoice(Invoices invoice)
 {
     repository.AddInvoice(invoice);
     return(RedirectToAction("Index"));
 }