Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public static int Reg_Trans(IDbHelp tHelp, object obj)
        {
            Reg_TransM     lsTrans = (Reg_TransM)obj;
            User_InfoM     infoMod = lsTrans.infoMod;
            User_PersonalM perMod  = lsTrans.perMod;

            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),
            };

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

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

            sql = "insert into User_Personal(FK_User) values(@FK_User)";
            IDataParameter[] dp1 =
            {
                DbHelp.Def.AddParam("@FK_User", uid),
            };
            //User_Personal
            if (tHelp.Update(sql, dp1) <= 0)
            {
                lsTrans.returnValue = "注册失败";
                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);
        }