private void cmdBuscar_Click(object sender, EventArgs e) { PuiCatDoctores pui = new PuiCatDoctores(db); DatosTbl = pui.BuscaDoctores(txtBuscar.Text); DataSet ds = new DataSet(); DatosTbl.Fill(ds); //grdView.Rows.Clear(); grdView.DataSource = ds.Tables[0]; /* * for (int j = 0; j < ds.Tables[0].Rows.Count; j++) * { * object[] tmp = ds.Tables[0].Rows[j].ItemArray; * grdView.Rows.Add(tmp); * } */ }
private void cmdEliminar_Click(object sender, EventArgs e) { try { if (MessageBoxAdv.Show("Esta seguro de eliminar el registro " + grdView[0, grdView.CurrentRow.Index].Value.ToString(), "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { PuiCatDoctores pui = new PuiCatDoctores(db); pui.keyCveDoctor = grdView[0, grdView.CurrentRow.Index].Value.ToString(); pui.EliminaDoctores(); LlenaGridView(); } } catch (Exception ex) { MessageBoxAdv.Show("Tienes que seleccionar un registro\n" + ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void LlenaGridView() { try { PuiCatDoctores pui = new PuiCatDoctores(db); //grdView.Rows.Clear(); grdView.DataSource = pui.ListarDoctores();; /* * for (int j = 0; j < Ds.Tables[0].Rows.Count; j++) * { * object[] tmp = Ds.Tables[0].Rows[j].ItemArray; * grdView.Rows.Add(tmp); * } */ } catch (Exception ex) { MessageBoxAdv.Show(ex.Message, "Error al cargar listado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }