Exemple #1
0
        public ActionResult loginValidate()
        {
            string username  = Request["username"];
            string password  = Request["password"];
            string isRemeber = Request["remember"];

            if (username != null)
            {
                bll_mem   = new BLL.member();
                model_mem = new member();
                model_mem = bll_mem.GetMemberByName(username);
                if (password == model_mem.userPwd)
                {
                    if (isRemeber != null)//记住密码
                    {
                        if (isRemeber == "true")
                        {
                            HttpCookie Username = new HttpCookie("username", username);
                            HttpCookie Password = new HttpCookie("password", password);
                            Response.Cookies.Add(Username);
                            Response.Cookies.Add(Password);
                        }
                    }
                    return(RedirectToAction("index", "mainForm"));
                }
            }
            return(null);
        }
Exemple #2
0
        public ActionResult HelloModelTest(Model.member model)
        {
            string name = model.userName;
            string text = model.userPwd;

            return(View());
        }
        //增加会员
        public bool Addmember(Model.member model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" insert into member(");
            strSql.Append(" Member_id,Name,Password,Level)");
            strSql.Append(" values (");
            strSql.Append(" @Member_id,@Name,@Password,@Level)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Member_id", SqlDbType.VarChar, 20),
                new SqlParameter("@Name",      SqlDbType.VarChar, 20),
                new SqlParameter("@Password",  SqlDbType.VarChar, 20),
                new SqlParameter("@Level",     SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.Member_id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.Level;



            int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
        /// <summary>
        /// 演示后台获取界面的值
        /// </summary>
        /// <returns></returns>
        public ActionResult login()
        {
            HttpCookie Username = HttpContext.Request.Cookies["username"];
            HttpCookie Password = HttpContext.Request.Cookies["password"];

            if (Username != null && Password != null)//判断是否处于登录状态
            {
                bll_mem   = new BLL.member();
                model_mem = new member();
                model_mem = bll_mem.GetMemberByName(Username.Value);
                if (Password.Value == model_mem.userPwd)
                {
                    return(RedirectToAction("index", "mainForm"));
                }
            }
            return(View());
        }
        //根据会员号,查询某个会员信息
        public Model.member GetOnemember(string Member_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" select top 1 Member_id,Name,Password,Level");
            strSql.Append(" from member where Member_id=@Member_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Member_id", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = Member_id;

            Model.member model = new Model.member();
            DataTable    dt    = SqlDbHelper.ExecuteDataTable(strSql.ToString(), CommandType.Text, parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["Member_id"] != null && dt.Rows[0]["Member_id"].ToString() != "")
                {
                    model.Member_id = dt.Rows[0]["Member_id"].ToString();
                }
                if (dt.Rows[0]["Name"] != null && dt.Rows[0]["Name"].ToString() != "")
                {
                    model.Name = dt.Rows[0]["Name"].ToString();
                }
                if (dt.Rows[0]["Password"] != null && dt.Rows[0]["Password"].ToString() != "")
                {
                    model.Password = dt.Rows[0]["Password"].ToString();
                }
                if (dt.Rows[0]["Level"] != null && dt.Rows[0]["Level"].ToString() != "")
                {
                    model.Level = dt.Rows[0]["Level"].ToString();
                }


                return(model);
            }
            else
            {
                return(null);
            }
        }
        //更改会员信息(更改密码,更改等级)
        public bool Updatemember_passwd(Model.member model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" update [member] set");
            strSql.Append(" Name=@Name,");
            strSql.Append(" Password=@Password,");
            strSql.Append(" Level=@Level");

            strSql.Append(" where Member_id=@Member_id");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",      SqlDbType.VarChar, 20),
                new SqlParameter("@Password",  SqlDbType.VarChar, 20),
                new SqlParameter("@Level",     SqlDbType.VarChar, 20),

                new SqlParameter("@Member_id", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Password;
            parameters[2].Value = model.Level;

            parameters[3].Value = model.Member_id;

            int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (rows == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 用于向 member EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddTomember(member member)
 {
     base.AddObject("member", member);
 }