Exemplo n.º 1
0
        public static Useremp getUseremp(string pLogin, string pPass)
        {
            Useremp item = null;

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand cmdGetItemById = new MySqlCommand("select * from useremp where Login=@pLogin and Pass=md5(@pPass)", _con);
                    cmdGetItemById.Parameters.AddWithValue("@pLogin", pLogin);
                    cmdGetItemById.Parameters.AddWithValue("@pPass", pPass);

                    MySqlDataReader _reader = cmdGetItemById.ExecuteReader();
                    while (_reader.Read())
                    {
                        item = new Useremp(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetString(2),
                            _reader.GetString(3),
                            _reader.GetInt64(4),
                            ContratoDAL.getContratoById(_reader.GetInt64(4)),
                            AcsSucursalDAL.getAcsSucursalesByIdUser(_reader.GetInt64(0))
                            );
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(item);
        }
Exemplo n.º 2
0
        public static List <Useremp> getUsersemp()
        {
            List <Useremp> lista = new List <Useremp>();

            using (MySqlConnection _con = new Conexion().Conectar())
            {
                try
                {
                    _con.Open();
                    MySqlCommand    comando = new MySqlCommand("select * from useremp", _con);
                    MySqlDataReader _reader = comando.ExecuteReader();
                    while (_reader.Read())
                    {
                        Useremp item = new Useremp(
                            _reader.GetInt64(0),
                            _reader.GetString(1),
                            _reader.GetString(2),
                            _reader.GetString(3),
                            _reader.GetInt64(4),
                            ContratoDAL.getContratoById(_reader.GetInt64(4)),
                            AcsSucursalDAL.getAcsSucursalesByIdUser(_reader.GetInt64(0))
                            );

                        lista.Add(item);
                    }
                    _reader.Close();
                }
                catch (Exception ex)
                {
                    _con.Close();
                    throw ex;
                }
                finally
                {
                    _con.Close();
                }
            }
            return(lista);
        }