//Een contactpersoontype toevoegen
        public static int AddContactPersonType(ContactpersonType type)
        {
            try
            {
                String sSQL = "INSERT INTO ContactpersonType(Name) VALUES(@Name)";

                DbParameter par1 = Database.AddParameter("@Name", type.Name);
                if (par1.Value == null) par1.Value = DBNull.Value;

                DbParameter[] pars = new DbParameter[] { par1 };
                int affected = Database.ModifyData(sSQL, pars);

                return affected;
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); return 0; }
        }
Esempio n. 2
0
 //Een nieuw contactpersoon maken
 private static Contactperson Create(IDataRecord record, ContactpersonType type)
 {
     return new Contactperson()
     {
         Id = record["Id"].ToString(),
         Name = record["Name"].ToString(),
         JobRole = type,
         Email = record["Email"].ToString(),
         Phone = record["Phone"].ToString()
     };
 }
        //Een bestaand contactpersoontype bewerken
        public static int EditContactPersonType(ContactpersonType Type)
        {
            try
            {
                String sSQL = "Update ContactpersonType Set Name=@Name WHERE ID=@Id";

                DbParameter par1 = Database.AddParameter("@Name", Type.Name);
                if (par1.Value == null) par1.Value = DBNull.Value;

                DbParameter par2 = Database.AddParameter("@Id", Type.Id);
                if (par2.Value == null) par2.Value = DBNull.Value;

                DbParameter[] pars = new DbParameter[] { par1, par2 };
                int affected = Database.ModifyData(sSQL, pars);

                return affected;
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); return 0; }
        }