public int ThemChuyenMuc(ChuyenMuc obj) { SqlParameter tcm = new SqlParameter("@TenChuyenMuc", obj.TenChuyenMuc); SqlParameter mt = new SqlParameter("@MoTa", obj.MoTa); SqlParameter tt = new SqlParameter("@TrangThai", obj.TrangThai); SqlParameter[] sqlParams = { tcm, mt, tt }; return(dl.SaveChanges("INSERT INTO [dbo].[tblChuyenMuc]([TenChuyenMuc],[MoTa],[TrangThai]) VALUES(@TenChuyenMuc,@MoTa,@TrangThai)", sqlParams)); }
public int SuaChuyenMuc(ChuyenMuc obj) { SqlParameter mcm = new SqlParameter("@MaChuyenMuc", obj.MaChuyenMuc); SqlParameter tcm = new SqlParameter("@TenChuyenMuc", obj.TenChuyenMuc); SqlParameter mt = new SqlParameter("@MoTa", obj.MoTa); SqlParameter tt = new SqlParameter("@TrangThai", obj.TrangThai); SqlParameter[] sqlParams = { mcm, tcm, mt, tt }; return(dl.SaveChanges("UPDATE tblChuyenMuc SET TenChuyenMuc = @TenChuyenMuc, MoTa = @MoTa, TRangThai = @TrangThai WHERE MaChuyenMuc = @MaChuyenMuc", sqlParams)); }