Exemplo n.º 1
0
        public Bill CreateBill(int id, string name)  //SE RECIBE EL ID DE LA FACTURA Y EL NOMBRE DE LA MISMA
        {
            decimal Tax       = Cost * CostaRicaTax; //CALCULAN LOS IMPUESTOS
            decimal FinalCost = Cost + Tax;          //CALCULA EL TOTAL

            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }
            else
            {
                if (SearchByID(id) != null)
                {
                    return(null);
                }
                else
                {
                    Bill bill = new Bill()
                    {
                        ID = id, Name = name, Orders = BillOrders.ToString(), Cost = Cost, Tax = Tax, FinalCost = FinalCost
                    };
                    DBAccessConnection.CreateBill(bill);   //CREA LA FACTURA EN LA BD
                    Bills = DBAccessConnection.GetBills(); //ACTUALIZA LA LISTA
                    return(bill);
                }
            }
        }
Exemplo n.º 2
0
 public BillLogic(int Table) //CUANDO UN CAJERO VAYA A FACTURAR MANDE OBLIGATORIAMENTE LA MESA
 {
     Bills      = DBAccessConnection.GetBills();
     this.Table = Table;
     BillOrders = new StringBuilder();
     OrdersToPayInTheSameTable = Orders.GetOrdersToPay(Table); //SE OBTIENEN LAS ORDENES PENDIENTES DE ESA MESA
 }
Exemplo n.º 3
0
        public Order_Product CreateOrder(int table, int product, decimal cost)
        {
            Order_Product order = new Order_Product()
            {
                Table_id = table, Product_id = product, Cost = cost, Completed = 0, Paid = 0
            };

            DBAccessConnection.CreateOrder(order);
            LoadOrders();
            return(order);
        }
Exemplo n.º 4
0
 public void PayOrder(Order order)
 {
     foreach (var i in Orders)
     {
         if (i == order)
         {
             DBAccessConnection.PayOrder(i.ID);
         }
     }
     LoadOrders();
 }
Exemplo n.º 5
0
        private Product SearchProductById(int id)
        {
            List <Product> Products = DBAccessConnection.GetProducts();

            foreach (var i in Products)
            {
                if (i.ID == id)
                {
                    return(i);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
 private void LoadOrders()
 {
     Orders.Clear();
     OrderProduct = DBAccessConnection.GetOrders();
     foreach (var i in OrderProduct)
     {
         Order order = new Order()
         {
             ID = i.ID, Table = i.Table_id, Cost = i.Cost, Paid = i.Paid, Completed = i.Completed, Product = SearchProductById(i.Product_id)
         };
         Orders.Add(order);
     }
 }
Exemplo n.º 7
0
 public Product DeleteProduct(int id)
 {
     if (SearchByID(id) == null)
     {
         return(null);
     }
     else
     {
         Product product = SearchByID(id);
         DBAccessConnection.DeleteProduct(product);
         Products = DBAccessConnection.GetProducts();
         return(product);
     }
 }
Exemplo n.º 8
0
 public Table FreeTable(int id)
 {
     foreach (var table in Tables)
     {
         if (table.ID == id)
         {
             if (table.Available == 0)
             {
                 DBAccessConnection.UpdateTableAvailability(table, 1);
                 Tables = DBAccessConnection.GetTables();
                 return(table);
             }
         }
     }
     return(null);
 }
Exemplo n.º 9
0
 public Table AddTable(int id, int people)
 {
     if (people > 0 && SearchById(id) == null)
     {
         Table table = new Table {
             ID = id, People = people, Available = 1
         };
         DBAccessConnection.CreateTable(table);
         Tables = DBAccessConnection.GetTables();
         return(table);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 10
0
 public Product AddProduct(int id, string name, string description, decimal cost)
 {
     if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(description) || cost < 0)
     {
         return(null);
     }
     else
     {
         if (SearchByID(id) != null)
         {
             return(null);
         }
         else
         {
             Product product = new Product()
             {
                 ID = id, Name = name, Description = description, Cost = cost
             };
             DBAccessConnection.CreateProduct(product);
             Products = DBAccessConnection.GetProducts();
             return(product);
         }
     }
 }
Exemplo n.º 11
0
 public ProductLogic()
 {
     Products = DBAccessConnection.GetProducts();
 }
Exemplo n.º 12
0
 public TableLogic()
 {
     Tables = DBAccessConnection.GetTables();
 }
Exemplo n.º 13
0
 /// <summary>
 /// Gestion de los usuario
 /// Creacion de nuevos usuarios por parte de un usuario administrador
 /// Busqueda de usuario por nombre de usuario
 /// Deshabilitar usuario existentes
 /// </summary>
 public UserLogic()
 {
     Users = DBAccessConnection.GetUsers();
 }