Пример #1
0
 private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dataGridView1.RowCount > 0)
     {
         try
         {
             EOcupaciones o = new EOcupaciones();
             o.OcupacionId = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["OcupacionId"].Value.ToString());
             var          i = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["Ocupacion"].Value.ToString();
             DialogResult d = MessageBox.Show("¿Realmente desea Eliminar la ocupacion " + i + "?", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Question);
             if (d == DialogResult.OK)
             {
                 NOcupaciones n = new NOcupaciones();
                 n.EliminarOcupacion(o);
                 MessageBox.Show("Eliminado con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Cargar();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "SGA", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("No hay registros que Eliminar", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Пример #2
0
        void OcupacionMadre()
        {
            NOcupaciones        n = new NOcupaciones();
            List <EOcupaciones> listaOcupaciones = n.ListaOcupaciones();

            cbmOcupacionMadre.DisplayMember = "Ocupacion";
            cbmOcupacionMadre.ValueMember   = "OcupacionId";
            cbmOcupacionMadre.DataSource    = listaOcupaciones;
        }
Пример #3
0
 void Cargar()
 {
     try
     {
         NOcupaciones        n     = new NOcupaciones();
         List <EOcupaciones> lista = n.ListaOcupaciones();
         dataGridView1.DataSource            = lista;
         dataGridView1.Columns[0].Visible    = false;
         dataGridView1.Columns[1].HeaderText = "LISTA OCUPACION";
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
 void CargarOcupaciones()
 {
     try
     {
         NOcupaciones        n     = new NOcupaciones();
         List <EOcupaciones> lista = n.ListaOcupaciones();
         cbmOcupacion.DataSource    = lista;
         cbmOcupacion.DisplayMember = "Ocupacion";
         cbmOcupacion.ValueMember   = "OcupacionId";
         cbmOcupacion.Text          = "Seleccione una Ocupación";
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #5
0
 private void btningresar_Click(object sender, EventArgs e)
 {
     try
     {
         EOcupaciones o = new EOcupaciones();
         NOcupaciones n = new NOcupaciones();
         if (bandera == 0)
         {
             o.Ocupacion = txtprofesion.Text;
             n.IngresarOcupacion(o);
             //MessageBox.Show("Ocupación ingresada con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information);
             Limpiar();
             Cargar();
         }
         if (bandera == 1)
         {
             if (chkeditar.Checked)
             {
                 o.OcupacionId = Convert.ToInt32(txtprofesion.Tag);
                 o.Ocupacion   = txtprofesion.Text;
                 n.ModifiarOcupacion(o);
                 MessageBox.Show("Ocupación Modificada con exito", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Limpiar();
                 Cargar();
             }
             else
             {
                 MessageBox.Show("Si has seleccionado un dato, por favor vuelve a marcar EDITAR", "SGA", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "SGA", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }