private void buttonSave_Click(object sender, EventArgs e) { if (textBoxAuthorName.Text == "") { MessageBox.Show("Hãy nhập tên tác giả !"); } else { var author = new TacGia() { HoTenTG = textBoxAuthorName.Text, DiaChi = textBoxAuthorAddress.Text, DienThoai = textBoxAuthorPhone.Text, TieuSu = textBoxAuthorBackground.Text }; TacGiaDao dao = new TacGiaDao(); var res = dao.insertAuthor(author.HoTenTG, author.DiaChi, author.TieuSu, author.DienThoai); if (res > 0) { MessageBox.Show("Thêm thành công !"); clearAll(); } else { MessageBox.Show("Chưa thêm được !"); } } }
private void buttonSave_Click(object sender, EventArgs e) { // Dựa vào các cái id mà update lại cho phù hợp if (textBoxBookTitle.Text != tensach) { SachDao sDao = new SachDao(); sDao.updateBooktitle(int.Parse(textBoxBookID.Text), textBoxBookTitle.Text); } if (comboBoxAuthor.Text != hotentg) { TacGiaDao tgDao = new TacGiaDao(); tgDao.updateAuthorName(idAuthor, comboBoxAuthor.Text); } if (comboBoxPublisher.Text != tennxb) { NhaXuatBanDao nxbDao = new NhaXuatBanDao(); nxbDao.updatePublisherName(idPub, comboBoxPublisher.Text); } if (comboBoxCategory.Text != tencd) { ChuDeDao cdDao = new ChuDeDao(); cdDao.updateCategoryName(idCate, comboBoxCategory.Text); } if (textBoxPrice.Text != giaban.ToString()) { SachDao ssDao = new SachDao(); ssDao.updatePrice(int.Parse(textBoxBookID.Text), int.Parse(textBoxPrice.Text)); } MessageBox.Show("Thành công !"); }
public ActionResult Edit(TacGia tacgia) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { var model = new TacGiaDao().CheckTacGia(tacgia.TenTacGia, tacgia.Email); if (model == false) { ModelState.AddModelError("", "Tác Giả Này Đã Tồn Tại"); return(View("Edit")); } else { if (ModelState.IsValid) { var dao = new TacGiaDao(); var result = dao.Update(tacgia); if (result) { return(RedirectToAction("Index", "TacGiaAD")); } else { ModelState.AddModelError("", "Cập Nhật Khách Hàng Thất Bại"); return(View("Edit")); } } return(View("Index")); } } }
public ActionResult Add(TacGia tacgia) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { var model = new TacGiaDao().CheckTacGia(tacgia.TenTacGia, tacgia.Email); if (model == false) { ModelState.AddModelError("", "Tác Giả Này Đã Tồn Tại"); return(View("Add")); } else { if (ModelState.IsValid) { var dao = new TacGiaDao(); int id = dao.Insert(tacgia); if (id > 0) { return(RedirectToAction("Index", "TacGiaAD")); } else { ModelState.AddModelError("", "Thêm Mới Thất Bại"); return(View("Add")); } } } return(View("Index")); } }
private void button1_Click(object sender, EventArgs e) { var ht = textBoxFullname.Text; var dc = textBoxAddress.Text; var ts = textBoxBackground.Text; var dt = textBoxPhone.Text; if (ht == "") { MessageBox.Show("Hãy chọn 1 tác giả để sửa !"); } else { var id = int.Parse(textBoxID.Text); TacGiaDao dao = new TacGiaDao(); var res = dao.updateAuthor(ht, dc, ts, dt, id); if (res > 0) { MessageBox.Show("Sửa thông tin thành công !"); } bindDataToGrid(); clearAll(); } }
private void button2_Click(object sender, EventArgs e) { var fullname = textBoxFullname.Text; if (fullname == "") { MessageBox.Show("Hãy nhập họ tên để thêm !"); } else { TacGia tg = new TacGia() { HoTenTG = textBoxFullname.Text, DiaChi = textBoxAddress.Text, TieuSu = textBoxBackground.Text, DienThoai = textBoxPhone.Text, }; TacGiaDao tgDao = new TacGiaDao(); var res = tgDao.insertAuthor(tg.HoTenTG, tg.DiaChi, tg.TieuSu, tg.DienThoai); if (res > 0) { MessageBox.Show("Thêm tác giả thành công !"); } bindDataToGrid(); clearAll(); } }
private void comboBoxAuthor_SelectedValueChanged(object sender, EventArgs e) { string name = comboBoxAuthor.Text; TacGiaDao dao = new TacGiaDao(); var res = dao.getIdAuthor(name); textBoxAuthorID.Text = res; }
public ActionResult SachTheoTacGia(int matacgia, int?page) { int pagesize = 9; var pagecurrent = (page ?? 1); IQueryable <Sach> model = new TacGiaDao().listSach_TacGia(matacgia); return(View("SachTheoTacGia", model.ToPagedList(pagecurrent, pagesize))); }
public ActionResult ShowTacGia() { var dao = new TacGiaDao(); var list = new List <TacGia>(); list = dao.GetAllTacGia(); return(View(list)); }
public void fillCombobox() { TacGiaDao daotacgia = new TacGiaDao(); daotacgia.populateAuthor(comboBoxAuthor); ChuDeDao daochude = new ChuDeDao(); daochude.populateCategory(comboBoxCategory); NhaXuatBanDao daonxb = new NhaXuatBanDao(); daonxb.populatePublisher(comboBoxPublisher); }
public ActionResult Edit(int id) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { var nxb = new TacGiaDao().ViewDetails(id); return(View(nxb)); } }
// GET: Admin/TacGiaAD public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { var dao = new TacGiaDao(); ViewBag.SearchString = searchString; var model = dao.ListAllPaging(searchString, page, pageSize); return(View(model)); } }
private void button3_Click(object sender, EventArgs e) { var textId = textBoxID.Text; if (textId == "") { MessageBox.Show("Hãy chọn 1 tác giả để XÓA !"); } else { if (MessageBox.Show("Xóa Author ??", "Xóa Author", MessageBoxButtons.YesNo) == DialogResult.Yes) { TacGiaDao dao = new TacGiaDao(); int id = int.Parse(textBoxID.Text); var check = dao.deleteAuthor(id); if (check > 0) { MessageBox.Show("Xóa thành công !"); bindDataToGrid(); clearAll(); } } } }
public ActionResult ViewDetails(int matacgia) { var model = new TacGiaDao().ViewDetails(matacgia); return(View(model)); }
public ActionResult TacGia() { var model = new TacGiaDao().GetAllTacGia(); return(PartialView(model)); }
//fix by Huy private void bindDataToGrid() { TacGiaDao dao = new TacGiaDao(); dataGridViewAuthor.DataSource = dao.listAuthor(); }