private void btnEnviar_Click(object sender, EventArgs e) { if (txtNome.Text == "" || mkdDatadeNascimento.Text == "" || txtRaca.Text == "" || mktRGA.Text == "") { MessageBox.Show("Preencha os dados", "Erro"); } else { String nome; String dataDeNascimento; String raca; String rga; int dono; nome = txtNome.Text; dataDeNascimento = mkdDatadeNascimento.Text; raca = txtRaca.Text; rga = mktRGA.Text; dono = (int)cmbDono.SelectedValue; Pet pet = new Pet(); pet.Nome = nome; pet.DataDeNascimento = dataDeNascimento; pet.Raca = raca; pet.RGA = rga; pet.Dono = dono; DAOPet daoPet = new DAOPet(); daoPet.inserePet(pet); txtNome.Text = ""; mkdDatadeNascimento.Clear(); txtRaca.Text = ""; mktRGA.Clear(); this.Close(); } }
private void btnEnviar_Click(object sender, EventArgs e) { if(txtNome.Text==""||mkdDatadeNascimento.Text==""||txtRaca.Text==""||mktRGA.Text==""){ MessageBox.Show("Preencha os dados","Erro"); } else{ String nome; String dataDeNascimento; String raca; String rga; int dono; nome = txtNome.Text; dataDeNascimento = mkdDatadeNascimento.Text; raca = txtRaca.Text; rga = mktRGA.Text; dono = (int)cmbDono.SelectedValue; Pet pet = new Pet(); pet.Nome = nome; pet.DataDeNascimento = dataDeNascimento; pet.Raca = raca; pet.RGA = rga; pet.Dono = dono; DAOPet daoPet = new DAOPet(); daoPet.inserePet(pet); txtNome.Text=""; mkdDatadeNascimento.Clear(); txtRaca.Text = ""; mktRGA.Clear(); this.Close(); } }