private void Button1_Click(object sender, EventArgs e) { if (verificaCampos()) { try { Locacao objl = new Locacao { locacao_tipo = txt_tipo.Text, locacao_valor = double.Parse(txt_valor.Text), locacao_dt_inicio = Convert.ToDateTime(txt_inicio.Text), locacao_dt_fim = Convert.ToDateTime(txt_fim.Text), automovel = (int)cb_carro.SelectedValue, cliente = (int)cb_carro.SelectedValue, funcionario = (int)cb_funcionario.SelectedValue }; LocacaoDAO ldao = new LocacaoDAO(); ldao.cadastra_locacao(objl); Uc_locacao_Load(null, null); } catch (Exception t) { MessageBox.Show("Erro: " + t); } } else { MessageBox.Show("Preencha todos os campos."); } }