public ActionResult CreateCate() { OLoaiTin data = new OLoaiTin(); data.TrangThai = false; return(View("UpdateCate", data)); }
public void Delete(OLoaiTin item) { conn.connect(); var comm = new SqlCommand("LoaiTin_Delete", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add("@MaLoaiTin", SqlDbType.NVarChar).Value = item.MaLoaiTin; comm.ExecuteNonQuery(); }
public void Add(OLoaiTin item) { conn.connect(); var comm = new SqlCommand("LoaiTin_Add", conn.db); comm.CommandType = System.Data.CommandType.StoredProcedure; comm.Parameters.Add(new SqlParameter("@MoTa", item.MoTa ?? (object)DBNull.Value)); comm.Parameters.Add("@Ten", SqlDbType.NVarChar).Value = item.Ten; comm.Parameters.Add("@IsActive", SqlDbType.Bit).Value = item.TrangThai; comm.Parameters.Add("@ShortName", SqlDbType.NVarChar).Value = Help.Helper.convertToUnSign3(item.Ten); comm.ExecuteNonQuery(); conn.Close(); }
public OLoaiTin Get(int id) { conn.connect(); var comm = new SqlCommand("LoaiTin_Get", conn.db); comm.CommandType = CommandType.StoredProcedure; OLoaiTin item = new OLoaiTin(); comm.Parameters.Add("@MaLoaiTin", SqlDbType.Int).Value = id; DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader()); item = Help.DAL.ConvertDataTable <OLoaiTin>(dt).FirstOrDefault(); conn.Close(); return(item); }
public OLoaiTin GetShortName(string shortname) { conn.connect(); var comm = new SqlCommand("LoaiTin_GetShortName", conn.db); comm.CommandType = CommandType.StoredProcedure; OLoaiTin item = new OLoaiTin(); comm.Parameters.Add("@ShortName", SqlDbType.NVarChar).Value = shortname; DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader()); item = Help.DAL.ConvertDataTable <OLoaiTin>(dt).FirstOrDefault(); conn.Close(); return(item); }
public ActionResult CreateCate(OLoaiTin model) { if (ModelState.IsValid) { // var pro = ServiceFactory.NewsgoryManager.Get(new Newsgories { NewsgoryId = model.NewsgoryId }); try { model.TenVanTat = Help.Helper.convertToUnSign3(model.Ten); loaiTinService.Add(model); return(RedirectToAction("SearchCate", "QuanLyTinTuc")); } catch (Exception e) { } } ViewBag.IsEdit = true; return(View("UpdateCate", model)); }
public ActionResult UpdateCate(OLoaiTin model) { if (ModelState.IsValid) { var pro = loaiTinService.Get(model.MaLoaiTin); if (pro != null) { try { loaiTinService.Update(model); return(RedirectToAction("SearchCate", "QuanLyTinTuc")); } catch (Exception e) { } } } ViewBag.IsEdit = true; return(View(model)); }