Example #1
0
    protected void btn_Tj_Click(object sender, EventArgs e)
    {
        openid = Session["openid"].ToString();
        DBCLASSFORWEIXIN.DAL.LocalWeixinUser   ld    = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();
        DBCLASSFORWEIXIN.Model.LocalWeixinUser wxmdl = ld.GetModel(openid);

        LVWEIBA.BLL.MemberList   mbll = new LVWEIBA.BLL.MemberList();
        LVWEIBA.Model.MemberList mmm  = new LVWEIBA.Model.MemberList();

        System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection(Request.Form);
        string txt_user = nc.GetValues("txt_user")[0].ToString();
        string txt_tel  = nc.GetValues("txt_tel")[0].ToString();
        string txt_xm   = nc.GetValues("txt_xm")[0].ToString();
        string txt_card = nc.GetValues("txt_card")[0].ToString();
        string txt_mail = nc.GetValues("txt_mail")[0].ToString();
        string txt_pwd  = nc.GetValues("txt_pwd")[0].ToString();
        string txt_pwd2 = nc.GetValues("txt_pwd2")[0].ToString();

        bool isexists = false;

        if (mbll.Exists(openid))
        {
            mmm      = mbll.GetModel(openid);
            isexists = true;
        }
        wxmdl.nickname = txt_user;
        wxmdl.Tel      = txt_tel;
        mmm.MemberName = txt_xm;
        wxmdl.sex      = int.Parse(ddl_sex.SelectedValue);
        mmm.Card       = txt_card;
        mmm.Mail       = txt_mail;
        mmm.UserPwd    = txt_pwd;
        mmm.UserPwd    = txt_pwd2;
        mmm.MemberId   = openid;
        bool isok = false;

        try
        {
            isok = ld.Update(wxmdl);
            if (isexists)
            {
                isok = mbll.Update(mmm);
            }
            else
            {
                isok = mbll.Add(mmm);
            }
            Response.Write(String.Format("<script>alert('个人信息修改成功');window.location='myindex.aspx';</script>"));
        }
        catch (Exception ex)
        {
            log4netHelper.WriteExceptionLog(typeof(aboutme), "aboutme异常", ex);
        }
    }
Example #2
0
 /// <summary>
 /// 对微信登陆操作进行验证
 /// </summary>
 /// <param name="request"></param>
 /// <param name="page"></param>
 /// <returns></returns>
 public static bool userAuthorize(HttpRequest request, Page page)
 {
     try
     {
         string code = request.QueryString["code"];
         if (code == null || code == "")
         {
             return(false);
         }
         string openid = new WEIxinUserApi().GetUserOpenid(code);
         DBCLASSFORWEIXIN.DAL.LocalWeixinUser ld = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();
         if (ld.Exists(openid))
         {
             //DBCLASSFORWEIXIN.Model.LocalWeixinUser localUser = new WeixinApiClass.WEIxinUserApi().GetSingleUserInf(openid);
             DBCLASSFORWEIXIN.Model.LocalWeixinUser user = ld.GetModel(openid);
             UserAuthorizationModel userInfo             = new UserAuthorizationModel();
             userInfo.mobile = user.Tel;
             userInfo.name   = user.nickname;
             userInfo.openId = user.openid;
             BaseClass.Common.Common.UserLoginSetCookie(userInfo.name, page, DateTime.Now.AddDays(30), userInfo);
             return(true);
         }
         else
         {
             HttpContext.Current.Session["weixincode"] = code;
             page.Response.Redirect("~/index/bindCode.aspx");
             return(false);
         }
     }
     catch (Exception ex)
     {
         // BaseClass.Common.LoggerUtil.printLog("userAuthorize error:"+ex.Message);
         log4netHelper.WriteExceptionLog(typeof(UserAuthorization), "userAuthorize", ex);
         return(false);
     }
 }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        //    try
        //    {
        //        UserAuthorizationModel userInfo = UserAuthorization.userLogin(this.Page);
        //        if (userInfo != null)
        //        {
        //            Response.Redirect("Default.aspx");
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        ////不做处理
        //    }
        //}
        if (IsPostBack)
        {
            string tel  = Request.Form["tel"];
            string pass = Request.Form["pass"];
            string code = Request.Form["code"];

            object codeCache = HttpContext.Current.Cache.Get("code" + tel);
            if (codeCache == null)
            {
                Response.Write("<script>alert('验证码失效');window.location='Login.aspx';</script>");
                return;
            }

            if (code != codeCache.ToString())
            {
                Response.Write("<script>alert('验证码不正确');window.location='Login.aspx';</script>");
                return;
            }

            var     bll     = new LVWEIBA.BLL.MemberInfo();
            var     blllist = new LVWEIBA.BLL.MemberList();
            DataSet ds      = bll.GetList(" tel='" + tel + "'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                string openid = ds.Tables[0].Rows[0]["openid"].ToString();

                UserAuthorizationModel userInfoNow = new UserAuthorizationModel();
                userInfoNow.mobile = tel;
                userInfoNow.openId = openid;
                userInfoNow.name   = tel;
                BaseClass.Common.Common.UserLoginSetCookie(userInfoNow.name, this.Page, DateTime.Now.AddDays(30), userInfoNow);
                log4netHelper.WriteDebugLog(typeof(Login), "login", "用户登录成功:" + userInfoNow.mobile + " " + openid);
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                string openid = BaseClass.Common.Common.getSuijiString(30);

                DBCLASSFORWEIXIN.Model.LocalWeixinUser SingleUserInf = new DBCLASSFORWEIXIN.Model.LocalWeixinUser();
                DBCLASSFORWEIXIN.DAL.LocalWeixinUser   ld            = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();

                SingleUserInf.country        = "";
                SingleUserInf.province       = "";
                SingleUserInf.city           = "";
                SingleUserInf.remark         = "";
                SingleUserInf.openid         = openid;
                SingleUserInf.regtime        = DateTime.Now;
                SingleUserInf.Tel            = tel;
                SingleUserInf.Jifen          = 0;
                SingleUserInf.money          = 0;
                SingleUserInf.vips           = 0;
                SingleUserInf.pid            = 0;
                SingleUserInf.refresh_token  = "";
                SingleUserInf.nickname       = "";
                SingleUserInf.headimgurl     = "";
                SingleUserInf.subscribe      = 1;
                SingleUserInf.subscribe_time = "";
                SingleUserInf.unionid        = "";
                SingleUserInf.groupid        = 0;
                SingleUserInf.sex            = 1;

                LVWEIBA.BLL.MemberList   bllMember = new LVWEIBA.BLL.MemberList();
                LVWEIBA.Model.MemberList model     = new LVWEIBA.Model.MemberList();


                model.MemberId = openid;
                model.UserPwd  = pass;
                model.Tel      = tel;
                if (bllMember.Add(model) && ld.Add(SingleUserInf) > 0)
                {
                    UserAuthorizationModel userInfoNow = new UserAuthorizationModel();
                    userInfoNow.mobile = tel;
                    userInfoNow.openId = openid;
                    userInfoNow.name   = tel;
                    BaseClass.Common.Common.UserLoginSetCookie(userInfoNow.name, this.Page, DateTime.Now.AddDays(30), userInfoNow);
                    log4netHelper.WriteDebugLog(typeof(Login), "login", "用户注册成功:" + userInfoNow.mobile + " " + openid);
                    Response.Redirect("~/Default.aspx");
                }
            }
        }
    }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     WeixinApiClass.WEIxinUserApi wwd = new WeixinApiClass.WEIxinUserApi();
     // wwd.GetTop10000UserList();
     DBCLASSFORWEIXIN.Model.LocalWeixinUser GetSingleUserInf = wwd.GetSingleUserInf("oZMY8tw4qxXjO9VQR1EAY_1B845k");
 }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            string tel = Request.Form["tel"];
            string code = Request.Form["code"];
            string pass = Request.Form["pass"];

            object codeCache = HttpContext.Current.Cache.Get("code" + tel);
            if (codeCache == null)
            {
                Jscript.NorefLocation(this.Page, "验证码失效请重新获取!手机号为:" + tel + "验证码为:" + code, "registration.aspx");
            }
            else
            {
                if (code != codeCache.ToString())
                {
                    Jscript.NorefLocation(this.Page, "验证码不正确!", "registration.aspx");
                }
                else
                {
                    try
                    {

                        var bll = new LVWEIBA.BLL.MemberInfo();
                        DataSet ds = bll.GetList(" tel='" + tel + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            Jscript.NorefLocation(this.Page, "该手机号已注册!", "registration.aspx");
                        }
                        else
                        {
                            openid = BaseClass.Common.Common.getSuijiString(30);

                            DBCLASSFORWEIXIN.Model.LocalWeixinUser SingleUserInf = new DBCLASSFORWEIXIN.Model.LocalWeixinUser();
                            DBCLASSFORWEIXIN.DAL.LocalWeixinUser ld = new DBCLASSFORWEIXIN.DAL.LocalWeixinUser();

                            SingleUserInf.country = "";
                            SingleUserInf.province = "";
                            SingleUserInf.city = "";
                            SingleUserInf.remark = "";
                            SingleUserInf.openid = openid;
                            SingleUserInf.regtime = DateTime.Now;
                            SingleUserInf.Tel = tel;
                            SingleUserInf.Jifen = 0;
                            SingleUserInf.money = 0;
                            SingleUserInf.vips = 0;
                            SingleUserInf.pid = 0;
                            SingleUserInf.refresh_token = "";
                            SingleUserInf.nickname = "";
                            SingleUserInf.headimgurl = "";
                            SingleUserInf.subscribe = 1;
                            SingleUserInf.subscribe_time = "";
                            SingleUserInf.unionid = "";
                            SingleUserInf.groupid = 0;
                            SingleUserInf.sex = 1;

                            LVWEIBA.BLL.MemberList bllMember = new LVWEIBA.BLL.MemberList();
                            LVWEIBA.Model.MemberList model = new LVWEIBA.Model.MemberList();


                            model.MemberId = openid;
                            model.UserPwd = pass;
                            model.Tel = tel;
                            if (bllMember.Add(model) && ld.Add(SingleUserInf) > 0)
                            {
                                Session["openid"] = openid;
                                Response.Redirect("Default.aspx");
                            }
                        }

                    }
                    catch (Exception EX)
                    {

                        throw;
                    }
                }
            }
        }
    }