Beispiel #1
0
        public bool Add()
        {
            if (this.Valid())
            {
                this.Id      = General.UniqueString(this.Id);
                this.AddDate = DateTime.Now;

                using (WMContext context = new WMContext())
                {
                    UserIntegrals model = new UserIntegrals
                    {
                        Id       = this.Id,
                        SourceId = this.SourceId,
                        UserId   = this.UserId,
                        Integral = this.Integral,
                        AddDate  = this.AddDate
                    };

                    context.UserIntegrals.Add(model);
                    context.SaveChanges();
                }

                return(WMUsers.UpdateIntegral(this.UserId, this.Integral));
            }

            return(false);
        }
Beispiel #2
0
        public static WMUsers Login(string userKey, string pwd)
        {
            WMUsers user = null;

            if (!General.IsNullable(userKey) && !General.IsNullable(pwd))
            {
                string userId = null;

                using (WMContext context = new WMContext())
                {
                    userId = (
                        from u in context.Users
                        where u.StatusId == 201 &&
                        u.Password.Equals(pwd) &&
                        (u.UserName.Equals(userKey) || u.Mobile == userKey)
                        select u.Id
                        ).FirstOrDefault();
                }

                if (userId != null)
                {
                    user = Get(userId);
                }
            }

            return(user);
        }
Beispiel #3
0
        public static WMUsers Login(string openId)
        {
            WMUsers user = null;

            if (!General.IsNullable(openId))
            {
                string userId = null;

                using (WMContext context = new WMContext())
                {
                    userId = (
                        from u in context.Users
                        where u.StatusId == 201 &&
                        u.OpenId == openId
                        select u.Id
                        ).FirstOrDefault();
                }

                if (userId != null)
                {
                    user = Get(userId);
                }
            }

            return(user);
        }
Beispiel #4
0
        public void Test_Add_Get()
        {
            //Add user
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Add Order
            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621
            };
            Assert.IsTrue(order.Add());
            Assert.AreEqual("小李", order.Contact);
        }
Beispiel #5
0
        public void Test_Add_Get()
        {
            //Add user
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Add address
            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621
            };
            Assert.IsTrue(order.Add());
            Assert.AreEqual("小李", order.Contact);

            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMOrderGoods orderGood = new WMOrderGoods()
            {
                Count = 2,
                GoodId = goodToAdd.Id,
                OrderId = order.Id,
                Price = 100,
            };
            Assert.IsTrue(orderGood.Add());

            int pageCount;
            List<WMOrderGoods> orderGoodsGetted = WMOrderGoods.GetList(out pageCount, order.Id);
            Assert.AreEqual(1, orderGoodsGetted.Count);
            Assert.AreEqual("砖石项链", orderGoodsGetted[0].GoodName);
            Assert.AreEqual(2, orderGoodsGetted[0].Count);
        }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        string msg = string.Empty;

        if (this.IsValid)
        {
            if (WMUsers.IsExitis(null, UserName.Text))
            {
                msg = "该用户名已存在";
            }
            else if (General.IsNullable(ValidCode) || ValidCode != ValidNum.Text)
            {
                msg = "输入的手机验证码不正确";
            }
            else
            {
                WMUsers user = new WMUsers();
                user.RoleId = 101;
                user.UserName = UserName.Text.Trim();
                user.Password = UserPassword.Text.Trim();
                user.NickName = NickName.Text.Trim();
                user.Mobile = UserMobile.Text.Trim();
                user.UnionId = UnionId;
                user.Image = HeadImage;
                if (Source == "weixin")
                    user.OpenId = OpenId;

                if (user.Add())
                {
                    user = WMUsers.Get(user.Id);
                    Helper.User = new Account
                    {
                        Id = user.Id.ToString(),
                        RoleId = user.RoleId,
                        RoleName = user.RoleName,
                        LoginName = user.UserName,
                        NickName = user.UserName,
                        LoginDate = DateTime.Now,
                        AddDate = user.AddDate
                    };
                    Response.Redirect("~/usercenter.aspx");
                }
                else
                {
                    msg = "注册失败! 请确认信息填写无误后,重新提交!";
                }
            }
        }

        Helper.ExecScript("alert('" + msg + "')");
    }
Beispiel #7
0
        public void Test_Exist_User()
        {
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            bool isExist = WMUsers.IsExitis(null, userToAdd.UserName);
            Assert.IsTrue(isExist);
        }
Beispiel #8
0
        public void Test_Add()
        {
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            WMUsers userGetted = WMUsers.Get(userToAdd.Id);
            Assert.IsNotNull(userGetted);
            Assert.AreEqual("user", userGetted.UserName);
        }
        public void Test_Updata()
        {
            //User
            WMUsers user = new WMUsers();
            user.Id = General.UniqueString(user.Id);
            user.RoleId = 101;
            user.UserName = "******";
            user.Password = "******";
            user.NickName = "nick";
            user.Mobile = "13512341234";
            Assert.IsTrue(user.Add());

            //Category
            WMGoodCategories cate = new WMGoodCategories();
            cate.ParentId = "root";
            cate.Name = "珠宝";
            Assert.IsTrue(cate.Add());

            //Good
            WMGoods good = new WMGoods();
            good.CategoryId = cate.Id;
            good.Name = "砖石项链";
            good.Unit = "件";
            good.OriginalPrice = 10000;
            good.StatusId = 501;
            bool isGoodAdded = good.Add();
            Assert.IsTrue(isGoodAdded);

            //Car
            WMShopCars car = new WMShopCars()
            {
                GoodId = good.Id,
                UserId = user.Id,
                Price = 100,
                Count = 2,
            };
            Assert.IsTrue(car.Add());

            WMShopCars.UpdateCount(car.Id, 3);

            int pageCount;
            List<WMShopCars> carsGetted = WMShopCars.GetList(out pageCount, user.Id, null, 0, 0);
            Assert.IsNotNull(carsGetted);
            Assert.AreEqual(1, carsGetted.Count);
            Assert.AreEqual(3, carsGetted[0].Count);
        }
Beispiel #10
0
        public void Test_Add_Get()
        {
            //Add user
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Add Order
            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621
            };
            Assert.IsTrue(order.Add());

            //AddBonus
            WMUserBonus bonus = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 101,
            };
            Assert.IsTrue(bonus.Add());

            int pageCount;
            DateTime firstDayInMonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            List<WMUserBonus> bonusesGetted = WMUserBonus.GetList(
                out pageCount, firstDayInMonth, null, userToAdd.Id);
            Assert.IsNotNull(bonusesGetted);
            Assert.AreEqual(1, bonusesGetted.Count);
            Assert.AreEqual(101, bonusesGetted[0].BonusSum);
        }
Beispiel #11
0
        public void Test_Fav_Add_Get()
        {
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //添加category
            WMGoodCategories cateToAdd = new WMGoodCategories();
            cateToAdd.ParentId = "root";
            cateToAdd.Name = "珠宝";
            bool isCateAdded = cateToAdd.Add();
            Assert.IsTrue(isCateAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cateToAdd.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMUserSets userSet = new WMUserSets()
            {
                TypeId = 401,
                UserId = userToAdd.Id,
                GoodId = goodToAdd.Id,
            };
            Assert.IsTrue(userSet.Add());

            int pageCount;
            List<WMUserSets> favs = WMUserSets.GetList(out pageCount, 401, userToAdd.Id);
            Assert.AreEqual(1, favs.Count);
            Assert.AreEqual("砖石项链", favs[0].GoodName);
        }
        public void Test_Add_Get()
        {
            //Add user
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Add address
            WMUserReceipts receipt = new WMUserReceipts()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
            };
            Assert.IsTrue(receipt.Add());
            Assert.AreEqual("小李", receipt.Contact);

            //测试simpleAddress
            List<WMUserReceipts> addresses = WMUserReceipts.GetList(userToAdd.Id);
            var simpleAddresses = (from a in addresses
                                   select new
                                   {
                                       Id = a.Id,
                                       Desc = a.Contact + " " + a.Phone + " "
                                           + a.ProvinceName + a.CityName + a.AreaName + a.Address
                                   }).ToList();
            Assert.AreEqual(1, simpleAddresses.Count);
        }
Beispiel #13
0
        public static WMUsers Get(string userId)
        {
            WMUsers user = null;

            if (!General.IsNullable(userId))
            {
                using (WMContext context = new WMContext())
                {
                    user = (
                        from u in context.Users
                        join r in context.Options on u.RoleId equals r.Id
                        join s in context.Options on u.StatusId equals s.Id
                        where u.Id.Equals(userId)
                        select new WMUsers
                    {
                        Id = u.Id,
                        RoleId = u.RoleId,
                        RoleName = r.Name,
                        OpenId = u.OpenId,
                        UserName = u.UserName,
                        Password = u.Password,
                        NickName = u.NickName,
                        Integral = u.Integral,
                        Image = u.Image,
                        Mobile = u.Mobile,
                        BankCard = u.BankCard,
                        StatusId = u.StatusId,
                        StatusName = s.Name,
                        AddDate = u.AddDate
                    }
                        ).FirstOrDefault();
                }
            }

            return(user);
        }
Beispiel #14
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        bool flag = false;
        string msg = string.Empty;

        if (this.IsValid)
        {
            if (WMUsers.IsExitis(null, UserName.Text))
            {
                msg = "用户名已存在";
            }
            else if (RandomReslt == string.Empty || ValidNum.Text != RandomReslt)
            {
                msg = "验证码错误";
            }
            else
            {
                WMUsers user = new WMUsers();
                user.Id = General.UniqueString(user.Id);
                user.RoleId = 101;
                user.UserName = UserName.Text;
                user.Password = UserPassword.Text;
                user.NickName = NickName.Text;
                user.Mobile = UserMobile.Text;

                if (IsGettedWeixin == "true" && WeiXinForRegister != null)
                {
                    user.OpenId = WeiXinForRegister.OpenId;
                    user.UnionId = WeiXinForRegister.UnionId;
                }

                flag = user.Add();

                if (flag)
                {
                    user = WMUsers.Get(user.Id);
                    Helper.User = new Account
                    {
                        Id = user.Id.ToString(),
                        RoleId = user.RoleId,
                        RoleName = user.RoleName,
                        LoginName = user.UserName,
                        NickName = user.UserName,
                        LoginDate = DateTime.Now,
                        AddDate = user.AddDate
                    };
                    Response.Redirect("/usercenter.aspx");
                }
                else
                {
                    msg = "请检查注册信息,确认符合要求,再次提交";
                }
            }
        }

        Helper.ExecScript("alert('" + msg + "')");
    }
Beispiel #15
0
        public void Test_AddAllDatas()
        {
            bool isAdded = false;

            //express
            WMOrderExpress express = new WMOrderExpress()
            {
                Name = "顺丰",
                URL = "www.shufen.com"
            };
            Assert.IsTrue(express.Add());

            //Admins
            WMAdministrators adminToAdd = new WMAdministrators();
            adminToAdd.RoleId = 302;
            adminToAdd.UserName = "******";
            adminToAdd.Password = "******";
            adminToAdd.Add();

            //Users
            WMUsers userToAdd = new WMUsers();
            userToAdd.Id = General.UniqueString(userToAdd.Id);
            userToAdd.RoleId = 101;
            userToAdd.UserName = "******";
            userToAdd.Password = "******";
            userToAdd.NickName = "nick";
            userToAdd.Mobile = "13512341234";
            Assert.IsTrue(userToAdd.Add());

            //Categories
            //珠宝
            WMGoodCategories cate_0 = new WMGoodCategories();
            cate_0.ParentId = "root";
            cate_0.Name = "珠宝";
            isAdded = cate_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_0_0 = new WMGoodCategories();
            cate_0_0.ParentId = cate_0.Id;
            cate_0_0.Name = "项链";
            isAdded = cate_0_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_0_1 = new WMGoodCategories();
            cate_0_1.ParentId = cate_0.Id;
            cate_0_1.Name = "手镯";
            isAdded = cate_0_1.Add();
            Assert.IsTrue(isAdded);

            //服装
            WMGoodCategories cate_1 = new WMGoodCategories();
            cate_1.ParentId = "root";
            cate_1.Name = "服装";
            isAdded = cate_1.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_1_0 = new WMGoodCategories();
            cate_1_0.ParentId = cate_1.Id;
            cate_1_0.Name = "衬衫";
            isAdded = cate_1_0.Add();
            Assert.IsTrue(isAdded);

            WMGoodCategories cate_1_1 = new WMGoodCategories();
            cate_1_1.ParentId = cate_1.Id;
            cate_1_1.Name = "T恤";
            isAdded = cate_1_1.Add();
            Assert.IsTrue(isAdded);

            //添加good
            WMGoods goodToAdd = new WMGoods();
            goodToAdd.CategoryId = cate_0.Id;
            goodToAdd.Name = "砖石项链";
            goodToAdd.Unit = "件";
            goodToAdd.OriginalPrice = 10000;
            goodToAdd.StatusId = 501;
            bool isGoodAdded = goodToAdd.Add();
            Assert.IsTrue(isGoodAdded);

            WMGoods good2ToAdd = new WMGoods();
            good2ToAdd.CategoryId = cate_0_0.Id;
            good2ToAdd.Name = "黄金项链";
            good2ToAdd.Unit = "件";
            good2ToAdd.OriginalPrice = 10000;
            good2ToAdd.StatusId = 501;
            good2ToAdd.Add();

            WMGoods good3ToAdd = new WMGoods();
            good3ToAdd.CategoryId = cate_0_0.Id;
            good3ToAdd.Name = "红宝石项链";
            good3ToAdd.Unit = "件";
            good3ToAdd.OriginalPrice = 10000;
            good3ToAdd.StatusId = 501;
            good3ToAdd.Add();

            WMGoods good4ToAdd = new WMGoods();
            good4ToAdd.CategoryId = cate_0_0.Id;
            good4ToAdd.Name = "蓝宝石项链";
            good4ToAdd.Unit = "件";
            good4ToAdd.OriginalPrice = 10000;
            good4ToAdd.StatusId = 501;
            good4ToAdd.Add();

            WMGoods good5ToAdd = new WMGoods();
            good5ToAdd.CategoryId = cate_0_0.Id;
            good5ToAdd.Name = "绿宝石项链";
            good5ToAdd.Unit = "件";
            good5ToAdd.OriginalPrice = 10000;
            good5ToAdd.StatusId = 501;
            good5ToAdd.Add();

            WMGoods good6ToAdd = new WMGoods();
            good6ToAdd.CategoryId = cate_0_0.Id;
            good6ToAdd.Name = "黄宝石项链";
            good6ToAdd.Unit = "件";
            good6ToAdd.OriginalPrice = 10000;
            good6ToAdd.StatusId = 501;
            good6ToAdd.Add();

            WMGoods good7ToAdd = new WMGoods();
            good7ToAdd.CategoryId = cate_0_0.Id;
            good7ToAdd.Name = "珍珠项链";
            good7ToAdd.Unit = "件";
            good7ToAdd.OriginalPrice = 10000;
            good7ToAdd.StatusId = 501;
            good7ToAdd.Add();

            WMGoods good8ToAdd = new WMGoods();
            good8ToAdd.CategoryId = cate_0_0.Id;
            good8ToAdd.Name = "石头项链";
            good8ToAdd.Unit = "件";
            good8ToAdd.OriginalPrice = 10000;
            good8ToAdd.StatusId = 501;
            good8ToAdd.Add();

            WMGoods good9ToAdd = new WMGoods();
            good9ToAdd.CategoryId = cate_0_0.Id;
            good9ToAdd.Name = "水泥项链";
            good9ToAdd.Unit = "件";
            good9ToAdd.OriginalPrice = 10000;
            good9ToAdd.StatusId = 501;
            good9ToAdd.Add();

            WMGoods good10ToAdd = new WMGoods();
            good10ToAdd.CategoryId = cate_0_0.Id;
            good10ToAdd.Name = "1项链";
            good10ToAdd.Unit = "件";
            good10ToAdd.OriginalPrice = 10000;
            good10ToAdd.StatusId = 501;
            good10ToAdd.Add();

            WMGoods good11ToAdd = new WMGoods();
            good11ToAdd.CategoryId = cate_0_0.Id;
            good11ToAdd.Name = "2项链";
            good11ToAdd.Unit = "件";
            good11ToAdd.OriginalPrice = 10000;
            good11ToAdd.StatusId = 501;
            good11ToAdd.Add();

            WMGoods good12ToAdd = new WMGoods();
            good12ToAdd.CategoryId = cate_0_0.Id;
            good12ToAdd.Name = "3项链";
            good12ToAdd.Unit = "件";
            good12ToAdd.OriginalPrice = 10000;
            good12ToAdd.StatusId = 501;
            good12ToAdd.Add();

            WMGoods good13ToAdd = new WMGoods();
            good13ToAdd.CategoryId = cate_0_0.Id;
            good13ToAdd.Name = "4项链";
            good13ToAdd.Unit = "件";
            good13ToAdd.OriginalPrice = 10000;
            good13ToAdd.StatusId = 501;
            good13ToAdd.Add();

            WMGoods good14ToAdd = new WMGoods();
            good14ToAdd.CategoryId = cate_0_0.Id;
            good14ToAdd.Name = "5项链";
            good14ToAdd.Unit = "件";
            good14ToAdd.OriginalPrice = 10000;
            good14ToAdd.StatusId = 501;
            good14ToAdd.Add();

            WMGoods good15ToAdd = new WMGoods();
            good15ToAdd.CategoryId = cate_0_0.Id;
            good15ToAdd.Name = "6项链";
            good15ToAdd.Unit = "件";
            good15ToAdd.OriginalPrice = 10000;
            good15ToAdd.StatusId = 501;
            good15ToAdd.Add();

            WMGoods good16ToAdd = new WMGoods();
            good16ToAdd.CategoryId = cate_0_0.Id;
            good16ToAdd.Name = "7项链";
            good16ToAdd.Unit = "件";
            good16ToAdd.OriginalPrice = 10000;
            good16ToAdd.StatusId = 501;
            good16ToAdd.Add();

            WMGoods good17ToAdd = new WMGoods();
            good17ToAdd.CategoryId = cate_0_0.Id;
            good17ToAdd.Name = "8项链";
            good17ToAdd.Unit = "件";
            good17ToAdd.OriginalPrice = 10000;
            good17ToAdd.StatusId = 501;
            good17ToAdd.Add();

            //添加brand
            WMGoodBrands brand1 = new WMGoodBrands();
            brand1.Name = "卡地亚";
            Assert.IsTrue(brand1.Add());

            WMGoodBrands brand2 = new WMGoodBrands();
            brand2.Name = "爱马仕";
            Assert.IsTrue(brand2.Add());

            //Car
            WMShopCars car = new WMShopCars()
            {
                GoodId = goodToAdd.Id,
                UserId = userToAdd.Id,
                Price = 100,
                Count = 2,
            };
            Assert.IsTrue(car.Add());

            WMShopCars car2 = new WMShopCars()
            {
                GoodId = good2ToAdd.Id,
                UserId = userToAdd.Id,
                Price = 500,
                Count = 3,
            };
            Assert.IsTrue(car2.Add());

            WMOrders order = new WMOrders()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
                PayId = 621,
                ExpressId = express.Id
            };
            Assert.IsTrue(order.Add());

            WMOrderGoods orderGood = new WMOrderGoods()
            {
                Count = 2,
                GoodId = goodToAdd.Id,
                OrderId = order.Id,
                Price = 100,
            };
            Assert.IsTrue(orderGood.Add());

            //Add address
            WMUserReceipts receipt = new WMUserReceipts()
            {
                UserId = userToAdd.Id,
                Address = "上海哪儿哪儿哪儿",
                Contact = "小李",
                Phone = "13512341235",
                ZipCode = "240101",
                ProvinceId = 110000,
                CityId = 110100,
                AreaId = 110101,
            };
            Assert.IsTrue(receipt.Add());

            //用户收藏
            WMUserSets userSet = new WMUserSets()
            {
                TypeId = 401,
                UserId = userToAdd.Id,
                GoodId = goodToAdd.Id,
            };
            Assert.IsTrue(userSet.Add());

            //用户积分
            WMUserIntegrals intergral = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral.Add());

            WMUserIntegrals intergral2 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral2.Add());

            WMUserIntegrals intergral3 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral3.Add());

            WMUserIntegrals intergral4 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral4.Add());

            WMUserIntegrals intergral5 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral5.Add());

            WMUserIntegrals intergral6 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral6.Add());

            WMUserIntegrals intergral7 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral7.Add());

            WMUserIntegrals intergral8 = new WMUserIntegrals()
            {
                UserId = userToAdd.Id,
                Integral = 100,
                SourceId = 451
            };
            Assert.IsTrue(intergral8.Add());

            //用户返利
            WMUserBonus bonus = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 101,
            };
            Assert.IsTrue(bonus.Add());

            WMUserBonus bonus2 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus2.Add());

            WMUserBonus bonus3 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus3.Add());

            WMUserBonus bonus4 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus4.Add());

            WMUserBonus bonus5 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus5.Add());

            WMUserBonus bonus6 = new WMUserBonus()
            {
                UserId = userToAdd.Id,
                OrderId = order.Id,
                BonusSum = 102,
                //AddDate = DateTime.Parse("2014-9-9")
            };
            Assert.IsTrue(bonus6.Add());
        }
Beispiel #16
0
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        bool flag = false;
        string msg = string.Empty;

        if (this.IsValid)
        {
            if (WMUsers.IsExitis(null, UserName.Text))
            {
                msg = "用户名已存在";
            }
            else
            {
                WMUsers user = new WMUsers();
                user.Id = General.UniqueString(user.Id);
                user.UserName = UserName.Text;
                user.Password = UserPassword.Text;
                user.RoleId = UserRole.SelectedValue.ToInt32();
                user.NickName = NickName.Text;
                user.Mobile = UserMobile.Text;
                user.Identity = UserIdentity.Text;
                user.BankAccount = UserBankAccount.Text;
                user.BankName = UserBankName.Text;
                user.BankCard = UserBankCard.Text;
                user.StatusId = UserState.SelectedValue.ToInt32();

                if (UserImageUpload.HasFile)
                {
                    string fileName = string.Format("/share/upload/user/{0}/face.jpg", user.Id);
                    Jumpcity.IO.FileUpload upload = new Jumpcity.IO.FileUpload("~" + fileName, 0, 0);
                    if (upload.Upload(UserImageUpload.PostedFile.InputStream))
                    {
                        user.Image = fileName;
                        UserImage.ImageUrl = upload.FileName;
                    }
                    else
                    {
                        msg = upload.ErrorMessage;
                        Helper.MessageBox(flag, msg);
                        return;
                    }
                }

                flag = user.Add();

                if (flag)
                {
                    //后台手动添加用户积分
                    int integarl = UserInte.Text.ToInt32();
                    if (integarl > 0)
                    {
                        WMUserIntegrals inte = new WMUserIntegrals();
                        inte.UserId = user.Id;
                        inte.Integral = integarl;
                        inte.SourceId = 452;
                        inte.Add();
                    }
                }
            }
        }

        Helper.MessageBox(flag, msg);
    }