public ActionResult Add(SalesViewModel salesvm)
        {
            var sales = new List <ProductSale>();
            //Purchase _purchase = new Purchase();
            CustomerSale _customerSale = new CustomerSale();

            if (ModelState.IsValid)
            {
                Customer _customer = new Customer();
                _customer.ID = salesvm.CustomerId;
                var customer = _customerManager.GetById(_customer);
                customer.LoyaltyPoint = salesvm.LoyaltyPoint;
                _customerManager.UpdateCustomer(customer);
                CustomerSale aCustomer = Mapper.Map <CustomerSale>(salesvm);
                _customerSaleManager.AddCustomerSale(aCustomer);

                ////_customerManager.UpdateCustomer(customer);
                ////_customerSale.Date = salesvm.Date;
                ////_customerSale.CustomerId = salesvm.CustomerId;
                ////_customerSale.LoyaltyPoint = salesvm.LoyaltyPoint;
                ////_customerSale.GrandTotal = salesvm.GrandTotal;
                ////_customerSale.Discount = salesvm.Discount;
                ////_customerSale.DiscountAmount = salesvm.DiscountAmount;
                ////_customerSale.PayableAmount = salesvm.PayableAmount;
                ////_customerSaleManager.AddCustomerSale(_customerSale);
                //var ps = _customerSaleManager.GetByCode(salesvm.InvoiceNumber);
                ////foreach (var sale in salesvm.ProductSales)
                ////{


                ////    sale.CustomerSaleId = 1;

                ////    sales.Add(sale);
                ////}

                ////_productSaleManager.AddProductSale(sales);
            }

            salesvm.CustomerList = _customerManager.GetAll().Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });

            salesvm.ProductList = _productManager.GetAll().Select(c => new SelectListItem()
            {
                Value = c.ID.ToString(),
                Text  = c.Name
            });

            return(View(salesvm));
        }
예제 #2
0
        public bool AddCustomerSale(CustomerSale customerSale)
        {
            int isExecuted = 0;

            db.CustomerSales.Add(customerSale);
            isExecuted = db.SaveChanges();
            if (isExecuted > 0)
            {
                return(true);
            }

            return(false);
        }
예제 #3
0
        public bool DeleteCustomerSale(CustomerSale customerSale)
        {
            int isExecuted = 0;

            CustomerSale aCustomerSale = db.CustomerSales.FirstOrDefault(c => c.ID == customerSale.ID);

            db.CustomerSales.Remove(aCustomerSale);
            isExecuted = db.SaveChanges();
            if (isExecuted > 0)
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        public bool UpdateCustomerSale(CustomerSale customerSale)
        {
            int isExecuted = 0;

            //CustomerSale aCustomerSale = db.CustomerSales.FirstOrDefault(c => c.Code == customerSale.Code);
            //if (aCustomerSale != null)
            //{
            //    aCustomerSale.Name = customerSale.Name;

            //}

            db.Entry(customerSale).State = EntityState.Modified;
            isExecuted = db.SaveChanges();


            if (isExecuted > 0)
            {
                return(true);
            }
            return(false);
        }
 public CustomerSale GetById(CustomerSale customerSale)
 {
     return(_customerSaleRepository.GetById(customerSale));
 }
 public bool UpdateCustomerSale(CustomerSale customerSale)
 {
     return(_customerSaleRepository.UpdateCustomerSale(customerSale));
 }
 public bool DeleteCustomerSale(CustomerSale customerSale)
 {
     return(_customerSaleRepository.DeleteCustomerSale(customerSale));
 }
 public bool AddCustomerSale(CustomerSale customerSale)
 {
     return(_customerSaleRepository.AddCustomerSale(customerSale));
 }
예제 #9
0
        public void AddControlCustomerBillFlowLayoutPanel()
        {
            flowLayoutPanelCustomer.Controls.Clear();
            for (int i = 0; i < salesOperation.SelectCustomerProducts().Rows.Count; i++)
            {
                Button b = new Button
                {
                    Name                  = salesOperation.SelectCustomerProducts().Rows[i][0].ToString(),
                    BackgroundImage       = Image.FromFile(salesOperation.SelectCustomerProducts().Rows[i][3].ToString()),
                    BackgroundImageLayout = ImageLayout.Stretch,
                    Height                = 100,
                    Width                 = 100,
                    Font                  = new Font(FontFamily.GenericMonospace, 18, FontStyle.Bold),
                };


                flowLayoutPanelCustomer.Controls.Add(b);
                b.Click += (s, e) =>
                {
                    if (s is Button button)
                    {
                        var selectedProduct = salesOperation.SelectCustomerProducts(Convert.ToInt32(button.Name));
                        if (selectedProduct.Rows.Count > 0)
                        {
                            Receipt obj = new Receipt
                            {
                                Id          = order++,
                                ProductName = selectedProduct.Rows[0][1].ToString(),
                                Price       = Convert.ToInt32(selectedProduct.Rows[0][4].ToString()),
                                Quantity    = 1
                            };
                            total += obj.Price * obj.Quantity;
                            receiptBindingSource.Add(obj);
                            receiptBindingSource.MoveLast();
                            txtTotal.Text = string.Format("RS {0}", total);
                            CustomerSale customerSale = new CustomerSale
                            {
                                ProductName = obj.ProductName,
                                Quantity    = obj.Quantity.ToString(),
                                SaleDate    = DateTime.Now.ToShortDateString(),
                                Total       = obj.Total.ToString()
                            };
                            customerSalesToSendInDB.Add(customerSale);
                        }
                    }
                };

                Label l = new Label
                {
                    Height  = 100,
                    Width   = 150,
                    Padding = new Padding(12),
                    Text    = "Name: " + salesOperation.SelectCustomerProducts().Rows[i][1].ToString() + "\n price:" + salesOperation.SelectCustomerProducts().Rows[i][4].ToString(),

                    Name = "lbl" + salesOperation.SelectCustomerProducts().Rows[i][0].ToString(),
                };
                flowLayoutPanelCustomer.Controls.Add(l);
            }



            flowLayoutPanelCustomer.AutoScroll = true;
        }
예제 #10
0
        public CustomerSale GetById(CustomerSale customerSale)
        {
            CustomerSale aCustomerSale = db.CustomerSales.FirstOrDefault(c => c.ID == customerSale.ID);

            return(aCustomerSale);
        }