/// <summary> /// 添加新生 /// </summary> /// <param name="info">所有用户信息库</param> public static void AddStudent(this HeadTeacher ht) { Write("账号: "); string account = ReadLine(); if (account.Contains(" ") || account.Equals(string.Empty)) { throw new NullReferenceException("Account is Empty"); } if (Client.CheckAccountAvailability(account) != null) { DisplayTheInformationOfErrorCode(ErrorCode.AccountAlreadyExists, account); return; } Write("密码: "); string passwd = EnterPasswd(); if (passwd.Contains(" ") || passwd.Equals(string.Empty)) { throw new NullReferenceException("Passwd is Empty"); } Write("姓名: "); string name = ReadLine(); UserRepository.StudentLibrary.Add(new Student(account, passwd, name)); UserRepository.HeadTeacherUser.AddHistory(new Message("你", $"注册了一个学生账户({account})")); ht.ReleaseNewMsg(new Message("班主任", $"班里来了一位新同学({account}), 快去看看吧~")); DisplayTheInformationOfSuccessfully(); }
/// <summary> /// 添加/注册新老师 /// </summary> public static void AddTeacher(this HeadTeacher ht) { WriteLine("你想创建哪一科目的任课教师? (选择: 上/下方向键 确定: 回车键) "); #region 使用动态加载 //Subject result = new Selector<Subject>( // new List<String>() // { // "C语言任课老师", // "C++任课老师", // "C#任课老师", // "HTML/Css任课老师", // "Java任课老师", // "SQL数据库任课老师" // }, // new Subject[] // { // Subject.C, // Subject.CPlusPlus, // Subject.CSharp, // Subject.HtmlAndCss, // Subject.Java, // Subject.SQL // } // ).GetSubject(); #endregion dynamic dm = Client.GetSelectorObject( info: new List <string> { "C语言任课老师", "C++任课老师", "C#任课老师", "HTML/Css任课老师", "Java任课老师", "SQL数据库任课老师" }, selects: new[] { Subject.C, Subject.CPlusPlus, Subject.CSharp, Subject.HtmlAndCss, Subject.Java, Subject.Sql }) ?? throw new NullReferenceException(); Subject result = dm.GetSelect(); Write("账号: "); string account = ReadLine(); if (account.Contains(" ") || account.Equals(string.Empty)) { throw new NullReferenceException("Account is Empty"); } if (Client.CheckAccountAvailability(account) != null) { DisplayTheInformationOfErrorCode(ErrorCode.AccountAlreadyExists, account); return; } Write("密码: "); string passwd = EnterPasswd(); if (passwd.Contains(" ") || passwd.Equals(string.Empty)) { throw new NullReferenceException("Passwd is Empty"); } Write("姓名: "); string name = ReadLine(); WriteLine("此用户从哪一年开始从事该行业?"); Write("> "); if (!int.TryParse(ReadLine(), out int years)) { throw new ArgumentException(); } UserRepository.TeacherLibrary.Add(new Instructor(account, passwd, name, years, result)); UserRepository.HeadTeacherUser.AddHistory(new Message("你", $"注册了一个教师账户({account})")); ht.ReleaseNewMsg(new Message("班主任", $"班里来了一位新老师({account}), 快去看看吧~")); DisplayTheInformationOfSuccessfully(); }