Beispiel #1
0
        private static DateTime GetStartDate()
        {
            StandardMessage.EnterFromDate();
            DateTime dateStart = ValidInputValue.GetDate();

            return(dateStart);
        }
Beispiel #2
0
        private static DateTime GetFinishDate()
        {
            StandardMessage.EnterToDate();
            DateTime dateFinish = ValidInputValue.GetDate();

            return(dateFinish);
        }
Beispiel #3
0
        public static void AskToContinue(IMember member)
        {
            StandardMessage.Continue();
            string answer = Console.ReadLine().ToLower();

            switch (answer)
            {
            case "y":
            {
                if (member.Post == "header")
                {
                    HeaderTypeOfAction.ChooseAction(member);
                }
                else
                {
                    TypeOfAction.ChooseAction(member);
                }
                break;
            }

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

            default:
                ErrorMessage.InputAnswerIsNotCorrect();
                AskToContinue(member);
                break;
            }
        }
Beispiel #4
0
        public static void ReadMemberReport()
        {
            HeaderMessage.EnterNameOfMember();
            string name = ValidInputValue.GetName();

            foreach (var member in ReaderMembersAndReports.members)
            {
                if (member.Name == name)
                {
                    StandardMessage.ReportForPeriod();

                    foreach (var report in ReaderMembersAndReports.reportOfMembers)
                    {
                        string[] dataOfReport = report.Split(new char[] { ',' });

                        if (dataOfReport[1].Contains(member.Name))
                        {
                            CalcSalary.GetSalaryOfMember(member);
                        }
                    }
                    StandardMessage.MemberHoursAndSalaryForPeriod(member);
                    return;
                }
            }

            ErrorMessage.MemberIsNotExists();
            ReadMemberReport();
        }
        public static void InitializeMember()
        {
            StandardMessage.EnterName();
            string inputName = ValidInputValue.GetName();

            foreach (var member in ReaderMembersAndReports.members)
            {
                //DataOfMember.GetDataOfMember(person);
                if (member.Name == inputName)
                {
                    IMember person = CreateModel(member);
                    Console.Clear();
                    if (person.Post == "header")
                    {
                        HeaderTypeOfAction.ChooseAction(person);
                    }
                    else
                    {
                        TypeOfAction.ChooseAction(person);
                    }

                    return;
                }
            }

            ErrorMessage.MemberIsNotExists();
            InitializeMember();
        }
Beispiel #6
0
        public static void AddHoursForMember()
        {
            HeaderMessage.EnterNameOfMember();
            string name = ValidInputValue.GetName();

            foreach (var memb in ReaderMembersAndReports.members)
            {
                if (memb.Name == name)
                {
                    StandardMessage.EnterDateToAddHours();
                    DateTime enterDate = ValidInputValue.GetDate();
                    ReportWriter.Date = enterDate.ToShortDateString();

                    StandardMessage.EnterAmountOfHours();
                    ReportWriter.Hours = ValidInputValue.GetHours();

                    HeaderMessage.EnterWhatMemberDid();
                    ReportWriter.Doing = Console.ReadLine();

                    ReportWriter.WriteHoursOfMember(name, memb.Post);
                    return;
                }
            }

            ErrorMessage.MemberIsNotExists();
            AddHoursForMember();
        }
        public static void AddHours(IMember member)
        {
            bool isDateCorrect = false;

            while (!isDateCorrect)
            {
                StandardMessage.EnterDateToAddHours();
                DateTime enterDate = ValidInputValue.GetDate();
                ReportWriter.Date = enterDate.ToShortDateString();

                if (member.Post == "freelancer")
                {
                    isDateCorrect = DateTime.Now.AddDays(-3) < enterDate && enterDate < DateTime.Now;

                    if (!isDateCorrect)
                    {
                        ErrorMessage.CanNotAddHoursBeforeTwoDays();
                        continue;
                    }
                }
                else
                {
                    isDateCorrect = true;
                }
            }

            StandardMessage.EnterAmountOfHours();
            ReportWriter.Hours = ValidInputValue.GetHours();

            StandardMessage.EnterWhatYouDid();
            ReportWriter.Doing = Console.ReadLine();

            ReportWriter.WriteHoursOfMember(member.Name, member.Post);
        }
Beispiel #8
0
        public static void ChooseAction(IMember member)
        {
            Console.Clear();

            StandardMessage.GreetMessageForEmpAndFreelan(member);
            int act = int.Parse(Console.ReadLine());

            Console.Clear();
            switch (act)
            {
            case 1:
                AddingHours.AddHours(member);
                Continue.AskToContinue(member);
                break;

            case 2:
                ReadingReport.ReadReportAndSalary(member);
                Continue.AskToContinue(member);
                break;

            case 3:
                Environment.Exit(0);
                break;

            default:
                ErrorMessage.WrongAction();
                break;
            }
        }
        public static void ReadReportAndSalary(IMember member)
        {
            StandardMessage.ReportForPeriod();

            CalcSalary.GetSalaryOfMember(member);

            StandardMessage.TotalHoursAndSalary(member);
        }
Beispiel #10
0
        static public void ReadAllReport()
        {
            StandardMessage.ReportForPeriod();

            foreach (var member in ReaderMembersAndReports.members)
            {
                foreach (var report in ReaderMembersAndReports.reportOfMembers)
                {
                    string[] dataOfReport = report.Split(new char[] { ',' });

                    if (dataOfReport[1].Contains(member.Name))
                    {
                        CalcSalary.GetSalaryOfMember(member);
                    }
                }
                StandardMessage.MemberHoursAndSalaryForPeriod(member);
            }
        }
        public static void WriteHoursOfMember(string name, string post)
        {
            string path = null;

            switch (post)
            {
            case "header":
                path = Path.toHoursOfHeaders;
                break;

            case "employee":
                path = Path.toHoursOfEmployees;
                break;

            case "freelancer":
                path = Path.toHoursOfFreelancers;
                break;
            }
            using (StreamWriter sr = new StreamWriter(path, true))
            {
                sr.WriteLine($"{Date},{name},{Hours},{Doing}");
                StandardMessage.HoursAdded();
            }
        }