Example #1
0
 private void CheckIncorrectFunds(string operationName, out decimal operationSum,
                                  string accountType, ClientAllData clientAllData)
 {
     while (true)
     {
         CheckInput(operationName, out operationSum);
         if (operationSum > clientAllData.Balance && accountType == Balance)
         {
             Console.WriteLine($"\nВведенная сумма превышает баланс на счету\nНа балансе доступно {clientAllData.Balance}\n");
             continue;
         }
         else if (operationSum > clientAllData.Balance && accountType == Credit)
         {
             Console.WriteLine($"\nНедостаточно средств для погашения кредита\nДля погашения доступно {clientAllData.Balance}\n");
             continue;
         }
         else if (operationSum > clientAllData.Balance && accountType == Deposit)
         {
             Console.WriteLine($"\nНедостаточно средств на основном счету\nНа балансе доступно {clientAllData.Deposit}\n");
             continue;
         }
         else if (operationSum > clientAllData.Deposit && accountType == DepositTransfer)
         {
             Console.WriteLine($"\nНедостаточно средств на депозитном счету\nНа депозите доступно {clientAllData.Deposit}\n");
             continue;
         }
         break;
     }
 }
Example #2
0
        public CheckClient()
        {
            ClientAccess  key           = new ClientAccess();
            ClientAllData clientAllData = new ClientAllData();

            while (true)
            {
                Console.Write("Номер телефона - ");//0503127845
                string inputPhone  = Console.ReadLine();
                string formatPhone = string.Format("{0:(0##)###-##-##}", Convert.ToInt64(inputPhone));

                if (key.data.TryGetValue(formatPhone, out clientAllData) == false)
                {
                    Console.WriteLine($"Клиент по номеру {formatPhone} не найден");
                    continue;
                }

                while (true)
                {
                    Console.Write($"Введите пароль для аккаунта {formatPhone} - ");//12345
                    string password = Console.ReadLine();

                    if (password != clientAllData.Password)
                    {
                        Console.WriteLine("Неправильный пароль");
                        continue;
                    }
                    break;
                }
                Console.Clear();
                ClientUI clientUI = new ClientUI(clientAllData);
                break;
            }
        }
Example #3
0
        private decimal PutDeposit(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                if (clientAllData.Deposit == 0)
                {
                    Console.WriteLine("\nУ Вас нет депозита. Вы создаете депозитный счет под 15% годовых\n");
                }

                decimal yearPercent  = 0.15M;
                decimal sumAfterYear = 0;

                Console.WriteLine($"\nНа депозитном счету {clientAllData.Deposit}, на основном {clientAllData.Balance}\n");

                CheckIncorrectFunds("Сумма для депозита", out operationSum, Deposit, clientAllData);

                clientAllData.Deposit += operationSum;
                clientAllData.Balance -= operationSum;

                OperationBalanceEffect(clientAllData);

                sumAfterYear += clientAllData.Deposit * yearPercent + clientAllData.Deposit;

                Console.WriteLine($"\nНа депозите {clientAllData.Deposit}\nЧерез год сумма будет составлять {sumAfterYear}\n");
                break;
            }

            return(clientAllData.Deposit);
        }
        private decimal PutDeposit(ClientAllData clientAllData)
        {
            while (true)
            {
                if (clientAllData.Deposit == 0)
                {
                    Console.WriteLine("У Вас нет депозита. Вы создаете депозитный счет под 15% годовых\n");
                }

                decimal yearPercent  = 0.15M;
                decimal sumAfterYear = 0;

                Console.WriteLine($"На депозитном счету {clientAllData.Deposit}, на основном {clientAllData.Balance}");
                Console.Write("Сумма для депозита - ");

                var inputAmount = Console.ReadLine();

                decimal operationSum = 0;

                IncorrectFunds(inputAmount, out operationSum, operationSum, "Balance", clientAllData);

                clientAllData.Balance -= operationSum;
                clientAllData.Deposit += operationSum;
                sumAfterYear          += clientAllData.Deposit * yearPercent + clientAllData.Deposit;

                Console.WriteLine($"На депозите {clientAllData.Deposit}\nЧерез год сумма будет составлять {sumAfterYear}");
                break;
            }

            return(clientAllData.Deposit);
        }
        private decimal PayCreditMoney(ClientAllData clientAllData)
        {
            while (true)
            {
                if (clientAllData.Credit == 0)
                {
                    Console.WriteLine("У вас нет кредитной задолженности");
                    break;
                }

                Console.Write($"Ваш кредит {clientAllData.Credit}\nСумма для погашения - ");
                var inputAmount = Console.ReadLine();

                decimal operationSum = 0;

                IncorrectInput(inputAmount, out operationSum);

                clientAllData.Credit  -= operationSum;
                clientAllData.Balance -= operationSum;

                if (clientAllData.Credit <= 0)
                {
                    Console.WriteLine("Ваш кредит погашен");
                }
                else
                {
                    Console.WriteLine($"Внесено {operationSum}, остаток по кредиту {clientAllData.Credit}");
                }

                break;
            }

            return(clientAllData.Credit);
        }
        public ClientAccess()
        {
            ClientAllData allData = new ClientAllData();

            foreach (var item in allData.AddAllClientInfo())
            {
                data.Add(item.Phone, new ClientAllData(item.ClientID, item.Name, item.Surname, item.Birthday, item.Phone, item.InfoID, item.Balance, item.Credit, item.Deposit, item.Password, item.ManagerName, item.ManagerSurname, item.ManagerPhone));
            }
        }
        public ClientUI(ClientAllData clientAllData)
        {
            ClientOperations clientOperations = new ClientOperations();

            while (true)
            {
                Console.WriteLine("\n1. Информация про мой счет\n");
                Console.WriteLine("2. Операции с балансом\n");
                Console.WriteLine("3. Кредитные операции\n");
                Console.WriteLine("4. Операции с депозитом\n");
                Console.WriteLine("5. Выйти из программы\n");

                Console.Write("Выберите номер операции - ");
                string input = Console.ReadLine();

                switch (input)
                {
                case "1":
                    clientOperations.ShowMyAccount(clientAllData);
                    break;

                case "2":
                    clientOperations.BalanceOperation(clientAllData);
                    break;

                case "3":
                    clientOperations.CreditOperation(clientAllData);
                    break;

                case "4":
                    clientOperations.DepositOperation(clientAllData);
                    break;

                case "5":
                    Console.WriteLine("\nВсего доброго! До свидания!\n");
                    return;

                default:
                    Console.WriteLine("\nОперация не найдена\n");
                    break;
                }

                char proceedChar = 'д';
                Console.Write("Продолжить? (д/н) - ");
                string rerun = Console.ReadLine();
                Console.Clear();

                if (rerun == proceedChar.ToString())
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
        }
Example #8
0
        private decimal PutMoney(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                CheckInput("Сумма для зачисления", out operationSum);

                clientAllData.Balance += operationSum;
                Console.WriteLine($"\nНа счет внесено {operationSum}, сумма на счету {clientAllData.Balance}\n");
                break;
            }

            return(clientAllData.Balance);
        }
Example #9
0
        private decimal GetCredit(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                CheckInput("Сумма кредита", out operationSum);

                clientAllData.Credit += operationSum;
                Console.WriteLine($"\nВаша кредитная задолженность составляет {clientAllData.Credit}\n");
                break;
            }

            return(clientAllData.Credit);
        }
Example #10
0
        private decimal WithdrowDeposit(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                if (clientAllData.Deposit == 0)
                {
                    Console.WriteLine("\nНа депозитном счету 0. Пополните счет\n");
                    break;
                }
                else
                {
                    CheckIncorrectFunds($"Доступно {clientAllData.Deposit}\nСумма для снятия", out operationSum,
                                        DepositTransfer, clientAllData);

                    Console.WriteLine("\n1. Сумму снять\n2. Перевести на баланс\n");
                    Console.Write("Ваш выбор - ");
                    string input = Console.ReadLine();

                    switch (input)
                    {
                    case "1":
                        clientAllData.Deposit -= operationSum;
                        Console.WriteLine($"\nУспешно снята сумма в {operationSum}\nОстаток на депозите {clientAllData.Deposit}\n");
                        break;

                    case "2":
                        clientAllData.Deposit -= operationSum;
                        clientAllData.Balance += operationSum;

                        OperationBalanceEffect(clientAllData);

                        Console.WriteLine($"\nУспешно переведено на баланс {operationSum}\n" +
                                          $"На балансе {clientAllData.Balance}\nОстаток на депозите {clientAllData.Deposit}\n");
                        break;

                    default:
                        Console.WriteLine("\nПовторите ввод\n");
                        break;
                    }
                }
                break;
            }

            return(clientAllData.Deposit);
        }
        private decimal GetCredit(ClientAllData clientAllData)
        {
            while (true)
            {
                Console.Write("Сумма кредита - ");
                var inputAmount = Console.ReadLine();

                decimal operationSum = 0;

                IncorrectInput(inputAmount, out operationSum);

                clientAllData.Credit += operationSum;
                Console.WriteLine($"Ваша кредитная задолженность составляет {clientAllData.Credit}");
                break;
            }

            return(clientAllData.Credit);
        }
        private decimal PutMoney(ClientAllData clientAllData)
        {
            while (true)
            {
                Console.Write("Сумма для зачисления - ");
                var inputAmount = Console.ReadLine();

                decimal operationSum = 0;

                IncorrectInput(inputAmount, out operationSum);

                clientAllData.Balance += operationSum;
                Console.WriteLine($"На счет внесено {operationSum}, сумма на счету {clientAllData.Balance}");
                break;
            }

            return(clientAllData.Balance);
        }
Example #13
0
        private void WriteNewValueInDB(string columnName, decimal sum, ClientAllData clientAllData)
        {
            DBConnector connector = new DBConnector();

            string connStr = connector.GetConnectionString("Persons");
            string query   = null;

            using (SqlConnection connection = new SqlConnection(connStr))
            {
                connection.Open();

                query = $"update ClientInfo set {columnName} = {sum} where ID = {clientAllData.InfoID}";

                SqlCommand command = new SqlCommand(query, connection);

                command.ExecuteNonQuery();
            }
        }
        private decimal WithdrowDeposit(ClientAllData clientAllData)
        {
            while (true)
            {
                if (clientAllData.Deposit == 0)
                {
                    Console.WriteLine("На депозитном счету 0. Пополните счет");
                    break;
                }
                else
                {
                    Console.Write($"Доступно {clientAllData.Deposit}\nСумма для снятия - ");
                    var inputAmount = Console.ReadLine();

                    decimal operationSum = 0;

                    IncorrectFunds(inputAmount, out operationSum, operationSum, "Deposit", clientAllData);

                    Console.WriteLine("1. Сумму снять\n2. Перевести на баланс");
                    string input = Console.ReadLine();

                    switch (input)
                    {
                    case "1":
                        clientAllData.Deposit -= operationSum;
                        Console.WriteLine($"Успешно снята сумма в {operationSum}\nОстаток на депозите {clientAllData.Deposit}");
                        break;

                    case "2":
                        clientAllData.Deposit -= operationSum;
                        clientAllData.Balance += operationSum;
                        Console.WriteLine($"Успешно переведено на баланс {operationSum}\nНа балансе {clientAllData.Balance}\nОстаток на депозите {clientAllData.Deposit}");
                        break;

                    default:
                        Console.WriteLine("Повторите ввод");
                        break;
                    }
                }
                break;
            }

            return(clientAllData.Deposit);
        }
Example #15
0
        private decimal PayCreditMoney(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                if (clientAllData.Credit == 0)
                {
                    Console.WriteLine("\nУ вас нет кредитной задолженности\n");
                    break;
                }

                if (clientAllData.Balance == 0)
                {
                    Console.WriteLine("\nНа балансе 0, пополните счет\n");
                    break;
                }

                CheckIncorrectFunds($"Ваш кредит {clientAllData.Credit}\nДля погашения на балансе доступно " +
                                    $"{clientAllData.Balance}\nСумма для погашения",
                                    out operationSum, Credit, clientAllData);

                clientAllData.Credit  -= operationSum;
                clientAllData.Balance -= operationSum;

                OperationBalanceEffect(clientAllData);

                if (clientAllData.Credit <= 0)
                {
                    Console.WriteLine("\nВаш кредит погашен\n");
                }
                else
                {
                    Console.WriteLine($"\nВнесено {operationSum}, остаток по кредиту {clientAllData.Credit}\n");
                }

                break;
            }

            return(clientAllData.Credit);
        }
Example #16
0
        private decimal WithdrawMoney(ClientAllData clientAllData)
        {
            decimal operationSum = 0;

            while (true)
            {
                if (clientAllData.Balance == 0)
                {
                    Console.WriteLine("\nНа счету 0. Внесите средства\n");
                    break;
                }

                CheckIncorrectFunds("Сумма для снятия", out operationSum, Balance, clientAllData);

                clientAllData.Balance -= operationSum;
                Console.WriteLine($"\nСо счета снято {operationSum}, сумма на счету {clientAllData.Balance}\n");
                break;
            }

            return(clientAllData.Balance);
        }
Example #17
0
        public void DepositOperation(ClientAllData clientAllData)
        {
            Console.WriteLine("\n1. Положить деньги на депозит\n2. Снять деньги с депозита\n");
            Console.Write("Ваш выбор - ");
            string depositInput = Console.ReadLine();

            switch (depositInput)
            {
            case "1":
                WriteNewValueInDB(Deposit, PutDeposit(clientAllData), clientAllData);
                break;

            case "2":
                WriteNewValueInDB(Deposit, WithdrowDeposit(clientAllData), clientAllData);
                break;

            default:
                Console.WriteLine("Повторите ввод");
                break;
            }
        }
Example #18
0
        public void CreditOperation(ClientAllData clientAllData)
        {
            Console.WriteLine("\n1. Погасить кредит\n2. Взять кредит\n");
            Console.Write("Ваш выбор - ");
            string creditInput = Console.ReadLine();

            switch (creditInput)
            {
            case "1":
                WriteNewValueInDB(Credit, PayCreditMoney(clientAllData), clientAllData);
                break;

            case "2":
                WriteNewValueInDB(Credit, GetCredit(clientAllData), clientAllData);
                break;

            default:
                Console.WriteLine("Повторите ввод");
                break;
            }
        }
Example #19
0
        public void BalanceOperation(ClientAllData clientAllData)
        {
            Console.WriteLine("\n1. Начислить средства\n2. Снять средства\n");
            Console.Write("Ваш выбор - ");
            string balanceInput = Console.ReadLine();

            switch (balanceInput)
            {
            case "1":
                WriteNewValueInDB(Balance, PutMoney(clientAllData), clientAllData);
                break;

            case "2":
                WriteNewValueInDB(Balance, WithdrawMoney(clientAllData), clientAllData);
                break;

            default:
                Console.WriteLine("Повторите ввод");
                break;
            }
        }
        private decimal WithdrawMoney(ClientAllData clientAllData)
        {
            while (true)
            {
                if (clientAllData.Balance == 0)
                {
                    Console.WriteLine("На счету 0. Внесите средства");
                    break;
                }

                Console.Write("Сумма для снятия - ");
                var inputAmount = Console.ReadLine();

                decimal operationSum = 0;

                IncorrectFunds(inputAmount, out operationSum, operationSum, "Balance", clientAllData);

                clientAllData.Balance -= operationSum;
                Console.WriteLine($"Со счета снято {operationSum}, сумма на счету {clientAllData.Balance}");
                break;
            }

            return(clientAllData.Balance);
        }
 private void IncorrectFunds(string inputAmount, out decimal operationSum, decimal inputSum, string accountType, ClientAllData clientAllData)
 {
     IncorrectInput(inputAmount, out operationSum);
     if (inputSum > clientAllData.Balance && accountType == "Balance")
     {
         Console.WriteLine("Введенная сумма превышает баланс на счету");
     }
     else if (inputSum > clientAllData.Deposit && accountType == "Deposit")
     {
         Console.WriteLine("Недостаточно средств на депозитном счету");
     }
     else if (inputSum > clientAllData.Balance && accountType == "Balance")
     {
         Console.WriteLine("Недостаточно средств на основном счету");
     }
 }
Example #22
0
 private void OperationBalanceEffect(ClientAllData clientAllData)
 {
     WriteNewValueInDB(Balance, clientAllData.Balance, clientAllData);
 }
Example #23
0
 public void ShowMyAccount(ClientAllData clientAllData)
 {
     Console.WriteLine(new string('-', 50));
     Console.WriteLine($"\n{clientAllData.Intro()}\n");
     Console.WriteLine(new string('-', 50));
 }