Ejemplo n.º 1
0
        public void loadInfoOrder(BillSell billSell)
        {
            fORDER f1 = Application.OpenForms.OfType <fORDER>().FirstOrDefault();

            if (f1 != null)
            {
                if (billSell == null)
                {
                    f1.lbCount.Text = 0.ToString();
                    f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", 0.0);
                    return;
                }
                DetailBillSellService detailBillSellService = new DetailBillSellService(new CoffeShopContext());
                f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString();
                BillSellService bsService = new BillSellService(new CoffeShopContext());
                var             detail    = detailBillSellService.GetDetailBillSell(billSell);
                if (detail.Count == 0)
                {
                    f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString();
                    f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", 0.0);
                    return;
                }

                bsService.SetTotal(detail, billSell);
                f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", bsService.GetTotal(billSell));
            }
        }
Ejemplo n.º 2
0
        public bool DeleteDetailBillSellAll(BillSell billSell)
        {
            var list = GetDetailBillSell(billSell);

            _context.DetailBillSells.RemoveRange(list);
            return(true);
        }
Ejemplo n.º 3
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            bool   check = true;
            fORDER f1    = Application.OpenForms.OfType <fORDER>().FirstOrDefault();

            if (f1 != null)
            {
                try
                {
                    BillSell billSell = f1.getBillSellofTable();
                    DetailBillSellService detailBillSellService = new DetailBillSellService(new CoffeShopContext());
                    int number         = Convert.ToInt32(cbbNumber.SelectedItem);
                    var DetailBillSell = detailBillSellService.CreateDetailBillSell(billSell, _product, number);
                    var DetailBill     = detailBillSellService.GetDetailBill(DetailBillSell);
                    f1.addProductToListOrder(DetailBill);
                    f1.lbCount.Text = detailBillSellService.GetCountDetail(billSell).ToString();
                    BillSellService bsService = new BillSellService(new CoffeShopContext());
                    bsService.SetTotal(detailBillSellService.GetDetailBillSell(billSell), billSell);
                    f1.lbTotal.Text = String.Format("{0:0,00} VNĐ", bsService.GetTotal(billSell));
                }
                catch (Exception)
                {
                    cbbNumber.Refresh();
                    check = false;
                }
            }
            if (check)
            {
                this.Dispose();
            }
        }
Ejemplo n.º 4
0
        public BillSell CreateBillSell(Employe employe, Customer customer = null, Tables table = null)
        {
            if (customer == null && !table.status)
            {
                CustomerService cust      = new CustomerService(_context);
                var             _customer = cust.GetCustomer(Constants.Constants.customerDefault);

                BillSell billSell = new BillSell()
                {
                    createDate = DateTime.Now,
                    totalMoney = 0,
                    status     = false,
                };
                UserService userService = new UserService(_context);
                billSell.Employe = userService.GetUser(employe);
                TableService tableService = new TableService(_context);
                billSell.Table = tableService.GetTables(table);
                _context.Entry(billSell);
                _context.BillSells.Attach(billSell);

                _context.BillSells.Add(billSell);
                _context.SaveChanges();

                tableService.SetStatusTable(table, true);
                return(billSell);
            }
            return(null);
        }
Ejemplo n.º 5
0
        public bool setStatus(bool status, BillSell billSell)
        {
            var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault();

            bill.status = status;
            _context.SaveChanges();
            return(true);
        }
Ejemplo n.º 6
0
        private void uc_Table_Load(object sender, EventArgs e)
        {
            BillSellService billSellService = new BillSellService(new CoffeShopContext());

            label1.Text = index.ToString();
            if (table.status)
            {
                label1.BackColor = Color.Yellow;
                Name             = billSellService.GetBillSell(table).Id.ToString();
                _billSell        = billSellService.GetBillSell(table);
            }
        }
Ejemplo n.º 7
0
        //public bool DeleteBill()
        public bool DeleteBillSell(BillSell billSell)
        {
            var bil = _context.BillSells.FirstOrDefault(x => x.Id == billSell.Id);

            if (bil != null)
            {
                _context.BillSells.Remove(bil);

                _context.SaveChanges();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        public bool SetTotal(List <DetailBillSell> detailBillSells, BillSell billSell)
        {
            decimal total = 0;

            foreach (var item in detailBillSells)
            {
                total += item.Total;
            }

            var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault();

            bill.totalMoney = total;
            _context.SaveChanges();
            return(true);
        }
Ejemplo n.º 9
0
        public DetailBillSell CreateDetailBillSell(BillSell billSell, Product product, int number)
        {
            DetailBillSell detailBillSell = new DetailBillSell
            {
                Quantum = number,
                Total   = product.priceProduct * number,
            };
            ProductService productService = new ProductService(_context);

            detailBillSell.Product = productService.GetProduct(product);
            BillSellService billSellService = new BillSellService(_context);

            detailBillSell.BillSells = new List <BillSell>()
            {
                billSellService.GetBillWithId(billSell.Id)
            };
            _context.DetailBillSells.Add(detailBillSell);
            _context.SaveChanges();
            return(detailBillSell);
        }
Ejemplo n.º 10
0
        private void orderProduct_Click(object sender, EventArgs e)
        {
            fORDER.checkStatus = false;
            BillSellService billSellService = new BillSellService(new CoffeShopContext());

            if (!table.status)
            {
                _billSell        = billSellService.CreateBillSell(employe, null, table);
                Name             = _billSell.Id.ToString();
                label1.BackColor = Color.Yellow;
            }
            else
            {
                Guid Id = new Guid(Name);
                _billSell = billSellService.GetBillWithId(Id);
            }
            if (_billSell != null)
            {
                reloadProducts();
            }
            checkOrderd        = true;
            fORDER.staticBill  = _billSell;
            fORDER.staticTable = table;
        }
Ejemplo n.º 11
0
 public void orderProducts(BillSell billSell)
 {
     _billSell = billSell;
     uc_PanelOrderProducts.Instance.BillSell = billSell;
     myControls.Instance.addCotrolTableToOrder(uc_PanelOrderProducts.Instance, pnlControl);
 }
Ejemplo n.º 12
0
        public List <DetailBillSell> GetDetailBillSell(BillSell billSell)
        {
            var bill = _context.DetailBillSells.Where(x => x.BillSells.Any(r => r.Id == billSell.Id)).Include(x => x.Product).Include(x => x.BillSells).ToList <DetailBillSell>();

            return(bill);
        }
Ejemplo n.º 13
0
 public int  GetCountDetail(BillSell billSell)
 {
     return(_context.DetailBillSells.Where(x => x.BillSells.Any(r => r.Id == billSell.Id)).Include(x => x.Product).Include(x => x.BillSells).ToList().Sum(x => x.Quantum));
 }
Ejemplo n.º 14
0
        public decimal GetTotal(BillSell billSell)
        {
            var bill = _context.BillSells.Where(x => x.Id == billSell.Id).Include(x => x.Employe).Include(x => x.DetailBillSells).Include(x => x.Table).SingleOrDefault();

            return(bill.totalMoney);
        }
Ejemplo n.º 15
0
 public Tables GetTables(BillSell billSell)
 {
     return(_context.Tables.Where(x => x.Id == billSell.Table.Id).Include(x => x.BillSells).SingleOrDefault());
 }