예제 #1
0
 public JsonResult UserInsert(string company = "",  string pwd = "", string name = "", string email = "", string grade = "", string tell = "")
 {
     bool result = true;
     try
     {
         UserGrade enumgrade = new UserGrade();
         if(grade == "0")
         {
             enumgrade = UserGrade.Civil;
         }
         if (grade == "1")
         {
             enumgrade = UserGrade.Night;
         }
         if (grade == "2")
         {
             enumgrade = UserGrade.King;
         }
         CompanyModel companyModel = new Dac_Company().CompanyInfoDetail(ObjectId.Parse(ConfigurationManager.AppSettings["COM"]));
         LoginModel model = new LoginModel();
         model.name = name;
         model.company = companyModel;
         model.password = pwd;
         model.email = email;
         model.tell = tell;
         model.grade = enumgrade;
         new Dac_User().UserSave(model);
     }
     catch (Exception ex)
     {
         result = false;
     }
     return Json(result);
 }
        public ActionResult AddGrade(UserGrade model)
        {
            if (ModelState.IsValid)
            {
                db.UserGrades.Add(model);
                db.SaveChanges();

                var courseId = db.GradeTypes.Find(model.GradeTypeId).CourseId;
                return(RedirectToAction("Grades", "Course", new { courseId = courseId }));
            }
            return(View(model));
        }
        public ActionResult ChangeGrade(UserGrade model)
        {
            if (ModelState.IsValid)
            {
                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();

                var courseId = db.GradeTypes.Find(model.GradeTypeId).CourseId;
                return(RedirectToAction("Grades", "Course", new { courseId = courseId }));
            }
            return(View(model));
        }
예제 #4
0
        public static UserGrade PopulateUserGradeFromIDataReader(IDataReader dr)
        {
            UserGrade userGrade = new UserGrade();

            userGrade.GradeID     = DataRecordHelper.GetInt32(dr, "GradeID");
            userGrade.UserID      = DataRecordHelper.GetInt32(dr, "UserID");
            userGrade.GradeLevel  = (UserLevel)DataRecordHelper.GetInt32(dr, "GradeLevel");
            userGrade.GradeLimit  = DataRecordHelper.GetString(dr, "GradeLimit");
            userGrade.GradeName   = DataRecordHelper.GetString(dr, "GradeName");
            userGrade.GradeDesc   = DataRecordHelper.GetString(dr, "GradeDesc");
            userGrade.GradeMemo   = DataRecordHelper.GetString(dr, "GradeMemo");
            userGrade.GradeStatus = (ComponentStatus)DataRecordHelper.GetInt32(dr, "GradeStatus");
            userGrade.CreateTime  = DataRecordHelper.GetDateTime(dr, "CreateTime");
            userGrade.CreateUser  = DataRecordHelper.GetInt32(dr, "CreateUser");
            userGrade.UpdateTime  = DataRecordHelper.GetDateTime(dr, "UpdateTime");
            userGrade.UpdateUser  = DataRecordHelper.GetInt32(dr, "UpdateUser");
            return(userGrade);
        }
        public JsonResult AddOrUpdateGradeJson(int gradeTypeId, string userId, float grade)
        {
            if (userId.IsNullOrWhiteSpace())
            {
                return(Json(new { Success = false, Message = "BadRequest" }, JsonRequestBehavior.AllowGet));
            }

            var gt = db.GradeTypes.Include("Course").FirstOrDefault(i => i.Id == gradeTypeId);

            if (gt == null)
            {
                return(Json(new { Success = false, Message = "HttpNotFound" }, JsonRequestBehavior.AllowGet));
            }

            if (!isCourseCreator(gt.Course))
            {
                return(Json(new { Success = false, Message = "Unauthorized" }, JsonRequestBehavior.AllowGet));
            }

            var model = db.UserGrades.Where(u => u.UserId == userId).FirstOrDefault(t => t.GradeTypeId == gradeTypeId);

            if (model == null)
            {
                model = new UserGrade {
                    UserId      = userId,
                    GradeTypeId = gradeTypeId,
                    Grade       = grade
                };

                model = db.UserGrades.Add(model);
                db.SaveChanges();
            }
            else
            {
                model.Grade = grade;

                db.Entry(model).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new { Success = true, Message = "OK", ID = model.Id }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddGrade(int?gradeTypeId, string userId)
        {
            if (gradeTypeId == null || userId.IsNullOrWhiteSpace())
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var gradeType = db.GradeTypes.Where(i => i.Id == gradeTypeId).Include("Course").SingleOrDefault();

            if (gradeType != null && !isCourseCreator(gradeType.Course))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            var model = new UserGrade {
                UserId      = userId,
                GradeTypeId = (int)gradeTypeId
            };

            return(View(model));
        }
예제 #7
0
        // Token: 0x060002F5 RID: 757 RVA: 0x0000B958 File Offset: 0x00009B58
        public static void UpdateUserExp(int uid, int exp)
        {
            UserInfo userInfo = UserBll.GetUserInfo(uid);

            userInfo.exp += exp;
            int num = FPUtils.StrToInt(DbHelper.ExecuteMax <UserGrade>("expupper"));

            if (userInfo.exp > num)
            {
                userInfo.exp = num;
            }
            UserGrade userGradeByExpHigher = UserBll.GetUserGradeByExpHigher(userInfo.exp);
            string    sqlstring            = string.Format("UPDATE [{0}WMS_UserInfo] SET [gradeid]={1},[exp]=[exp]+{2} WHERE [id]={3}", new object[]
            {
                DbConfigs.Prefix,
                userGradeByExpHigher.id,
                exp,
                uid
            });

            DbHelper.ExecuteSql(sqlstring);
        }
            public bool Match(UserGrade userGrade, int userId, int mediaId = 0, string regionId = "")
            {
                var grade = (byte)userGrade;

                if (UserGrade > 0 && UserGrade < grade)
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(UserScope) && !Users.Contains(userId))
                {
                    return(false);
                }

                if (mediaId > 0 && !string.IsNullOrEmpty(MediaScope) && !Medias.Contains(mediaId))
                {
                    return(false);
                }
                if (!string.IsNullOrEmpty(regionId) && !string.IsNullOrEmpty(RegionScope) && !Regions.Contains(regionId))
                {
                    return(false);
                }
                return(true);
            }
예제 #9
0
 public abstract UserGrade CreateUpdateUserGrade(UserGrade userGrade, DataProviderAction action, out DataActionStatus status);
예제 #10
0
        // Token: 0x060000B5 RID: 181 RVA: 0x0000DF80 File Offset: 0x0000C180
        protected override void View()
        {
            if (this.id > 0)
            {
                this.fulluserinfo = DbHelper.ExecuteModel <FullUserInfo>(this.id);
            }
            this.bday = FPUtils.SplitString(this.fulluserinfo.bday, ",", 3);
            if (this.ispost)
            {
                this.fulluserinfo.isreal   = 0;
                this.fulluserinfo.isemail  = 0;
                this.fulluserinfo.ismobile = 0;
                string username = this.fulluserinfo.username;
                this.fulluserinfo = FPRequest.GetModel <FullUserInfo>(this.fulluserinfo);
                if (this.fulluserinfo.roleid == 0)
                {
                    this.ShowErr("请选择用户角色。");
                    return;
                }
                if (this.fulluserinfo.username == "")
                {
                    this.ShowErr("请输入用户名。");
                    return;
                }
                string @string = FPRequest.GetString("password1");
                if (this.fulluserinfo.isidcard != 0)
                {
                    this.fulluserinfo.isidcard = ((this.fulluserinfo.isreal == 1) ? 1 : -1);
                }
                if (FPRequest.GetInt("isgrade") == 1)
                {
                    UserGrade userGradeByExpHigher = UserBll.GetUserGradeByExpHigher(this.fulluserinfo.exp);
                    this.fulluserinfo.gradeid = userGradeByExpHigher.id;
                }
                if (this.fulluserinfo.id > 0)
                {
                    if (this.fulluserinfo.username != username)
                    {
                        if (UserBll.CheckUserName(this.fulluserinfo.username))
                        {
                            this.ShowErr("该用户名已经存在,请使用别的用户名。");
                            return;
                        }
                    }
                    if (@string.Trim() != "")
                    {
                        this.fulluserinfo.password = FPUtils.MD5(@string);
                    }
                    DbHelper.ExecuteUpdate <FullUserInfo>(this.fulluserinfo);
                }
                else
                {
                    if (@string.Trim() == "")
                    {
                        this.ShowErr("登录密码不能为空!");
                        return;
                    }
                    if (UserBll.CheckUserName(this.fulluserinfo.username))
                    {
                        this.ShowErr("该用户名已经存在,请使用别的用户名。");
                        return;
                    }
                    this.fulluserinfo.password = FPUtils.MD5(@string);
                    this.fulluserinfo.regip    = FPRequest.GetIP();
                    this.fulluserinfo.lastip   = FPRequest.GetIP();
                    this.fulluserinfo.id       = DbHelper.ExecuteInsert <FullUserInfo>(this.fulluserinfo);
                }
                base.Response.Redirect("usermanage.aspx");
            }
            SqlParam sqlParam = DbHelper.MakeAndWhere("parentid", 0);

            this.deparlist = DbHelper.ExecuteList <Department>(OrderBy.ASC, new SqlParam[]
            {
                sqlParam
            });
            sqlParam      = DbHelper.MakeAndWhere("id", WhereType.NotEqual, 2);
            this.rolelist = DbHelper.ExecuteList <RoleInfo>(OrderBy.ASC, new SqlParam[]
            {
                sqlParam
            });
            this.usergradelist = DbHelper.ExecuteList <UserGrade>(OrderBy.ASC);
            this.typelist      = TypeBll.GetTypeListByMarkup("usertype");
            base.SaveRightURL();
        }
예제 #11
0
 //获取用户等级对应的提成金额
 public void SetUserGradeRate(string ggid, decimal money, string type, string ordertime, string ordercode, string SettlementTime)
 {
     try
     {
         //当前用户信息
         var       tempuser = db.tb_userinfos.FirstOrDefault(s => s.Adzoneid == ggid);
         UserGrade sdd      = tempuser.UserGrade;
         //运营商
         if (sdd == UserGrade.Operator)
         {
             decimal returnmoney = decimal.Round(decimal.Parse((money * ((decimal)50 / 100)).ToString()), 2);
             int     rows        = SaveSettlement(tempuser.ID, ggid, returnmoney, ordercode, ordertime, SettlementTime, 50, money, type);
             if (tempuser.ParentID > 0 && rows > 0)
             {
                 //用户上级合伙人用户
                 var Partneruser = db.tb_userinfos.FirstOrDefault(s => s.ID == tempuser.ParentID);
                 if (Partneruser != null)
                 {
                     decimal tempmoney = decimal.Round(decimal.Parse((money * ((decimal)30 / 100)).ToString()), 2);
                     SaveSettlement(Partneruser.ID, ggid, tempmoney, ordercode, ordertime, SettlementTime, 30, money, type);
                 }
             }
         }
         //合伙人
         else if (sdd == UserGrade.Partner)
         {
             decimal returnmoney = decimal.Round(decimal.Parse((money * ((decimal)50 / 100)).ToString()), 2);
             int     rows        = SaveSettlement(tempuser.ID, ggid, returnmoney, ordercode, ordertime, SettlementTime, 50, money, type);
         }
         //初级会员
         else if (sdd == UserGrade.Primary)
         {
             decimal returnmoney = decimal.Round(decimal.Parse((money * ((decimal)10 / 100)).ToString()), 2);
             int     rows        = SaveSettlement(tempuser.ID, ggid, returnmoney, ordercode, ordertime, SettlementTime, 10, money, type);
             if (tempuser.ParentID > 0 && rows > 0)
             {
                 //用户上级运营商用户
                 var Operatoruser = db.tb_userinfos.FirstOrDefault(s => s.ID == tempuser.ParentID);
                 if (Operatoruser != null)
                 {
                     decimal tempmoney = decimal.Round(decimal.Parse((money * ((decimal)30 / 100)).ToString()), 2);
                     int     rows2     = SaveSettlement(Operatoruser.ID, ggid, tempmoney, ordercode, ordertime, SettlementTime, 30, money, type);
                     if (Operatoruser.ParentID > 0 && rows2 > 0)
                     {
                         //用户上级合伙人用户
                         var Partneruser = db.tb_userinfos.FirstOrDefault(s => s.ID == tempuser.ParentID);
                         if (Partneruser != null)
                         {
                             decimal tempmoney1 = decimal.Round(decimal.Parse((money * ((decimal)30 / 100)).ToString()), 2);
                             SaveSettlement(Partneruser.ID, ggid, tempmoney1, ordercode, ordertime, SettlementTime, 30, money, type);
                         }
                     }
                 }
             }
         }
         //高级会员
         else if (sdd == UserGrade.Senior)
         {
             decimal returnmoney = decimal.Round(decimal.Parse((money * ((decimal)50 / 100)).ToString()), 2);
             int     rows        = SaveSettlement(tempuser.ID, ggid, returnmoney, ordercode, ordertime, SettlementTime, 50, money, type);
             if (tempuser.ParentID > 0 && rows > 0)
             {
                 //用户上级运营商用户
                 var Operatoruser = db.tb_userinfos.FirstOrDefault(s => s.ID == tempuser.ParentID);
                 if (Operatoruser != null)
                 {
                     decimal tempmoney = decimal.Round(decimal.Parse((money * ((decimal)20 / 100)).ToString()), 2);
                     int     rows2     = SaveSettlement(Operatoruser.ID, ggid, tempmoney, ordercode, ordertime, SettlementTime, 20, money, type);
                     if (Operatoruser.ParentID > 0 && rows2 > 0)
                     {
                         //用户上级合伙人用户
                         var Partneruser = db.tb_userinfos.FirstOrDefault(s => s.ID == tempuser.ParentID);
                         if (Partneruser != null)
                         {
                             decimal tempmoney1 = decimal.Round(decimal.Parse((money * ((decimal)20 / 100)).ToString()), 2);
                             SaveSettlement(Partneruser.ID, ggid, tempmoney1, ordercode, ordertime, SettlementTime, 20, money, type);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
        public ActionResult Register(RegisterModel model)
        {
            var db = new Context();
            if (ModelState.IsValid)
            {
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { model.Email, model.First, model.Last });
                    WebSecurity.Login(model.UserName, model.Password);

                    var school = db.Schools.FirstOrDefault(t => t.Id == model.School);
                    var user = db.UserProfiles.FirstOrDefault(t => t.UserName == model.UserName);
                    db.UserProfileSchools.Add(new UserProfileSchool { School = school, UserProfile = user });

                    foreach (var gradeId in model.GradeIds)
                    {
                        var userGrade = new UserGrade { UserProfile = user, Grade_Id = gradeId };
                        db.UserGrades.Add(userGrade);
                    }

                    foreach (var subjectId in model.SubjectIds)
                    {
                        var userSubject = new UserSubject { UserProfile = user, Subject_Id = subjectId };
                        db.UserSubjects.Add(userSubject);
                    }
                    db.SaveChanges();
                    return RedirectToAction("TakeATour", "Home", new { Area = "" });
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }
            return View(GenerateRegisterForm(model));
        }