Exemple #1
0
        public Department ChangeWorker(Department company)
        {
            var foundWorker = found.FoundWorker(company);

            Console.WriteLine("Select what you want change:\n" +
                              "WorkerID = 1," +
                              "WorkerSurName = 2," +
                              "WorkerPosition = 3," +
                              "WorkerSalary = 4");
            byte choiseMode = Enter.ChoiseMode();

            switch ((EnterDataEnum)choiseMode + 1)
            {
            case EnterDataEnum.WorkerID:
                for (int i = 0; i < foundWorker.Count - 1; i++)
                {
                    Worker work = company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]];
                    work.ID = Enter.EnterIntData(Convert.ToByte(choiseMode + 1));
                    company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]] = work;
                }
                break;

            case EnterDataEnum.WorkerSurName:
                for (int i = 0; i < foundWorker.Count - 1; i++)
                {
                    Worker work = company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]];
                    work.SurName = $"{Enter.EnterStringData(Convert.ToByte(choiseMode + 1))}";
                    company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]] = work;
                }
                break;

            case EnterDataEnum.WorkerPosition:
                for (int i = 0; i < foundWorker.Count - 1; i++)
                {
                    Worker work = company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]];
                    work.Position = $"{Enter.EnterStringData(Convert.ToByte(choiseMode + 1))}";
                    company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]] = work;
                }
                break;

            case EnterDataEnum.WorkerSalary:
                for (int i = 0; i < foundWorker.Count - 1; i++)
                {
                    Worker work = company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]];
                    work.Salary = Enter.EnterIntData(Convert.ToByte(choiseMode + 1));
                    company.Departments[foundWorker[0]].Workers[foundWorker[i + 1]] = work;
                }
                break;

            default:
                Console.WriteLine("Wrong data...");
                break;
            }
            return(company);
        }
Exemple #2
0
        public Department ChangeDepartment(Department company)
        {
            var foundDepartment = found.FoundDepartament(company);

            company.Departments[foundDepartment].DepartmentName = $"{Enter.EnterStringData(1)}";
            //update department data for employees
            for (int j = 0; j < company.Departments[foundDepartment].Workers.Count; j++)
            {
                Worker worker = company.Departments[foundDepartment].Workers[j];
                worker.Department = company.Departments[foundDepartment].DepartmentName;
                company.Departments[foundDepartment].Workers[j] = worker;
            }
            return(company);
        }
Exemple #3
0
        static public byte Select()
        {
            Console.WriteLine("Select an action:");
            Console.WriteLine(
                "Create department = 1,\n" +
                "Add new an empoyee = 2,\n" +
                "Change depertment details = 3,\n" +
                "Change employee details= 4,\n" +
                "Delete department = 5,\n" +
                "Delete employee = 6,\n" +
                "sorting employees only by age in all departments = 7,\n" +
                "sorting employees by age and salary in all departments = 8,\n" +
                "sorting employees by age and salary in each department = 9,\n" +
                "Import file in XML format = 10,\n" +
                "Import file in JSON format = 11,\n" +
                "Save file in XML format = 12,\n" +
                "Save file in JSON format = 13\n" +
                "Cancel = 0");
            byte choiseMode = Enter.ChoiseMode();

            return(choiseMode);
        }
Exemple #4
0
        public Department CreateNewWorker(Department company)
        {
            Found found = new Found();

            var foundDepartment = found.FoundDepartament(company);

            Console.WriteLine("Select a department to create an employee");
            foreach (var department in company.Departments)
            {
                Console.WriteLine(department.Print());
            }
            company.Departments[foundDepartment].Workers.Add(
                new Worker(
                    Enter.EnterIntData(2),                                        //ID
                    Enter.EnterStringData(6),                                     //firstname
                    Enter.EnterStringData(3),                                     //surname
                    Convert.ToByte(Enter.EnterIntData(7)),                        //age
                    $"Dep_{company.Departments[foundDepartment].DepartmentName}", //departmentName
                    Enter.EnterStringData(4),                                     //position
                    Enter.EnterIntData(5)                                         //salary
                    ));

            return(company);
        }
Exemple #5
0
 public Department CreateNewDepartment(byte byteEnterMode, Department company)
 {
     company.Departments.Add(new Department(Enter.EnterStringData(byteEnterMode)));
     return(company);
 }