Exemple #1
0
        public static User_ContactM GetData()
        {
            string        sMsg = string.Empty;
            User_ContactM mod  = GetData(ref sMsg);

            new MessageGeneral().Error(sMsg);
            return(mod);
        }
Exemple #2
0
        public static bool Edit(User_ContactM pMod, int pContaceID, int pUserID)
        {
            string strSql = "update User_Contact set Name=@Name,Address=@Address,FixTel=@FixTel,Tel=@Tel,FK_Area=@FK_Area where ConSN=" + pContaceID + " and FK_User="******"@Name",    pMod.Name),
                DbHelp.Def.AddParam("@Address", pMod.Address),
                DbHelp.Def.AddParam("@FixTel",  pMod.FixTel),
                DbHelp.Def.AddParam("@Tel",     pMod.Tel),

                DbHelp.Def.AddParam("@FK_Area", pMod.FK_Area),
            };
            return(DbHelp.Update(strSql, dp) > 0);
        }
Exemple #3
0
        /// <summary>
        /// 获取数据及验证
        /// </summary>
        /// <returns></returns>
        public static User_ContactM GetData(ref string pMsg)
        {
            User_ContactM mod = new User_ContactM();

            string sName = Fn.EncodeHtml(Req.GetForm("cName").Trim());
            //string sSex = Req.GetForm("cSex").Trim();
            string sAddress = Fn.EncodeHtml(Req.GetForm("cAddress").Trim());
            string sFixTel  = Fn.EncodeHtml(Req.GetForm("cFixTel").Trim());
            string sTel     = Fn.EncodeHtml(Req.GetForm("cTel").Trim());
            string sArea    = Req.GetForm("cArea").Trim();

            if (sName.Length < 1 || sName.Length > 30)
            {
                pMsg = "请输入收货人,不超30个字;";
                return(mod);
            }

            if ((sTel.Length < 1 || sTel.Length > 25) && (sFixTel.Length < 1 || sFixTel.Length > 25))
            {
                pMsg = "手机,固定电话必填一个,不超25个位;";
                return(mod);
            }

            if (sAddress.Length < 1 || sAddress.Length > 300)
            {
                pMsg = "请输入详细地址,不超300个字;";
                return(mod);
            }

            if ((!Fn.IsIntBool(sArea)))
            {
                pMsg = "请选择地区;";
                return(mod);
            }
            else if (Convert.ToInt32(sArea) < 1)
            {
                pMsg = "请选择地区;";
                return(mod);
            }

            mod.Name    = sName;
            mod.Address = sAddress;
            mod.FixTel  = sFixTel;
            mod.Tel     = sTel;
            mod.FK_Area = Convert.ToInt32(sArea);
            return(mod);
        }
Exemple #4
0
        public bool Add(User_ContactM pMod, ref string pMsg)
        {
            if (GetUserContactN(pMod.FK_User) >= 10)
            {
                pMsg = "最多不能超过10条;";
                return(false);
            }

            string sSQL = "insert into User_Contact(FK_User,Name,Address,FixTel,Tel,FK_Area) values(@FK_User,@Name,@Address,@FixTel,@Tel,@FK_Area)";

            IDataParameter[] dp =
            {
                DbHelp.Def.AddParam("@FK_User", pMod.FK_User),
                DbHelp.Def.AddParam("@Name",    pMod.Name),
                DbHelp.Def.AddParam("@Address", pMod.Address),
                DbHelp.Def.AddParam("@FixTel",  pMod.FixTel),
                DbHelp.Def.AddParam("@Tel",     pMod.Tel),
                DbHelp.Def.AddParam("@FK_Area", pMod.FK_Area),
            };
            return(curHelp.Update(sSQL, dp) > 0);
        }
Exemple #5
0
        ////添加
        //protected void bOK_Click(object sender, EventArgs e)
        //{
        //    cb_ok();
        //}

        private void cb_ok()
        {
            string sMsg = string.Empty;
            //获取数据及验证
            User_ContactM mod = User_ContactL.GetData(ref sMsg);

            if (sMsg.Length > 0)
            {
                msgAjax.Error(sMsg);
                return;
            }

            if (id > 0)
            {
                if (User_ContactL.Edit(mod, id, UserID))
                {
                    BGList();
                    msgAjax.AddMessage("html", Fn.GetControlHtml(this.clist));
                    msgAjax.Success("修改成功");
                }
                else
                {
                    msgAjax.Error("修改失败,请刷新此网页解决此问题");
                }
            }
            else
            {
                mod.FK_User = UserID;
                if (new User_ContactL().Add(mod))
                {
                    BGList();
                    msgAjax.AddMessage("html", Fn.GetControlHtml(this.clist));
                    msgAjax.Success("添加成功");
                }
                else
                {
                    msgAjax.Error("添加失败,最多不超过10条");
                }
            }
        }
Exemple #6
0
        public bool Add(User_ContactM pMod)
        {
            string sMsg = string.Empty;

            return(Add(pMod, ref sMsg));
        }
Exemple #7
0
        private void Reg()
        {
            if (Req.GetForm("cIsAgree") != "1")
            {
                msgAjax.Error("必需同意[搜菜网用户注册协议]才能注册;");
                return;
            }

            if (!Fn.IsVerifyCode1("cCode", "uverify"))
            {
                msgAjax.Error("code.wrong;");
                return;
            }

            string cname     = Fn.EncodeHtml(Req.GetForm("cname").Trim());
            string email     = Fn.EncodeHtml(Req.GetForm("email").Trim());
            string pwd       = Req.GetForm("pwd").Trim();
            string pwd1      = Req.GetForm("pwd1").Trim();
            string realname  = Fn.EncodeHtml(Req.GetForm("realname").Trim());
            string sSex      = Req.GetForm("cSex").Trim();
            string sArea     = Req.GetForm("cArea").Trim();
            string address   = Fn.EncodeHtml(Req.GetForm("address").Trim());
            string tel       = Fn.EncodeHtml(Req.GetForm("tel").Trim());
            string telfix    = Fn.EncodeHtml(Req.GetForm("telfix").Trim());
            string sCard     = Fn.EncodeHtml(Req.GetForm("card").Trim());
            string sPromoter = Req.GetForm("cPromoter").Trim();

            //用户名
            if (cname.Length == 0)
            {
                msgAjax.Error("请输入用户名;");
            }
            else
            {
                if (cname.Length < 5 || cname.Length > 30)
                {
                    msgAjax.Error("用户名需在5-30个字符之间;");
                }
                else
                {
                    if (!Fn.IsRegex(cname, Fn.EnumRegex.用户名))
                    {
                        msgAjax.Error("用户名中有非法字条;");
                    }
                    else
                    {
                        if (User_InfoL.IsUserName(cname))
                        {
                            msgAjax.Error("此用户名已被注册,请重新输入;");
                        }
                    }
                }
            }

            if (email.Length == 0)
            {
                msgAjax.Error("请输入邮箱;");
            }
            else
            {
                if (email.Length < 5 || email.Length > 30)
                {
                    msgAjax.Error("邮箱需在5-30个字符之间;");
                }
                else
                {
                    if (!Fn.IsRegex(email, Fn.EnumRegex.电子邮件))
                    {
                        msgAjax.Error("邮箱格式不正确;");
                    }
                    else
                    {
                        if (User_InfoL.IsEmail(email))
                        {
                            msgAjax.Error("此邮箱名已被注册,请重新输入;");
                        }
                    }
                }
            }

            if (pwd.Length == 0)
            {
                msgAjax.Error("请输入密码;");
            }
            else
            {
                if (pwd.Length < 5 || pwd.Length > 30)
                {
                    msgAjax.Error("密码需在5-30位数之间;");
                }
                else
                {
                    if (pwd1.Length == 0)
                    {
                        msgAjax.Error("请输入确认密码;");
                    }
                    else
                    {
                        if (pwd != pwd1)
                        {
                            msgAjax.Error("两次密码输入不一致;");
                        }
                    }
                }
            }

            //会员卡号
            int exp = 0;

            if (sCard.Length > 0)
            {
                if (!Activity_InfoL.IsOpen("user_card"))
                {
                    msgAjax.Error("会员卡活动已关闭;");
                    return;
                }

                if (!User_CardL.IsUse(sCard, out exp))
                {
                    msgAjax.Error("会员卡错误或不存在此卡号;");
                    return;
                }

                if (exp <= 0)
                {
                    msgAjax.Error("会员卡错误或不存在此卡号;");
                    return;
                }
            }

            //推广员号码
            int UserBTJ = 0;

            if (sPromoter.Length > 0)
            {
                int iPromoter;

                if (!int.TryParse(sPromoter, out iPromoter))
                {
                    msgAjax.Error("推广员号码错误或不存在此推广员;");
                    return;
                }

                if (!Activity_InfoL.IsOpen("user_promoter"))
                {
                    msgAjax.Error("注册推广员活动已关闭;");
                    return;
                }

                if (!User_InfoL.IsUserPromoter(iPromoter))
                {
                    msgAjax.Error("推广员号码错误或不存在此推广员;");
                    return;
                }

                UserBTJ = iPromoter;
            }

            if (realname.Length > 30)
            {
                msgAjax.Error("联系人不超过30个字;");
            }

            if (tel.Length > 25)
            {
                msgAjax.Error("手机不超过25字;");
            }

            if (telfix.Length > 25)
            {
                msgAjax.Error("固定电话不超过25字;");
            }

            if (address.Length > 300)
            {
                msgAjax.Error("地址不超过300字;");
            }

            int iArea = Fn.IsInt(sArea, 0);

            if (iArea < 0)
            {
                msgAjax.Error("非法操作;");
            }
            else if (iArea > 0)
            {
                if (ClassData.HasNext("Pub_Area", iArea))
                {
                    msgAjax.Error("请选择最后一级分类;");
                }
            }

            //if (tel.Length == 0 && telfix.Length == 0)
            //{
            //    msgAjax.Error("手机和固定电话必填一个;");
            //}

            if (msgAjax.IsError)
            {
                return;
            }

            //账号信息
            User_InfoM infoMod = new User_InfoM();

            infoMod.FK_User_Level = User_LevelL.GetDefaultLevel();
            infoMod.UserName      = cname;
            infoMod.UserPwd       = Fn.MD5(pwd);
            infoMod.LastLoginIP   = Request.UserHostAddress;
            infoMod.OpenIdentity  = 1;//个人用户
            infoMod.Email         = email;
            infoMod.UserCard      = sCard;
            infoMod.UserBTJ       = UserBTJ;

            //个人用户信息
            User_PersonalM perMod = new User_PersonalM();

            perMod.RealName = realname;
            perMod.Sex      = byte.Parse(sSex);
            perMod.Area     = iArea;
            perMod.Address  = address;
            perMod.FixTel   = telfix;
            perMod.Tel      = tel;

            //收货信息
            User_ContactM conMod = new User_ContactM();

            conMod.FK_Area = iArea;
            conMod.Name    = realname;
            conMod.Address = address;
            conMod.FixTel  = telfix;
            conMod.Tel     = tel;

            //事务类
            User_InfoL.Reg1_TransM lsTrans = new User_InfoL.Reg1_TransM();
            lsTrans.infoMod = infoMod;
            lsTrans.perMod  = perMod;
            lsTrans.conMod  = conMod;

            if (exp > 0)
            {
                lsTrans.IsUseCard = true;
                lsTrans.Exp       = exp;
            }
            DbHelp.ExecuteTrans(new DbHelpParam(), User_InfoL.Reg1_Trans, lsTrans);

            if (lsTrans.returnValue == "1")
            {
                Session.Remove("uverify");
                User_Info.Login(cname, pwd);

                int isSend = 0;
                try
                {
                    string url   = Request.Url.AbsoluteUri.Replace(Request.Url.AbsolutePath, "") + "/email/regSuccess.aspx?un=" + cname;
                    string sText = Fn.GetPageHtml(url);

                    User_InfoL.SendEmail(email, cname + " 您好,您在搜菜网已成功注册会员", sText);
                    isSend = 1;
                }
                catch
                { }

                msgAjax.Success(isSend.ToString());
            }
            else
            {
                msgAjax.Error(lsTrans.returnValue);
            }
        }
Exemple #8
0
        public static int Reg1_Trans(IDbHelp tHelp, object obj)
        {
            Reg1_TransM    lsTrans = (Reg1_TransM)obj;
            User_InfoM     infoMod = lsTrans.infoMod;
            User_PersonalM perMod  = lsTrans.perMod;
            User_ContactM  conMod  = lsTrans.conMod;

            if (lsTrans.IsUseCard)
            {
                if (new User_InfoL(tHelp).IsUserCard(infoMod.UserCard))
                {
                    lsTrans.returnValue = "此会员卡卡号已被人注册";
                    return(0);
                }
            }

            string sql = "insert into User_Info(FK_User_Level,UserName,UserPwd,OpenIdentity,Email,UserCard,UserBTJ) values(@FK_User_Level,@UserName,@UserPwd,@OpenIdentity,@Email,@UserCard,@UserBTJ);select SCOPE_IDENTITY()";

            IDataParameter[] dp =
            {
                DbHelp.Def.AddParam("@FK_User_Level", infoMod.FK_User_Level),
                DbHelp.Def.AddParam("@UserName",      infoMod.UserName),
                DbHelp.Def.AddParam("@UserPwd",       infoMod.UserPwd),
                DbHelp.Def.AddParam("@OpenIdentity",  infoMod.OpenIdentity),
                DbHelp.Def.AddParam("@Email",         infoMod.Email),
                DbHelp.Def.AddParam("@UserCard",      infoMod.UserCard),
                DbHelp.Def.AddParam("@UserBTJ",       infoMod.UserBTJ),
            };

            int uid = int.Parse(tHelp.First(sql, dp, "0").ToString());

            //try
            //{
            //uid = int.Parse(tHelp.First(sql, dp, "0").ToString());
            //}
            //catch (Exception ex)
            //{
            //    lsTrans.returnValue = "注册失败:" + ex.Message;
            //    return 0;
            //}

            if (uid <= 0)
            {
                lsTrans.returnValue = "注册失败2";
                return(0);
            }

            sql = "insert into User_Personal(FK_User,RealName,Sex,Area,Address,Tel,FixTel) values(@FK_User,@RealName,@Sex,@Area,@Address,@Tel,@FixTel)";
            IDataParameter[] dp1 =
            {
                DbHelp.Def.AddParam("@FK_User",  uid),
                DbHelp.Def.AddParam("@RealName", perMod.RealName),
                DbHelp.Def.AddParam("@Sex",      perMod.Sex),
                DbHelp.Def.AddParam("@Area",     perMod.Area),
                DbHelp.Def.AddParam("@Address",  perMod.Address),
                DbHelp.Def.AddParam("@Tel",      perMod.Tel),
                DbHelp.Def.AddParam("@FixTel",   perMod.FixTel),
            };
            //User_Personal
            if (tHelp.Update(sql, dp1) <= 0)
            {
                lsTrans.returnValue = "注册失败1";
                return(0);
            }

            //是否添加收货地址
            if (conMod.Name.Length > 0 && conMod.Address.Length > 0 && (conMod.Tel.Length > 0 || conMod.FixTel.Length > 0) && conMod.FK_Area > 0)
            {
                User_ContactL uc = new User_ContactL(tHelp);
                conMod.FK_User = uid;
                string sMsg = string.Empty;

                if (uc.Add(conMod, ref sMsg))//添加收货地址
                {
                }
                else
                {
                    lsTrans.returnValue = "注册失败:" + sMsg;
                    return(0);
                }
            }

            //if (uid > 0)//账号添加成功
            //{
            //    //sql = "insert into User_Personal(FK_User,RealName,Sex,Area,Address,Tel,FixTel) values(@FK_User,@RealName,@Sex,@Area,@Address,@Tel,@FixTel)";

            //    //IDataParameter[] dp1 = {
            //    //                    DbHelp.Def.AddParam("@FK_User",uid),
            //    //                    DbHelp.Def.AddParam("@RealName",perMod.RealName),
            //    //                    DbHelp.Def.AddParam("@Sex",perMod.Sex),
            //    //                    DbHelp.Def.AddParam("@Area",perMod.Area),
            //    //                    DbHelp.Def.AddParam("@Address",perMod.Address),
            //    //                    DbHelp.Def.AddParam("@Tel",perMod.Tel),
            //    //                    DbHelp.Def.AddParam("@FixTel",perMod.FixTel),
            //    //                       };

            //    //bool isUser_Personal;
            //    //try
            //    //{
            //    //    isUser_Personal = tHelp.Update(sql, dp1) > 0;
            //    //}
            //    //catch (Exception ex)
            //    //{
            //    //    lsTrans.returnValue = "注册失败:" + ex.Message;
            //    //    return 0;
            //    //}

            //    if (isUser_Personal)//个人用户信息添加成功
            //    {
            //        //是否添加收货地址

            //        //if (conMod.Name.Length > 0 && conMod.Address.Length > 0 && (conMod.Tel.Length > 0 || conMod.FixTel.Length > 0) && conMod.FK_Area > 0)
            //        //{
            //        //    User_ContactL uc = new User_ContactL(tHelp);
            //        //    conMod.FK_User = uid;
            //        //    string sMsg = string.Empty;

            //        //    if (uc.Add(conMod, ref sMsg))//添加收货地址
            //        //    {
            //        //    }
            //        //    else
            //        //    {
            //        //        lsTrans.returnValue = "注册失败:" + sMsg;
            //        //        return 0;
            //        //    }
            //        //}
            //        //else
            //        //{
            //        //}
            //    }
            //    else
            //    {
            //        //lsTrans.returnValue = "注册失败1";
            //        //return 0;
            //    }
            //}
            //else
            //{
            //    //lsTrans.returnValue = "注册失败2";
            //    //return 0;
            //}

            //增加积分或经验
            User_FractHandler.FractHandlerParam ufParam = new User_FractHandler.FractHandlerParam(uid, "system", 1, "reg", "reg", "注册成功 \"" + infoMod.UserName + "\"");
            string slog = new User_FractHandler(tHelp).SetFract(ufParam);

            if (slog != "1")
            {
                lsTrans.returnValue = slog;
                return(0);
            }

            //是否使用会员卡
            if (lsTrans.IsUseCard)
            {
                //设置会员卡状态
                sql = "update User_Card set FK_User=@FK_User,card_Status=1 where card_Number=@card_Number";
                IDataParameter[] dp_usercard =
                {
                    DbHelp.Def.AddParam("@FK_User",     uid),
                    DbHelp.Def.AddParam("@card_Number", infoMod.UserCard),
                };
                if (tHelp.Update(sql, dp_usercard) <= 0)
                {
                    lsTrans.returnValue = "注册失败2";
                    return(0);
                }

                slog = new User_InfoL(tHelp).SetUserExp(uid, uid, "reg_card", lsTrans.Exp, "system", "注册使用会员卡 \"" + infoMod.UserCard + "\" 赠送" + lsTrans.Exp + "经验");
                if (slog != "1")
                {
                    lsTrans.returnValue = slog;
                    return(0);
                }
            }

            lsTrans.returnValue = "1";
            return(1);
        }