示例#1
0
        private void dgvPresentacion_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataTable tabla = new DataTable();


                if (dgvPresentacion.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar"))
                {
                    int idpresentacion = Convert.ToInt32(dgvPresentacion.Rows[e.RowIndex].Cells[5].Value);
                    tabla = NPresentacion.BuscarCodigo(idpresentacion);
                    new frmPresentacion().Show();
                    int numFilas = tabla.Rows.Count;
                    if (numFilas == 1)
                    {
                        frmPresentacion.MyFormPresentation.txtNombre.Text      = tabla.Rows[0]["nombre"].ToString();
                        frmPresentacion.MyFormPresentation.txtDescripcion.Text = tabla.Rows[0]["Descripcion"].ToString();
                        frmPresentacion.MyFormPresentation.idPresentacion      = int.Parse(tabla.Rows[0]["idpresentacion"].ToString());
                        frmPresentacion.MyFormPresentation.isNew = false;
                    }
                }
                if (dgvPresentacion.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar"))
                {
                    int          idpresentacion = Convert.ToInt32(dgvPresentacion.Rows[e.RowIndex].Cells[5].Value);
                    DialogResult rspta          = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (DialogResult.Yes == rspta)
                    {
                        //var empleado = new Clases.Empleado(id_personal);
                        bool objPres = NPresentacion.Eliminar(idpresentacion);
                        if (objPres)
                        {
                            dgvPresentacion.Rows.RemoveAt(e.RowIndex);
                            MostrarPresentacion();
                        }
                        else
                        {
                            MessageBox.Show("Error al eliminar ");
                        }
                    }
                }
            }
        }