예제 #1
0
        //添加班级处理
        public void AddGra(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  ACName = col["ACName"];
            ACademy ac     = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                string ACId = ac.ACId;
                Grade  gra  = new Grade();
                gra.GId   = col["GId"];
                gra.GName = col["GName"];
                gra.GNum  = Convert.ToInt16(col["GNum"]);
                gra.ACId  = ACId;

                entity.Grades.Add(gra);
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddGrade"));
            }
        }
예제 #2
0
 public void Login(string userType, string userName, string Pwd, string yzm)
 {
     if (!yzm.Equals(TempData["SecurityCode"]))
     {
         Response.Write(JsHelper.Messagebox("验证码不正确,登录不成功!", "Login", "Index"));
     }
     else
     {
         if (userType == "管理员")
         {
             Admin admin = entity.Admins.Where(p => p.AName == userName && p.APassword == Pwd).FirstOrDefault();
             if (admin == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["AId"]       = admin.AId;
                 Session["userName"]  = userName;
                 Session["userType"]  = userType;
                 Session["userPower"] = admin.APower;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Admin", "AdminList"));
             }
         }
         else if (userType == "教师")
         {
             Teacher teacher = entity.Teachers.Where(p => p.TName == userName && p.TPassword == Pwd).FirstOrDefault();
             if (teacher == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["TId"] = teacher.TId;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Teacher", "Index"));
             }
         }
         else if (userType == "学生")
         {
             Student student = entity.Students.Where(p => p.SName == userName && p.SPassword == Pwd).FirstOrDefault();
             if (student == null)
             {
                 Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
             }
             else
             {
                 Session["SId"] = student.SId;
                 Response.Write(JsHelper.Messagebox("登录成功!", "Student", "Index"));
             }
         }
         else
         {
             Response.Write(JsHelper.Messagebox("登录不成功!", "Login", "Index"));
         }
     }
 }
예제 #3
0
        //使用邮件修改密码功能
        public void forgetemail()
        {
            string s    = Session["email"].ToString();
            User   user = entity.User.Where(p => p.QQ == s).FirstOrDefault();

            user.Password = "******";
            entity.Entry <User>(user).State = System.Data.EntityState.Modified;
            entity.SaveChanges();
            Response.Write(JsHelper.Messagebox("密码修改成功!", "Home", "Index"));
        }
예제 #4
0
 //退出功能
 public void goback()
 {
     if (Convert.ToInt16(Session["coockie"]) != 0)
     {
         HttpCookie hc = Request.Cookies["AUFElogin"];
         hc.Expires = DateTime.Now.AddDays(-1);
         Response.Cookies.Add(hc);
     }
     Session.Abandon();
     Response.Write(JsHelper.Messagebox("退出成功!", "Home", "Index"));
 }
예제 #5
0
        //添加学生处理
        public void AddStu(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string ACName = col["ACName"];
            string GName  = col["GName"];

            ACademy ac = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                Grade grade = ac.Grades.Where(p => p.GName == GName).FirstOrDefault();
                if (grade != null)
                {
                    string  ACId = ac.ACId;
                    string  GId  = grade.GId;
                    Student stu  = new Student();
                    stu.SId         = col["SId"];
                    stu.SName       = col["SName"];
                    stu.SSex        = col["SSex"];
                    stu.SAge        = Convert.ToInt16(col["SAge"]);
                    stu.SDepartment = col["SDepartment"];
                    stu.SClass      = GId;
                    stu.ACId        = ACId;
                    stu.SPassword   = col["SPassword"];

                    entity.Students.Add(stu);
                    int i = entity.SaveChanges();

                    ac.ACStudentNum++;
                    entity.Entry <ACademy>(ac).State = System.Data.EntityState.Modified;
                    int j = entity.SaveChanges();

                    grade.GNum++;
                    entity.Entry <Grade>(grade).State = System.Data.EntityState.Modified;
                    int k = entity.SaveChanges();
                    if (i != 0 && j != 0 && k != 0)
                    {
                        Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "CheckStudent"));
                    }
                    else
                    {
                        Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                    }
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddStudent"));
            }
        }
예제 #6
0
 //竞赛登录模块
 public void OCLogin(int page, int OCid)
 {
     if (Convert.ToInt32(Session["Login"]) == 1)
     {
         Response.Write(JsHelper.Jump("Home", "OnlineCP?id=" + OCid));
     }
     else
     {
         Response.Write(JsHelper.Messagebox("请先登录!", "OnlineCon?page=" + page));
     }
 }
예제 #7
0
        //登录功能
        public void Login(FormCollection col)
        {
            string UserName = col["UserName"];
            string Password = col["Password"];
            string Checkbox = col["checkbox"];
            string yzm      = col["yzm"];
            string Href     = col["Href"];

            if (!yzm.Equals(TempData["SecurityCode"]))
            {
                Response.Write(JsHelper.Messagebox("验证码不正确,登录不成功!", Href));
            }
            else
            {
                User user = entity.User.Where(p => p.Name == UserName && p.Password == Password).FirstOrDefault();
                //判断用户是否存在
                if (user == null)
                {
                    Session["UId"] = null;
                    Response.Write(JsHelper.Messagebox("登录不成功,请检查用户名或密码是否正确!", Href));
                }
                else
                {
                    Session["Login"]     = 1;
                    Session["UId"]       = user.ID;
                    Session["UserName"]  = UserName;
                    Session["Password"]  = Password;
                    Session["QQ"]        = user.QQ;
                    Session["Tel"]       = user.Tel;
                    Session["Introduce"] = user.Introduce;
                    Session["coockie"]   = 0;

                    //是否记住
                    if (Checkbox != null)
                    {
                        if (Checkbox.Equals("on"))
                        {
                            //保存cookie
                            Session["coockie"] = 1;
                            cookie["UId"]      = user.ID.ToString();
                            cookie["Password"] = Password;
                            cookie["UserName"] = HttpUtility.UrlEncode(UserName);
                            cookie.Expires     = System.DateTime.Now.AddDays(7.0);
                            Response.Cookies.Add(cookie);
                        }
                    }


                    //记录表和用户记录表添加记录
                    AddRecord(user, Href, Href, 1, 1);
                }
            }
        }
예제 #8
0
        //登录时:用户记录表添加记录
        public void AddRecordUser(User user, Record record, string Href, int flag)
        {
            RecordUser recorduser = new RecordUser();

            recorduser.RecordID  = record.ID;
            recorduser.UserID    = user.ID;
            recorduser.LoginTime = DateTime.Now;
            entity.RecordUser.Add(recorduser);
            entity.SaveChanges();
            if (flag == 1)
            {
                Response.Write(JsHelper.Messagebox("登录成功!", Href));
            }
        }
예제 #9
0
        public void Update(Student stu)
        {
            entity.Entry <Student>(stu).State = System.Data.EntityState.Modified;
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("更新成功!", "Student", "Index"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("更新失败!", "Student", "Index"));
            }
        }
예제 #10
0
        public void Update(Teacher tea)
        {
            entity.Entry <Teacher>(tea).State = System.Data.EntityState.Modified;
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("更新成功!", "Teacher", "Index"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("更新失败!", "Teacher", "Index"));
            }
        }
예제 #11
0
        //修改管理员处理
        public void UpdateA(Admin admin)
        {
            ViewBag.AId = Session["AId"];
            entity.Entry <Admin>(admin).State = System.Data.EntityState.Modified;
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("更新成功!", "Admin", "AdminList"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("更新失败!", "Admin", "UpdateAdmin"));
            }
        }
예제 #12
0
        //忘记密码功能
        public void forget(string forgetemail)
        {
            string email = forgetemail;
            User   user  = entity.User.Where(p => p.QQ == email).FirstOrDefault();

            if (user != null)
            {
                SendM(email);
                Session["email"] = email;
                Response.Write(JsHelper.Messagebox("邮件发送成功!", "Home", "Index"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("邮箱不存在!", "Home", "Index"));
            }
        }
예제 #13
0
        //选课处理页
        public void SelectingCourse(string id)
        {
            //课程表选课人数增加
            Course course = entity.Courses.Where(p => p.CId == id).FirstOrDefault();
            int    num    = course.CNum;

            //选课人数必须少于等于50人
            if (num < 50)
            {
                num++;
                course.CNum = num;
                entity.Entry <Course>(course).State = System.Data.EntityState.Modified;
                int j = entity.SaveChanges();
                if (j != 0)
                {
                    //添加选课记录
                    SeleCourse se = new SeleCourse();
                    se.CId     = id;
                    se.SId     = Convert.ToString(Session["SId"]);
                    se.SCGrade = 0;
                    entity.SeleCourses.Add(se);
                    int i = entity.SaveChanges();
                    if (i != 0)
                    {
                        Response.Write(JsHelper.Messagebox("选课成功!", "Student", "Index"));
                    }
                    else
                    {
                        //添加选课记录失败后,课程表还原
                        num--;
                        course.CNum = num;
                        entity.Entry <Course>(course).State = System.Data.EntityState.Modified;
                        entity.SaveChanges();
                        Response.Write(JsHelper.Messagebox("选课失败!", "Student", "Index"));
                    }
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("选课失败!", "Student", "Index"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("选课人数过多,选课失败!", "Student", "Index"));
            }
        }
예제 #14
0
        //登录控制
        public void LoginCheck(FormCollection col)
        {
            string name     = col["Username"];
            string password = col["Password"];

            if ((name != null) && (password != null))
            {
                Admin admin = entity.Admin.Where(p => p.Name == name && p.Password == password).FirstOrDefault();
                if (admin != null)
                {
                    Session["adminid"]   = admin.ID;
                    Session["adminname"] = admin.Name;
                    Response.Write(JsHelper.Messagebox("登录成功!", "Admin", "Index"));
                }
            }

            Response.Write(JsHelper.Messagebox("登录失败!", "Admin", "Login"));
        }
예제 #15
0
        //添加管理员处理
        public void EditA(FormCollection col)
        {
            Admin admin = new Admin();

            admin.AId       = col["AId"];
            admin.AName     = col["AName"];
            admin.APassword = col["APassword"];
            admin.APower    = Convert.ToInt16(col["APower"]);
            entity.Admins.Add(admin);
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("管理员添加成功!", "Admin", "AdminList"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("管理员添加失败!", "Admin", "EditAdmin"));
            }
        }
예제 #16
0
        //添加教师处理
        public void AddTea(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  ACName = col["ACName"];
            ACademy ac     = entity.ACademys.Where(p => p.ACName == ACName).FirstOrDefault();

            if (ac != null)
            {
                string  ACId = ac.ACId;
                Teacher tea  = new Teacher();
                tea.TId       = col["TId"];
                tea.TName     = col["TName"];
                tea.TPosition = col["TPosition"];
                tea.TSex      = col["TSex"];
                tea.TAge      = Convert.ToInt16(col["TAge"]);
                tea.TEmail    = col["TEmail"];
                tea.TTel      = col["TTel"];
                tea.ACId      = ACId;
                tea.TPassword = col["TPassword"];

                entity.Teachers.Add(tea);
                int i = entity.SaveChanges();

                ac.ACTeacherNum++;
                entity.Entry <ACademy>(ac).State = System.Data.EntityState.Modified;
                int j = entity.SaveChanges();
                if (i != 0 && j != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "CheckTeacher"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddTeacher"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddTeacher"));
            }
        }
예제 #17
0
        //退选课程处理页
        public void UnselectedCourse(string id)
        {
            //选课记录表删除记录
            string     sid        = Convert.ToString(Session["SId"]);
            SeleCourse selecourse = entity.SeleCourses.Where(p => p.CId == id && p.SId == sid).FirstOrDefault();

            entity.SeleCourses.Remove(selecourse);
            int i = entity.SaveChanges();

            if (i != 0)
            {
                //课程表选课人数减少
                Course course = entity.Courses.Where(p => p.CId == id).FirstOrDefault();
                int    num    = course.CNum;
                num--;
                course.CNum = num;
                entity.Entry <Course>(course).State = System.Data.EntityState.Modified;
                int j = entity.SaveChanges();
                if (j != 0)
                {
                    Response.Write(JsHelper.Messagebox("退课成功!", "Student", "Index"));
                }
                else
                {
                    //选课记录表还原
                    SeleCourse se = new SeleCourse();
                    se.CId     = id;
                    se.SId     = Convert.ToString(Session["SId"]);
                    se.SCGrade = 0;
                    entity.SeleCourses.Add(se);
                    entity.SaveChanges();
                    Response.Write(JsHelper.Messagebox("退课失败!", "Student", "Index"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("退课失败!", "Student", "Index"));
            }
        }
예제 #18
0
        //添加学院处理
        public void AddACa(FormCollection col)
        {
            ViewBag.AId = Session["AId"];

            ACademy aca = new ACademy();

            aca.ACId         = col["ACId"];
            aca.ACName       = col["ACName"];
            aca.ACTeacherNum = Convert.ToInt16(col["ACTeacherNum"]);
            aca.ACStudentNum = Convert.ToInt16(col["ACStudentNum"]);

            entity.ACademys.Add(aca);
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败!", "Admin", "AddACademy"));
            }
        }
예제 #19
0
        //添加课程处理
        public void AddCou(FormCollection col)
        {
            ViewBag.AId = Session["AId"];
            string  TName = col["TName"];
            Teacher tea   = entity.Teachers.Where(p => p.TName == TName).FirstOrDefault();

            if (tea != null)
            {
                string TId = tea.TId;

                Course cou = new Course();
                cou.CId         = col["CId"];
                cou.CName       = col["CName"];
                cou.CDepartment = col["CDepartment"];
                cou.CWeekly     = Convert.ToInt16(col["CWeekly"]);
                cou.CTime       = Convert.ToInt16(col["CTime"]);
                cou.CClassroom  = col["CClassroom"];
                cou.CCredit     = Convert.ToInt16(col["CCredit"]);
                cou.TId         = TId;
                cou.CNum        = Convert.ToInt16(col["CNum"]);

                entity.Courses.Add(cou);
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    Response.Write(JsHelper.Messagebox("添加成功!", "Admin", "AdminList"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("添加失败1!", "Admin", "AddCourse"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("添加失败2!", "Admin", "AddCourse"));
            }
        }
예제 #20
0
        //删除管理员处理:id为操作管理员编号,deleteid为删除管理员编号
        public void DeleteAdmin(string aid, string deid)
        {
            ViewBag.userName  = Session["userName"];
            ViewBag.userType  = Session["userType"];
            ViewBag.userPower = Session["userPower"];
            ViewBag.AId       = Session["AId"];
            Admin admin = entity.Admins.Find(deid);

            entity.Admins.Remove(admin);
            int i = entity.SaveChanges();

            if (i != 0)
            {
                Response.Write(JsHelper.Messagebox("删除成功!", "Admin", "AdminList"));
            }
            else
            {
                Response.Write(JsHelper.Messagebox("删除失败!", "Admin", "AdminList"));
            }
            if (aid == deid)
            {
                LoginOut();
            }
        }
예제 #21
0
        //登录时:记录表和用户记录表添加记录

        /*
         * Href1: 成功时跳转位置
         * Href2: 失败时跳转位置
         * flag1: 成功时是否需要跳转
         * flag2: 失败时是否需要跳转
         */
        public void AddRecord(User user, string Href1, string Href2, int flag1, int flag2)
        {
            List <Record> records = entity.Record.OrderBy(p => p.TodayDate).ToList();
            int           flag    = 0;
            Record        record  = new Record();

            foreach (var item in records)
            {
                if (item.TodayDate.ToShortDateString() == DateTime.Now.ToShortDateString())
                {
                    flag   = 1;
                    record = item;

                    break;
                }
            }
            //Record表中有今天的记录
            if (flag == 1)
            {
                record.LoginNumber++;
                entity.Entry <Record>(record).State = System.Data.EntityState.Modified;
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    //插入用户记录表RecordUser表
                    AddRecordUser(user, record, Href1, flag1);
                }

                else
                {
                    record.LoginNumber--;
                    entity.Entry <Record>(record).State = System.Data.EntityState.Modified;
                    entity.SaveChanges();
                    if (flag2 == 1)
                    {
                        Response.Write(JsHelper.Messagebox("登录失败!", Href2));
                    }
                }
            }
            else
            {
                record.LoginNumber++;
                record.TodayDate = DateTime.Now;
                entity.Record.Add(record);
                int i = entity.SaveChanges();
                if (i != 0)
                {
                    //插入用户记录表RecordUser表
                    AddRecordUser(user, record, Href1, flag);
                }
                else
                {
                    record.LoginNumber--;
                    entity.Entry <Record>(record).State = System.Data.EntityState.Modified;
                    entity.SaveChanges();
                    if (flag2 == 1)
                    {
                        Response.Write(JsHelper.Messagebox("登录失败!", Href2));
                    }
                }
            }
        }
예제 #22
0
 //没有登录先登录
 public void PleaseLogin(string id)
 {
     Response.Write(JsHelper.Messagebox("请先登录后再试!", "Home", "Problem?id=" + id));
 }
예제 #23
0
 public void LoginOut()
 {
     Session.Clear();
     Response.Write(JsHelper.Messagebox("登出成功!", "Login", "Index"));
 }
예제 #24
0
        //注册功能
        public void register(FormCollection col)
        {
            string username      = col["UserName"];
            string password      = col["Password"];
            string passwordagain = col["Passwordagain"];
            string sex           = col["Sex"];
            string age           = col["Age"];
            string qq            = col["QQ"];
            string tel           = col["Tel"];
            string introduce     = col["Introduce"];

            if (password.Equals(passwordagain))
            {
                User existuser = new User();
                existuser = entity.User.Where(p => p.Name == username).FirstOrDefault();
                if (existuser != null)
                {
                    Response.Write(JsHelper.Messagebox("注册失败!用户名已经存在!", "Home", "Index"));
                }
                else
                {
                    existuser = entity.User.Where(p => p.QQ == qq).FirstOrDefault();
                    if (existuser != null)
                    {
                        Response.Write(JsHelper.Messagebox("注册失败!该QQ号已经绑定了!", "Home", "Index"));
                    }
                    else
                    {
                        existuser = entity.User.Where(p => p.Tel == tel).FirstOrDefault();
                        if (existuser != null)
                        {
                            Response.Write(JsHelper.Messagebox("注册失败!该电话号码已经绑定了!", "Home", "Index"));
                        }
                        else
                        {
                            User user = new User();
                            user.Name         = username;
                            user.Password     = password;
                            user.Sex          = sex;
                            user.Age          = Convert.ToInt16(age);
                            user.QQ           = qq;
                            user.Tel          = tel;
                            user.Introduce    = introduce;
                            user.CreationDate = DateTime.Now;
                            entity.User.Add(user);
                            int i = entity.SaveChanges();
                            if (i != 0)
                            {
                                Session["Login"]     = 1;
                                Session["UId"]       = user.ID;
                                Session["UserName"]  = username;
                                Session["Password"]  = password;
                                Session["QQ"]        = user.QQ;
                                Session["Tel"]       = user.Tel;
                                Session["Introduce"] = user.Introduce;
                                Session["coockie"]   = 0;

                                //记录表和用户记录表添加记录
                                AddRecord(user, "", "", 0, 0);

                                Response.Write(JsHelper.Messagebox("注册成功!", "Home", "Index"));
                            }
                            else
                            {
                                Response.Write(JsHelper.Messagebox("注册失败!", "Home", "Index"));
                            }
                        }
                    }
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("两次密码不一致,注册失败!", "Home", "Index"));
            }
        }
예제 #25
0
        public void AnswerPro(FormCollection col)
        {
            SetSessionAndCookie();
            string mycode = col["Code"];
            string id     = col["id"];

            Session["Evaluate"] = col["Eva"];

            if ((!string.IsNullOrEmpty(id)) && (Session["Evaluate"] != null))
            {
                short evaluate = Convert.ToInt16(Session["Evaluate"]);


                int     i   = Convert.ToInt16(id);
                Problem pro = entity.Problem.Where(p => p.ID == i).FirstOrDefault();
                if (pro != null)
                {
                    int userid   = Convert.ToInt16(Session["UId"]);
                    int resultid = Judge(mycode, pro.ID, userid);

                    //修改问题表回答人数
                    UserProblem updateup = entity.UserProblem.Where(p => p.ProblemID == pro.ID && p.UserID == userid).FirstOrDefault();
                    if (updateup == null)
                    {
                        pro.Answers++;
                    }
                    pro.Answers = pro.Answers;
                    entity.Entry <Problem>(pro).State = System.Data.EntityState.Modified;
                    int sc = entity.SaveChanges();

                    //修改记录表答题量
                    int arp = AddRecordPro();

                    //修改用户表回答问题数
                    int uupn = UpdateUserProNumber(pro.ID, userid, resultid);

                    //插入用户问题表记录
                    UserProblem UserPro = new UserProblem();
                    UserPro.UserID     = userid;
                    UserPro.ProblemID  = i;
                    UserPro.ResultID   = resultid;
                    UserPro.Runtime    = Convert.ToInt32(AvgRunTime);
                    UserPro.Memory     = pro.MemLimit;
                    UserPro.Language   = "C/C++";
                    UserPro.Code       = mycode;
                    UserPro.Evaluate   = evaluate;
                    UserPro.SubmitDate = DateTime.Now;
                    entity.UserProblem.Add(UserPro);
                    int up = entity.SaveChanges();

                    //修改结果表中某种结果类型问题数
                    Result result = entity.Result.Where(p => p.ID == resultid).FirstOrDefault();
                    result.ProNumber++;
                    entity.Entry <Result>(result).State = System.Data.EntityState.Modified;
                    int res = entity.SaveChanges();

                    //重新统计评价
                    List <UserProblem> UPList = entity.UserProblem.Where(p => p.ProblemID == i).ToList();
                    double             ProEva = 0;
                    foreach (var item in UPList)
                    {
                        ProEva += item.Evaluate;
                    }
                    ProEva /= UPList.Count();
                    if (ProEva < 5)
                    {
                        ProEva += 1;
                    }
                    pro.Evaluate = (short)ProEva;
                    entity.Entry <Problem>(pro).State = System.Data.EntityState.Modified;
                    int eva = entity.SaveChanges();


                    if ((sc != 0) && (arp != 0) && (uupn != 0) && (up != 0) && (res != 0) && (eva != 0))
                    {
                        Response.Write(JsHelper.Messagebox("提交成功!", "Problem?id=" + id));
                    }
                    Response.Write(JsHelper.Messagebox("提交不成功!", "Problem?id=" + id));
                }
                Response.Write(JsHelper.Messagebox("提交不成功!", "Problem?id=" + id));
            }

            Response.Write(JsHelper.Messagebox("提交不成功!", "Problem?id=" + id));
        }
예제 #26
0
        //修改用户信息
        public void UpdateUser(FormCollection col)
        {
            string username      = col["UserName"];
            string password      = col["Password"];
            string passwordagain = col["Passwordagain"];
            string sex           = col["Sex"];
            string age           = col["Age"];
            string qq            = col["QQ"];
            string tel           = col["Tel"];
            string introduce     = col["Introduce"];

            int  UserID = Convert.ToInt16(Session["UId"]);
            User myuser = entity.User.Where(p => p.ID == UserID).First();

            //Response.Write(JsHelper.Messagebox("11"));

            //判断两次新密码否一致
            if (password != "" && passwordagain != "" && password.Equals(passwordagain))
            {
                //Response.Write(JsHelper.Messagebox("22"));

                User existuser = new User();
                existuser = entity.User.Where(p => p.QQ == qq).FirstOrDefault();
                //判断QQ号是否已经绑定
                if (existuser != null)
                {
                    if (existuser.ID != myuser.ID)
                    {
                        Response.Write(JsHelper.Messagebox("修改失败!该QQ号已经绑定了!", "Home", "Index"));
                    }
                }

                existuser = entity.User.Where(p => p.Tel == tel).FirstOrDefault();
                //判断电话号码号是否已经绑定
                if (existuser != null)
                {
                    if (existuser.ID != myuser.ID)
                    {
                        Response.Write(JsHelper.Messagebox("修改失败!该电话号码已经绑定了!", "Home", "Index"));
                    }
                }

                myuser.Password     = password;
                myuser.Sex          = sex;
                myuser.Age          = Convert.ToInt16(age);
                myuser.QQ           = qq;
                myuser.Tel          = tel;
                myuser.Introduce    = introduce;
                myuser.CreationDate = DateTime.Now;

                int i = entity.SaveChanges();
                if (i != 0)
                {
                    Session["Login"]     = 1;
                    Session["UId"]       = myuser.ID;
                    Session["UserName"]  = myuser.Name;
                    Session["Password"]  = myuser.Password;
                    Session["QQ"]        = myuser.QQ;
                    Session["Tel"]       = myuser.Tel;
                    Session["Introduce"] = myuser.Introduce;
                    Session["coockie"]   = 0;
                    Response.Write(JsHelper.Messagebox("修改成功!", "Home", "Index"));
                }
                else
                {
                    Response.Write(JsHelper.Messagebox("修改失败!", "Home", "Index"));
                }
            }
            else
            {
                Response.Write(JsHelper.Messagebox("两次新密码不一致,修改失败!", "Home", "Index"));
            }
        }