public static void InputCustomerInfo(Customer c, out bool b1, out bool b2) { Console.WriteLine("请再次输入用户名!"); c.Name = Console.ReadLine(); b1 = AccountManagement.FindAccountByName(c, c.Name); Console.WriteLine("请输入密码!"); c.Pwd = Console.ReadLine(); b2 = AccountManagement.FindAccountById(c, c.Pwd); }
public static void InputSellerInfo(Seller s, out bool b1, out bool b2) { Console.WriteLine("请再次输入用户名!"); s.Name = Console.ReadLine(); b1 = AccountManagement.FindAccountByName(s, s.Name); Console.WriteLine("请输入密码!"); s.Pwd = Console.ReadLine(); b2 = AccountManagement.FindAccountById(s, s.Pwd); }
static void Main(string[] args) { Console.WriteLine("welcome~"); while (true) { Console.WriteLine("请选择用户类型:1--商家 2--顾客 3--其他键退出"); string choice = Console.ReadLine(); if (choice == "1") { Console.Clear();//清屏 Console.WriteLine("商家您好!欢迎使用本系统!"); while (true) { Console.WriteLine("请选择:1--注册 2--登录 3--其他键退出"); Seller s = new Seller(); string ch = Console.ReadLine(); if (ch == "1")//商家注册 { AccountManagement.Open(s); } else if (ch == "2")//商家登录 { bool b = Log.Login(s); if (b) { Service.Ser(s);//去选择服务项目 break; } else { AccountManagement.Open(s);//注册新账号 } } else { break; } } } else if (choice == "2") { Console.Clear();//清屏 Console.WriteLine("顾客您好!欢迎使用本系统!"); while (true) { Console.WriteLine("请选择:1--注册 2--登录 3--其他键退出"); Customer c = new Customer(); string ch = Console.ReadLine(); if (ch == "1") { AccountManagement.Open(c); } else if (ch == "2") { Console.WriteLine("请输入用户名!"); string name = Console.ReadLine(); c = AccountManagement.GetCustomer(name); bool b = Log.Login(c); if (b) //顾客登录成功 { Service.Ser(c); //去选择服务项目 break; } else { AccountManagement.Open(c);//注册新账号 } } else { break; } } } else { break; } } }
public static void Open(object o)//注册账户 { if (o is Seller) { Seller s = (Seller)o; Console.WriteLine("请输入用户名,20个字符以内"); s.Name = Console.ReadLine(); bool b = AccountManagement.FindAccountByName(s, s.Name); if (b) { Console.WriteLine("用户名已存在,请重新输入!"); s.Name = Console.ReadLine(); b = AccountManagement.FindAccountByName(s, s.Name); } else { Console.WriteLine("用户名合法!"); } Console.WriteLine("请输入密码,20个字符以内"); string s1 = Console.ReadLine(); Console.WriteLine("请再输入一次密码!"); string s2 = Console.ReadLine(); if (s1 != s2) { Console.WriteLine("两次密码不一致,请重新输入!"); s2 = Console.ReadLine(); } else { s.Pwd = s2; } Console.WriteLine("请输入初始账户金额!"); s.Balance = Convert.ToDouble(Console.ReadLine()); bool b1 = AddAccount(s); } else if (o is Customer) { Customer c = (Customer)o; Console.WriteLine("请输入用户名,20个字符以内"); c.Name = Console.ReadLine(); bool b = AccountManagement.FindAccountByName(c, c.Name); if (b) { Console.WriteLine("用户名已存在,请重新输入!"); c.Name = Console.ReadLine(); b = AccountManagement.FindAccountByName(c, c.Name); } else { Console.WriteLine("用户名合法!"); } Console.WriteLine("请输入密码,20个字符以内"); string s1 = Console.ReadLine(); Console.WriteLine("请再输入一次密码!"); string s2 = Console.ReadLine(); if (s1 != s2) { Console.WriteLine("两次密码不一致,请重新输入!"); s2 = Console.ReadLine(); } else { c.Pwd = s2; } Console.WriteLine("请输入初始账户金额!"); c.Balance = Convert.ToDouble(Console.ReadLine()); bool b1 = AddAccount(c); } }
public static void SerCustomer(Customer c, string choice) { while (true) { if (choice == "1")//个人信息管理 { while (true) { Console.WriteLine("请选择:1--修改用户名 2--修改密码 3--退出"); string ss = Console.ReadLine(); if (ss == "1") { Console.WriteLine("请输入修改后的用户名"); string name = Console.ReadLine(); if (AccountManagement.UpdateAccountByName(c, name)) { Console.WriteLine("用户名修改成功!"); } else { Console.WriteLine("用户名修改失败!"); } } else if (ss == "2") { Console.WriteLine("请输入修改后的密码"); string pwd = Console.ReadLine(); if (AccountManagement.UpdateAccountByPwd(c, pwd)) { Console.WriteLine("密码修改成功!"); } else { Console.WriteLine("密码修改失败!"); } } else { break; } } } else if (choice == "2")//购物车管理 { Shopping.ShowAllGoods(); while (true) { Console.WriteLine("请选择:1--添加购物信息 2--删除购物信息 3--更改购物信息 4--查看购物信息 5--退出"); string ss = Console.ReadLine(); if (ss == "1") { Console.WriteLine("请输入购买商品的名字和数量,以分号隔开"); string s1 = Console.ReadLine(); string[] p = s1.Split(','); string shoppingName = p[0]; //得到商品的名字 int nums = Convert.ToInt32(p[1]); //得到商品的数量 if (Shopping.AddShoppingByName(c, shoppingName, nums)) { Console.WriteLine("商品添加成功!"); } else { Console.WriteLine("商品添加失败!"); } } else if (ss == "2") { Console.WriteLine("请输入删除的商品"); string name = Console.ReadLine(); if (Shopping.DelShoppingByName(c, name)) { Console.WriteLine("商品删除成功!"); } else { Console.WriteLine("商品删除失败!"); } } else if (ss == "3") { Console.WriteLine("请输入更改的商品的名字和数量,以分号隔开"); string s1 = Console.ReadLine(); string[] p = s1.Split(','); string name = p[0]; //得到商品的名字 int nums = Convert.ToInt32(p[1]); //得到商品的数量 if (Shopping.UpdateShoppingByName(c, name, nums)) { Console.WriteLine("商品信息更新成功!"); } else { Console.WriteLine("商品信息更新失败!"); } } else if (ss == "4") { Console.WriteLine("请输入查询的商品名称"); string name = Console.ReadLine(); if (Shopping.SelecteShoppingByName(c, name)) { Console.WriteLine("商品查询成功!"); } else { Console.WriteLine("商品查询失败!"); } } else if (ss == "5") { break; } } } else if (choice == "3") { //订单计算 } //else //{ // break; //} } }