private void btnDelete_Click(object sender, EventArgs e) { if (dgvAuthor.SelectedCells.Count > 0) { int selectedrowindex = dgvAuthor.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = dgvAuthor.Rows[selectedrowindex]; int id = Convert.ToInt32(selectedRow.Cells["clmnId"].Value); DialogResult result = MessageBox.Show("Do you want to delete author: " + selectedRow.Cells["clmnName"].Value + "?", "Warning", MessageBoxButtons.OKCancel); switch (result) { case DialogResult.Cancel: break; case DialogResult.OK: AuthorBLL authorBLL = new AuthorBLL(Convert.ToInt32(selectedRow.Cells["clmnId"].Value), selectedRow.Cells["clmnName"].Value.ToString(), selectedRow.Cells["clmnWorkPlace"].Value.ToString()); if (AuthorDAL.getAuthorItem(authorBLL) != null) { MessageBox.Show("Can't delete! Please delete all book of " + selectedRow.Cells["clmnName"].Value + " before delete this author!", "Error"); break; } else { AuthorDAL.deleteAuthor(authorBLL); MessageBox.Show("Delete complete!", "Success"); this.LoadDataToGridView(); break; } } } }
public AuthorUnitTest() { _context = new LibrayContextFactory("AegisDBTest").Create(); _author_dal = new AuthorDAL(_context); Cleanup(); }
// GET: Author public ActionResult Index() { AuthorDAL autdal = new AuthorDAL(); var models = autdal.GetAll(); return(View(models)); }
public List <Author> GetAuthorsForEdition() { string bookName = Helper.ReadString("Introduce the name of the book:"); while (!BookDAL.CheckBook(bookName)) { Helper.DisplayError("\n Wrong book name!"); Console.ForegroundColor = ConsoleColor.Red; bookName = Helper.ReadString("Reintroduce the name of the book:"); } List <Author> authors = null; int PublicationYear = Helper.ReadYear("Introduce the year of publishing:"); string PublishingHouseName = Helper.ReadString("Introduce publishing house name:"); while (!EditionDAL.CheckEdition(bookName, PublishingHouseName, PublicationYear)) { Helper.DisplayError("\n Edition doesn't exist!"); Console.ForegroundColor = ConsoleColor.Red; PublicationYear = Helper.ReadYear("Reintroduce the year of publishing:"); PublishingHouseName = Helper.ReadString("Reintroduce publishing house name:"); } authors = AuthorDAL.GetAuthorsForBook(bookName, PublicationYear, PublishingHouseName); return(authors); }
private void DisplayAuthors_Click(object sender, EventArgs e) { try { listView.Clear(); var authorDAL = new AuthorDAL(); var authors = authorDAL.GetAuthors(); listView.View = View.Details; listView.Columns.Add("Id"); listView.Columns.Add("AuthorName"); foreach (var author in authors) { ListViewItem lvi = new ListViewItem(author.id.ToString()); lvi.SubItems.Add(author.authorName.Remove(author.authorName.Length - 1)); //lvi.SubItems.Add(author.id.ToString()); listView.Items.Add(lvi); } listView.Columns[0].Width = -1; listView.Columns[1].Width = -1; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { try { AuthorsBAL a = new AuthorsBAL(); a.AuthorID = txt_a_id.Text.Trim(); a.AuthorFirstName = txt_a_fname.Text.Trim(); a.AuthorLastName = txt_a_lname.Text.Trim(); a.AuthorPhone = txt_a_phone.Text.Trim(); a.AuthorAddress = txt_a_address.Text.Trim(); a.AuthorCity = txt_a_city.Text.Trim(); a.AuthorState = txt_a_state.Text.Trim(); a.AuthorZip = txt_a_zip.Text.Trim(); a.AuthorContract = Convert.ToBoolean(txt_a_contract); AuthorDAL dal = new AuthorDAL(); bool astatus = dal.InsertAuthorToDB(a); if (astatus == true) { MessageBox.Show("Done"); } else { MessageBox.Show("CheckData"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnSearch_Click(object sender, EventArgs e) { string key = this.txtSearch.Text; string catalog = ""; if (key == "".Trim()) { MessageBox.Show("Please enter keyword!", "Notice"); return; } if (this.cboSearch.SelectedItem.ToString() == "Work Place") { catalog = "noicongtac"; } else { catalog = "tentacgia"; } AuthorBLL authorBLL = new AuthorBLL(); List <AuthorBLL> authorArr = new List <AuthorBLL>(); authorArr = AuthorDAL.search(catalog, key); this.dgvAuthor.Rows.Clear(); foreach (AuthorBLL row in authorArr) { this.dgvAuthor.Rows.Add(row.AuthorId, row.Name, row.WorkPlace); } this.GetSelectedValue(); this.dgvAuthor.CellClick += new DataGridViewCellEventHandler(dgvAuthor_CellClick); }
public void BorrowEdition() { string email = Helper.ReadString("Introduce user's email: "); while (!UserDAL.CheckUser(email)) { Helper.DisplayError("\n User not found!"); Console.ForegroundColor = ConsoleColor.Red; email = Helper.ReadString("\nReintroduce email: "); } string bookName = Helper.ReadString("Introduce the name of the book: "); while (!BookDAL.CheckBook(bookName)) { Helper.DisplayError("\n Book not found!"); Console.ForegroundColor = ConsoleColor.Red; bookName = Helper.ReadString("Introduce the name of the book: "); } int publicationYear = Helper.ReadYear("Introduce the year of publishing: "); string publishingHouseName = Helper.ReadString("Introduce publishing house name: "); while (!EditionDAL.CheckEdition(bookName, publishingHouseName, publicationYear)) { Helper.DisplayError("\n Edition not found!"); Console.ForegroundColor = ConsoleColor.Red; publicationYear = Helper.ReadYear("Introduce the year of publishing: "); publishingHouseName = Helper.ReadString("Introduce publishing house name: "); } string authorName = Helper.ReadString("Introduce the name of the author: "); Author author = new Author(authorName); while (!AuthorDAL.CheckAuthor(author)) { Helper.DisplayError("\n Wrong author!"); Console.ForegroundColor = ConsoleColor.Red; authorName = Helper.ReadString("Introduce the name of the author: "); author = new Author(authorName); } if (ValidBorrow(email, bookName, publishingHouseName, publicationYear)) { Edition edition = new Edition() { PublicationYear = publicationYear, PublishingHouseName = publishingHouseName, Name = bookName, }; int daysLeft = Helper.ReadInteger("Introduce the number of days of the borrow: "); DateTime endDate = DateTime.Now.AddDays(daysLeft); EditionDAL.BorrowEdition(email, edition, author, endDate); Console.WriteLine("\n Operation completed succesfully!"); } }
public ActionResult Search(string txtSearch) { using (AuthorDAL aut = new AuthorDAL()) { var result = aut.Search(txtSearch).ToList(); return(View("Index", result)); } }
//------------------------------------------------------------- //public ActionResult EditAuthor(int id) //{ // using (AuthorDAL service = new AuthorDAL()) // { // var Author = service.GetDataByID(id); // return View(Author); // } //} //[HttpPost, ActionName("EditAuthors")] //blm bisa //public ActionResult EditPost(int? id, Authors Aut) //int? --> bisa diisi nilai NULL //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // using (AuthorDAL service = new AuthorDAL()) // { // try // { // service.Edit(id.Value, Aut); // TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data has been updated"); // } // catch (Exception ex) // { // TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error", ex.Message); // } // } // return RedirectToAction("Index"); //} public ActionResult EditAuthor(int id) { using (AuthorDAL service = new AuthorDAL()) { var author = service.GetDataByID(id); return(View(author)); } }
public int AuthorCreate( string Name, DateTime?DOB, string Location) { AuthorDAL dal = new AuthorDAL(_connection); return(dal.AuthorCreate(Name, DOB, Location)); }
protected void Session_Start() { BaseUser.IdMax = 0; // Init Authors GenerateAuthors(); var dal = new AuthorDAL((List <Author>)Session["Authors"]); dal.Delete(2); dal.Update(3, new Author() { Id = 3, Firstname = "FirstName", Name = "Name" }); GenerateBooks(); GenerateMembers(); Session["BooksBorrowing"] = new List <BooksBorrowing>(); // Create test BooksBorrowing List <Author> authors = (List <Author>)Session["Authors"]; List <Member> members = (List <Member>)Session["Members"]; List <Book> books = (List <Book>)Session["Books"]; var dalResa = new ReservationDAL((List <BooksBorrowing>)Session["BooksBorrowing"]); // Books classic BooksBorrowing resa = new BooksBorrowing(); resa.beginDate = new DateTime(); resa.isReturned = false; resa.book = books.ElementAt(0); resa.user = members.ElementAt(0); resa.returnDate = new DateTime(2017, 08, 31); dalResa.Add(resa); // Return date resa = new BooksBorrowing(); resa.beginDate = new DateTime(2017, 07, 01); resa.isReturned = false; resa.book = books.ElementAt(1); resa.user = members.ElementAt(1); resa.returnDate = new DateTime(2017, 07, 15); resa.daysRetard = (int)(DateTime.Now - (DateTime)resa.returnDate).TotalDays; dalResa.Add(resa); // Is returned resa = new BooksBorrowing(); resa.beginDate = new DateTime(2017, 07, 15); resa.book = books.ElementAt(2); resa.user = members.ElementAt(2); resa.isReturned = true; resa.returnDate = new DateTime(2017, 07, 17); dalResa.Add(resa); }
static public string AddAuthor(AuthorModel author) { string msg = "作者信息插入失败"; if (AuthorDAL.InsertAuthor(author) == 1) { msg = "作者信息插入成功"; } return(msg); }
public int AuthorUpdateJust( int AuthorID, string Name, DateTime?DOB, string Location) { AuthorDAL dal = new AuthorDAL(_connection); return(dal.AuthorUpdateJust(AuthorID, Name, DOB, Location)); }
public ActionResult Edit(int id) // Edition des informations d'un auteur { // Récupération des auteurs AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]); Author author = authorDAL.Read(id); // Lecture des datas de l'auteur en question var model = new EditAuthorModelView(); // Création de la modelView de l'edition de l'auteur model.author = author; // Ajout de l'auteur a la modelView return(View(model)); }
public ActionResult Details(int id) // Pour afficher toutes les infos d'un auteur en particulier { AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]); // Récupération des auteurs (général) BookDAL bookDAL = new BookDAL((List <Book>)Session["Books"]); // Récupération des livres (général) Author author = authorDAL.Read(id); // Récupération de l'auteur en particulier //Création d'une modelView avec l'auteur + ses livres ShowAuthorModelView model = new ShowAuthorModelView(author, bookDAL.FindByAuthor(author)); return(View(model)); }
[ValidateAntiForgeryToken] // Création d'un nouvel auteur public ActionResult Create([Bind(Include = "Name, Firstname")] Author author) { AuthorDAL dal = new AuthorDAL((List <Author>)Session["Authors"]); if (ModelState.IsValid) { dal.Add(author); return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Delete(int id) // Suppression d'un auteur { AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]); Author author = authorDAL.Read(id); // R2cupération des infos d'un livre pour un id donné authorDAL.Delete(id); AuthorModelView model = new AuthorModelView((List <Author>)Session["Authors"]); return(View(model)); }
// GET: Author public ActionResult Index() { using (AuthorDAL service = new AuthorDAL()) { var authors = service.GetData().ToList(); if (TempData["Message"] != null) { ViewBag.msg = TempData["Message"].ToString(); } return(View(authors)); } }
public ActionResult Add() // Pour l'ajout d'un nouveau livre { // Récupération des informations sur l'auteur via le form + ajout au model AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]); List <Author> authors = authorDAL.GetAll(); var model = new AddBookViewModel(); model.authors = GetSelectListItems(authors); model.book = new Book(); return(View(model)); }
public List <AuthorBLL> getAuthor() { List <String> authorIdList = new List <string>(); authorIdList = AuthorBookTitleDAL.getAuthorId(this); List <AuthorBLL> authorList = new List <AuthorBLL>(); foreach (string authorId in authorIdList) { authorList.Add(AuthorDAL.getAuthorItem(authorId)); } return(authorList); }
[ValidateAntiForgeryToken] // Edition d'un auteur existant public ActionResult Edition([Bind(Include = "author")] EditAuthorModelView model) // On récupére l'entity Autheur spécial EditAuthorModelView { // Récupération des datas d'auteurs AuthorDAL dal = new AuthorDAL((List <Author>)Session["Authors"]); if (ModelState.IsValid) { dal.Update(model.author.Id, model.author); // Mise à jour des datas de l'auteur return(RedirectToAction("Index")); // Retourner à la liste des auteurs si OK } return(View("Edit", model)); // Rester sur le formulaire d'edition }
private void LoadDataToGridView() { this.dgvAuthor.Rows.Clear(); List <AuthorBLL> authorArr = new List <AuthorBLL>(); authorArr = AuthorDAL.getAuthorList(); foreach (AuthorBLL row in authorArr) { this.dgvAuthor.Rows.Add(row.AuthorId, row.Name, row.WorkPlace); } this.GetSelectedValue(); this.dgvAuthor.CellClick += new DataGridViewCellEventHandler(dgvAuthor_CellClick); }
static public int GetAuthorIDByname(string name) { object id = AuthorDAL.SelectAuthorIDByName(name); if (id != null) { id = (int)id; } else { id = -1; } return((int)id); }
// GET: Books public ActionResult Index() { using (AuthorDAL svAuthor = new AuthorDAL()) using (BookDAL svBook = new BookDAL()) { var result = svBook.GetData().ToList(); if (TempData["Message"] != null) { ViewBag.msg = TempData["Message"].ToString(); } return(View(result)); } }
public ActionResult Create(Author author) { try { // TODO: Add insert logic here AuthorDAL autdal = new AuthorDAL(); autdal.Create(author); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View()); } }
public int AuthorUpdateJust( int AuthorID, string oldName, DateTime?oldDOB, string oldLocation, string newName, DateTime?newDOB, string newLocation) { AuthorDAL dal = new AuthorDAL(_connection); return(dal.AuthorUpdateSafe(AuthorID, oldName, oldDOB, oldLocation, newName, newDOB, newLocation)); }
private void btnAdd_Click(object sender, EventArgs e) { AuthorBLL authorBLL = new AuthorBLL(); authorBLL.Name = this.txtAuthorName.Text; authorBLL.WorkPlace = this.txtWorkPlace.Text; if (authorBLL.Name == "") { MessageBox.Show("Author name is not null!", "Notice"); return; } AuthorDAL.addAuthor(authorBLL); MessageBox.Show("Add success!", "Success"); this.LoadDataToGridView(); }
public ActionResult Details(int id) // Affichage des détails d'un membre { // Récupération des datas du membre : ses données, ses livres emprunté et les datas des livres emprunté AuthorDAL authorDAL = new AuthorDAL((List <Author>)Session["Authors"]); BookDAL bookDAL = new BookDAL((List <Book>)Session["Books"]); MemberDAL memberDAL = new MemberDAL((List <Member>)Session["Members"]); ReservationDAL resaDAL = new ReservationDAL((List <BooksBorrowing>)Session["BooksBorrowing"]); // Lecture des données du membre selectionne Member member = memberDAL.Read(id); ShowMemberModelView model = new ShowMemberModelView(member); // Creation de la view d'affichage model.Reservations = resaDAL.GetByMember(member); // Récupération des réservations return(View(model)); }
public ActionResult CreateAuthor(Authors au) { using (AuthorDAL service = new AuthorDAL()) { try { service.tambah(au); TempData["Message"] = Helper.MsgBox.GetMsg("success", "Success! ", "Your data has been added"); } catch (Exception ex) { TempData["Message"] = Helper.MsgBox.GetMsg("danger", "Error", ex.Message); } } return(RedirectToAction("Index")); }