/// <summary>
        /// добавление нового члена клуба
        /// </summary>
        /// <param name="berserkMembers">член клуба</param>
        public void AddNewMember(List <BerserkMembers> berserkMembers)
        {
            var flag = true;

            while (flag)
            {
                Console.WriteLine("Введите имя нового члена клуба:");
                string name = Console.ReadLine();
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentNullException("Имя не может быть пустым", nameof(name));
                }

                using (var db = new BerserkMembersDatabase())
                {
                    if (db.BerserkMembers.Any(n => n.BerserksName == name))
                    {
                        Console.WriteLine("Такое имя уже существует");
                    }
                    else
                    {
                        int monthPaymentSum = CashBoxPaymentsOperation.ParseInt("Введите сумму ежемесячного взноса");

                        BerserkMembers newMember = new BerserkMembers {
                            BerserksName = name, StartDebt = monthPaymentSum, StartDate = DateTime.Now, CurrentDate = DateTime.Now
                        };
                        berserkMembers.Add(newMember);
                        Console.WriteLine($"{name} добавлен в члены клуба");

                        db.BerserkMembers.Add(newMember);
                        db.SaveChanges();

                        flag = false;
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// общая текущая сумма в казне
 /// </summary>
 /// <param name="monthPaymentOperations">месячные клубные взносы</param>
 /// <param name="cashBox">операции по кассе</param>
 /// <param name="cashBoxPaymentsOperation">операции с БД по кассе</param>
 public void TotalSumInCashBox(BerserkMembersMonthPaymentOperations monthPaymentOperations, CashBox cashBox, CashBoxPaymentsOperation cashBoxPaymentsOperation)
 {
     using (var db = new CashBoxDatabase())
     {
         var monthDifference = cashBoxPaymentsOperation.MonthDifference(DateTime.Now);
         if (monthDifference > 0)
         {
             var previousMonthCashBoxSum = PreviousMonthCashBoxSum(monthPaymentOperations, cashBox.BaseCashBoxSum);
             CurrentMonthCashBoxSum(monthPaymentOperations, previousMonthCashBoxSum);
         }
         else
         {
             CurrentMonthCashBoxSum(monthPaymentOperations, cashBox.BaseCashBoxSum);
         }
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            var cashBox = new CashBox()
            {
                BaseCashBoxSum = 2500
            };
            var cashBoxReport             = new CashBoxReport();
            var cashBoxPaymentsOperation  = new CashBoxPaymentsOperation();
            var berserkMembersMonthReport = new BerserkMembersMonthReport();
            var berserkMembers            = new List <BerserkMembers>();

            var monthPaymentOperations   = new BerserkMembersMonthPaymentOperations();
            var add_RemoveBerserksMember = new Add_RemoveBerserkMembers();

            #region Инициализация объектами
            berserkMembers.Add(new BerserkMembers {
                BerserksName = "Ragnar", StartDebt = 250, CurrentDate = DateTime.Now, StartDate = DateTime.Now
            });
            berserkMembers.Add(new BerserkMembers {
                BerserksName = "Ottar", StartDebt = 250, CurrentDate = DateTime.Now, StartDate = DateTime.Now
            });
            berserkMembers.Add(new BerserkMembers {
                BerserksName = "Torbiorn", StartDebt = 250, CurrentDate = DateTime.Now, StartDate = DateTime.Now
            });
            berserkMembers.Add(new BerserkMembers {
                BerserksName = "Eivar", StartDebt = 150, CurrentDate = DateTime.Now, StartDate = DateTime.Now
            });
            using (var db = new BerserkMembersDatabase())
            {
                if (db.BerserkMembers.Count() == 0)
                {
                    db.BerserkMembers.AddRange(berserkMembers);
                    db.SaveChanges();
                }
            }
            #endregion

            bool flag = true;
            while (flag)
            {
                ConsoleColor color = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("1.Ежемесячный взнос  \t 2. Оплата мастерской  \t 3. Оплата общинного дома");
                Console.WriteLine("4. Другие расходы \t 5. Другие доходы \t 6. Баланс по людям");
                Console.WriteLine("7. Баланс по кассе \t 8. Добавить/удалить члена клуба \t 9. Выйти из программы");
                Console.WriteLine("--------------------------------");
                Console.WriteLine("Введите номер пункта:");
                Console.ForegroundColor = color;
                try
                {
                    int number = Convert.ToInt32(Console.ReadLine());

                    switch (number)
                    {
                    case 1:
                        monthPaymentOperations.GetMonthPayment(berserkMembers);
                        berserkMembersMonthReport.MembersPaymentsMonthReport(berserkMembers);
                        break;

                    case 2:
                        cashBoxPaymentsOperation.WorkshopRentalPayment(cashBox);
                        break;

                    case 3:
                        cashBoxPaymentsOperation.CommunityHouseRentalPayment(cashBox);
                        break;

                    case 4:
                        cashBoxPaymentsOperation.GetOtherExpenses(cashBox);
                        break;

                    case 5:
                        cashBoxPaymentsOperation.GetOtherIncomes(cashBox);
                        break;

                    case 6:
                        berserkMembersMonthReport.MembersPaymentsMonthReport(berserkMembers);
                        break;

                    case 7:
                        cashBoxReport.TotalSumInCashBox(monthPaymentOperations, cashBox, cashBoxPaymentsOperation);
                        break;

                    case 8:
                        add_RemoveBerserksMember.AddAndRemoveMembers(berserkMembers);
                        break;

                    case 9:
                        flag = false;
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    color = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = color;
                }
            }
        }