private void InsertSach(string tenSach, string tenTacGia, string tenTheLoai, string tenNXB, string gia, string soLuong) { int maNXB = NXB_DAO.GetIdNXBByName(tenNXB); int maTheLoai = TheLoaiDAO.GetIdTheLoaiByName(tenTheLoai); int maTacGia = TacGiaDAO.GetIdTacGiaByName(tenTacGia); if (SachDAO.InsertSach(tenSach, maNXB, maTacGia, maTheLoai, Convert.ToDouble(gia), Convert.ToInt32(soLuong))) { MessageBox.Show("Thêm thành công"); Dispose(); } else { MessageBox.Show("Thêm thất bại"); } }
public ActionResult Index(Sach sach, HttpPostedFileBase anhBia, string chude, string ncc, string tg, string nxb, string km, HttpPostedFileBase anh1, HttpPostedFileBase anh2, double?chieuDai, double?chieuRong, double?chieuSau, string mota) { var tk = Session["TaiKhoan"] as KhachHang; if (tk == null) { return(View("../Login/Index")); } else { if (tk.LoaiTK != "Admin") { return(View("../Home/Index")); } else { if (Session["UpdateSach"] == null) { var db = new SachDAO(); db.InsertSach(sach, anhBia, chude, ncc, tg, nxb, km, anh1, anh2, chieuDai, chieuRong, chieuSau); Session["ListSach"] = null; View("Index"); return(Redirect(Request.UrlReferrer.ToString())); } else { var db = new SachDAO(); var newSach = Session["UpdateSach"] as Sach; db.UpdateSach(newSach.ID, sach, anhBia, chude, ncc, tg, nxb, km, anh1, anh2, chieuDai, chieuRong, chieuSau, mota); Session["UpdateSach"] = null; Session["ListSach"] = null; return(RedirectToAction("Reset", "Sach", new { area = "Admin" })); } } } }