Exemplo n.º 1
0
        private void invoice_saveChange_Click(object sender, EventArgs e)
        {
            foreach (var i in invoiceDetails)
            {
                if (i.ProductId == int.Parse(invoice_item_id_selected.Text))
                {
                    var product = new PublicProductService().GetProductById(i.ProductId);


                    if (product.ProductAmount >= int.Parse(invoice_changeAmount.Text) && int.Parse(invoice_changeAmount.Text) > 0)
                    {
                        i.InvoiceDetailAmount = int.Parse(invoice_changeAmount.Text);
                        i.InvoiceDetailTotal  = MultiplyMoney(product.ProductPrice, i.InvoiceDetailAmount);
                    }
                    else
                    {
                        MessageBox.Show("The number of products is not enough, please check the stock !!!");
                        i.InvoiceDetailAmount     = 1;
                        i.InvoiceDetailTotal      = MultiplyMoney(product.ProductPrice, 1);
                        invoice_changeAmount.Text = "1";
                    }

                    break;
                }
            }
            SetEnabledFormChangeProductDetail(false);
            LoadInvoiceDetail();
        }
Exemplo n.º 2
0
        //Control Product Panel-----------------------------------------------------------------------------------
        private void LoadProductType()
        {
            var productTypes = new PublicProductService().GetProductType();

            productTypes.ForEach(prdt =>
            {
                select_productType.Items.Add(prdt.ProductTypeId + " - " + prdt.ProductTypeName);
            });
        }
Exemplo n.º 3
0
 private void btn_select_product_Click(object sender, EventArgs e)
 {
     try
     {
         var product = new PublicProductService().GetProductById(int.Parse(product_id_selected.Text));
         invoiceDetails.Add(CreateInvoiceDetailByProduct(product, 1));
         LoadInvoiceDetail();
         UpdateProvisionalAmount();
     }
     catch { }
 }
Exemplo n.º 4
0
        private void LoadProducts(int typeid)
        {
            product_table.Rows.Clear();
            var products = new PublicProductService().GetProductByType(typeid);

            products.ForEach(p =>
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(product_table);

                row.Cells[0].Value = p.ProductId;
                row.Cells[1].Value = p.ProductName;
                row.Cells[2].Value = p.ProductAmount;
                product_table.Rows.Add(row);
            });
        }
Exemplo n.º 5
0
        //Control Invoice Panel-----------------------------------------------------------------------------------

        private void LoadInvoiceDetail()
        {
            invoice_detail_table.Rows.Clear();
            invoiceDetails.ForEach(p =>
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(invoice_detail_table);
                var product = new PublicProductService().GetProductById(p.ProductId);

                row.Cells[0].Value = p.ProductId;
                row.Cells[1].Value = product.ProductName;
                row.Cells[2].Value = p.InvoiceDetailAmount;
                row.Cells[3].Value = product.ProductPrice;
                row.Cells[4].Value = p.InvoiceDetailTotal;
                invoice_detail_table.Rows.Add(row);
            });

            UpdateProvisionalAmount();
        }
Exemplo n.º 6
0
        private void LoadTable()
        {
            product_table.Rows.Clear();
            List <Product> products = new PublicProductService().GetProductByType(search_product_type.SelectedIndex);

            products.ForEach(s =>
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(product_table);

                row.Cells[0].Value = s.ProductId;
                row.Cells[1].Value = s.ProductName;
                row.Cells[2].Value = s.ProductAmount;
                row.Cells[3].Value = s.ProductPrice;
                row.Cells[4].Value = s.ProductDescription;
                row.Cells[5].Value = s.ProductTypeId;
                row.Cells[6].Value = s.ProductImg;
                product_table.Rows.Add(row);
            });
        }
Exemplo n.º 7
0
        public InvoiceReportVM GetInvoiceReportVM(int id)
        {
            Invoice                   i = _context.Invoices.FirstOrDefault(_i => _i.InvoiceId == id);
            InvoiceReportVM           invoiceReportVM = new InvoiceReportVM();
            List <InvoiceRowReportVM> rows            = new List <InvoiceRowReportVM>();

            _context.InvoiceDetails.Where(idt => idt.InvoiceId == id).ToList().ForEach(iDetail =>
            {
                Product product = new PublicProductService().GetProductById(iDetail.ProductId);
                InvoiceRowReportVM invoiceRowReportVM = new InvoiceRowReportVM();

                invoiceRowReportVM.ProductName = product.ProductName;
                invoiceRowReportVM.Amount      = iDetail.InvoiceDetailAmount;
                invoiceRowReportVM.Price       = product.ProductPrice;
                invoiceRowReportVM.Total       = iDetail.InvoiceDetailTotal;

                rows.Add(invoiceRowReportVM);
            });
            invoiceReportVM.InvoiceId = id;

            invoiceReportVM.InvoiceDate  = i.InvoiceDate;
            invoiceReportVM.invoiceRows  = rows;
            invoiceReportVM.CustomerName = _context.Customers.FirstOrDefault(c => c.CustomerId == i.CustomerId).CustomerFullname;
            invoiceReportVM.StaffName    = _context.Staffs.FirstOrDefault(s => s.StaffId == i.StaffId).StaffFullname;

            var address = _context.DeliveryAddresses.FirstOrDefault(da => da.DeliveryAddressId == i.DeliveryAddressId);

            invoiceReportVM.DeliveryAddressRecipient = address.DeliveryAddressRecipient;
            invoiceReportVM.DeliveryAddressAddress   = address.DeliveryAddressAddress;
            invoiceReportVM.DeliveryAddressPhone     = address.DeliveryAddressPhone;

            invoiceReportVM.ProvisionalAmount = i.InvoiceProvisionalAmount;
            invoiceReportVM.Discount          = i.InvoiceDiscount;
            invoiceReportVM.Total             = i.InvoiceTotal;

            return(invoiceReportVM);
        }