public static void SellerView() { int choice; string input; Goods good; List <Goods> lgs = null; Console.WriteLine("欢迎店长{0}", Mostone.user.Name); while (true) { choice = ChoiceGuide("1、查看自属商品 2、查看所有商品 3、新增商品 4、修改商品信息 5、订单消息 6、查看账户 7、退出", 1, 7); switch (choice) { case 1: lgs = MySQLDemo.FindGoodsByOwner(Mostone.user); if (null != lgs) { foreach (Goods gd in lgs) { if (0 == gd.Nums) { gd.IsSale = false; MySQLDemo.UpdateGoods(gd); } } } DisplayList(lgs); break; case 2: DisplayList(MySQLDemo.FindAllGoods()); break; case 3: good = InputGoodsMess(new Goods(Mostone.user.Id)); MySQLDemo.InserGoods(good); break; case 4: while (true) { Console.Write("输入欲操作商品编号\n>>"); input = Console.ReadLine(); if (!StringRegular.RegularChecker(input, StringRegular.ALLNUM)) { Console.WriteLine("输入有误"); continue; } good = MySQLDemo.FindGoodsById(int.Parse(input)); if (null == good) { Console.WriteLine("输入有误"); continue; } break; } good = InputGoodsMess(good); MySQLDemo.UpdateGoods(good); break; case 5: OrderView(); break; case 6: Console.WriteLine("余额为:{0}", Mostone.user.Saves); break; case 7: Mostone.user = null; return; } } }
public static void BuyerView() { int choice; int temp = 0; int key; string input; Goods good; Console.WriteLine("欢迎顾客{0}", Mostone.user.Name); while (true) { choice = ChoiceGuide("1、浏览商品 2、购买商品 3、管理购物车 4、充值 5、查看余额 6、购买记录 7、退出", 1, 7); switch (choice) { case 1: DisplayList(MySQLDemo.FindAllGoods()); break; case 2: good = null; while (true) { Console.Write("输入欲购买商品编号\n>>"); input = Console.ReadLine(); if (!StringRegular.RegularChecker(input, StringRegular.ALLNUM)) { continue; } good = MySQLDemo.FindGoodsById(int.Parse(input)); if (null == good) { continue; } break; } while (true) { Console.Write("输入购买数量\n>>"); input = Console.ReadLine(); if (!StringRegular.RegularChecker(input, StringRegular.ALLNUM)) { continue; } if (int.Parse(input) < 0 || int.Parse(input) > good.Nums) { continue; } break; } key = MController.IsContain(good); if (key != -1) { temp = MController.GetTrolleyGoodsNums(good); Mostone.trolley.Remove(key); } good.Nums = int.Parse(input) + temp; Mostone.trolley.Add(Mostone.trolley.Count, good); break; case 3: TrolleyHandleView(); break; case 4: Console.Write("输入要充值的金额\n>>"); while (true) { input = Console.ReadLine(); if (!StringRegular.RegularChecker(input, StringRegular.ALLNUM) || !StringRegular.RegularChecker(input, StringRegular.ISFLOAT)) { Console.WriteLine("输入有误"); continue; } Mostone.user.Saves += double.Parse(input); MySQLDemo.UpdateUser(Mostone.user); break; } break; case 5: Console.WriteLine("余额为:{0}", Mostone.user.Saves); break; case 6: DisplayList(MySQLDemo.FindPurMessByBuyer((Buyer)Mostone.user)); break; case 7: Mostone.user = null; return; } } }