public bool Delete(TableName tableName, string strKey, ref string error) { string strTableName = tableName.ToString(); string key = ""; switch (tableName) { case TableName.SinhVien: key = "MSSV"; break; case TableName.NhanVien: key = "MaNV"; break; case TableName.HoaDon: key = "MaHD"; break; case TableName.PhieuDK: key = "MaPDK"; break; case TableName.LoaiPhong: key = "MaLoaiPhong"; break; case TableName.DichVu: key = "MaDV"; break; case TableName.SDDV: key = "MaHD"; break; case TableName.Stay: key = "MSSV"; break; } string sql = $"DELETE FROM {strTableName} WHERE {key} = @Key"; SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("Key", strKey) }; return(db.ExecuteNonQuery(sql, sqlParameters, CommandType.Text, ref error)); }