示例#1
0
        private void grid1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            row = e.RowIndex + 1;
            if (this.grid1.Columns[e.ColumnIndex].Name == "Editar")
            {
                string    query = "select nombre,telefono,direccion from jugador where idjugador = '" + grid1.CurrentRow.Cells["idjugador"].Value + "'";
                ArrayList array = db.consultar(query);
                foreach (Dictionary <string, string> v in array)
                {
                    txt_nombre_jugador.Text    = v["nombre"];
                    txt_direccion_jugador.Text = v["direccion"];
                    txt_tel_jugador.Text       = v["telefono"];
                    modificado = true;
                }
                panel_insercion.Visible = true;
                txt_nombre_jugador.Focus();
            }
            else if (this.grid1.Columns[e.ColumnIndex].Name == "Eliminar")
            {
                if (MessageBox.Show("¿Estás seguro de eliminar este registro?", "Eliminar registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    int p = Convert.ToInt32(grid1.CurrentRow.Cells["idjugador"].Value);
                    db.eliminar("jugador", "idjugador=" + p);

                    MessageBox.Show("Registro eliminado", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    controldatagrid();
                }
            }
        }
示例#2
0
        private void barra1_click_eliminar_button()
        {
            band_nuevo    = false;
            band_edit     = false;
            band_eliminar = true;

            int rowIndex = grid_clientes.CurrentCell.RowIndex;

            DialogResult dialogResult = MessageBox.Show("Seguro quieres eliminar?", "Eliminar Cliente", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                int a = Convert.ToInt32(grid_clientes.Rows[rowIndex].Cells[0].Value);

                db.eliminar("tbm_cliente", "idtbm_cliente = " + a);

                consultar();

                ocultar();
            }
            else if (dialogResult == DialogResult.No)
            {
                //do something else
            }
        }