示例#1
0
 public empleadoForm(int accion, Empleado emp, estacionamiento estacionamientoCampus)
 {
     InitializeComponent();
     this.emp    = emp;
     this.campus = estacionamientoCampus;
     this.accion = accion;
     if (accion == 1)
     {
         lblOpcionTitulo.Text = "Agregar Empleado";
         btnAccion.Text       = "Agregar";
     }
     else
     {
         lblOpcionTitulo.Text = "Modificar Empleado";
         btnAccion.Text       = "Modificar";
         llenarCampos();
         if (!(emp.Sex != 1)) // que es mujer
         {
             pintaPanel.BackColor = Color.LightPink;
         }
         else
         {
             pintaPanel.BackColor = Color.LightSkyBlue;
         }
     }
 }
示例#2
0
        private void cargaDatosEscuela()
        {
            int    idEscuela = 1;
            string nom;
            int    tot;
            int    ocu;
            int    dis;
            //estacionamiento unam;
            // Realizar la conexion a la BD para obtener la informacion de la escuela
            string query = "SELECT `nomEsc`, `lugaresTot`,`lugaresOc`,`lugaresDis` " +
                           " FROM `estacionamiento` WHERE `idEst` = " + idEscuela + " ";
            // Prepara la conexión
            Conexion        cn = new Conexion();
            MySqlConnection databaseConnection = cn.ConexionNew();
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();
                reader = commandDatabase.ExecuteReader();
                //copia del reader
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string[] row =
                        {
                            reader.GetString("nomEsc"),                // 0
                            reader.GetString("lugaresTot"),            // 1
                            reader.GetString("lugaresOc"),             // 2
                            reader.GetString("lugaresDis")             // 3
                        };

                        nom = row[0];
                        tot = Convert.ToInt32(row[1]);
                        ocu = Convert.ToInt32(row[2]);
                        dis = Convert.ToInt32(row[3]);

                        estacionamiento unam = new estacionamiento(idEscuela, nom, tot, ocu, dis);
                        fesc = unam; // se la asigno al obj global de tipo estacionamiento
                    }
                }
                // Cerrar la conexión
                databaseConnection.Close();
            }

            catch (Exception ex)
            {
                // Mostrar cualquier excepción
                MessageBox.Show(ex.Message);
            }
        }