예제 #1
0
 public static BillingSystem Get()
 {
     if (_bs == null)
     {
         _bs = new BillingSystem();
     }
     return(_bs);
 }
예제 #2
0
 public AccountCredit(Terminal terminal, string firstName, string secondName)
 {
     Terminal   = terminal;
     FirstName  = firstName;
     SecondName = secondName;
     Calls      = new List <CallInfo>();
     BillingSystem.Get().ChangeDateEvent += CheckBalance;
     BlockForDebtEvent += Terminal.TerminalBlock;
     UnBlockEvent      += Terminal.TerminalUnBlock;
 }
예제 #3
0
 private void CheckBalance(object o, EventArgs e)
 {
     if (BillingSystem.Get().CurrentDate.Day == 1)
     {
         DateTime LastMonth = BillingSystem.Get().CurrentDate.AddMonths(-1);
         LastMonthDebt = SumForPeriod(new DateTime(LastMonth.Year, LastMonth.Month, 1), new DateTime(LastMonth.Year, LastMonth.Month, BillingSystem.Get().CurrentDate.AddDays(-1).Day));
     }
     if (BillingSystem.Get().CurrentDate.Day == 25 && LastMonthDebt > 0)
     {
         BlockForDebtEvent?.Invoke(this, e);
     }
 }
예제 #4
0
 public void SetTariff(double pricePerSecond, int freeMinutes)
 {
     if ((BillingSystem.Get().CurrentDate - DateSignTariff).Days > 30)
     {
         PricePerSecond = pricePerSecond;
         FreeMinutes    = freeMinutes;
         DateSignTariff = BillingSystem.Get().CurrentDate;
     }
     else
     {
         Console.WriteLine("You have already changed tarif this month!");
     }
 }