private void Bind() { List <BookInfo> lstBooks = BookInfoBLL.FinfAllBooks(); GridView1.DataSource = lstBooks; GridView1.DataBind(); }
// GET: Home public ActionResult Index() { var list = BookInfoBLL.Find(new BookInfo_View()); FindSele(); return(View(list)); }
private void bindata() { BookInfoBLL bll = new BookInfoBLL(); BookInfoEntity entity = new BookInfoEntity(); bool i = int.TryParse(Request.QueryString["BookId"], out int x); if (string.IsNullOrWhiteSpace(Request.QueryString["BookId"])) { return; } else if (i == true) { entity = bll.list(int.Parse(Request.QueryString["BookId"])); if (entity != null) { ViewState["Bookid"] = entity.BookId; Image1.ImageUrl = "uploadfile/" + entity.PicPath; lblname.Text = entity.BookName; lblPrice.Text = entity.BookPrice.ToString().Split('.')[0]; lblDis.Text = (decimal.Parse(entity.BookPrice.ToString()) * decimal.Parse(entity.BookDisCount.ToString())).ToString("n"); lblAuthor.Text = entity.BookAuthor; lblPress.Text = entity.BookPress; lblRemark.Text = entity.BookRemark; } } else { } }
private void BookSearch_Search() { BookInfoEntity infoEntity = new BookInfoEntity(); if (!string.IsNullOrWhiteSpace(Request["TypeId"])) { BookTypeBLL typeBLL = new BookTypeBLL(); BookTypeEntity typeEntity = typeBLL.lists(int.Parse(Request["TypeId"])); if (typeEntity == null) { infoEntity.TypeId = 0; } else if (typeEntity.ParentId != 0) { infoEntity.TypeId = int.Parse(Request["TypeId"]); } } if (!string.IsNullOrWhiteSpace(Request["ParentId"])) { infoEntity.SellCount = int.Parse(Request["ParentId"]); } if (!string.IsNullOrWhiteSpace(Request["BookName"])) { infoEntity.BookName = Request["BookName"]; } BookInfoBLL infoBLL = new BookInfoBLL(); int count = 0; List <BookInfoEntity> infolist = infoBLL.list(infoEntity, int.Parse(Request["Pageint"]), int.Parse(Request["Pagesize"]), out count); Response.Write(count + "_" + MyJson.ToJsJson(infolist)); Response.End(); }
private void BookSearch_delete() { BookInfoBLL bookInfo = new BookInfoBLL(); Response.Write(bookInfo.Delete(int.Parse(Request["BookId"]))); Response.End(); }
private void Bind() { List <BookInfo> lstBooks = BookInfoBLL.FinfAllBooksIndent(true); //显示购物车 GridView1.DataSource = lstBooks; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int id = int.Parse(Request["id"]); BookInfoBLL bll = new BookInfoBLL(); biModel = bll.GetBookInfoById(id); }
protected void Page_Load(object sender, EventArgs e) { Model.BookInfo bi = new Model.BookInfo(); if (IsPostBack) { bi.BookTitle = Request["title"]; bi.SubTitle = Request["subtitle"]; bi.PriceNew = Convert.ToInt32(Request["price"]); bi.PriceOld = Convert.ToInt32(Request["discountprice"]); bi.Author = Request["author"]; bi.Publisher = Request["publisher"]; bi.PublishDate = Convert.ToDateTime(Request["publishdate"]); bi.SaleDate = System.DateTime.Now; bi.Isbn = Request["isbn"]; bi.TypeId = Request["type1"] + "," + Request["type2"] + "," + Request["type3"]; bi.ImgTitle = Request["imgTitle"]; bi.Details = Request["editorValue"]; BookShopBLL.BookInfoBLL bll = new BookInfoBLL(); if (bll.InsertBookInfo(bi)) { Response.Redirect("BookInfo.aspx"); } else { Response.Redirect("Error.html"); } } }
/// <summary> /// 确定修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBookAdd_Click(object sender, EventArgs e) { BookInfoModel book = this.pnlModify.Tag as BookInfoModel; book.BookName = txtBookName.Text; book.Author = txtAuthor.Text; book.Publish = txtPublish.Text; book.BookStatus = "可借"; book.BookType = txtBookType.Text; BookInfoBLL bll = new BookInfoBLL(); int res = bll.updateBookInfoModel(book); if (res == 1) { MessageBox.Show("修改成功"); this.pnlModify.Visible = false; } else if (res < 1) { MessageBox.Show("修改失败"); } else if (res > 1) { MessageBox.Show("修改多于一条记录"); this.pnlModify.Visible = false; } }
protected void btAdd_Click(object sender, EventArgs e) { BookInfoBLL infoBLL = new BookInfoBLL(); BookInfoEntity infoEntity = new BookInfoEntity(); infoEntity.TypeId = int.Parse(hdTwoType.Value); infoEntity.BookCode = txtBookCode.Text; infoEntity.BookName = txtBookName.Text; infoEntity.BookPrice = decimal.Parse(txtBookPrice.Text); infoEntity.BookDisCount = decimal.Parse(txtBookDisCount.Text); infoEntity.BookAuthor = txtBookAuthor.Text; infoEntity.BookPress = txtBookPress.Text; infoEntity.PressTime = DateTime.Parse(txtPressTime.Text); infoEntity.PicPath = hdPicPath.Value; infoEntity.SellCount = 0; infoEntity.BookRemark = txtBookRemark.Text; if (infoBLL.Add(infoEntity) == 1) { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功!');</script>"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('未知错误!');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { string sort = Request.QueryString["Sort"]; List <BookInfo> lstBooks = BookInfoBLL.FinfAllBooksBT(sort); dlstShowBook.DataSource = lstBooks; dlstShowBook.DataBind(); }
protected void BindData() { if (Request["category"] != null) { list.DataSource = BookInfoBLL.GetAllBookOfCategory(int.Parse(Request["category"])); list.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { string bookName = Request.QueryString["BookName"]; List <BookInfo> lstAllBooks = BookInfoBLL.FinfAllBooks(); lstAllBooks = lstAllBooks.FindAll(book => book.BookName.ToLower().Contains(bookName.ToLower())); Repeater1.DataSource = lstAllBooks; Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { BookInfoBLL bll = new BookInfoBLL(); BookInfo bi = new BookInfo(); int pageIndex = 1; int pageSize = 12; int rowsCount = bll.GetRecordCount(""); int pageCount = Convert.ToInt32(Math.Ceiling(rowsCount * 1.0 / pageSize)); if (!string.IsNullOrEmpty(Request["pIndex"])) { pageIndex = int.Parse(Request["pIndex"]); if (pageIndex <= 1) { pageIndex = 1; } if (pageIndex >= pageCount) { pageIndex = pageCount; } } DataTable dt = bll.GetListByPage("", "", (pageIndex - 1) * pageSize + 1, pageIndex * pageSize).Tables[0]; BookList = new List <BookInfo>(); foreach (DataRow dr in dt.Rows) { BookList.Add(new BookInfo() { Id = Convert.ToInt32(dr["Id"]), ImgTitle = dr["imgTitle"].ToString(), BookTitle = dr["Title"].ToString(), SubTitle = dr["SubTitle"].ToString(), PriceOld = Convert.ToDecimal(dr["PriceOld"].ToString()), PriceNew = Convert.ToDecimal(dr["PriceNew"].ToString()), Author = dr["Author"].ToString(), Details = dr["Details"].ToString() }); } StringBuilder sb = new StringBuilder(); sb.Append("<ul class='pagination'>"); sb.Append("<li><a href='?pIndex=1'> << </a></li>"); for (int i = 1; i <= pageCount; i++) { if (i == pageIndex) { sb.Append("<li class='active'><a href='?pIndex=" + i + "'>" + i + "</a></li>"); } else { sb.Append("<li><a href='?pIndex=" + i + "'>" + i + "</a></li>"); } } sb.Append("<li><a href='?pIndex=" + pageCount + "'> >> </a></li>"); sb.Append("</ul>"); PageBar = sb.ToString(); }
// Open Edit public ActionResult EditPage(int id) { var bk = BookInfoBLL.Find(new BookInfo_View() { BkId = id })[0]; FindSele(bk); return(View(bk)); }
protected void LinkButton2_Click(object sender, EventArgs e) { LinkButton LinkButton2 = (LinkButton)sender; Label bookName = (Label)LinkButton2.Parent.FindControl("Label1"); BookInfo book = new BookInfo(); book.BookName = bookName.Text; RegisterStartupScript("key", "<script type='text/javascript'>alert('购买成功');</script>"); BookInfoBLL.AddBook(book, 1); //1用于购物车 }
public ActionResult Add(FormCollection fc) { BookInfo bk = new BookInfo(); bk.BkName = fc["BkName"]; bk.BkPrice = Convert.ToDecimal(fc["BkPrice"]); bk.BkDate = Convert.ToDateTime(fc["BkDate"]); bk.TypeId = Convert.ToInt32(fc["BkType"]); BookInfoBLL.Add(bk); return(RedirectToAction("Index")); }
/// <summary> /// 重构出来的根据图书姓名模糊查询出来的结果 /// </summary> protected void beginSearch() { if (!string.IsNullOrEmpty(this.txtBookSearch.Text.Trim())) { BookInfoBLL bll = new BookInfoBLL(); string searchStr = this.txtBookSearch.Text.Trim(); List <BookInfoModel> list = bll.getBookInfoLikeName(this.txtBookSearch.Text.Trim(), 1); this.dgvBook.DataSource = list; BookPage.DataCount = bll.getBookCountLike(searchStr); BookPage.PageIndex = 1; } }
//绑定数据 private void bindata() { int count = 1; if (string.IsNullOrWhiteSpace(Request.QueryString["Count"])) { count = 1; } else if (int.TryParse(Request.QueryString["Count"], out count) == false || count <= 0) { count = 1; } if (string.IsNullOrWhiteSpace(Request.QueryString["BookId"])) { return; } if (int.TryParse(Request.QueryString["BookId"], out int i)) { BookInfoBLL infoBLL = new BookInfoBLL(); BookInfoEntity infoEntity = new BookInfoEntity(); MemberEntity member = (MemberEntity)Session["usr"]; BookCartBLL cartBLL = new BookCartBLL(); infoEntity = infoBLL.list(i); if (infoEntity == null) { return; } ContentPlaceHolder1_imgBook.ImageUrl = "~/uploadfile/" + infoEntity.PicPath; lblTitle.Text = "书名:" + infoEntity.BookName; lblInfo.Text = "作者:" + infoEntity.BookAuthor + " 出版社:" + infoEntity.BookPress + ""; lblPrice.InnerHtml = "<span style='text-decoration:line-through;'>原价:" + (infoEntity.BookPrice * count).ToString().Split('.')[0] + "元</span> 现价:" + ((infoEntity.BookPrice * infoEntity.BookDisCount) * count).ToString("n") + " 数量:" + count; //加入购物车 BookCartEntity cartEntity = cartBLL.list(member.MemberId, infoEntity.BookId); if (cartEntity != null) { cartEntity.BookCount += count; cartBLL.Update(cartEntity); } else { BookCartEntity bookCart = new BookCartEntity(); bookCart.MemberId = member.MemberId; bookCart.BookId = infoEntity.BookId; bookCart.BookCount = count; cartBLL.Add(bookCart); } } }
public ActionResult FindPostData(FormCollection fc) { BookInfo_View bkFilter = new BookInfo_View(); bkFilter.BkName = fc["BookName"].ToString(); if (fc["seleList"].ToString() != "") { bkFilter.TypeId = Convert.ToInt32(fc["seleList"]); } var list = BookInfoBLL.Find(bkFilter); FindSele(); return(View("Index", list)); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { string isbn = GridView1.Rows[e.RowIndex].Cells[0].Text; bool result = BookInfoBLL.DeleteBook(isbn); if (result) { RegisterStartupScript("key", "<script type='text/javascript'>alert('删除成功');</script>"); } else { RegisterStartupScript("key", "<script type='text/javascript'>alert('删除失败');</script>"); } Bind(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id = int.Parse(context.Request["id"]); BookInfoBLL bll = new BookInfoBLL(); if (bll.DeleteBookInfoById(id)) { context.Response.Write(1); } else { context.Response.Write(0); } }
protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { if (((CheckBox)GridView1.Rows[i].FindControl("cb1")).Checked == true) { string isbn = GridView1.Rows[i].Cells[1].Text; int numbers = Convert.ToInt32(((TextBox)GridView1.Rows[i].Cells[12].FindControl("TextBox5")).Text); BookInfoBLL.AddBookToIndent(isbn, numbers); bool result = ShoppingCartBLL.DeleteBook(isbn); Button1.Text = isbn; RegisterStartupScript("key", "<script type='text/javascript'>alert('成功添加到购物车');</script>"); } } Bind(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; if (context.Session["isadmin"] != null && (bool)context.Session["isadmin"] == true) { int page = -1; int limit = -1; if (context.Request["page"] != null && context.Request["limit"] != null) { page = int.Parse(context.Request["page"]); limit = int.Parse(context.Request["limit"]); } context.Response.Write(BookInfoBLL.GetAllBooks(page, limit)); return; } context.Response.Write("null"); }
protected void Page_Load(object sender, EventArgs e) { BookInfoBLL bll = new BookInfoBLL(); int pageIndex = 1; int pageSize = 8; if (!string.IsNullOrEmpty(Request["pIndex"])) { pageIndex = int.Parse(Request["pIndex"]); } int rowsCount = bll.GetRecordCount(""); int pageCount = Convert.ToInt32(Math.Ceiling(rowsCount * 1.0 / pageSize)); if (pageIndex <= 1) { pageIndex = 1; } if (pageIndex >= pageCount) { pageIndex = pageCount; } int startIndex = (pageIndex - 1) * pageSize + 1; int endIndex = pageIndex * pageSize; Repeater1.DataSource = bll.GetListByPage("", "Id", startIndex, endIndex); Repeater1.DataBind(); StringBuilder sb = new StringBuilder(); sb.Append("<ul class='pagination'>"); sb.Append("<li><a href='?pIndex=1'> << </a></li>"); for (int i = 1; i <= pageCount; i++) { if (i == pageIndex) { sb.Append("<li class='active'><a href='?pIndex=" + i + "'>" + i + "</a></li>"); } else { sb.Append("<li><a href='?pIndex=" + i + "'>" + i + "</a></li>"); } } sb.Append("<li><a href='?pIndex=" + pageCount + "'> >> </a></li>"); sb.Append("</ul>"); PageBar = sb.ToString(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/json"; if (context.Session["isadmin"] != null && (bool)context.Session["isadmin"] == true) { int bookid = -1; int delnew = -1; if (context.Request["bookid"] != null && context.Request["delnew"] != null) { bookid = int.Parse(context.Request["bookid"]); delnew = int.Parse(context.Request["delnew"]); } context.Response.Write(BookInfoBLL.DelBook(bookid, delnew)); return; } context.Response.Write("null"); }
private void bindata() { if (string.IsNullOrWhiteSpace(Request.QueryString["BookList"])) { return; } bool i = int.TryParse(Request.QueryString["BookList"], out int a); if (i == true) { BookInfoBLL infoBLL = new BookInfoBLL(); int count = 0; Repeater1.DataSource = infoBLL.Order(a, 1, 24, out count); Repeater1.DataBind(); ViewState["BookList"] = a == 1 ? "销售排行" :a == 2? "打折优惠" : "新书上架"; } }
protected void btnSubmmit_Click(object sender, EventArgs e) { if (Request["bookid"] != null) { BookInfoModel book = new BookInfoModel(); book.id = int.Parse(Request["bookid"]); book.title = txttitle.Text; book.origintitle = txtorigin.Text; book.subtitle = txtsub.Text; book.category_id = int.Parse(DropDownList2.SelectedValue); book.author_id = int.Parse(txtauthorid.Text); book.publisher_id = int.Parse(txtpublisherid.Text); book.isbn = txtisbn.Text; book.pubdate = txtpubdate.Text; book.pages = txtpages.Text; book.price = txtOriginPrice.Text; BookInfoBLL.SetBook(book); } }
protected void Button3_Click(object sender, EventArgs e) { BookInfoModel book = new BookInfoModel(); book.author_id = int.Parse(txtauthorid.Text); book.catalog = txtcatalog.Text; book.category_id = int.Parse(DropDownList2.SelectedValue); book.image = ""; book.isbn = txtisbn.Text; book.origintitle = txtorigin.Text; book.pages = txtpages.Text; book.price = txtprice.Text; book.pubdate = txtpubdate.Text; book.publisher_id = int.Parse(txtpublisherid.Text); book.subtitle = txtsub.Text; book.summary = txtsummary.Text; book.title = txttitle.Text; string msg = BookInfoBLL.AddBook(book); ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>showModal('" + msg + "');</script>"); }
/// <summary> /// 增加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { BookInfoModel book = new BookInfoModel(); book.Author = txtAuthor.Text.Trim(); book.Publish = txtPublish.Text.Trim(); book.BookID = txtBookID.Text.Trim(); book.BookName = txtBookName.Text.Trim(); book.BookType = txtBookType.Text.ToString(); book.PicPath = txtBookPic.Text.Trim(); BookInfoBLL bll = new BookInfoBLL(); if (bll.insertBookInfo(book) == 1) { this.Close(); } else { MessageBox.Show("添加错误,请检查一下内容"); } }