• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
阳光DE我
博客园    首页    新随笔    联系   管理    订阅  订阅

刚写的学生管理系统,不好请指正

static void Main(string[] args)
        {
            Console.WriteLine("欢迎使用学生管理系统,为确保你是教师身份,请输入密匙。");
                     string  ms = Console.ReadLine();
            mishi(ms);
            Console.ReadKey();
        }
        static bool mishi(string s)
        {
           
            bool mishi =false  ;
            while (mishi == false)
            {
                if (s == "123")
                { mishi = true; xuesheng(mishi); break; }
                else
                {
                    Console.WriteLine("真不好意思,你不是教师,本系统不能为你服务!");
                    Console.WriteLine("请重新输入密匙");
                    s = Console.ReadLine();
                    mishi = false;
                }
            }
        return mishi;
        }
        static void   xuesheng(bool mishi)
        {
            Console.WriteLine("老师好,你现在可以使用学生管理系统了。");
            Console.WriteLine("1:没有账号,请先注册教师账号!");
            Console.WriteLine("2:我有账号,请先使用账号登陆!");
            Console.WriteLine("3:时机尚未成熟。放弃使用系统!");
            Console.WriteLine("<------选择操作选项------>");
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine("<------选择操作完毕------>");
            switch (a)
            {
                case 1: zhuche(); denglu(); break;
                case 2: denglu(); break;
                case 3: break;
      }
        }
        static void zhuche()
        {
            Console.WriteLine("<------注册教师信息------>");
            Console.WriteLine("请在下一行写入你的信息,格式为‘姓名-密码-格式’");
            string zh = Console.ReadLine();
            bool xp=false;
            while (xp == false )
            {  string path = @"e:\a\tea.txt";
               string[] xx = zh.Split('-');
                foreach(string x in xx )
                {
                    //限制空值
                    if (x == "")
                    {
                        Console.WriteLine("格式不正确,请严格按照‘姓名-密码-格式’,重新输入");
                       
                    }
                }
   // Open the file to read from.
                    string[] readText = File.ReadAllLines(path);
                    foreach (string s in readText)
                    {
                        if (zh == s)
                        {
                            Console.WriteLine("用户名以存在");
                            Console.WriteLine("请在下一行填写你的信息,格式如‘姓名-密码-格式’");
                            zh = Console.ReadLine();
                        }
                        else
                        {
                            xp = true;  using (StreamWriter sw = File.AppendText(path))
                            {
                                sw.Write(sw.NewLine);//换行
                                sw.WriteLine("{0}",zh);
                               
                            }

                            Console.WriteLine("注册成功");
                            Console.WriteLine("<------注册教师完毕------>"); break;
                        }

                     }
       
                  }

        }
        static void denglu()
        {
                Console.WriteLine("<------教师登陆验证------->");
            string zh = Console.ReadLine();
            string path = @"e:\a\tea.txt";
             // Open the file to read from.
                string[] readText = File.ReadAllLines(path);
                foreach (string s in readText)
                {
                    if (zh == s)
                    {
                        denglu1(zh );
                    }
                    else { }
                }
           
          
                Console.WriteLine("登陆结束");
            }
        static void denglu1(string zh)
        {
            string path = @"e:\a\tea.txt";
            string[] readText = File.ReadAllLines(path);
            Console.WriteLine("<------登陆验证完毕------->");
            Console.WriteLine("欢迎进入简易成绩管理系统");
            string[] xx = zh.Split('-');
            Console.WriteLine("---------------------------");
            for (int i = 0; i < readText.Length; i++)
            {
                Console.WriteLine("姓名:{0}", xx[0]);
                Console.WriteLine("密码:{0}", xx[1]);
                Console.WriteLine("课程:{0}", xx[2]); break;
            }
            Console.WriteLine("---------------------------");
        }
        }
    }

 

posted @ 2009-04-27 20:45  阳光DE我  阅读(214)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3