Beispiel #1
0
        public List <PhoneClient> getPhoneClient(int idClient)
        {
            phones.Clear();
            ConnectionDB connection = new ConnectionDB();

            connection.openConnection();
            string          command = $"SELECT * FROM telefone WHERE Cliente_idcliente = {idClient};";
            MySqlDataReader result  = connection.select(command);

            while (result.Read())
            {
                PhoneClient phone = new PhoneClient(Convert.ToInt32(result[0]), result[1].ToString(), result[2].ToString(), result[3].ToString(), idClient);
                phones.Add(phone);
            }
            result.Close();
            connection.closeConnection();

            return(phones);
        }
Beispiel #2
0
 public void savePhoneClient(PhoneClient phone)
 {
     try {
         ConnectionDB connection = new ConnectionDB();
         connection.openConnection();
         string command = $"INSERT INTO telefone (idtelefone, tipo, codArea, numero, criado, Cliente_idcliente) VALUES (null,'{phone.type}', '{phone.code}', '{phone.number}', NOW(), {phone.idClient});";
         connection.insert(command);
         message = "Contato inserido com sucesso !!";
         caption = "Sucesso";
     }
     catch (Exception err)
     {
         Console.WriteLine(err.ToString());
         message = "Falha ao inserir novo contato.";
         caption = "Falha";
         icon    = MessageBoxIcon.Error;
     }
     finally
     {
         MessageBox.Show(message, caption, buttons, icon);
     }
 }