//Read //Update //Delete public bool deletePhuongTien(int MaPT) { db = new DBLib(); try { db.AddParameter("@MaPT", MaPT); return db.ExecuteNonQuery("sp_DeletePhuongTien", CommandType.StoredProcedure) > 0; } catch (Exception) { throw; } }
//Phương thức xóa dữ liệu bảng public bool DeleteUser(int IdUser) { int count = 0; try { db = new DBLib(); db.AddParameter("@IdUser", IdUser); count = db.ExecuteNonQuery("sp_DeleteUser", CommandType.StoredProcedure); } catch (Exception) { throw; } return count > 0; }
//Phương thức thêm dữ liệu vào bảng public bool InsertUser(UsersDTO dto) { db = new DBLib(); try { db.AddParameter("@Fullname", dto.Fullname); db.AddParameter("@Username", dto.Username); db.AddParameter("@Password", func.pHash(dto.Password)); db.AddParameter("@IdPermission", dto.IdPermission); return db.ExecuteNonQuery("sp_InsertUser", CommandType.StoredProcedure) > 0; } catch (Exception) { throw; } }
//Phương thức cập nhật dữ liệu bảng public bool UpdateUser(UsersDTO dto) { int count = 0; try { db = new DBLib(); db.AddParameter("@IdUser", dto.Id); db.AddParameter("@Fullname", dto.Fullname); db.AddParameter("@Password", func.pHash(dto.Password)); db.AddParameter("@IdPermission", dto.IdPermission); count = db.ExecuteNonQuery("sp_UpdateUser", CommandType.StoredProcedure); } catch (Exception) { throw; } return count > 0; }