コード例 #1
0
 public void updateOrder(string username, int quantity)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Cart cart = entities.Carts.Where(p => p.Username == username).First <Cart>();
         cart.Quantity = quantity;
         entities.SaveChanges();
     }
 }
コード例 #2
0
 public static void DeleteDiscount(int discountId)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Discount discount = entities.Discounts.Where(p => p.discountID == discountId).First <Discount>();
         entities.Discounts.Remove(discount);
         entities.SaveChanges();
     }
 }
コード例 #3
0
 public void ManageOrder_DeleteOrder(int orderId)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Order order = entities.Orders.Where(p => p.OrderID == orderId).First <Order>();
         entities.Orders.Remove(order);
         entities.SaveChanges();
     }
 }
コード例 #4
0
 public void deleteOrder(int bookID)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Cart cart = entities.Carts.Where(p => p.BookID == bookID).First <Cart>();
         entities.Carts.Remove(cart);
         entities.SaveChanges();
     }
 }
コード例 #5
0
 public void DeleteOrder(int bookID)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Book b = entities.Books.Where(p => p.BookID == bookID).First <Book>();
         entities.Books.Remove(b);
         entities.SaveChanges();
     }
 }
コード例 #6
0
    public void AddOrder(int bookID, int quantity, decimal price)
    {
        BookshopEntities1 bk = new BookshopEntities1();

        Cart ct = new Cart();

        ct.BookID   = bookID;
        ct.Quantity = quantity;
        ct.Price    = price;

        bk.Carts.Add(ct);
        bk.SaveChanges();
    }
コード例 #7
0
 public void UpdateBook(int bookID, string title, string categoryID, string ISBN, string author, string stock, string price)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Book b = entities.Books.Where(p => p.BookID == bookID).First <Book>();
         b.Title      = title;
         b.CategoryID = Int32.Parse(categoryID);
         b.ISBN       = ISBN;
         b.Author     = author;
         b.Stock      = Int32.Parse(stock);
         b.Price      = Decimal.Parse(price);
         entities.SaveChanges();
     }
 }
コード例 #8
0
 public static void AddDiscount(DateTime startDate, DateTime endDate, decimal Discount)
 {
     using (BookshopEntities1 entities = new BookshopEntities1())
     {
         Discount discount = new Discount
         {
             StartDate = startDate,
             EndDate   = endDate,
             Discount1 = Discount
         };
         entities.Discounts.Add(discount);
         entities.SaveChanges();
     }
 }
コード例 #9
0
    //public static List<Book> BookChoice()
    //{
    //    using (Model entities = new Model())
    //    {
    //        return entities.Books.ToList<Book>();
    //    }
    //}



    public void UpdateOrder(int orderID,
                            string userName, DateTime orderDate, decimal price)
    {
        using (BookshopEntities1 entities = new BookshopEntities1())
        {
            Order order = entities.Orders.Where(p => p.OrderID == orderID).First <Order>();
            order.OrderID    = orderID;
            order.UserName   = userName;
            order.OrderDate  = orderDate;
            order.TotalPrice = price;

            entities.SaveChanges();
        }
    }
コード例 #10
0
    //public static string GetBookName(int id)
    //{
    //    using (Model entities = new Model())
    //    {
    //        Book books = entities.Books.Where(f => f.BookID == id).ToList<Book>()[0];
    //        return books.Title;
    //    }
    //}

    public void AddBook(
        string title, int categoryID, string ISBN, string author, int stock, decimal price) // "AddBook METHOD IS NEW "- ALEX
    {
        using (BookshopEntities1 entities = new BookshopEntities1())
        {
            Book b = new Book();
            b.Title      = title;
            b.CategoryID = categoryID;
            b.ISBN       = ISBN;
            b.Author     = author;
            b.Stock      = stock;
            b.Price      = price;
            entities.Books.Add(b);
            entities.SaveChanges();
        }
    }
コード例 #11
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Request.IsAuthenticated)
     {
         Cart cart = new Cart();
         cart.Username = Context.User.Identity.Name;
         cart.BookID   = context.Books.Where(x => x.ISBN == ISBN).First().BookID;
         cart.Quantity = Int32.Parse(DropDownList1.SelectedValue);
         cart.Price    = decimal.Parse(Price) * cart.Quantity;
         context.Carts.Add(cart);
         context.SaveChanges();
         Response.Write("<script>alert('Add Success!')</script>");
     }
     else
     {
         Response.Redirect("login.aspx");
     }
 }
コード例 #12
0
    public Boolean CreateAccount(string username, string password, string email, string phone, string address)
    {
        using (BookshopEntities1 ctx = new BookshopEntities1())
        {
            if (ctx.Users.Where(x => x.UserName == username).Count() > 0)
            {
                return(false);
            }
            else
            {
                User user = new User();
                user.UserName = username;
                user.Password = password;
                user.Email    = email;
                user.Phone    = phone;
                user.Address  = address;
                user.Role     = "User";

                ctx.Users.Add(user);
                ctx.SaveChanges();
                return(true);
            }
        }
    }