Beispiel #1
0
        public SchoolFellow getOne(int id)
        {
            string sql = "select top 10 RealName,Sex,HeadPicture,Birthday,Email,QQ,Handset,Address,WorkPlace,SpecialityName,Graduation,ClassName from T_User "
                         + "where UserID=@id";
            SqlParameter p  = new SqlParameter("@id", id);
            DataTable    dt = DbHelperSQL.Query(sql, p).Tables[0];

            Console.WriteLine(dt.Rows[0][1]);
            if (dt != null)
            {
                DataRow      row          = dt.Rows[0];
                SchoolFellow schoolFellow = new SchoolFellow(
                    id, row["RealName"].ToString(),
                    row["Sex"].ToString(), row["SpecialityName"].ToString(),
                    row["ClassName"].ToString(), row["HeadPicture"].ToString(),
                    row["Graduation"].ToString(), row["WorkPlace"].ToString(),
                    row["Address"].ToString(), row["Handset"].ToString(),
                    row["Email"].ToString(), row["Birthday"].ToString(), row["QQ"].ToString());
                Console.WriteLine(schoolFellow.ToString());
                Console.WriteLine("------" + DateTime.Now.ToString() + "-------");
                Console.WriteLine(sql);
                Console.WriteLine(schoolFellow.ToString());
                return(schoolFellow);
            }
            return(null);
        }
        public List <SchoolFellow> getSchoolFellowsList(Stream data)
        {
            StreamReader reader = new StreamReader(data, Encoding.UTF8);
            string       json   = reader.ReadToEnd();

            Console.WriteLine(json);
            JavaScriptSerializer js   = new JavaScriptSerializer();
            SchoolFellow         list = js.Deserialize <SchoolFellow>(json);

            Console.WriteLine(list.ToString());
            List <SchoolFellow> jsonbackLists = new getList().GetList(list);

            Console.WriteLine("------" + DateTime.Now.ToString() + "-------");
            foreach (SchoolFellow stu in jsonbackLists)
            {
                Console.WriteLine(stu.RealName
                                  + "---" + stu.Address + "---" + stu.Sex + "---" + stu.SpecialityName);
            }
            return(jsonbackLists);
        }