Exemplo n.º 1
0
        //Een contactpersoon verwijderen
        public static int DeleteContactperson(Contactperson cp)
        {
            try
            {
                String sSQL = "DELETE FROM Contactperson WHERE Id=@Id";

                DbParameter par1 = Database.AddParameter("@Id", cp.Id);
                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; }
        }
Exemplo n.º 2
0
        //Een bestaand contact bewerken
        public static int EditContact(Contactperson c)
        {
            try
            {
                String sSQL = "Update Contactperson Set Name=@Name,JobRole=@JobRole,Email=@Email,Phone=@Phone WHERE ID=@ID";

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

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

                DbParameter par3 = Database.AddParameter("@ID", c.Id);
                if (par3.Value == null) par3.Value = DBNull.Value;

                DbParameter par4 = Database.AddParameter("@Email", c.Email);
                if (par4.Value == null) par4.Value = DBNull.Value;

                DbParameter par5 = Database.AddParameter("@Phone", c.Phone);
                if (par5.Value == null) par5.Value = DBNull.Value;

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

                return affected;
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); return 0; }
        }
Exemplo n.º 3
0
        //Een nieuw contactpersoon toevoegen in database
        public static int AddContactperson(Contactperson cp)
        {
            try
            {
                String sSQL = "INSERT INTO Contactperson(Name, Jobrole, Email, Phone) VALUES(@Name, @JobRole, @Email, @Phone)";

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

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

                DbParameter par3 = Database.AddParameter("@Email", cp.Email);
                if (par3.Value == null) par3.Value = DBNull.Value;

                DbParameter par4 = Database.AddParameter("@Phone", cp.Phone);
                if (par4.Value == null) par4.Value = DBNull.Value;

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

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