Exemplo n.º 1
0
        public ActionResult AgentForUpdate(Dictionary <string, string> queryvalues)
        {
            int       id    = queryvalues.ContainsKey("id") ? Convert.ToInt32(queryvalues["id"]) : 0;
            AgentInfo model = AgentInfoBLL.GetModelByID(new AgentInfo()
            {
                AgentID = id
            });

            if (model == null)
            {
                return(RedirectToAction("Agent"));
            }

            AgentInfo Higher = AgentInfoBLL.GetModelByID(new AgentInfo()
            {
                AgentID = model.HigherLevel.Value
            });

            if (Higher == null)
            {
                ViewBag.AgentLv  = agentLv.公司;
                ViewBag.HigherID = 0;
                ViewBag.Top      = true;
            }
            else
            {
                ViewBag.HigherID = Higher.AgentID;
                ViewBag.AgentLv  = Higher.AgentLv + 1;
                ViewBag.Top      = false;
            }

            ViewData["Higher"] = Higher;


            AgentInfo Lower = AgentInfoBLL.GetModelByIDForLower(new AgentInfo()
            {
                AgentID = model.AgentID
            });

            if (Lower == null)
            {
                ViewBag.Low = true;
            }
            else
            {
                ViewBag.Low = false;
            }

            ViewData["Lower"]   = Lower;
            model.DrawingPasswd = "";


            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AgentForUpdate(Dictionary <string, string> queryvalues, AgentInfo model)
        {
            if (string.IsNullOrWhiteSpace(model.AgentName) || string.IsNullOrWhiteSpace(model.AgentQQ) || string.IsNullOrWhiteSpace(model.AgentEmail) || string.IsNullOrWhiteSpace(model.AgentTel))
            {
                return(Json(new { result = Result.ValueCanNotBeNull }));
            }


            if (!Regex.IsMatch(model.AgentName, @"^[\u0391-\uFFE5a-zA-Z_]\w{3,16}"))
            {
                return(Json(new { result = Result.AccountOnlyConsistOfLettersAndNumbers }));
            }
            //if (!Regex.IsMatch(model.AgentName, @"^[\u0391-\uFFE5a-zA-Z_]\w{3,16}"))
            //{
            //    return new { result = Result.AccountOnlyConsistOfLettersAndNumbers };
            //}

            if (!Regex.IsMatch(model.AgentQQ, @"^\w{5,20}"))
            {
                return(Json(new { result = Result.AccountOnlyConsistOfLettersAndNumbers }));
            }

            if (!Regex.IsMatch(model.AgentTel, @"^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})"))
            {
                return(Json(new { result = Result.PhoneIsWrong }));
            }

            if (!Regex.IsMatch(model.AgentEmail, @"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))"))
            {
                return(Json(new { result = Result.EmailIsWrong }));
            }

            AgentInfo mi = AgentInfoBLL.GetModelByID(model);

            if (!string.IsNullOrWhiteSpace(model.AgentPasswd) && mi.AgentPasswd != Utils.MD5(model.AgentPasswd))
            {
                mi.AgentPasswd = Utils.MD5(model.AgentPasswd);
            }
            if (!string.IsNullOrWhiteSpace(model.DrawingPasswd) && mi.DrawingPasswd != Utils.MD5(model.DrawingPasswd))
            {
                mi.DrawingPasswd = Utils.MD5(model.DrawingPasswd);
            }



            //mi.AgentAccount = model.AgentAccount;
            mi.AgentName = model.AgentName;
            //mi.AgentLv = model.AgentLv;
            mi.AgentQQ    = model.AgentQQ;
            mi.AgentEmail = model.AgentEmail;
            mi.AgentTel   = model.AgentTel;
            //mi.InitialAmount = model.InitialAmount;
            mi.RevenueModel  = model.RevenueModel;
            mi.EarningsRatio = model.EarningsRatio;
            mi.RebateRate    = model.RebateRate;

            //model.AgentState = 0;
            //model.OnlineState = 0;
            //model.AgentPasswd = Utils.MD5(model.AgentPasswd);
            //model.HigherLevel = 0;
            //model.Deposit = 0;

            //model.AmountAvailable = 0;
            //model.HavaAmount = 0;

            //model.Drawing = 0;
            //model.DrawingPasswd = Utils.MD5(model.DrawingPasswd);

            //model.LoginIP = "127.0.0.1";
            //model.LoginTime = DateTime.MinValue;
            //model.LowerLevel = 0;
            //model.Recharge = 0;
            //model.RegisterTime = DateTime.Now;
            //model.JurisdictionID = string.Empty;


            AgentInfo Higher = AgentInfoBLL.GetModelByID(new AgentInfo()
            {
                AgentID = mi.HigherLevel.Value
            });
            AgentInfo Lower = AgentInfoBLL.GetModelByIDForLower(new AgentInfo()
            {
                AgentID = mi.AgentID
            });

            if (Higher != null)
            {
                if (Higher.EarningsRatio < mi.EarningsRatio)
                {
                    return(Json(new { result = Result.BeyondTheScopeOfNumerical }));
                }
                if (Higher.RebateRate < mi.RebateRate)
                {
                    return(Json(new { result = Result.BeyondTheScopeOfNumerical }));
                }
            }


            if (Lower != null)
            {
                if (Lower.EarningsRatio > mi.EarningsRatio)
                {
                    return(Json(new { result = Result.BeyondTheScopeOfNumerical }));
                }
                if (Lower.RebateRate > mi.RebateRate)
                {
                    return(Json(new { result = Result.BeyondTheScopeOfNumerical }));
                }
            }



            int result = AgentInfoBLL.Update(mi);

            if (result > 0)
            {
                return(Json(new { result = 0 }));
            }

            return(Json(new { result = 4 }));
        }