Beispiel #1
0
        public data_list Get(int RecordID)
        {
            data_list users = new data_list();

            dal.Open();
            dal.SetSql("SELECT * FROM users WHERE RecordID = @id");
            dal.AddParameter("@id", RecordID);
            SqlDataReader dr = dal.GetReader();

            if (dr.Read() == true)
            {
                users.RecordID    = (int)dr[0];
                users.RecordName  = dr[1].ToString();
                users.StudentID   = (int)dr[2];
                users.Name        = dr[3].ToString();
                users.TelNumber   = dr[4].ToString();
                users.Address     = dr[5].ToString();
                users.Email       = dr[6].ToString();
                users.Username    = dr[7].ToString();
                users.MothersName = dr[8].ToString();
                users.MTelNumber  = dr[9].ToString();
            }
            dr.Close();
            dal.Close();
            return(users);
        }
Beispiel #2
0
        public List <data_list> GetAll()
        {
            List <data_list> list = new List <data_list>();

            dal.Open();
            dal.SetSql("SELECT * FROM users");
            SqlDataReader dr = dal.GetReader();

            while (dr.Read() == true)
            {
                data_list users = new data_list();
                users.RecordID    = (int)dr["RecordID"];
                users.RecordName  = dr["RecordName"].ToString();
                users.StudentID   = (int)dr["StudentID"];
                users.Name        = dr["Name"].ToString();
                users.TelNumber   = dr["TelNumber"].ToString();
                users.Address     = dr["Address"].ToString();
                users.Email       = dr["Email"].ToString();
                users.Username    = dr["Username"].ToString();
                users.MothersName = dr["MothersName"].ToString();
                users.MTelNumber  = dr["MTelNumber"].ToString();
                list.Add(users);
            }
            dr.Close();
            dal.Close();

            return(list);
        }