Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
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);
    }