public int AddBookOrder(BookOrderModel bs) { try { if (bs != null) { if (GetOrder().Where(obj => obj.book_order_id == bs.book_order_id).ToList().Count == 0) { book_order brDb = new book_order(); brDb.cus_id = bs.cus_id; brDb.book_status_code = bs.book_status_code; brDb.book_order_total = bs.book_order_total; brDb.book_order_date = DateTime.Today; db.book_order.Add(brDb); db.SaveChanges(); return(brDb.book_order_id); } return(0); } return(0); } catch (Exception ex) { throw ex; } }
public List <BookOrderModel> Mapping(List <book_order> list) { try { if (list != null && list.Count > 0) { List <BookOrderModel> oList = new List <BookOrderModel>(); foreach (book_order bo in list) { BookOrderModel bookOrder = new BookOrderModel(); bookOrder.book_order_id = bo.book_order_id; bookOrder.book_order_date = bo.book_order_date; bookOrder.book_order_total = bo.book_order_total; bookOrder.book_status_code = bo.book_status_code; bookOrder.cus_id = bo.cus_id; oList.Add(bookOrder); } return(oList); } return(null); } catch (Exception ex) { throw ex; } }
public static int SelectOrderBookCount(BookOrderModel bookOrder, OrderModel order) { string sql = "select count(*) from bookinfo_order where order_id=@orderid and book_id=@bookid"; return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter[] { new SqlParameter("orderid", order.id), new SqlParameter("bookid", bookOrder.book.id) })); }
public static int SelectBookQuantityInCart(CartModel cart, BookOrderModel book) { string sql = "select quantity from bookinfo_cart where book_id = @bookid and user_id=@userid and enabled=1"; return((int)SqlHelper.ExecuteScalar(sql, new SqlParameter[] { new SqlParameter("bookid", book.book.id), new SqlParameter("userid", cart.user.id) })); }
public static int UpdateBookInCart(CartModel cart, BookOrderModel book) { string sql = "update bookinfo_cart set quantity=@quantity where user_id=@userid and book_id = @bookid and enabled=1"; return((int)SqlHelper.ExecuteNonQuery(sql, new SqlParameter[] { new SqlParameter("quantity", book.quantity), new SqlParameter("userid", cart.user.id), new SqlParameter("bookid", book.book.id) })); }
public static int UpdateOrderBook(BookOrderModel bookOrder, OrderModel order) { string sql = "update bookinfo_order set amount = @newvalue where order_id=@orderid and book_id=@bookid"; return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter[] { new SqlParameter("newvalue", bookOrder.quantity), new SqlParameter("orderid", order.id), new SqlParameter("bookid", bookOrder.book.id) })); }
public static int InsertOrderBook(BookOrderModel bookOrder, OrderModel order) { string sql2 = "insert into bookinfo_order values (@bookid,@order_id,@amount,@price)"; return(SqlHelper.ExecuteNonQuery(sql2, new SqlParameter[] { new SqlParameter("bookid", bookOrder.book.id), new SqlParameter("order_id", order.id), new SqlParameter("amount", bookOrder.quantity), new SqlParameter("price", bookOrder.price) })); }
public static int SetBookQuantity(BookOrderModel bookOrder, OrderModel order) { if (OrderDAL.SelectOrderBookCount(bookOrder, order) == 0) { return(OrderDAL.InsertOrderBook(bookOrder, order)); } else { return(OrderDAL.UpdateOrderBook(bookOrder, order)); } }
public static int InsertBookToCart(CartModel cart, BookOrderModel book) { string sql = "insert into bookinfo_cart values (@bookid,@userid,@quantity,1)"; return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter[] { new SqlParameter("bookid", book.book.id), new SqlParameter("userid", cart.user.id), new SqlParameter("quantity", book.quantity) })); }
protected void list_ItemCommand(object sender, ListViewCommandEventArgs e) { string commandName = e.CommandName; string commandArguments = (string)e.CommandArgument; BookOrderModel c = (BookOrderModel)e.Item.DataItem; if (e.CommandName == "btnDelete") { int id = CartBLL.DeleteBook((int)Session["uid"], int.Parse((string)e.CommandArgument)); } DataRebind(); }
public void SetBook(BookOrderModel bookOrder, OrderModel order) { BookOrderInThisControl = bookOrder; OrderOnThisPage = order; linkDetail.Text = bookOrder.book.title; linkDetail.PostBackUrl = "/details.aspx?book=" + bookOrder.book.id; imgCover.ImageUrl = "/public/images/cover/" + bookOrder.book.image; txtCategory.Text = bookOrder.book.category; txtNum.Text = bookOrder.quantity.ToString(); txtPrice.Text = bookOrder.price.ToString("F2"); TotalPrice = bookOrder.quantity * bookOrder.book.price; txtTotal.Text = TotalPrice.ToString("F2"); }
protected void txtNum_TextChanged(object sender, EventArgs e) { int quantity = 0; if (int.TryParse(((TextBox)sender).Text, out quantity)) { BookOrderModel book = new BookOrderModel(); TextBox textBox = (TextBox)sender; book.book.id = int.Parse(((TextBox)sender).Attributes["bookid"]); book.quantity = quantity; CartBLL.SetBookCount(GetCart(), book); } DataRebind(); return; }
public async Task <IActionResult> Put(long id, [FromBody] BookOrderModel um) { if (id == 0) { return(BadRequest(id)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var vm = await this.service.UpdateAsync <BookOrderModel, BookViewModel>(um, id); return(Ok(vm)); }
public ActionResult AddOrderDetail(BookOrderModel id, List <BookOrderDetailModel> bookDetail) { try { bool added = orderHelp.AddBookDetailOrder(id, bookDetail); if (added) { var b = orderHelp; return(Json(b, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
public static CartModel GetUserCart(int userid) { CartModel cart = new CartModel(); cart.user = UserInfoBLL.GetUserInfoByID(userid); var reader = CartDAL.SelectBooksInCart(userid); while (reader.Read()) { BookOrderModel book = new BookOrderModel(); book.book = BookStatBLL.GetBookByID(reader.GetInt32(0)); book.enabled = 1; book.quantity = reader.GetInt32(1); cart.book.Add(book); } reader.Close(); return(cart); }
public static int AddBookToCart(CartModel cart, BookOrderModel book) { int bookcount = CartDAL.SelectBookCountInCart(cart, book); if (bookcount > 0) { book.quantity += CartDAL.SelectBookQuantityInCart(cart, book); if (book.quantity > 99) { book.quantity = 99; } return(CartDAL.UpdateBookInCart(cart, book)); } else { return(CartDAL.InsertBookToCart(cart, book)); } }
public ActionResult AddBookOrder(BookOrderModel bookOrder, List <BookOrderDetailModel> bookOrderDetailList) { try { var orderId = homehlep.AddBookOrder(bookOrder); if (orderId > 0) { //var List = homehlep.GetBookOrder(bookOrder, bookOrderDetailList); var list = AddBookOrderDetail(bookOrderDetailList, orderId); return(Json(list, JsonRequestBehavior.AllowGet)); } return(Json(false, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { throw ex; } }
/* * public int AddBookOrder(BookOrderModel bookOrder) * { * try * { * book_order bc = Mapping(bookOrder); * db.book_order.Add(bc); * db.SaveChanges(); * return bc.book_order_id; * * } * catch (Exception ex) * { * throw ex; * } * } */ public bool AddBookOrder(BookOrderModel bookOrder, List <BookOrderDetailModel> bookDetail) { try { book_order bc = Mapping(bookOrder); db.book_order.Add(bc); db.SaveChanges(); int id = bc.book_order_id; AddOrderDetail(id, bookDetail); return(true); } catch (Exception ex) { throw ex; } }
protected void btnBuy_Click(object sender, EventArgs e) { if (Session["uid"] == null) { Response.Redirect("/login.aspx"); } int userid = (int)Session["uid"]; AddressModel address = AddressBLL.GetUserDefaultAddress(userid); if (address.id == 0) { Modal.Show(this, "你还没有收货地址,请前往个人中心添加"); return; } OrderModel order = new OrderModel(); order.address = address; BookOrderModel bookOrder = new BookOrderModel(); bookOrder.quantity = int.Parse(txtNum.Text); bookOrder.price = BookOnThisPage.price; bookOrder.book = BookOnThisPage; order.books = new List <BookOrderModel>() { bookOrder }; order.comment = ""; order.dateTime = DateTime.Now; order.status = 0; order.CalculateTotalPrice(); order.user.id = userid; int msg = OrderBLL.AddOrder(order); if (msg != -1) { Modal.Show(this, "下单成功,即将前往付款界面", 1000, "/placeorder.aspx?orderid=" + msg); } else { Modal.Show(this, "购买失败", 1000, HttpContext.Current.Request.Url.PathAndQuery); } }
public static OrderModel GetOrderByID(int id) { OrderModel order = new OrderModel(); var reader = OrderDAL.SelectOrderByID(id); if (reader == null) { return(new OrderModel()); } reader.Read(); order.id = reader.GetInt32(0); int userid = reader.GetInt32(1); order.dateTime = reader.GetDateTime(2); order.totalPrice = reader.GetDouble(3); order.comment = reader.GetString(4); order.status = (OrderStatus)reader.GetInt32(5); int addressid = reader.GetInt32(6); order.user = UserInfoBLL.GetUserInfoByID(userid); order.address = AddressBLL.GetAddressByID(addressid); order.books = new List <BookOrderModel>(); if (!reader.IsClosed) { reader.Close(); } reader = OrderDAL.SelectOrderBooksByID(id); while (reader.Read()) { BookOrderModel bookOrder = new BookOrderModel(); bookOrder.book = BookStatBLL.GetBookByID(reader.GetInt32(0)); bookOrder.quantity = reader.GetInt32(2); bookOrder.price = reader.GetDouble(3); order.books.Add(bookOrder); } if (!reader.IsClosed) { reader.Close(); } return(order); }
public BookOrderModel Mapping(book_order o) { try { if (o != null) { BookOrderModel bookOrder = new BookOrderModel(); bookOrder.book_order_id = o.book_order_id; bookOrder.cus_id = o.cus_id; bookOrder.book_status_code = o.book_status_code; bookOrder.book_order_total = o.book_order_total; bookOrder.book_order_date = o.book_order_date; return(bookOrder); } return(null); } catch (Exception ex) { throw ex; } }
public book_order Mapping(BookOrderModel bs) { try { book_order bsm = new book_order(); if (bs != null) { bsm.book_order_id = bs.book_order_id; bsm.cus_id = bs.cus_id; bsm.book_status_code = bs.book_status_code; bsm.book_order_total = bs.book_order_total; bsm.book_order_date = bs.book_order_date; return(bsm); } return(null); } catch (Exception ex) { throw ex; } }
public book_order Mapping(BookOrderModel o) { try { if (o != null) { book_order bookOrder = new book_order(); bookOrder.book_order_id = o.book_order_id; bookOrder.book_order_date = o.book_order_date; bookOrder.book_order_total = o.book_order_total; bookOrder.book_status_code = "WP"; bookOrder.cus_id = 3; return(bookOrder); } return(null); } catch (Exception ex) { throw ex; } }
protected void btnCart_Click(object sender, EventArgs e) { if (Session["uid"] == null) { Response.Redirect("/login.aspx"); } int userid = (int)Session["uid"]; CartModel cart = new CartModel(); cart.user.id = userid; BookOrderModel bookOrder = new BookOrderModel(); bookOrder.quantity = int.Parse(txtNum.Text); bookOrder.price = BookOnThisPage.price; bookOrder.book = BookOnThisPage; if (CartBLL.AddBookToCart(cart, bookOrder) > 0) { Modal.Show(this, "已添加到购物车"); } }
public bool AddBookOrder(BookOrderModel m, List <BookOrderDetailModel> list) { return(new BookOrderLibrary().AddBookOrder(m, list)); }
public int AddBookOrder(BookOrderModel bookOrder) { return(new HomeLibrary().AddBookOrder(bookOrder)); }
internal void SetBook(BookOrderModel book) { linkdetail.NavigateUrl = "/details.aspx?book=" + book.book.id; img.Attributes["title"] = book.book.title; img.ImageUrl = "/public/images/cover/" + book.book.image; }
public bool AddBookDetailOrder(BookOrderModel id, List <BookOrderDetailModel> bookDetail) { return(new BookOrderLibrary().AddBookOrder(id, bookDetail)); }