public void tipoBotonClic(DataGridViewCellEventArgs e) { //si el click es en el boton actualizar if (e.RowIndex >= 0) { if (e.ColumnIndex == btnUpdate.Index) { frmInsertarOfertas frm = new frmInsertarOfertas(); frm.MdiParent = this.MdiParent; frm.WindowState = FormWindowState.Maximized; frm.Show(); frm.TipoInsercion = 1; frm.PkOfertas = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[0].Value); frm.NombreOferta = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[1].Value); frm.FechaInicio = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[2].Value); frm.FechaFin = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[3].Value); frm.Descripcion = Convert.ToString(tblOfertas.Rows[e.RowIndex].Cells[4].Value); this.Dispose(); } //si el click es en el boton eliminar if (e.ColumnIndex == btnEliminar.Index) { if (MessageBox.Show("Esta seguro de eliminar este registro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (MessageBox.Show("Esta totalmente seguro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes) { int codigo = Convert.ToInt32(tblOfertas.Rows[e.RowIndex].Cells[0].Value); OfertaBLL.DeleteOferta(codigo); MessageBox.Show("Registro eliminado"); this.cargarDatosOfertas(); } } } } }
private void MenuAgregarOfertas_Click(object sender, EventArgs e) { frmInsertarOfertas frm = new frmInsertarOfertas(); frm.MdiParent = this; frm.WindowState = FormWindowState.Maximized; frm.MaximizeBox = false; frm.Show(); this.DisposeAllButThis(frm); }