Ejemplo n.º 1
0
 private void AddMemberInvite(M.XMember mobj)
 {
     for (int i = 0; i < 2; i++)
     {
         M.XMemberInvite miobj = new M.XMemberInvite()
         {
             MIID       = CreateID() + i, //防止重复
             MID        = mobj.MID,
             CID        = "",
             CreateTime = DateTime.Now,
             Grade1     = 1,
             Grade2     = 2,
             IsAdd      = 0,
             IsDeleted  = 0,
             IsReply    = 0,
             SortIndex  = 100,
             UpdateTime = DateTime.Now
         };
         bllXMemberInvite.Add(miobj);
     }
 }
Ejemplo n.º 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            //注册步骤:
            //1、验证空值
            //2、验证昵称是否存在,因为微信昵称是作为登录名,唯一
            //3、微信号和手机号码验证,唯一
            //4、会员分支管理,2条分支,如果满了,往一下级查找空缺的位置
            //4.1  查找自己是否还有空缺
            //4.2  如果已满,往下查找空缺
            //5、如果没有了空缺位置怎么办?
            //6、会员注册完成之后,添加两个分支空缺
            string msg = "";

            #region //1、验证空值
            if (txtNickName.Text.Length == 0)
            {
                msg = "微信昵称不能为空!";
            }
            else if (bllXMember.GetCountBySearch(" and LoginName='" + txtNickName.Text + "'") > 0)
            {
                msg = "该用户名已被注册";
            }
            else if (txtWxCode.Text.Length == 0)
            {
                msg = "微信号不能为空!";
            }
            else if (txtPhone.Text.Length == 0)
            {
                msg = "手机号码不能为空!";
            }
            else if (TextBox1.Text.Length == 0)
            {
                msg = "密保答案不能为空!";
            }
            else if (txtPassword.Text.Length < 6)
            {
                msg = "密码不得小于6位";
            }
            else if (txtConfirmPassword.Text != txtPassword.Text)
            {
                msg = "两次密码输入不一致";
            }
            #endregion
            #region
            //2、验证昵称是否存在,因为微信昵称是作为登录名,唯一
            //3、微信号和手机号码验证,唯一
            else if (bllXMember.CheckReg(txtNickName.Text, txtWxCode.Text, txtPhone.Text) > 0)
            {
                msg = "微信昵称、微信号、手机号码已注册!";
            }
            #endregion
            #region //4、会员分支管理,2条分支,如果满了,往一下级查找空缺的位置
            else
            {
                string    tmpCode = Request.QueryString["ic"];
                M.XMember mobj    = bllXMember.GetOneByInviteCode(tmpCode);
                if (mobj != null)
                {
                    #region //唯一 邀请码
                    string tmpIC      = "";
                    int    tmpICCount = 0;
                    do
                    {
                        tmpIC      = XCommon.CreateRandom.Code(6).ToLower(); //6位小写字母和数字
                        tmpICCount = bllXMember.GetCountBySearch(string.Format(" and InviteCode='{0}'", tmpIC));
                    }while (tmpICCount > 0);
                    #endregion
                    #region  //4.1  查找自己是否还有空缺
                    M.XMemberInvite miObj = bllXMemberInvite.GetTopOneByMID(mobj.MID);
                    if (miObj != null)
                    {
                        #region //创建会员
                        M.XMember newOjb = new M.XMember()
                        {
                            MID         = CreateID(),
                            CreateTime  = DateTime.Now,
                            UpdateTime  = DateTime.Now,
                            Answer      = TextBox1.Text,
                            IsDeleted   = 0,
                            IsDisable   = 0,
                            LoginPWD    = XCommon.Uitl.MD5(txtPassword.Text),
                            ManagePWD   = XCommon.Uitl.MD5("888888"),
                            CurrentCode = tmpCode,
                            Grade       = 1,
                            InviteCode  = tmpIC,
                            LoginIP     = "",
                            LoginName   = txtNickName.Text,
                            LoginSign   = "",
                            LoginTime   = DateTime.Now,
                            NickName    = txtNickName.Text,
                            PCode       = mobj.InviteCode,
                            PCodeStr    = mobj.PCodeStr + mobj.InviteCode + "|", //
                            Phone       = txtPhone.Text,
                            WXCode      = txtWxCode.Text,
                            Question    = DropDownList1.SelectedItem.Text,
                            Remark      = "",
                            SortIndex   = 100
                        };
                        if (bllXMember.Add(newOjb))
                        {
                            //创建成功
                            //修改自己的空缺名额,用掉了一个
                            miObj.IsAdd      = 1;
                            miObj.IsReply    = 1;
                            miObj.CID        = newOjb.MID;
                            miObj.UpdateTime = DateTime.Now;
                            bllXMemberInvite.Update(miObj);
                            //给会员增加两个2个空缺名额
                            AddMemberInvite(newOjb);
                        }
                        else
                        {
                            msg = "数据保存失败,请重新提交。";
                        }
                        #endregion
                    }
                    #endregion
                    #region  //4.2  如果已满,往下查找空缺
                    else
                    {
                        miObj = bllXMemberInvite.GetTopOneByPCode(mobj.PCodeStr + mobj.InviteCode + "|");
                        if (miObj != null)
                        {
                            #region
                            M.XMember cobj = bllXMember.GetOneById(miObj.MID);
                            if (cobj != null)
                            {
                                #region //创建会员
                                M.XMember newOjb = new M.XMember()
                                {
                                    MID         = CreateID(),
                                    CreateTime  = DateTime.Now,
                                    UpdateTime  = DateTime.Now,
                                    Answer      = TextBox1.Text,
                                    IsDeleted   = 0,
                                    IsDisable   = 0,
                                    LoginPWD    = XCommon.Uitl.MD5(txtPassword.Text),
                                    ManagePWD   = XCommon.Uitl.MD5("888888"),
                                    CurrentCode = tmpCode,
                                    Grade       = 1,
                                    InviteCode  = tmpIC,
                                    LoginIP     = "",
                                    LoginName   = txtNickName.Text,
                                    LoginSign   = "",
                                    LoginTime   = DateTime.Now,
                                    NickName    = txtNickName.Text,
                                    PCode       = cobj.InviteCode,                       //需要修改地方
                                    PCodeStr    = cobj.PCodeStr + cobj.InviteCode + "|", //需要修改地方
                                    Phone       = txtPhone.Text,
                                    WXCode      = txtWxCode.Text,
                                    Question    = DropDownList1.SelectedItem.Text,
                                    Remark      = "",
                                    SortIndex   = 100
                                };
                                if (bllXMember.Add(newOjb))
                                {
                                    //创建成功
                                    //修改自己的空缺名额,用掉了一个
                                    miObj.IsAdd      = 1;
                                    miObj.IsReply    = 1;
                                    miObj.CID        = newOjb.MID;
                                    miObj.UpdateTime = DateTime.Now;
                                    bllXMemberInvite.Update(miObj);
                                    //给会员增加两个2个空缺名额
                                    AddMemberInvite(newOjb);
                                }
                                #endregion
                            }
                            #endregion
                        }
                        else
                        {
                            #region  //5、如果没有了空缺位置怎么办?
                            M.XMember pobj = bllXMember.GetOneById("12980");
                            if (pobj != null)
                            {
                                #region //创建会员
                                M.XMember newOjb = new M.XMember()
                                {
                                    MID         = CreateID(),
                                    CreateTime  = DateTime.Now,
                                    UpdateTime  = DateTime.Now,
                                    Answer      = TextBox1.Text,
                                    IsDeleted   = 0,
                                    IsDisable   = 0,
                                    LoginPWD    = XCommon.Uitl.MD5(txtPassword.Text),
                                    ManagePWD   = XCommon.Uitl.MD5("888888"),
                                    CurrentCode = tmpCode,
                                    Grade       = 1,
                                    InviteCode  = tmpIC,
                                    LoginIP     = "",
                                    LoginName   = txtNickName.Text,
                                    LoginSign   = "",
                                    LoginTime   = DateTime.Now,
                                    NickName    = txtNickName.Text,
                                    PCode       = pobj.InviteCode,                       //需要修改地方
                                    PCodeStr    = pobj.PCodeStr + pobj.InviteCode + "|", //需要修改地方
                                    Phone       = txtPhone.Text,
                                    WXCode      = txtWxCode.Text,
                                    Question    = DropDownList1.SelectedItem.Text,
                                    Remark      = "",
                                    SortIndex   = 100
                                };
                                if (bllXMember.Add(newOjb))
                                {
                                    //创建成功
                                    //给会员增加两个2个空缺名额
                                    AddMemberInvite(newOjb);
                                }
                                #endregion
                            }
                            #endregion
                        }
                    }
                    #endregion
                }
                else
                {
                    msg = "当前会员无资格邀请注册!";
                }
            }
            #endregion
            if (msg.Length == 0)
            {
                //成功
                RedirectToLogin();
            }
            else
            {
                //失败
                phMsg.Visible = true;
                litMsg.Text   = msg;
            }
        }
Ejemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string msg = "";

            //第一步:空值判断
            if (username.Text.Length == 0 || password.Text.Length == 0 || vcode.Text.Length == 0)
            {
                if (username.Text.Length == 0)
                {
                    msg = "请输入用户名";
                }
                if (password.Text.Length == 0)
                {
                    msg = "请输入密码";
                }
                if (vcode.Text.Length == 0)
                {
                    msg = "请输入验证码";
                }
            }
            else
            {
                //第二步:验证码判断
                //验证码不区别大小写
                if (Session["XCVCode"] != null && vcode.Text.ToLower() == Session["XCVCode"].ToString().ToLower())//转换成小写再比较
                {
                    //第三步:用户名和密码判断
                    M.XMember mobj = bllXMember.GetOneByLogin(username.Text, XCommon.Uitl.MD5(password.Text));
                    if (mobj != null)
                    {
                        //第四步:禁用状态判断
                        if (mobj.IsDeleted == 0)
                        {
                            string     sign    = Guid.NewGuid().ToString();//生成一起签名
                            HttpCookie hcookie = new HttpCookie("MLOGIN");
                            hcookie.Values.Add("MSIGN", sign);
                            mobj.LoginSign  = sign;
                            mobj.UpdateTime = DateTime.Now;
                            if (bllXMember.Update(mobj))       //修改登录签名到数据库中
                            {
                                Response.Cookies.Add(hcookie); //把Cookie发送到客户端
                                msg = "";
                            }
                        }
                        else
                        {
                            msg = "此账号已被禁用,无法登录!";
                        }
                    }
                    else
                    {
                        msg = "用户名或密码错误!";
                    }
                }
                else
                {
                    msg = "验证码错误!";
                }
                if (msg.Length > 0)
                {
                    litMsg.Text   = msg;
                    phMsg.Visible = true;
                }
                else
                {
                    Response.Redirect("./?cmd=member_home");
                }
            }
        }