Пример #1
0
 private void dtgGestionUnidades_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 2 && e.RowIndex >= 0)
         //Editar
         {
             UnidadesEdicion f = new UnidadesEdicion();
             f.txbIDunidad.Text = dtgGestionUnidades.CurrentRow.Cells["idunidad"].Value.ToString();
             f.txbUnidad.Text   = dtgGestionUnidades.CurrentRow.Cells["Unidades"].Value.ToString();
             f.ShowDialog();
             Cargar();
         }
         else if (e.ColumnIndex == 3 && e.RowIndex >= 0)
         //eliminar
         {
             if (MessageBox.Show("Seguro que desea ELIMINAR este registro", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 CLS.Unidad oUnidad = new CLS.Unidad();
                 oUnidad.IDUnidad = dtgGestionUnidades.CurrentRow.Cells["idunidad"].Value.ToString();
                 oUnidad.Eliminar();
                 Cargar();
             }
         }
     }
     catch
     {
     }
 }
Пример #2
0
 private void btnAceptar_Click(object sender, EventArgs e)
 {
     try
     {
         if (VerificarDatos())
         {
             CLS.Unidad oUnidad = new CLS.Unidad();
             oUnidad.IDUnidad = txbIDunidad.Text;
             oUnidad.Nombre   = txbUnidad.Text;
             if (txbIDunidad.Text.Length > 0)
             {
                 oUnidad.Actualizar();
             }
             else
             {
                 oUnidad.Guardar();
             }
             Close();
         }
     }
     catch
     {
     }
 }