public ActionResult Create() { ONhaCungCap data = new ONhaCungCap(); data.TrangThai = false; return(View("Update", data)); }
public void Add(ONhaCungCap item) { conn.connect(); var comm = new SqlCommand("NCC_Add", conn.db); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@TenNCC", SqlDbType.NVarChar).Value = item.TenNCC; 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("@IsActive", item.TrangThai ?? (object)DBNull.Value)); comm.ExecuteNonQuery(); conn.Close(); }
public ONhaCungCap Get(int id) { conn.connect(); var comm = new SqlCommand("NCC_Get", conn.db); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@MaNCC", SqlDbType.Int).Value = id; DataTable dt = new DataTable(); ONhaCungCap NCC = new ONhaCungCap(); dt.Load(comm.ExecuteReader()); NCC = Help.DAL.ConvertDataTable <ONhaCungCap>(dt).FirstOrDefault(); return(NCC); }
public ActionResult Create(ONhaCungCap model) { if (ModelState.IsValid) { try { nccService.Add(model); return(RedirectToAction("Search", "QuanLyNCC")); } catch (Exception e) { } } ViewBag.IsEdit = true; return(View("Update", model)); }
public ActionResult Update(ONhaCungCap model) { if (ModelState.IsValid) { var pro = nccService.Get(model.MaNCC); if (pro != null) { try { nccService.Update(model); return(RedirectToAction("Search", "QuanLyNCC")); } catch (Exception e) { } } } ViewBag.IsEdit = true; return(View(model)); }