public void inserirMedicamento(Medicamento medicamento) { using (OdbcConnection conexao = ConexaoPadrao.createConnection()) { string sql = "insert into MEDICAMENTO (DESCRICAO, QUANTIDADE, MINIMO_EM_ESTOQUE, MAXIMO_EM_ESTOQUE) values(?,?,?,?)"; OdbcCommand command = new OdbcCommand(sql, conexao); command.Parameters.AddWithValue("@DESCRICAO", medicamento.descricao); command.Parameters.AddWithValue("@QUANTIDADE", medicamento.quantidade); command.Parameters.AddWithValue("@MINIMO_EM_ESTOQUE", medicamento.minimoEmEstoque); command.Parameters.AddWithValue("@MAXIMO_EM_ESTOQUE", medicamento.maximoEmEstoque); conexao.Open(); command.ExecuteNonQuery(); } }
public void alteraMedicamento(Medicamento medicamento) { using (OdbcConnection conexao = ConexaoPadrao.createConnection()) { string sql = "update MEDICAMENTO set DESCRICAO = ?, QUANTIDADE = ?, MINIMO_EM_ESTOQUE = ?, MAXIMO_EM_ESTOQUE = ? where ID_MEDICAMENTO = ?"; OdbcCommand command = new OdbcCommand(sql, conexao); command.Parameters.AddWithValue("@DESCRICAO", medicamento.descricao); command.Parameters.AddWithValue("@QUANTIDADE", medicamento.quantidade); command.Parameters.AddWithValue("@MINIMO_EM_ESTOQUE", medicamento.minimoEmEstoque); command.Parameters.AddWithValue("@MAXIMO_EM_ESTOQUE", medicamento.maximoEmEstoque); command.Parameters.AddWithValue("@ID_MEDICAMENTO", medicamento.id); conexao.Open(); command.ExecuteNonQuery(); } }
// ver o que é realmente obrigatório public bool validaMedicamento(Medicamento medicamento) { bool entrou = true; if (medicamento.descricao.Length < 3) { MessageBox.Show("Insira o tipo de funcionário!"); entrou = false; } return entrou; }