Example #1
0
        public DataTable GetUserList()
        {
            Postgre   db = new Postgre();
            DataTable dt = new DataTable();

            string sql = "SELECT * FROM person WHERE isadmin = false";

            dt = db.Select(sql);

            return(dt);
        }
Example #2
0
        public DataTable GetExam(string user)
        {
            Postgre   db = new Postgre();
            DataTable dt = new DataTable();

            // Dictionary to send parameters in format key-value
            Dictionary <string, string> myParams = new Dictionary <string, string>();

            myParams.Add("@uname", user);
            string sql = "select distinct on (\"username\") * from examresult WHERE username = @uname ORDER BY username, date DESC";

            dt = db.Select(sql, myParams);

            return(dt);
        }
Example #3
0
        public DataTable AdmLogin()
        {
            Postgre   db = new Postgre();
            DataTable dt = new DataTable();

            Dictionary <string, string> myParams = new Dictionary <string, string>();

            myParams.Add("@username", Username);
            myParams.Add("@password", Password);

            // Sql query with parameters
            string sql = "SELECT * FROM person " +
                         "WHERE username = @username AND " +
                         "password = @password AND " +
                         "isadmin = true";


            dt = db.Select(sql, myParams);

            return(dt);
        }