示例#1
0
 public string Attend(int ActivityID)
 {
     try
     {
         if (Session["UserName"].ToString() != "")
         {
             int      level      = usermanager.GetUserLevel(Session["UserName"].ToString());
             Users    user       = usermanager.GetUserByName(Session["UserName"].ToString());
             Activity act        = activitymanager.GetActivity(ActivityID);
             bool     UserAttend = attendancemanager.IsAttendActivity(user.UserID, ActivityID);
             if (user != null && !UserAttend && level >= act.LevelRequest)
             {
                 Attendance attendance = new Attendance();
                 attendance.ActivityID     = ActivityID;
                 attendance.UserID         = user.UserID;
                 attendance.AttendanceTime = DateTime.Now;
                 attendancemanager.InsertAttendance(attendance);
                 return("报名成功");
             }
             else if (UserAttend)
             {
                 return("您已报过名啦,去上传作品吧~");
             }
             else
             {
                 return("对不起,您不满足参赛条件!");
             }
         }
         else
         {
             return("请先登录!");
         }
     }
     catch (Exception ex)
     {
         return("抱歉,系统出错!错误信息:" + ex.Message + "请稍后再试..");
     }
 }