/// <summary> /// Кнопка продолжить /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonNext_Click(object sender, EventArgs e) { var salary = new TariffPayment { WorkingDaysInMonth = Int32.Parse(WorkingDaysBox.Text), DaysWorked = Int32.Parse(WorkedDaysBox.Text), Tariff = Decimal.Parse(CostBox.Text) }; OnSendDataFromFormEvent(new NachislatorEventArgs(salary)); Close(); }
/// <summary> /// Метод для ввода с клавиатуры /// </summary> /// <returns>з/п</returns> private static Worker InputSelection() { var worker = new Worker(); var validationWorkerActions = new List <Tuple <string, Action> >() { new Tuple <string, Action> ( "Имя: ", () => { worker.Name = Console.ReadLine(); } ), new Tuple <string, Action> ( "Фамилия: ", () => { worker.Surname = Console.ReadLine(); } ), new Tuple <string, Action> ( "Тип зарплаты\n" + "\t1 - Почасовая\n" + "\t2 - Оклад\n" + "\t3 - Ставка\n" + "Введите 1, 2 или 3: ", () => { switch (Console.ReadLine()) { case "1": { worker.TypeOfSalary = TypeOfSalary.HourlyPayment; break; } case "2": { worker.TypeOfSalary = TypeOfSalary.TariffPayment; break; } case "3": { worker.TypeOfSalary = TypeOfSalary.RatePayment; break; } default: { throw new ArgumentException("Вам нужно выбрать 1, 2 или 3"); } } } ), }; ActionForEach(validationWorkerActions); switch (worker.TypeOfSalary) { case TypeOfSalary.HourlyPayment: { var salary = new HourlyPayment(); var validationHourlyPaymentActions = new List <Tuple <string, Action> >() { new Tuple <string, Action> ( "Количество отработанных часов: ", () => { salary.HoursWorked = Int32.Parse(Console.ReadLine()); } ), new Tuple <string, Action> ( "Стоимость одного часа работы: ", () => { //так еще будет проверка на null //salary.CostPerHour = Convert.ToDecimal(Console.ReadLine()); salary.CostPerHour = Decimal.Parse(ConvertDecimalSeparator(Console.ReadLine())); } ) }; ActionForEach(validationHourlyPaymentActions); worker.Salary = salary.Salary; break; } case TypeOfSalary.RatePayment: { var salary = new RatePayment(); var validationHourlyPaymentActions = new List <Tuple <string, Action> >() { new Tuple <string, Action> ( "Количество отработанных дней: ", () => { salary.DaysWorked = Int32.Parse(Console.ReadLine()); } ), new Tuple <string, Action> ( "Стоимость одного дня работы: ", () => { salary.CostPerDay = Decimal.Parse(ConvertDecimalSeparator(Console.ReadLine())); } ) }; ActionForEach(validationHourlyPaymentActions); worker.Salary = salary.Salary; break; } case TypeOfSalary.TariffPayment: { var salary = new TariffPayment(); var validationTariffPaymentActions = new List <Tuple <string, Action> >() { new Tuple <string, Action> ( "Оклад: ", () => { salary.Tariff = Decimal.Parse(ConvertDecimalSeparator(Console.ReadLine())); } ), new Tuple <string, Action> ( "Введите номер месяца: ", () => { salary.WorkingDaysInMonth = GetBusinessDays(CheckMounthInput(Console.ReadLine())); Console.WriteLine($"Количество рабочих дней: {salary.WorkingDaysInMonth}"); //вывести сколько дней получилось } ), new Tuple <string, Action> ( "Количество отработанных дней (не больше чем рабочих): ", () => { salary.DaysWorked = Int32.Parse(Console.ReadLine()); } ), }; ActionForEach(validationTariffPaymentActions); worker.Salary = salary.Salary; break; } } return(worker); }