private void UserForm_Load(object sender, EventArgs e)
        {
            labelSurname.Text    = user.data_of_user.Surname;
            labelName.Text       = user.data_of_user.Name;
            labelPatronymic.Text = user.data_of_user.Patronymic;
            labelPassSer.Text    = user.data_of_user.Passport_series;
            labelPassNum.Text    = user.data_of_user.Passport_number;

            user.bank_account = userContext.GetBankAccountsToBindingList(user.Login);

            dataGridViewAccounts.DataSource         = user.bank_account;
            dataGridViewAccounts.Columns[0].Visible = false;
            dataGridViewAccounts.Columns[2].Visible = false;
            dataGridViewAccounts.Columns[4].Visible = false;
            dataGridViewAccounts.Columns[5].Visible = false;

            user.credit = userContext.GetCreditsToBindingList(user.Login);
            foreach (credit credit in user.credit)
            {
                double debt = CreditRegulator.СalculateDebt(credit);
                if ((debt > 0) && CreditRegulator.CheckImpositionOfFine(credit))
                {
                    MessageBox.Show("You are in arrears on the loan! You are fined in the amount of " + CreditRegulator.ImposeAFine(credit, debt).ToString());
                    userContext.UpdateUser(user);
                }
            }

            dataGridViewCredits.DataSource         = user.credit;
            dataGridViewCredits.Columns[0].Visible = false;
            dataGridViewCredits.Columns[1].Visible = false;
            dataGridViewCredits.Columns[2].Visible = false;
            dataGridViewCredits.Columns[7].Visible = false;
            dataGridViewCredits.Columns[8].Visible = false;

            viewUserDeposits();

            BindingList <bank_account> blAccountsWithoutDeposits = new BindingList <bank_account>(user.bank_account.Where(a => a.bank_deposit == null).ToList());

            dataGridViewAccountsWithoutDeposits.DataSource         = blAccountsWithoutDeposits;
            dataGridViewAccountsWithoutDeposits.Columns[0].Visible = false;
            dataGridViewAccountsWithoutDeposits.Columns[2].Visible = false;
            dataGridViewAccountsWithoutDeposits.Columns[4].Visible = false;
            dataGridViewAccountsWithoutDeposits.Columns[5].Visible = false;

            List <bank_deposit> userDeposits = user.bank_account.Where(a => a.bank_deposit != null).Select(d => d.bank_deposit).ToList();

            foreach (bank_deposit deposit in userDeposits)
            {
                if (AccountsAndDepositsRegulator.InterestAccrual(deposit))
                {
                    userContext.DeleteBankDeposit(deposit);
                    MessageBox.Show("The deposit period has expired! Deposit is closed! The account number of the deposit: " + deposit.bank_account.Number);
                }
                userContext.UpdateUser(user);
                viewUserDeposits();
            }
        }
        private void buttonMakePayment_Click(object sender, EventArgs e)
        {
            if (dataGridViewCredits.SelectedRows.Count > 0)
            {
                object[] accounts         = user.bank_account.Where(a => a.bank_deposit == null).Select(a => a.Number).ToArray();
                int      selectedCreditId = Convert.ToInt32(dataGridViewCredits.SelectedRows[0].Cells[0].Value);
                credit   selectedCredit   = user.credit.Where(c => c.id == selectedCreditId).FirstOrDefault();
                double   debt             = CreditRegulator.СalculateDebt(selectedCredit);
                double   recommendedPay   = CreditRegulator.CalculateRecommendedSumOfPayment(selectedCredit) + debt;
                double   fullyRepaySum    = CreditRegulator.CalculateSumForEarlyPayment(selectedCredit);

                CreditPayForm payForm = new CreditPayForm(accounts, debt, recommendedPay, fullyRepaySum);
                if (payForm.ShowDialog() == DialogResult.OK)
                {
                    string numberAccountFrom = payForm.comboBoxFrom.Text;
                    if (numberAccountFrom != "")
                    {
                        double sum;
                        if (payForm.textBoxSum != null && double.TryParse(payForm.textBoxSum.Text, out sum))
                        {
                            sum = Math.Round(sum, 1);
                            bank_account accountFrom = user.bank_account.Where(a => a.Number == numberAccountFrom).First();
                            if (CreditRegulator.PayForCredit(accountFrom, sum, selectedCredit))
                            {
                                userContext.UpdateUser(user);
                                dataGridViewCredits.Refresh();
                            }
                        }
                        else
                        {
                            MessageBox.Show("The sum entered is not correct!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The account is not selected!");
                    }
                }
                else
                {
                    MessageBox.Show("Credit is not selected!");
                }
            }
        }