protected void btnAceptar_Click(object sender, EventArgs e) { if (txtNombre.Text == "") { Response.Write("Debe llenar todos los campos"); } else { Animal mascota = new Animal(); AnimalNegocio mascotaNegocio = new AnimalNegocio(); Cliente cliente = new Cliente(); ClienteNegocio clientenegocio = new ClienteNegocio(); int idMascota; cliente = clientenegocio.DevolverClienteWEB((int)Session["variable_sesion"]); mascota.nombre = txtNombre.Text; mascota.apellido = cliente.apellido; if (rdbPerro.Checked == true) { mascota.especie = "Perro"; } else if (rdbGato.Checked == true) { mascota.especie = "Gato"; } else { mascota.especie = "Otro"; } mascota.idcliente = cliente.id; mascota.raza = new Raza(); mascota.raza.id = Convert.ToInt32(drpRazas.SelectedItem.Value); mascotaNegocio.AgregarAnimal(mascota); idMascota = mascotaNegocio.buscar_ultimo_idanimal(); mascotaNegocio.AgregarAnimalXcliente(cliente.id, idMascota); Response.Write("<script>window.alert('Mascota agregada');</script>"); txtNombre.Text = ""; txtOtro.Text = ""; } }
private void btnAgregarMascota_Click(object sender, EventArgs e) { if (txtNombreMasc.Text == "" || rdbOtro.Checked == true && txtOtro.Text == "") { MessageBox.Show("Debe completar TODOS los campos", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { AnimalNegocio negocio = new AnimalNegocio(); Animal animal = new Animal(); int aux; animal.nombre = txtNombreMasc.Text; animal.apellido = txtapellido.Text; animal.idcliente = int.Parse(txtID.Text); animal.raza = (Raza)cmbRazas.SelectedItem; if (rbtGato.Checked == true) { animal.especie = "Gato"; } if (rbtPerro.Checked == true) { animal.especie = "Perro"; } if (rdbOtro.Checked == true) { txtOtro.Enabled = true; animal.especie = txtOtro.Text; } animal.idcliente = int.Parse(txtID.Text); negocio.AgregarAnimal(animal); aux = negocio.buscar_ultimo_idanimal(); negocio.AgregarAnimalXcliente(int.Parse(txtID.Text), aux); MessageBox.Show("Mascota agregada", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cargarGrilla(); } }