Ejemplo n.º 1
0
 public ActionResult Edit(UserFM userFM)
 {
     //if user valid edit user
     UserService users = new UserService();
     users.UpdateUser(userFM);
     return RedirectToAction("Index");
     //else return edit with errors
 }
Ejemplo n.º 2
0
 public ActionResult Create(UserFM user)
 {
     //if user valid create user
     UserService users = new UserService();
     users.CreateUser(user);
     return RedirectToAction("Index");
     //else return to create with errors
 }
Ejemplo n.º 3
0
 //
 // GET: /User/
 public ActionResult Index()
 {
     if(Session["UserID"] == null)
     {
         return RedirectToAction("../Login/Index");
     }
     UserService userS = new UserService();
     UsersVM usersVM = userS.GetUsers();
     return View(usersVM);
 }
Ejemplo n.º 4
0
 public ActionResult ChangePassword(PasswordFM passwordFM)
 {
     //if user valid edit pass
     UserService users = new UserService();
     if(users.VerifyPassword(passwordFM) && passwordFM.NewPassword == passwordFM.VerifyPassword && passwordFM.NewPassword.Length > 7)
     {
         users.UpdatePassword(passwordFM);
     }
     return RedirectToAction("Index");
     //else return edit with errors
 }
Ejemplo n.º 5
0
        public static AddUsers getInstance()
        {
            instance = new AddUsers();

            if (userService == null)
            {
                userService = new UserService();
            }

            return instance;
        }
Ejemplo n.º 6
0
        public AddUser()
        {
            InitializeComponent();

            button1.BackColor = Color.FromArgb(255, 80, 151, 228);
            button1.ForeColor = Color.White;

            button2.BackColor = Color.FromArgb(255, 80, 151, 228);
            button2.ForeColor = Color.White;

            if (userService == null)
            {
                userService = new UserService();
            }
        }
Ejemplo n.º 7
0
 public static BodyTea createForm()
 {
     if (instance == null || instance.IsDisposed)
     {
         instance = new BodyTea();
     }
     if (userService == null)
     {
         userService = UserService.getInstance();
     }
     if (strWheres == null)
     {
         strWheres = new Dictionary<string, string>();
     }
     return instance;
 }
Ejemplo n.º 8
0
        public static BodyStu createForm()
        {
            if (instance == null || instance.IsDisposed)
            {
                instance = new BodyStu();
                if (userService == null)
                    userService = UserService.getInstance();

                if (classService == null)
                    classService = ClassService.getInstance();

                if (strWheres == null)
                    strWheres = new Dictionary<string, string>();
            }
            return instance;
        }
Ejemplo n.º 9
0
        public ModifyPassword()
        {
            InitializeComponent();

            //this.BackColor = Color.FromArgb(255, 208, 232, 253);

            button1.BackColor = Color.FromArgb(255, 80, 151, 228);
            button1.ForeColor = Color.White;

            button2.BackColor = Color.FromArgb(255, 80, 151, 228);
            button2.ForeColor = Color.White;

            userId = LoginRoler.userId;
            userService = UserService.getInstance();
            if (mainFram == null)
            {
                mainFram = new MainFrame();
            }
        }
Ejemplo n.º 10
0
 public ActionResult Edit(int ID)
 {
     UserService users = new UserService();
     UserFM userFM = users.GetUserFM(ID);
     return View(userFM);
 }
Ejemplo n.º 11
0
 public ActionResult Delete(int ID)
 {
     UserService users = new UserService();
     users.DeleteUser(ID);
     return RedirectToAction("Index");
 }
Ejemplo n.º 12
0
 public ActionResult ChangePassword(int ID)
 {
     UserService users = new UserService();
     return View(users.GetPasswordFM(ID));
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 更新占成
        /// By xzz
        /// 2010-10-8
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="percent"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public static string UpdatePercent(int ID, double percent, int roleId)
        {
            double maxPercent = 0;
            double UpPercent  = 10;
            object ob;

            if (roleId == 5)
            {
                UserService userService = new UserService();
                ob = userService.GetMaxPercentByUserName(ID);
                if (!Convert.IsDBNull(ob))
                {
                    maxPercent = Convert.ToDouble(ob);
                }
            }
            else
            {
                ob = agentService.GetMaxPercentByUserName(ID);
                if (!Convert.IsDBNull(ob))
                {
                    maxPercent = Convert.ToDouble(ob);
                }
            }

            Agent agent = GetAgentByPK(ID);

            if (agent != null)
            {
                if (roleId != 2)
                {
                    Agent upAgent = GetAgentByPK(agent.UpUserID);
                    if (upAgent != null)
                    {
                        UpPercent = upAgent.Percent;
                    }
                }
            }



            if (percent < maxPercent)
            {
                return("不能小于下级最大占成:" + maxPercent.ToString(""));
            }
            else if (percent > UpPercent)
            {
                return("不能大于上级占成:" + UpPercent.ToString(""));
            }
            else
            {
                if (agentService.UpdatePercent(percent, ID))
                {
                    //更新会员占成
                    if (roleId == 5)
                    {
                        agentService.UpdatePercentAll(UpPercent - percent, percent, agent.RoleId, agent.UserName);
                    }
                    else
                    {
                        IList <Agent> nextAgents = agentService.GetAgentByupUsername(agent.UserName);
                        foreach (Agent info in nextAgents)
                        {
                            agentService.UpdatePercentAll(UpPercent - percent, percent - info.Percent, agent.RoleId, info.UserName);
                        }
                    }
                    return("ok");
                }
                else
                {
                    return("更新失败");
                }
            }
        }