Exemplo n.º 1
0
 protected void btnEliminarPaciente_Click(object sender, EventArgs e)
 {
     try
     {
         ControlPaciente control         = new ControlPaciente();
         string          documento       = this.txtDocumento.Text;
         short           tipoDocumentoId = short.Parse(
             this.ddlTiposDocumento.SelectedValue);
         control.EliminarPaciente(documento, tipoDocumentoId);
         this.lblResultado.Text = "El paciente se ha eliminado exitosamente";
     }
     catch (Exception exc)
     {
         this.lblResultado.Text = "Error al eliminar el paciente: " + exc.Message;
     }
 }
Exemplo n.º 2
0
 protected void gvPacientes_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Detalle")
     {
         GridViewRow row           = (GridViewRow)((Control)e.CommandSource).NamingContainer;
         Label       lblIdPaciente = (Label)row.FindControl("lblIdPaciente");
         this.Session["IdPaciente"] = long.Parse(lblIdPaciente.Text);
         Response.Redirect("DatosPaciente.aspx", true);
     }
     if (e.CommandName == "EliminarPaciente")
     {
         GridViewRow row           = (GridViewRow)((Control)e.CommandSource).NamingContainer;
         Label       lblIdPaciente = (Label)row.FindControl("lblIdPaciente");
         long        idPaciente    = long.Parse(lblIdPaciente.Text.ToString());
         lblMensajes.Text = "Paciente eliminado exitosamente";
         ControlPaciente control = new ControlPaciente();
         control.EliminarPaciente(idPaciente);
         this.Consultar();
     }
 }
Exemplo n.º 3
0
 public void EliminarPaciente()
 {
     if (dgvPacientes.SelectedRows.Count > 0)
     {
         if (MessageBox.Show("Está seguro de eliminar el paciente",
                             this.Text, MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 long idPaciente = ((Entidades.Paciente)(dgvPacientes.SelectedRows[0].DataBoundItem)).Id;
                 ControlPaciente.EliminarPaciente(idPaciente);
                 ConsultarPacientes();
                 MessageBox.Show("El paciente se eliminó correctamente", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception exc)
             {
                 MessageBox.Show("No se pudo eliminar el paciente. " + exc.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }