public ActionResult Create() { ONhaXuatBan data = new ONhaXuatBan(); data.TrangThai = false; return(View("Update", data)); }
public ONhaXuatBan Get(int id) { conn.connect(); var comm = new SqlCommand("NXB_Get", conn.db); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@MaNXB", SqlDbType.Int).Value = id; DataTable dt = new DataTable(); ONhaXuatBan nxb = new ONhaXuatBan(); dt.Load(comm.ExecuteReader()); nxb = Help.DAL.ConvertDataTable <ONhaXuatBan>(dt).FirstOrDefault(); return(nxb); }
public void Add(ONhaXuatBan item) { conn.connect(); var comm = new SqlCommand("NXB_Add", conn.db); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@TenNXB", SqlDbType.NVarChar).Value = item.TenNXB; comm.Parameters.Add(new SqlParameter("@DiaChi", item.DiaChi ?? (object)DBNull.Value)); comm.Parameters.Add(new SqlParameter("@SDT", item.SDT ?? (object)DBNull.Value)); comm.Parameters.Add(new SqlParameter("@Email", item.Email ?? (object)DBNull.Value)); comm.Parameters.Add(new SqlParameter("@GhiChu", item.GhiChu ?? (object)DBNull.Value)); comm.Parameters.Add(new SqlParameter("@TrangThai", item.TrangThai ?? (object)DBNull.Value)); comm.ExecuteNonQuery(); conn.Close(); }
public ActionResult Create(ONhaXuatBan model) { if (ModelState.IsValid) { try { nxbService.Add(model); return(RedirectToAction("Search", "QuanLyNXB")); } catch (Exception e) { } } ViewBag.IsEdit = true; return(View("Update", model)); }
public ActionResult Update(ONhaXuatBan model) { if (ModelState.IsValid) { var pro = nxbService.Get(model.MaNXB); if (pro != null) { try { nxbService.Update(model); return(RedirectToAction("Search", "QuanLyNXB")); } catch (Exception e) { } } } ViewBag.IsEdit = true; return(View(model)); }