public static void EditRole(ContactpersonType role, String naam) { String sql = "UPDATE ContactpersonType Set Name=@naam WHERE ID=@Role"; DbParameter par1 = Database.AddParameter("@Role", role._ID); DbParameter par2 = Database.AddParameter("@naam", naam); if (par2.Value == null) par2.Value = DBNull.Value; Database.ModifyData(sql, par1, par2); }
public static ObservableCollection<ContactpersonType> getAll() { ObservableCollection<ContactpersonType> lijst = new ObservableCollection<ContactpersonType>(); String sSQL = "SELECT * FROM ContactpersonType"; DbDataReader reader = Database.GetData(sSQL); while (reader.Read()) { ContactpersonType aNew = new ContactpersonType(); aNew.ID = reader["ID"].ToString(); aNew.Name = reader["Name"].ToString(); lijst.Add(aNew); } return lijst; }
public static void DeleteRole(ContactpersonType role) { String sql = "DELETE FROM ContactpersonType WHERE ID = @Role"; DbParameter par1 = Database.AddParameter("@Role", role._ID); if (par1.Value == null) par1.Value = DBNull.Value; Database.ModifyData(sql, par1); }
//string IDataErrorInfo.Error //{ // get { return "Model not valid"; } //} //string IDataErrorInfo.this[string columnName] //{ // get // { // try // { // object value = this.GetType().GetProperty(columnName).GetValue(this); // Validator.ValidateProperty(value, new ValidationContext(this, null, null) // { // MemberName = columnName // }); // } // catch (ValidationException ex) // { // return ex.Message; // } // return String.Empty; // } //} #endregion public static ContactpersonType getType(String id) { ContactpersonType type = new ContactpersonType(); String sSQL = "SELECT * FROM ContactpersonType WHERE ID = @ID"; DbParameter par1 = Database.AddParameter("@ID", id); if (par1.Value == null) par1.Value = DBNull.Value; DbDataReader reader = Database.GetData(sSQL, par1); while (reader.Read()) { type.Name = reader["Name"].ToString(); type.ID = id; } return type; }