Exemplo n.º 1
0
        protected void ButtonEliminar_Click(object sender, EventArgs e)
        {
            string NombreMascota = txtNombre.Text;
            string RutDueno      = TextBoxRutDueno.Text;


            if (!NombreMascota.Equals("") && !RutDueno.Equals(""))
            {
                DataTable dt = MascotaDAO.EliminarMascota(NombreMascota, RutDueno);
                if (dt != null)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Bien, datos eliminados correctamente" + "');", true);
                    LabelError.Text      = "";
                    LabelOk.Text         = "Bien, mascota eliminada creado";
                    txtNombre.Text       = "";
                    txtRaza.Text         = "";
                    txtEspecie.Text      = "";
                    TextBoxFechaNac.Text = "";
                    DropDownListGenero.SelectedValue.ToString();
                    TextBoxFoto.Text     = "";
                    TextBoxRutDueno.Text = "";
                }
                else
                {
                    LabelOk.Text    = "";
                    LabelError.Text = "Error, no existe mascota asociada al rut del dueño";
                }
            }
            else
            {
                LabelOk.Text    = "";
                LabelError.Text = "Error, hay campos vacios. Debe ingresar nombre y rut del dueño para poder eliminar";
            }
        }
        protected void gvdListaMascotas_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow fila   = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            int         indice = fila.RowIndex;

            if (e.CommandName == "Eliminar")
            {
                int        idMascota  = int.Parse(gvdListaMascotas.Rows[indice].Cells[0].Text);
                MascotaDAO mascotaDAO = new MascotaDAO();
                bool       resultado  = mascotaDAO.EliminarMascota(idMascota);
                if (resultado == true)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alarm", "delete_success_modal()", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alarm", "delete_fail_modal()", true);
                }
                CargarGrillas();
            }

            if (e.CommandName == "Actualizar")
            {
                Session["idMascotaActualizar"] = gvdListaMascotas.Rows[indice].Cells[0].Text;
                Response.Redirect("ActualizarDatosMascotasAdmin.aspx");
                CargarGrillas();
            }
            if (e.CommandName == "Ver")
            {
                Session["idMascotaVer"] = gvdListaMascotas.Rows[indice].Cells[0].Text;
                Response.Redirect("VerInfoMascotaAdmin.aspx");
            }
        }
Exemplo n.º 3
0
        protected void gvdListaMascotas_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            GridViewRow fila   = (GridViewRow)((Control)e.CommandSource).NamingContainer;
            int         indice = fila.RowIndex;

            if (e.CommandName == "Eliminar")
            {
                int        idMascota  = int.Parse(gvdListaMascotas.Rows[indice].Cells[0].Text);
                MascotaDAO mascotaDAO = new MascotaDAO();
                CargarGrilla();
                lblMensaje.Text = mascotaDAO.EliminarMascota(idMascota);
            }

            if (e.CommandName == "Actualizar")
            {
                Session["idMascotaActualizar"] = gvdListaMascotas.Rows[indice].Cells[0].Text;
                Response.Redirect("VerInfoMascotaAdmin.aspx");
            }
        }