예제 #1
0
        public void inserirServico(Servico servico)
        {
            using (OdbcConnection conexao = ConexaoPadrao.createConnection())
            {
                string sql = "insert into SERVICO (DESCRICAO, PRECO) values(?,?)";
                OdbcCommand command = new OdbcCommand(sql, conexao);

                command.Parameters.AddWithValue("@DESCRICAO", servico.descricao);
                command.Parameters.AddWithValue("@PRECO", servico.preco);

                conexao.Open();
                command.ExecuteNonQuery();
            }
        }
예제 #2
0
        public void alteraServico(Servico servico)
        {
            using (OdbcConnection conexao = ConexaoPadrao.createConnection())
            {
                string sql = "update SERVICO set DESCRICAO = ?, PRECO = ? where ID_SERVICO = ?";
                OdbcCommand command = new OdbcCommand(sql, conexao);

                command.Parameters.AddWithValue("@DESCRICAO", servico.descricao);
                command.Parameters.AddWithValue("@PRECO", servico.preco);
                command.Parameters.AddWithValue("@ID_SERVICO", servico.id);

                conexao.Open();
                command.ExecuteNonQuery();
            }
        }
예제 #3
0
 public bool validaServico(Servico servico)
 {
     bool entrou = true;
     if (servico.descricao.Length < 3)
     {
         MessageBox.Show("Insira a descrição do serviço!");
         entrou = false;
     }
     if (servico.preco <= 0)
     {
         MessageBox.Show("Insira o Preço!");
         entrou = false;
     }
     return entrou;
 }