Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ID"] != null)
            {
                try
                {
                    if (Session["userobject"] != null || Session["Org"] != null)
                    {
                        int iID = int.Parse(Request.QueryString["ID"].ToString());
                        CQGJ.passport.User user = new CQGJ.passport.User();

                        passport.CQGJPassport cqgj = new CQGJ.passport.CQGJPassport();
                        user = cqgj.GetCQGJUser(iID);
                        Response.ContentType = user.PhotoType;
                        Response.BinaryWrite((byte[])user.Photo);
                    }

                }
                catch
                {
                }

            }
        }
Esempio n. 2
0
        public void ShowClass(int id)
        {
            TrainShowClassViewData viewData = new TrainShowClassViewData();
            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();
            viewData.Classes = classes;
            viewData.PhotoUrl = ConfigurationManager.AppSettings["PhotoUrl"].ToString();

            List<int> ListID = (from s in CQGJ.Student where s.Classes.ClassID == id select s.User.UserID).ToList();
            passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();
            viewData.UserList = new List<CQGJ.passport.User>();
            for (int i = 0; i < ListID.Count; ++i)
            {
                ListID[i] = ToPassportUserID(ListID[i]);
                CQGJ.passport.User user = cqgjp.GetCQGJUser(ListID[i]);
                viewData.UserList.Add(user);
            }

            //班级课程
            viewData.CourseList = (from cs in CQGJ.Course
                                   where cs.Classes.ClassID == id
                                   select cs).ToList();

            RenderView("ShowClass", viewData);
        }
Esempio n. 3
0
 public void ResultList(int id)
 {
     TrainResultListViewData viewData = new TrainResultListViewData();
     Classes classes = (from c in CQGJ.Classes
                        where c.ClassID == id
                        select c).First();
     viewData.Classes = classes;
     List<int> ListID = (from s in CQGJ.Student
                         where s.Classes.ClassID == id
                         select s.User.UserID).ToList();
     passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();
     viewData.UserList = new List<CQGJ.passport.User>();
     for (int i = 0; i < ListID.Count; ++i)
     {
         ListID[i] = ToPassportUserID(ListID[i]);
         CQGJ.passport.User user = cqgjp.GetCQGJUser(ListID[i]);
         viewData.UserList.Add(user);
     }
     //班级课程
     viewData.CourseList = (from cs in CQGJ.Course
                            where cs.Classes.ClassID == id
                            select cs).ToList();
     RenderView("ResultList", viewData);
 }
Esempio n. 4
0
        public void EditResult(int id)
        {
            TrainResultListViewData viewData = new TrainResultListViewData();
            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();
            viewData.Classes = classes;
            List<int> ListID = (from s in CQGJ.Student
                                where s.Classes.ClassID == id
                                select s.User.UserID).ToList();
            passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();
            viewData.UserList = new List<CQGJ.passport.User>();
            for (int i = 0; i < ListID.Count; ++i)
            {
                ListID[i] = ToPassportUserID(ListID[i]);
                CQGJ.passport.User user = cqgjp.GetCQGJUser(ListID[i]);
                viewData.UserList.Add(user);
            }
            //班级课程
            viewData.CourseList = (from cs in CQGJ.Course
                                   where cs.Classes.ClassID == id
                                   select cs).ToList();
            if (GetString("flag") != "")
            {
                foreach (var co in viewData.CourseList)
                {
                    for (int i = 0; i < ListID.Count; i++)
                    {
                        int temp = GetInt(co.CourseID.ToString() + "-" + i.ToString());
                        int x = ListID[i];
                        Student student = (from s in CQGJ.Student
                                           from cs in CQGJ.Course
                                           where cs.CourseID == co.CourseID && cs.Classes == s.Classes && s.User.UserID == x
                                           select s).First();
                        var result = (from cr in CQGJ.CourseResult
                                      from s in CQGJ.Student
                                      where cr.Course.CourseID == co.CourseID && cr.Student.StudentID == student.StudentID
                                      select cr);
                        if (result.Count() > 0)
                        {
                            result.First().Mark = temp.ToString();
                        }
                        else
                        {
                            CourseResult r = new CourseResult();
                            r.Course = co;
                            r.Student = student;
                            r.Mark = temp.ToString();
                            CQGJ.AddToCourseResult(r);
                        }

                        CQGJ.SaveChanges();
                    }
                }
            }
            RenderView("Editresult", viewData);
        }
Esempio n. 5
0
        public void AddAttend(int id)
        {
            TrainResultListViewData viewData = new TrainResultListViewData();
            Classes classes = (from c in CQGJ.Classes
                               where c.ClassID == id
                               select c).First();
            viewData.Classes = classes;
            List<int> ListID = (from s in CQGJ.Student
                                where s.Classes.ClassID == id
                                select s.User.UserID).ToList();
            passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();
            viewData.UserList = new List<CQGJ.passport.User>();
            for (int i = 0; i < ListID.Count; ++i)
            {
                ListID[i] = ToPassportUserID(ListID[i]);
                CQGJ.passport.User user = cqgjp.GetCQGJUser(ListID[i]);
                viewData.UserList.Add(user);
            }
            //班级课程
            viewData.CourseList = (from cs in CQGJ.Course
                                   where cs.Classes.ClassID == id
                                   select cs).ToList();

            if (GetString("flag") != "")
            {
                Course course = viewData.CourseList.First();
                for (int i = 0; i < ListID.Count; i++)
                {
                    int temp = 0;
                    if (GetString("user-" + i.ToString()) == "on")
                    { temp = 1; }
                    int x = ListID[i];
                    Student student = (from s in CQGJ.Student
                                       from cs in CQGJ.Course
                                       where cs.CourseID == course.CourseID && cs.Classes == s.Classes && s.User.UserID == x
                                       select s).First();
                    var result = (from cr in CQGJ.CourseResult
                                  from s in CQGJ.Student
                                  where cr.Course.CourseID == course.CourseID && cr.Student.StudentID == student.StudentID
                                  select cr);
                    Attend attend = new Attend();
                    if (result.Count() <= 0)
                    {
                        CourseResult r = new CourseResult();
                        r.Course = course;
                        r.Student = student;
                        r.Mark = temp.ToString();
                        CQGJ.AddToCourseResult(r);
                        CQGJ.SaveChanges();
                        attend.CourseResult = r;
                    }
                    else
                    {
                        attend.CourseResult = result.First();
                    }
                    attend.Status = temp;
                    attend.AttendTime = DateTime.Now;
                    CQGJ.AddToAttend(attend);
                    CQGJ.SaveChanges();
                }
                RedirectToAction("attendlist");
            }
            RenderView("AddAttend", viewData);
        }
Esempio n. 6
0
        /// <summary>
        /// 根据用户ID获取用户信息
        /// </summary>
        /// <param name="userID">CQGJ数据库中用户ID</param>
        /// <returns>Passport数据库中的用户对象</returns>
        public CQGJ.passport.User GetUserInfoByID(int userID)
        {
            // 根据当前数据库UserID获取他在Passport数据库User表中的ID
            int PassportUserID = ToPassportUserID(userID);

            passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();

            // 从Passport数据库中获取用户对象
            CQGJ.passport.User user = cqgjp.GetCQGJUser(PassportUserID);

            return user;
        }
Esempio n. 7
0
        /// <summary>
        /// 取得可能成为管理员的BBS用户
        /// </summary>
        /// <param name="id">BBS ID</param>
        /// <returns></returns>
        public List<CQGJ.passport.User> GetPotentialAdminByBBSID(int id)
        {
            BBSInfo BBSInformation = new BBSInfo();

            // 定义User,用于将班级学员转化为User对象
            List<CQGJ.passport.User> users = new List<CQGJ.passport.User>();

            try
            {
                // 获取BBS相关信息
                BBSInformation.BBS = (from bbs in CQGJ.BBS where bbs.BBSID == id select bbs).First();

                // 获取BBS当前管理员ID
                int BBSOwnerID = (int)(from b in CQGJ.BBS where b.BBSID == id select b.OwnerID).First();

                // 根据BBS当前管理员ID获取他在Passport数据库User表中的ID
                int PassportUserID = ToPassportUserID(BBSOwnerID);
                passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();

                // 从Passport数据库中获取用户对象
                CQGJ.passport.User admin = cqgjp.GetCQGJUser(PassportUserID);

                // 获取该班级的所有学员, i 为该BBS对应班级的ID
                // (注意要另行定义int i,
                // 不能直接写成List<int> sid = (from s in CQGJ.Student where s.Classes.ClassID == (int)BBSInformation.BBS.ClassesReference.EntityKey.EntityKeyValues[0].Value select s.User.UserID).ToList();)
                // 否则会报错,原因未知
                int i = (int)BBSInformation.BBS.ClassesReference.EntityKey.EntityKeyValues[0].Value;
                List<int> sid = (from s in CQGJ.Student where s.Classes.ClassID == i select s.User.UserID).ToList();

                // 将当前管理员添加到users对象中,作为潜在的管理员
                users.Add(admin);

                // 将班级学员添加到users对象中,作为潜在的管理员
                foreach (var studentId in sid)
                {
                    passport.CQGJPassport cqgjp2 = new CQGJ.passport.CQGJPassport();

                    int passportUserID = ToPassportUserID(studentId);

                    CQGJ.passport.User student = cqgjp2.GetCQGJUser(passportUserID);

                    // 判断当然管理是否是该班级,如果不是则添加,如果是就不添加
                    if (student.UserID != admin.UserID)
                    {
                        users.Add(student);

                    }

                }

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }

            return users;
        }
Esempio n. 8
0
        /// <summary>
        /// 根据BBSID获取BBS相关信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BBSInfo GetBBSInfo(int id)
        {
            BBSInfo BBSInformation = new BBSInfo();

            try
            {
                // 获取BBS相关信息
                BBSInformation.BBS = (from bbs in CQGJ.BBS where bbs.BBSID == id select bbs).First();
                // 获取BBS内发帖的条数
                BBSInformation.BBSItemsNbr = (from bi in CQGJ.BBSItem where bi.BBS.BBSID == id && bi.ParentID == -1 select bi).Count();

                // 获取BBS当前管理员ID
                int BBSOwnerID = (int)(from b in CQGJ.BBS where b.BBSID == id select b.OwnerID).First();

                // 根据BBS当前管理员ID获取他在Passport数据库User表中的ID
                int PassportUserID = ToPassportUserID(BBSOwnerID);
                passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();

                // 从Passport数据库中获取用户对象,并取得管理员名字
                CQGJ.passport.User admin = cqgjp.GetCQGJUser(PassportUserID);
                BBSInformation.OwnerName = admin.Username;

                // 获取该班级的所有学员, i 为该BBS对应班级的ID
                // (注意要另行定义int i,
                // 不能直接写成List<int> sid = (from s in CQGJ.Student where s.Classes.ClassID == (int)BBSInformation.BBS.ClassesReference.EntityKey.EntityKeyValues[0].Value select s.User.UserID).ToList();)
                // 否则会报错,原因未知
                int i = (int)BBSInformation.BBS.ClassesReference.EntityKey.EntityKeyValues[0].Value;
                List<int> sid = (from s in CQGJ.Student where s.Classes.ClassID == i select s.User.UserID).ToList();

                // 定义User,用于将班级学员转化为User对象
                List<CQGJ.passport.User> users = new List<CQGJ.passport.User>();

                // 定义用户姓名的数组
                List<string> names = new List<string>();
                List<int> ownerIds = new List<int>();

                // 将当前管理员添加到users对象中,作为潜在的管理员
                users.Add(admin);
                // 添加管理员的名字
                names.Add(admin.Username);
                ownerIds.Add(admin.UserID);

                // 将班级学员添加到users对象中,作为潜在的管理员
                foreach (var studentId in sid)
                {
                    passport.CQGJPassport cqgjp2 = new CQGJ.passport.CQGJPassport();

                    int passportUserID = ToPassportUserID(studentId);

                    CQGJ.passport.User student = cqgjp2.GetCQGJUser(passportUserID);

                    // 判断当然管理是否是该班级,如果不是则添加,如果是就不添加
                    if (student.UserID != admin.UserID)
                    {
                        users.Add(student);
                        names.Add(student.Username);
                        ownerIds.Add(student.UserID);
                    }

                }

                BBSInformation.Oweners = users;
                BBSInformation.OwernNames = names;
                BBSInformation.OwernIDs = ownerIds;
            }
            catch (Exception ex)
            {

            }

            return BBSInformation;
        }
Esempio n. 9
0
        /// <summary>
        /// 根据BBSID获取其管理员
        /// </summary>
        /// <param name="id">BBS ID</param>
        public CQGJ.passport.User GetAdminByBBSID(int id)
        {
            // 获取BBS当前管理员ID
            int BBSOwnerID = (int)(from b in CQGJ.BBS where b.BBSID == id select b.OwnerID).First();
            // 根据BBS当前管理员ID获取他在Passport数据库User表中的ID
            int PassportUserID = ToPassportUserID(BBSOwnerID);
            passport.CQGJPassport cqgjp = new CQGJ.passport.CQGJPassport();

            // 从Passport数据库中获取用户对象
            CQGJ.passport.User admin = cqgjp.GetCQGJUser(PassportUserID);

            return admin;
        }
Esempio n. 10
0
        // for testing
        public void toTest()
        {
            BBSListViewData bvd = new BBSListViewData();

            Classes d = (from b in CQGJ.BBS where b.BBSID == 1 select b.Classes).First();

            //bvd.BBSList = (from c in CQGJ.Classes
            //               join b in CQGJ.BBS on c.ClassID equals b.Classes.ClassID
            //               select b).ToList();
            //bvd.BBSList = (from b in CQGJ.BBS
            //               join c in CQGJ.Classes on b.Classes.ClassID equals c.ClassID
            //               select b).ToList();

            bvd.BBSList = (from b in CQGJ.BBS
                           join c in CQGJ.Classes on b.Classes.ClassID equals c.ClassID
                           where c.ClassID == (from s in CQGJ.Student
                                               where s.User.UserID == 1
                                               select s.User.UserID).FirstOrDefault()
                           select b).ToList();
            passport.CQGJPassport pqgj = new CQGJ.passport.CQGJPassport();

            bvd.User = pqgj.GetCQGJUser(1);

            int i = bvd.User.UserID;

            RenderView("test", bvd);
        }