コード例 #1
0
 public bool ChangeTableStatus(int TableID, bool isOrdered, bool isPaid, bool isBooked)
 {
     try
     {
         if (TableID > 0)
         {
             var x = dbContext.Tables.Where(t => t.TableID == TableID).FirstOrDefault();
             if (x != null)
             {
                 if (isOrdered == true)
                 {
                     x.Status = 2;
                 }
                 else if (isPaid == true)
                 {
                     x.Status = 0;
                 }
                 else if (isBooked == true)
                 {
                     x.Status = 1;
                 }
                 dbContext.SaveChanges();
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #2
0
 public bool AddEmployee(Employee e)
 {
     try
     {
         if (e != null)
         {
             dbContext.Employees.Add(e);
             dbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #3
0
 public bool AddCustomer(Customer e)
 {
     try
     {
         if (e != null)
         {
             dbContext.Customers.Add(e);
             dbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #4
0
 public bool AddBookingTable(BookingTable bookingTable)
 {
     if (bookingTable != null)
     {
         dbContext.BookingTables.Add(bookingTable);
         dbContext.SaveChanges();
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: OrderDAL.cs プロジェクト: tiendat07/QuanLyNhaHang
 // return lại giá trị orderID
 public int AddOrder(Order o, List <OrderDetail> orderDetails)
 {
     using (DbContextTransaction transaction = dbContext.Database.BeginTransaction())
     {
         try
         {
             if (o != null)
             {
                 var hoaDonTam = dbContext.Orders.Add(new Order()
                 {
                     OrderDate    = o.OrderDate,
                     IsPaid       = false,
                     Total        = o.Total,
                     CustomerID   = o.CustomerID,
                     TableID      = o.TableID,
                     EmployeeID   = o.EmployeeID,
                     OrderDetails = orderDetails
                 });
                 dbContext.SaveChanges();
                 foreach (OrderDetail chiTiet in o.OrderDetails)
                 {
                     chiTiet.OrderID = hoaDonTam.OrderID;
                     dbContext.OrderDetails.Add(chiTiet);
                 }
                 dbContext.SaveChanges();
                 transaction.Commit();
                 return(hoaDonTam.OrderID);
             }
             return(-1);
         }
         catch (Exception e)
         {
             transaction.Rollback();
             return(-1);
         }
     }
 }
コード例 #6
0
 public bool EditFoodDrink(FoodDrink food)
 {
     try
     {
         if (food != null)
         {
             FoodDrink fDrink = dbContext.FoodDrinks.Where(f => f.FoodDrinkID == food.FoodDrinkID).FirstOrDefault();
             if (fDrink == null)
             {
                 return(false);
             }
             fDrink.ImageURL      = food.ImageURL;
             fDrink.FoodDrinkName = food.FoodDrinkName;
             fDrink.Description   = food.Description;
             dbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #7
0
 public bool AddOrderDetail(OrderDetail orderDetail)
 {
     try
     {
         if (orderDetail != null)
         {
             dbContext.OrderDetails.Add(orderDetail);
             dbContext.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         return(false);
     }
 }