//REJECT THE REQUESTED BOOK =>PL private void BtnReject_Click(object sender, RoutedEventArgs e) { try { RequestedBook request = dgRequests.SelectedItem as RequestedBook; if (request != null) { BookBL bookBL = new BookBL(); bool isDone1 = bookBL.IncBookCopyBL(request.BookId); UserRequestBL userRequest = new UserRequestBL(); bool isDone2 = userRequest.DeleteRequestBL(request.BookId, request.UserId); if (isDone1 == true && isDone2 == true) { MessageBox.Show("Rejected request successfully..."); InitializeRequests(); } else { MessageBox.Show("Try again latter..."); } } else { MessageBox.Show("Select book properly..."); } } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } }
//DELETE THE BOOK FROM BOOK TABLE =>PL private void BtnDelete_Click(object sender, RoutedEventArgs e) { try { Book book = dgBooks.SelectedItem as Book; if (book != null) { BookBL bookBL = new BookBL(); bool isDone = bookBL.DeleteBookBL(book.BookId); if (isDone) { MessageBox.Show("Book deleted successfuly.."); InitializeAdminBooks(); } else { MessageBox.Show("Try later.."); } } else { MessageBox.Show("Select a book to delete..."); } } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } }
public ActionResult PostUserAddBook(Book _book) { try { if (ValidateLogin() == false) { return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from User DashBoard, plz login again", color = "Red" })); } Book obj = new Book() { Title = _book.Title, Auther = _book.Auther, UserId = Convert.ToInt32(sdto.getId()), IsActive = 1, CreatedAt = DateTime.Now }; bool checkUser = new BookBL().AddBook(obj, db); if (checkUser == true) { return(RedirectToAction("UserAddBook", "User", new { msg = "Book inserted Successfully", color = "green" })); } else { return(RedirectToAction("UserAddBook", "User", new { msg = "Somethings' Wrong", color = "Red" })); } } catch { return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found", color = "Red" })); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { BookBL bookBL = new BookBL(); MemberBL memBL = new MemberBL(); string orderID = bookBL.orderID(DateTime.Now.ToString("yyyyMM")).ToString(); int orders = bookBL.orders_Add(orderID, Convert.ToInt32(HttpContext.Current.Server.UrlDecode(cookie.Values["mID"].ToString())), Label5.Text, DateTime.Now.ToString(), Convert.ToInt32(Label4.Text), Convert.ToInt32(Label1.Text)); if (orders > 0) { for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { int orderDetails = bookBL.orderDetailes_Add(orderID, GridView1.Rows[i].Cells[0].Text, Convert.ToInt32(GridView1.Rows[i].Cells[3].Text), Convert.ToInt32(GridView1.Rows[i].Cells[2].Text)); } //訂單成立後暢銷書+1與庫存-1 for (int j = 0; j <= GridView1.Rows.Count - 1; j++) { bookBL.sel_hit_amonet(GridView1.Rows[j].Cells[0].Text); int hit = bookBL.bookhit + 1; int amount = bookBL.bookAmonet - 1; bookBL.hit_amonet(GridView1.Rows[j].Cells[0].Text, amount, hit); } //購物完成寄送信件 //string content = "<p>感謝您的光臨,您已經成功完成訂單程序。</p><p>您的訂單編號為:" + orderID.ToString() + ",您可使用此編號查詢您的訂購內容。"; //memBL.send_mail(HttpContext.Current.Server.UrlDecode(cookie.Values["email"].ToString()), content); //清除購物車所有商品 ht.Clear(); } iPayPal paypal = new iPayPal(); paypal.PayPal_Payment(GridView1, Label3.Text, orderID, "http://" + Request.ServerVariables["Server_Name"] + "/Bookstore/shopOK.aspx", ""); }
//REFRESH THE BOOK GRID VIEW =>PL private void btnRefresh_Click(object sender, EventArgs e) { BookBL bookBl = new BookBL(); DataSet ds = bookBl.GetAllBooksBL(); dgvBookDetails.DataSource = ds.Tables[0]; }
public ActionResult Index() { BookBL bookContext = new BookBL(); IEnumerable <Book> books = bookContext.GetBooks(); return(View(books)); }
// Get the Book Details From Book List public JsonResult GetOrderedBookDetails(int BookID) { IBookBL IBookBL = new BookBL(); Book book = IBookBL.GetBookDetails(BookID); return(Json(book, JsonRequestBehavior.AllowGet)); }
public void InitializeUserBorrow() { try { BookBL bookBl = new BookBL(); DataSet ds = bookBl.GetAllBooksBL(); userId = UserLogin.userId; ObservableCollection <Book> lst = new ObservableCollection <Book>(); foreach (DataRow dr in ds.Tables[0].Rows) { lst.Add(new Book { BookName = Convert.ToString(dr["BookName"]), BookId = Convert.ToInt32(dr["BookId"]), BookAuthor = Convert.ToString(dr["BookAuthor"]), BookISBN = Convert.ToString(dr["BookISBN"]), BookCopies = Convert.ToInt32(dr["BookCopies"]), BookPrice = Convert.ToInt32(dr["BookPrice"]), }); } dgBorrow.ItemsSource = lst; } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } }
public ActionResult UserViewBook(String msg = "", string color = "black", string title = "", string author = "") { try { if (ValidateLogin() == false) { return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from User DashBoard, plz login again", color = "Red" })); } List <Book> booklist = new BookBL().GetBookListByUserId(sdto.getId(), db).ToList(); if (title != "") { booklist = booklist.Where(x => x.Title.ToLower().Contains(title.ToLower())).ToList(); } if (author != "") { booklist = booklist.Where(x => x.Auther.ToLower().Contains(author.ToLower())).ToList(); } ViewBag.BookList = booklist; ViewBag.msg = msg; ViewBag.color = color; ViewBag.title = title; ViewBag.author = author; return(View()); } catch { return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found", color = "Red" })); } }
protected void Insert(object sender, EventArgs e) { try { BookBL bookBL = new BookBL(); BookBO book = new BookBO(); book = GetBookObject(book); bookTable = (List <BookBO>)Session[Common.sessionBookList]; if (bookTable == null) { bookTable = new List <BookBO>(); } bookTable = bookBL.Add(book, bookTable); Session[Common.sessionBookList] = bookTable; Session["bookId"] = book.Id + 1; gvBookList.EditIndex = -1; FillGrid(); lblSuccessMessage.Text = Common.msgAddSuccess; } catch (Exception ex) { lblErrorMessage.Text = Common.msgAddFailure; } }
//REQUEST TO BORROW A BOOK FROM BORROW BOOK TABLE =>PL private void btnRequestBook_Click(object sender, EventArgs e) { if (BookId > 0) { if (BookCopy == 0) { MessageBox.Show("Book is empty..."); } else { BookCopy = BookCopy - 1; BookBL bookBL = new BookBL(); UserRequestBL userRequestBL = new UserRequestBL(); bool isDone1 = bookBL.UpdateBookBL(BookId, BookName, BookAuthor, BookISBN, BookPrice, BookCopy); bool isDone2 = userRequestBL.AddRequestBL(BookId, BookName, userId); if (isDone1 == true && isDone2 == true) { MessageBox.Show("Requested successfully.."); } else { MessageBox.Show("Try again.."); } } } else { MessageBox.Show("Select a book to request..."); } }
//DELETE THE RETURN BOOK =>PL private void BtnAccept_Click(object sender, RoutedEventArgs e) { try { ReturnedBook returned = dgReturn.SelectedItem as ReturnedBook; if (returned != null) { UserReturnBL userReturnBL = new UserReturnBL(); bool isDone1 = userReturnBL.DeleteReturnBL(returned.BookId, returned.UserId); BookBL bookBL = new BookBL(); bool isDone2 = bookBL.IncBookCopyBL(returned.BookId); if (isDone1 == true && isDone2 == true) { MessageBox.Show("Book taken back successfully..."); InitializeAdminReturn(); } else { MessageBox.Show("Try again..."); } } } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["book_id"] == null) { Response.Redirect("index.aspx"); } else { BookBL bookBL = new BookBL(); FormView1.DataSource = bookBL.product(Request.QueryString["book_id"].ToString()); FormView1.DataBind(); string author = ((HyperLink)FormView1.FindControl("HyperLink4")).Text.ToString(); Label15.Text = author; DataList1.DataSource = bookBL.authorBook(author); DataList1.DataBind(); //書籍內容 FormView2.DataSource = bookBL.product(Request.QueryString["book_id"].ToString()); FormView2.DataBind(); //書籍簡介 FormView3.DataSource = bookBL.product(Request.QueryString["book_id"].ToString()); FormView3.DataBind(); //留言板 GridView1.DataSource = bookBL.product_message(Request.QueryString["book_id"].ToString()); GridView1.DataBind(); } }
protected void btnadd_Click(object sender, EventArgs e) { int result = 0; _BookBL = new BookBL(); if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("~/Book/") + FileUpload1.FileName); result = _BookBL.BL_Book_Insert(txtbname.Text, txtauthor.Text, txtdetail.Text, (txtprice.Text), drppublication.SelectedItem.Text, drpbranch.SelectedItem.Text, (txtqnt.Text), txtqnt.Text, "0", "~/Book/" + FileUpload1.FileName.ToString()); if (result != 0) { lblmsg.Text = "Book Added Successfullly !!"; txtauthor.Text = ""; txtbname.Text = ""; txtdetail.Text = ""; txtprice.Text = ""; txtqnt.Text = ""; drpbranch.SelectedIndex = 0; drppublication.SelectedIndex = 0; txtbname.Focus(); } } else { lblmsg.Text = "Please, Select Book Image First !!"; } }
protected void Page_Load(object sender, EventArgs e) { BookBL bookBL = new BookBL(); GridView1.DataSource = bookBL.new_Message(); GridView1.DataBind(); }
//ADD THE BOOKS DETAILS INTO BOOK TABEL =>PL private void BtnSubmit_Click(object sender, RoutedEventArgs e) { if (tbBName.Text != string.Empty && tbBAuthor.Text != string.Empty && tbBISBN.Text != string.Empty && tbBPrice.Text != string.Empty && tbBCopy.Text != string.Empty ) { try { BookBL bookBL = new BookBL(); string isDone = bookBL.AddBookBL(tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); if (isDone == "true") { MessageBox.Show("Book added successfuly.."); this.Close(); } else { MessageBox.Show(isDone + "Try again.."); } } catch (FormatException) { MessageBox.Show("Invalid Book price or Book copy!!!,\nThey should not be a string, Try again.."); } catch (Exception) { MessageBox.Show("Some unknown exception is occured!!!, Try again.."); } } else { MessageBox.Show("Enter the fields properly!!!, Every field is required.."); } }
public ActionResult <AddToCartResponseModel> AddToCart([FromBody] AddBookInputModel data) { AddToCartResponseModel res = new AddToCartResponseModel(); try { BookBL bl = new BookBL(DbContext); var temp = bl.SaveCart(data); res.data = temp; if (temp.BookID == Guid.Empty) { res.Message = "Item ini sudah ada di list keranjang / list order"; res.Response = false; } else { res.Message = "Item berhasil ditambahkan di keranjang"; res.Response = true; } return(Ok(res)); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(BadRequest(res)); } }
public JsonResult GetSearchingData(string SearchValue) { BookBL bookContext = new BookBL(); IEnumerable <Book> BookList = bookContext.SearchResult(SearchValue); return(Json(BookList, JsonRequestBehavior.AllowGet)); }
public ActionResult UserDeleteBook(int id) { try { if (ValidateLogin() == false) { return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from User DashBoard, plz login again", color = "Red" })); } Book b = new BookBL().GetBookById(id, db); b.IsActive = 0; bool checkUser = new BookBL().UpdateBook(b, db); if (checkUser == true) { return(RedirectToAction("UserViewBook", "User", new { msg = "Book has been deleted Successful", color = "green" })); } else { return(RedirectToAction("UserViewBook", "User", new { msg = "Somethings' Wrong", color = "Red" })); } } catch { return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found ", color = "Red" })); } }
public AdminBook() { InitializeComponent(); BookBL bookBl = new BookBL(); DataSet ds = bookBl.GetAllBooksBL(); dgvBookDetails.DataSource = ds.Tables[0]; }
//ADD THE BOOKS DETAILS INTO BOOK TABEL =>PL private void btnAdd_Click(object sender, EventArgs e) { if (tbBName.Text != string.Empty && tbBAuthor.Text != string.Empty && tbBISBN.Text != string.Empty && tbBPrice.Text != string.Empty && tbBCopy.Text != string.Empty ) { try { BookBL bookBL = new BookBL(); string isDone = bookBL.AddBookBL(tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); if (isDone == "true") { MessageBox.Show("Book added successfuly.."); } else { MessageBox.Show(isDone + "Try again.."); } } catch (Exception) { MessageBox.Show("Enter the fields properly..."); } } else { MessageBox.Show("Enter the fields properly.."); } /*if (tbBName.Text!=string.Empty && tbBAuthor.Text!= string.Empty && tbBISBN.Text != string.Empty && tbBPrice.Text != string.Empty && * tbBCopy.Text != string.Empty * ) * { * try * { * BookBL bookBL = new BookBL(); * bool isDone = bookBL.AddBookBL(tbBName.Text, tbBAuthor.Text, tbBISBN.Text, double.Parse(tbBPrice.Text), int.Parse(tbBCopy.Text)); * if (isDone) * { * MessageBox.Show("Book added successfuly.."); * } * else * { * MessageBox.Show("Try later.."); * } * } * catch (Exception) * { * MessageBox.Show("Enter the fields properly..."); * } * } * else * { * MessageBox.Show("Enter the fields properly.."); * }*/ }
public UserBorrow() { InitializeComponent(); userId = UserForm.UserId; BookBL bookBl = new BookBL(); DataSet ds = bookBl.GetAllBooksBL(); dgvBookDetails.DataSource = ds.Tables[0]; }
public ActionResult AdminViewUserBook(string Name = "", string Title = "", string Author = "", int id = -1) { try { if (ValidateLogin() == false) { return(RedirectToAction("Login", "Auth", new { msg = "Session Expired from ADMIN DashBoard, plz login again", color = "Red" })); } if (id == -1) { List <Book> bookList = new BookBL().GetActiveBookList(db).ToList(); if (Name != "") { bookList = bookList.Where(x => x.User.FirstName.ToLower().Contains(Name.ToLower()) || x.User.LastName.ToLower().Contains(Name.ToLower())).ToList(); } if (Title != "") { bookList = bookList.Where(x => x.Title.ToLower().Contains(Title.ToLower())).ToList(); } if (Author != "") { bookList = bookList.Where(x => x.Auther.ToLower().Contains(Author.ToLower())).ToList(); } ViewBag.Book = bookList; ViewBag.Name = Name; ViewBag.Title = Title; ViewBag.Author = Author; return(View()); } else { List <Book> bookList = new BookBL().GetActiveBookList(db).Where(x => x.UserId == id).ToList(); if (Name != "") { bookList = bookList.Where(x => x.User.FirstName.ToLower().Contains(Name.ToLower()) || x.User.LastName.ToLower().Contains(Name.ToLower())).ToList(); } if (Title != "") { bookList = bookList.Where(x => x.Title.ToLower().Contains(Title.ToLower())).ToList(); } if (Author != "") { bookList = bookList.Where(x => x.Auther.ToLower().Contains(Author.ToLower())).ToList(); } ViewBag.Book = bookList; ViewBag.Name = Name; ViewBag.Title = Title; ViewBag.Author = Author; return(View()); } } catch { return(RedirectToAction("Error", "Auth", new { msg = "search for the page was not found ", color = "Red" })); } }
public ActionResult CreateBook(Book u) { if (ModelState.IsValid) { BookBL.Insert(u); return(RedirectToAction("BookB")); } else { return(View()); } }
public ActionResult EditBook(Book u) { if (ModelState.IsValid) { BookBL.Update(u); return(RedirectToAction("BookB")); } else { return(View()); } }
public ActionResult addborrow(BorrowBook u) { if (ModelState.IsValid) { int id = int.Parse(Session["book_id"].ToString()); BookBL.Insertborrow(u, id); return(RedirectToAction("BookEmp")); } else { return(View()); } }
protected void drppublication_SelectedIndexChanged(object sender, EventArgs e) { List <Book> _BOOKList = new List <Book>(); _BookBL = new BookBL(); _BOOKList = _BookBL.BL_BOOK_Select_BY_Publication(drppublication.SelectedItem.Text); drpbook.DataSource = _BOOKList; drpbook.DataTextField = "BookName"; drpbook.DataValueField = "BID"; drpbook.DataBind(); drpbook.Items.Insert(0, "SELECT"); }
public ActionResult <ApprovalBookResponseModel> ApprovalBooked([FromBody] ApprovalBookInputModel data) { ApprovalBookResponseModel res = new ApprovalBookResponseModel(); try { BookBL bl = new BookBL(DbContext); var temp = bl.ApprovalBook(data); string configJSON = JsonConvert.SerializeObject(AppSettings.EmailConfig); res.data = temp; res.Response = true; res.Message = temp.Message; res.TotalPages = 1; //Send email to Media Buyer var bodyBuyer = bl.BuilBookEmailApprovalToMediaBuyer(data, temp.Message); UserRepository userRepo = new UserRepository(DbContext); var mediaBuyerInfo = userRepo.FindByID(data.UserID).FirstOrDefault(); MailMessage message = new MailMessage(); message.To.Add(mediaBuyerInfo.UserName); message.Body = bodyBuyer; message.Subject = "Booking "; message.From = new MailAddress(AppSettings.EmailConfig.FromAddress); message.IsBodyHtml = true; PdfConvertEngine pdfEngine = new PdfConvertEngine(); var pdfPath = pdfEngine.ConvertHTMLToPDF(bodyBuyer, AppSettings.PDFPath, "INV_01_123"); Attachment dataPDF = new Attachment(pdfPath); dataPDF = new Attachment(pdfPath); message.Attachments.Add(dataPDF); EmailSenderEngine emailEngine = new EmailSenderEngine(); emailEngine.SendEmail(message, configJSON); dataPDF.Dispose(); //end send email to media buyer return(Ok(res)); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(BadRequest(res)); } }
protected void Button12_Click(object sender, EventArgs e) { if (drppublication.SelectedIndex == 0) { lblmsg.Text = "Select Student First !!"; lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1; } else if (drpbook.SelectedIndex == 0) { lblmsg.Text = "Select Book !!"; lblmsg.ForeColor = System.Drawing.Color.Red; MultiView1.ActiveViewIndex = -1; } else { MultiView1.ActiveViewIndex = 0; List <Book> _BookList = new List <Book>(); _BookBL = new BookBL(); _BookList = _BookBL.BL_BOOK_Select_BY_BNAME(drpbook.SelectedItem.Text); ViewState["BBID"] = _BookList[0].BID.ToString(); lblbname.Text = _BookList[0].BookName.ToString(); lblauthor.Text = _BookList[0].Author.ToString(); lblbran.Text = _BookList[0].Branch.ToString(); lblpub.Text = _BookList[0].Publication.ToString(); lblprice.Text = _BookList[0].Price.ToString(); Image2.ImageUrl = _BookList[0].Image.ToString(); List <Student> _StudentList = new List <Student>(); _StudentBL = new StudentBL(); _StudentList = _StudentBL.BL_Student_Select_BY_SID(Convert.ToInt32(drppublication.SelectedValue)); lblstudent.Text = _StudentList[0].STUDENTNAME.ToString(); List <Rent> __RentList = new List <Rent>(); _RentBL = new RentBL(); __RentList = _RentBL.BL_Student_Select_BY_SID_BName_Status(Convert.ToInt32(drppublication.SelectedValue), drpbook.SelectedItem.Text, 0); lbldays.Text = __RentList[0].Days.ToString(); lblidate.Text = __RentList[0].IssueDate.ToString(); ViewState["RRID"] = __RentList[0].RID.ToString(); } }
protected void gvBookList_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { bookTable = (List <BookBO>)Session[Common.sessionBookList]; BookBL bookBL = new BookBL(); bookTable = bookBL.DeleteById(gvBookList.DataKeys[e.RowIndex].Values[0], bookTable); Session["BooksList"] = bookTable; FillGrid(); lblSuccessMessage.Text = Common.msgDeleteSuccess; } catch (Exception ex) { // log exception lblErrorMessage.Text = Common.msgDeleteFailure; } }