Ejemplo n.º 1
0
        public List <LogonModel> readList()
        {
            List <LogonModel> logonModelList = new List <LogonModel>();

            openConnection();

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format("select brugerId, lastLogon, logonCnt from Logon");

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                LogonModel logonModel = new LogonModel();
                logonModel.brugerId  = reader.GetString("brugerId");
                logonModel.lastlogon = reader.GetDateTime("lastlogon");
                logonModel.logonCnt  = reader.GetInt32("logonCnt");
                logonModelList.Add(logonModel);
            }

            closeConnection();
            return(logonModelList);
        }
Ejemplo n.º 2
0
        public LogonModel read(string id)
        {
            openConnection();
            LogonModel   logonModel = new LogonModel();
            MySqlCommand cmd        = new MySqlCommand();

            cmd.Connection  = connection;
            cmd.CommandText = string.Format("select brugerId, lastLogon, logonCnt from Logon where brugerId='{0}'", id);

            MySqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                logonModel.brugerId  = reader.GetString("brugerId");
                logonModel.lastlogon = reader.GetDateTime("lastlogon");
                logonModel.logonCnt  = reader.GetInt32("logonCnt");
            }

            closeConnection();
            return(logonModel);
        }