Example #1
0
        private string saveUser(HttpContext context)
        {
            string uname    = context.Request.Form["uname"].ToString();
            string pwd      = context.Request.Form["pwd"].ToString();
            string realname = context.Request.Form["realname"].ToString();
            string sex      = context.Request.Form["sex"].ToString();
            string birthday = context.Request.Form["birthday"].ToString();
            string contact  = context.Request.Form["contact"].ToString();
            string email    = context.Request.Form["email"].ToString();

            Model.users top = new Model.users();
            int         id  = new DAL.usersdal().GetMaxId();

            top.id       = id;
            top.uname    = uname;
            top.pwd      = pwd;
            top.realname = realname;
            top.sex      = sex;
            top.birthday = birthday;
            top.contact  = contact;
            top.email    = email;

            bool res = new DAL.usersdal().Add(top);

            if (res == true)
            {
                context.Response.Redirect("index.aspx");
            }
            return("");
        }
Example #2
0
        private string loginUser(HttpContext context)
        {
            string    uname = context.Request.Form["uname"].ToString();
            string    pwd   = context.Request.Form["pwd"].ToString();
            DataTable dt    = new DAL.usersdal().GetList(" uname='" + uname + "' and pwd='" + uname + "' ").Tables[0];

            Model.users user = null;
            if (dt.Rows.Count > 0)
            {
                user = new DAL.usersdal().DataRowToModel(dt.Rows[0]);
                if (HttpContext.Current.Session != null)
                {
                    if (HttpContext.Current.Session["User"] != null)
                    {
                        HttpContext.Current.Session.Remove("User");
                    }
                }
                HttpContext.Current.Session.Add("User", user);
                context.Response.Redirect("index.aspx");
            }
            else
            {
                context.Response.Redirect("login.aspx?log=false");
            }
            return("");
        }