示例#1
0
        public void Initialize()
        {
            Console.WriteLine("Введите ваше имя:");
            name = Actions.ToUpperName();
            if (Actions.SearchNameForInitialize(name, Actions.PathEmployees))
            {
                string employees;

                using (StreamReader sr = new StreamReader(Actions.PathEmployees))
                {
                    while ((employees = sr.ReadLine()) != null)
                    {
                        string[] firstWord = employees.Split(new char[] { ',' });
                        if (name == firstWord[0])
                        {
                            if (employees.Contains(name) && employees.Contains(post = "header"))
                            {
                                sr.Close();
                                Header header = new Header(name, post);
                                header.Greet();
                                break;
                            }
                            else if (employees.Contains(name) && employees.Contains(post = "employee"))
                            {
                                sr.Close();
                                Employee employee = new Employee(name, post);
                                employee.Greet();
                                break;
                            }
                            else if (employees.Contains(name) && employees.Contains(post = "freelancer"))
                            {
                                sr.Close();
                                Freelancer freelancer = new Freelancer(name, post);
                                freelancer.Greet();
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Такого сотрудника не существует. Повторите попытку.");
                Initialize();
            }
        }
示例#2
0
        static public void ContinueOrExite(string act)
        {
            switch (act.ToLower())
            {
            case "y":
            {
                if (Initialization.post == "header")
                {
                    Header header = new Header(Initialization.name, Initialization.post);
                    header.Greet();
                    break;
                }
                else if (Initialization.post == "employee")
                {
                    Employee employee = new Employee(Initialization.name, Initialization.post);
                    employee.Greet();
                    break;
                }
                else
                {
                    Freelancer freelancer = new Freelancer(Initialization.name, Initialization.post);
                    freelancer.Greet();
                    break;
                }
            }

            case "n":
            {
                Environment.Exit(0);
                break;
            }

            default:
            {
                Console.WriteLine("Некорректный ввод! Попробуйте еще раз.");
                act = Console.ReadLine();
                ContinueOrExite(act);
                break;
            }
            }
        }