Ejemplo n.º 1
0
 public AccountViewModel(Account account)
 {
     using (var db = new ClientsEntities())
     {
         var client = db.GetClientById(account.ClientID);
         _surname    = client?.Surname;
         _name       = client?.Name;
         _patronimic = client?.Patronimic;
         var depositType = db.GetDepositTypeById(account.DepositTypeID);
         _depositType   = depositType.Name;
         _accountNumber = account.AccountNumber;
         _moneyAmount   = account.MoneyAmount.ToString();
         _startDate     = account.StartDate;
         _endDate       = account.EndDate;
         _daysCount     = account.DaysCount.ToString();
         _percents      = depositType.Percents.ToString();
         _currency      = db.GetCurrencyById(account.CurrencyID);
         _isPercentage  = (account.PercentAccountID == null) ? "Да" : "Нет";
         if (account.PercentAccountID != null)
         {
             var percentAcc = db.GetAccountById(account.PercentAccountID.Value);
             _percentMoney = percentAcc.MoneyAmount.ToString();
         }
         _isClosed = account.IsClosed ? "Закрыт" : "Открыт";
     }
 }
Ejemplo n.º 2
0
 private void EndOfTermPayments(ClientsEntities db, List <Account> list)
 {
     foreach (var acc in list)
     {
         if ((acc.EndDate - acc.StartDate).Days + 1 == acc.DaysCount)
         {
             var percentAccount = db.GetAccountById(acc.PercentAccountID.Value);
             percentAccount.IsClosed = true;
             acc.IsClosed            = true;
             if (acc.DepositTypeID == 1 || acc.DepositTypeID == 2)
             {
                 acc.MoneyAmount += percentAccount.MoneyAmount;
                 var bankResources = db.BankResourse.ToList();
                 bankResources[0].RealMoney -= ConvertCurrencyToByn(acc.CurrencyID) * percentAccount.MoneyAmount;
             }
             if (acc.DepositTypeID == 3 || acc.DepositTypeID == 4)
             {
                 var bankResources = db.BankResourse.ToList();
                 bankResources[0].RealMoney += ConvertCurrencyToByn(acc.CurrencyID) * (percentAccount.MoneyAmount + acc.MoneyAmount);
                 acc.MoneyAmount             = 0;
             }
             percentAccount.MoneyAmount = 0;
         }
     }
     db.SaveChanges();
 }
Ejemplo n.º 3
0
        private void MoneyForMobileEntered(object sender, RoutedEventArgs e)
        {
            Button1.Click -= MoneyForMobileEntered;
            double sum;

            if (double.TryParse(InputTextBox.Text, out sum))
            {
                if (_account.MoneyAmount * ConvertCurrencyToByn(_account.CurrencyID) > sum)
                {
                    using (var db = new ClientsEntities())
                    {
                        var acc = db.GetAccountById(_account.AccountID);
                        acc.MoneyAmount -= sum / ConvertCurrencyToByn(_account.CurrencyID);
                        db.SaveChanges();
                        cash = sum;
                        MessageBox.Show("Оплата мобильной связи. Номер телефона: " + phoneNumber + "; Дата: " + DateTime.Now + "; Номер карты: " + _card.Number
                                        + "; Сумма на счёте: " + acc.MoneyAmount + "; Денег снято: " + cash + "BYN.");
                        MenuState();
                    }
                }
                else
                {
                    MessageBox.Show("На вашем счёте недостаточно средств.");
                    MenuState();
                }
            }
            else
            {
                MessageBox.Show("Введите корректную сумму.");
                EnteringMoneyForMobileState();
            }
        }
Ejemplo n.º 4
0
        private void CashAmountEntered(object sender, RoutedEventArgs e)
        {
            Button1.Click -= CashAmountEntered;
            double sum;

            if (double.TryParse(InputTextBox.Text, out sum))
            {
                if (_account.MoneyAmount * ConvertCurrencyToByn(_account.CurrencyID) > sum)
                {
                    using (var db = new ClientsEntities())
                    {
                        var acc = db.GetAccountById(_account.AccountID);
                        acc.MoneyAmount -= sum / ConvertCurrencyToByn(_account.CurrencyID);
                        db.SaveChanges();
                        cash = sum;
                        ShowMoneyAmountState();
                    }
                }
                else
                {
                    MessageBox.Show("На вашем счёте недостаточно средств.");
                    MenuState();
                }
            }
            else
            {
                MessageBox.Show("Введите корректную сумму.");
                GetCashState();
            }
        }
Ejemplo n.º 5
0
        private void CheckCardNumber(object sender, RoutedEventArgs e)
        {
            string text = InputTextBox.Text;

            if (IsDigitsOnly(text) && text.Length == 16)
            {
                using (var db = new ClientsEntities())
                {
                    _card = db.GetCardByNumber(text);
                    if (_card != null)
                    {
                        _account = db.GetAccountById(_card.AccountID);
                        WaitingForPINState();
                        Button1.Click -= CheckCardNumber;
                    }
                    else
                    {
                        InfoTextBox.Text = "Карта с таким номером не найдена.";
                    }
                }
            }
            else
            {
                InfoTextBox.Text = "Введите корректный номер карты.";
            }
        }
Ejemplo n.º 6
0
 private void IncrimentDaysCount(ClientsEntities db, List <Account> list)
 {
     foreach (var acc in list)
     {
         acc.DaysCount++;
         db.GetAccountById(acc.PercentAccountID.Value).DaysCount++;
     }
     db.SaveChanges();
 }
Ejemplo n.º 7
0
 private void CalculatePercents(ClientsEntities db, List <Account> list)
 {
     foreach (var acc in list)
     {
         var percents = (db.GetDepositTypeById(acc.DepositTypeID).Percents *acc.MoneyAmount) / (100 * 365);
         db.GetAccountById(acc.PercentAccountID.Value).MoneyAmount += Math.Round(percents, 4);
     }
     db.SaveChanges();
 }
Ejemplo n.º 8
0
 private void PrintCheque()
 {
     using (var db = new ClientsEntities())
     {
         var currency = db.GetCurrencyById(_account.CurrencyID);
         var acc      = db.GetAccountById(_account.AccountID);
         MessageBox.Show("Дата: " + DateTime.Now + "; Номер карты: " + _card.Number + "; Сумма на счёте: " + acc.MoneyAmount + "; Денег снято: " + cash + currency + ".");
     }
 }
Ejemplo n.º 9
0
 private void ShowMoneyAmountState()
 {
     InputTextBox.Text = string.Empty;
     using (var db = new ClientsEntities())
     {
         var acc = db.GetAccountById(_account.AccountID);
         InfoTextBox.Text = "Сумма средств: " + acc.MoneyAmount + ". Печатать чек?";
     }
     Button1.Content = "Да";
     Button1.Click  += PrintCheque;
     Button2.Content = "Нет";
     Button2.Click  += DontPrintCheque;
     Button3.Content = string.Empty;
 }
Ejemplo n.º 10
0
 private void CloseButton_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new ClientsEntities())
     {
         var mainAcc = db.GetAccountByAccountNumber(_account.AccountNumber);
         mainAcc.IsClosed = true;
         if (mainAcc.PercentAccountID.HasValue)
         {
             var percentAcc = db.GetAccountById(mainAcc.PercentAccountID.Value);
             percentAcc.MoneyAmount = 0;
             percentAcc.IsClosed    = true;
         }
         db.SaveChanges();
         this.Close();
     }
 }
Ejemplo n.º 11
0
        private void EndOfMonthPayments(ClientsEntities db, List <Account> list)
        {
            foreach (var acc in list)
            {
                if (acc.DaysCount % 30 == 0)
                {
                    var percentAccount = db.GetAccountById(acc.PercentAccountID.Value);
                    if (acc.DepositTypeID == 1)
                    {
                        acc.MoneyAmount += percentAccount.MoneyAmount;
                        var bankResources = db.BankResourse.ToList();
                        bankResources[0].RealMoney -= ConvertCurrencyToByn(acc.CurrencyID) * percentAccount.MoneyAmount;
                        percentAccount.MoneyAmount  = 0;
                    }

                    if (acc.DepositTypeID == 3)
                    {
                        var daysCount       = (acc.EndDate - acc.StartDate).Days + 1;
                        var mainAmount      = Convert.ToDouble(acc.MoneyAmount);
                        var percents        = mainAmount * db.GetDepositTypeById(acc.DepositTypeID).Percents / 100;
                        var percentsByDay   = Math.Round(percents / daysCount, 2);
                        var mainAmountByDay = Math.Round(mainAmount / daysCount, 2);
                        acc.MoneyAmount            -= mainAmountByDay * 30;
                        percentAccount.MoneyAmount -= percentsByDay * 30;
                        var bankResources = db.BankResourse.ToList();
                        bankResources[0].RealMoney += ConvertCurrencyToByn(acc.CurrencyID) * (percentsByDay + mainAmountByDay) * 30;
                    }

                    if (acc.DepositTypeID == 4)
                    {
                        var daysCount     = (acc.EndDate - acc.StartDate).Days + 1;
                        var mainAmount    = Convert.ToDouble(acc.MoneyAmount);
                        var percents      = mainAmount * db.GetDepositTypeById(acc.DepositTypeID).Percents / 100;
                        var percentsByDay = Math.Round(percents / daysCount, 2);
                        percentAccount.MoneyAmount -= percentsByDay * 30;
                        var bankResources = db.BankResourse.ToList();
                        bankResources[0].RealMoney += ConvertCurrencyToByn(acc.CurrencyID) * percentsByDay * 30;
                    }
                }
            }
            db.SaveChanges();
        }