Exemplo n.º 1
0
        public ActionResult ChildUser(FormCollection collection)
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;

            int userid = Int32.Parse(CurrentUserInfo.UserID);
            MemberUserInfo mui=new MemberUserInfoDao().Find(userid);
            int memberid = mui.MemberID;
            CRMService crm = new CRMService();
            int memberlevel=(int)crm.GetUserMemberLevel(userid);
            if (CurrentUserInfo != null)
            {
                if (collection.Count == 0)
                {
                    ViewData["Name"] = CurrentUserInfo.UserName;
                    //获得初始的功能列表

                    Hashtable htparm = new Hashtable();
                    htparm["MemberLevel"] = memberlevel;
                    //IList<ProductFunction> versionFunctionList = crm.GetFunctions(memberid, ProductID,htparm);
                    //string functionlist = string.Empty;
                    Dictionary<string, string> functiondict = new Dictionary<string, string>();
                    int functioncount = 1;

                    string html = string.Empty;
                    IList<ProductFunction> versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm,1);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind1");
                        functioncount++;
                    }
                    functiondict.Add("kind1", html);

                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 12);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind12");
                        functioncount++;
                    }
                    functiondict.Add("kind12", html);

                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 2);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind2");
                        functioncount++;
                    }
                    functiondict.Add("kind2", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 3);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind3");
                        functioncount++;
                    }
                    functiondict.Add("kind3", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 4);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind4");
                        functioncount++;
                    }
                    functiondict.Add("kind4", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 5);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind5");
                        functioncount++;
                    }
                    functiondict.Add("kind5", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 6);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind6");
                        functioncount++;
                    }
                    functiondict.Add("kind6", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 7);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind7");
                        functioncount++;
                    }
                    functiondict.Add("kind7", html);
                    html = string.Empty;
                    versionFunctionList = crm.GetEachKindFunctions(memberid, ProductID, htparm, 8);
                    foreach (ProductFunction func in versionFunctionList)
                    {

                        html += GetDict(functioncount, func, "kind8");
                        functioncount++;
                    }
                    functiondict.Add("kind8", html);
                    html = string.Empty;
                    ViewData["Function"] = functiondict;
                    ViewData["Max"] = "";
                }
                else
                {

                    bool IsAdmin = new MemberUserInfoDao().IsAdmin(userid);
                    if (!IsAdmin)
                    {
                        ViewData["Admin"] = IsAdmin;
                        ViewData["Function"] = "";
                        ViewData["Max"] = "";
                        return View();
                    }
                    else
                    {
                        //检查是否超过规定的子账户数
                        Hashtable htp=new Hashtable();
                        htp["MemberID"] = memberid;
                        int maxchildcount = 0;
                        int childusercount = CRMMapper.Get().QueryForObject<int>("MemberUserInfo.ChildUserCount", htp);
                        if (CRMMapper.Get().QueryForObject<int>("SpecialChild.getcount", memberid) > 0)
                        {
                            maxchildcount = CRMMapper.Get().QueryForObject<int>("SpecialChild.getchildcount", memberid);
                        }
                        else
                        {
                        maxchildcount=GetMaxCount(memberlevel);
                        }
                        if (childusercount >= maxchildcount)
                        {
                            ViewData["Max"] = "对不起,您的子账户数超过了您的会员等级规定的子账户数!";
                        }
                        else
                        {
                            UserModel newuser = new UserModel();
                            newuser.Username = collection["UserName"];
                            newuser.Password = collection["Password"];
                            newuser.Email = "";

                            /*if (!MembershipService.CheckValidateCode(collection["ValidateCode"]))
                            {
                                ViewData["Name"] = CurrentUserInfo.UserName;
                                ViewData["UserInfo"] = collection["UserName"];
                                ViewData["Validatecode"] = "False";
                                return View();
                            }*/
                            if (!MembershipService.UserIsExists(newuser.Username))
                            {
                                MembershipService.CreateNewUser(newuser);
                                MemberUserInfo newMember = new MemberUserInfo();
                                int tempuserid = MembershipService.GetUserID(collection["UserName"]);
                                newMember.UserID = tempuserid;
                                newMember.MemberID = memberid;
                                newMember.Name = collection["Name"];
                                newMember.IsMemberAdmin = 0;
                                newMember.Mobile = collection["Mobile"];
                                newMember.Status = 1;
                                new MemberUserInfoDao().Insert(newMember);

                                //插入子账户功能表
                                ChildUserFunction newchildfunc = new ChildUserFunction();
                                newchildfunc.UserID = tempuserid;
                                newchildfunc.ProductID = ProductID;
                                newchildfunc.FunctionIDList = GetFunctionstring(collection);
                                new ChildUserFunctionDao().Insert(newchildfunc);
                                ViewData["Function"] = GetFunctionstringForView(userid, newchildfunc.FunctionIDList, memberid, ProductID);
                                ViewData["PostExist"] = "False";
                                ViewData["ChildUser"] = "True";
                                ViewData["Max"] = "";
                            }
                            else
                            {
                                ViewData["PostExist"] = "True";
                                ViewData["Max"] = "";
                            }

                        }

                            ViewData["IsExists"] = false;
                            ViewData["Admin"] = IsAdmin;
                            ViewData["Name"] = CurrentUserInfo.UserName;
                            ViewData["UserInfo"] = collection["UserName"];
                            ViewData["RealName"] = collection["Name"];
                            ViewData["Mobile"] = collection["Mobile"];
                    }
                }

            }
            ViewData["titlename"] = "子账户新增";
            return View();
        }
Exemplo n.º 2
0
 public JsonResult Modify(string UserName, string functionlist)
 {
     int userid = MembershipService.GetUserID(UserName);
     functionlist = functionlist.Replace("on,", "");
     try
     {
         Hashtable htparm = new Hashtable();
         htparm["UserID"] = userid;
         htparm["ProductID"] = productid;
         htparm["functionlist"] = functionlist;
         ChildUserFunction user = CRMMapper.Get().QueryForObject<ChildUserFunction>("ChildUserFunction.MyFind", userid);
         if (user != null)
             CRMMapper.Get().QueryForObject<string>("ChildUserFunction.UpdateFunctionlist", htparm);
         else
         {
             user = new ChildUserFunction();
             user.UserID = userid;
             user.ProductID = productid;
             user.FunctionIDList = functionlist;
             CRMMapper.Get().QueryForObject<string>("ChildUserFunction.Insert", user);
         }
         return Json("True");
     }
     catch (Exception ex)
     {
         //string temp = ex.Message;
         return Json("false");
     }
 }