///<summary>
        ///Внесение денег
        ///</summary>
        public void PaymentStory(float _summ, string _login)
        {
            SQLManager    _sqlManger = new SQLManager();
            string        date       = $"{DateTime.Now.Day.ToString()}.{DateTime.Now.Month.ToString()}.{DateTime.Now.Year.ToString()}";
            float         _toPlay    = 0.0f;
            SqlConnection _sqlConn   = new SqlConnection(_sqlManger.ConnectionString());

            _sqlConn.Open();
            if (_sqlConn.State == ConnectionState.Open)
            {
                SqlCommand    _sqlCmd = new SqlCommand($"select _summ from [Faridun].[dbo].[payment_list] where _login={_login}", _sqlConn);
                SqlDataReader _reader = _sqlCmd.ExecuteReader();
                while (_reader.Read())
                {
                    _toPlay = float.Parse(_reader.GetValue(0).ToString().Trim().Replace('.', ','));
                }
                _reader.Close();
                _sqlConn.Close();
            }

            _summ = _toPlay - _summ;
            _sqlManger.InsertData("payment_list", "_login, _date, _summ", $"{_login}, '{date}', {_summ}");
            if (_summ <= 0)
            {
                _sqlManger.UpdateData("users_application", "_is_payed=1", $"_login={_login}");
            }
        }
        ///<summary>
        ///Возвращает True если пользователь с заданым логином существует, иначе Else
        ///</summary>
        public bool isPreviouslyCreated(bool _admin)
        {
            string _query = string.Empty;

            if (_admin)
            {
                _query = $"select _name from [Faridun].[dbo].[admin_list_table] where _name='{username}'";
            }
            else
            {
                _query = $"select _name from [Faridun].[dbo].[users_list_table] where _name='{username}'";
            }
            bool          _created = false;
            int           _counted = 0;
            SqlConnection _sqlConn = new SqlConnection(_sqlManage.ConnectionString());

            _sqlConn.Open();
            if (_sqlConn.State == ConnectionState.Open)
            {
                SqlCommand    _sqlCmd = new SqlCommand(_query, _sqlConn);
                SqlDataReader _reader = _sqlCmd.ExecuteReader();
                while (_reader.Read())
                {
                    _counted++;
                }
                if (_counted > 0)
                {
                    _created = true;
                }
                else
                {
                    _created = false;
                }
                _reader.Close();
                _sqlConn.Close();
            }
            return(_created);
        }
        ///<summary>
        ///Возвращает кол-во кредитов
        ///</summary>
        public int CreditsCount()
        {
            int           _results    = 0;
            SQLManager    _sqlManager = new SQLManager();
            SqlConnection _sqlConn    = new SqlConnection(_sqlManager.ConnectionString());

            _sqlConn.Open();
            if (_sqlConn.State == ConnectionState.Open)
            {
                SqlCommand    _sqlCmd = new SqlCommand("select _status from [Faridun].[dbo].[users_application] where _status = 'OK'", _sqlConn);
                SqlDataReader _reader = _sqlCmd.ExecuteReader();
                while (_reader.Read())
                {
                    _results++;
                }
                _reader.Close();
                _sqlConn.Close();
            }
            return(_results);
        }
        ///<summary>
        ///Возвращает кол-во не оплаченных кредитов
        ///</summary>
        public int CreditArrearage()
        {
            int           _results    = 0;
            SQLManager    _sqlManager = new SQLManager();
            SqlConnection _sqlConn    = new SqlConnection(_sqlManager.ConnectionString());

            _sqlConn.Open();
            if (_sqlConn.State == ConnectionState.Open)
            {
                SqlCommand    _sqlCmd = new SqlCommand("select _summ from [Faridun].[dbo].[payment_list] where _summ != 0", _sqlConn);
                SqlDataReader _reader = _sqlCmd.ExecuteReader();
                while (_reader.Read())
                {
                    _results++;
                }
                _reader.Close();
                _sqlConn.Close();
            }
            return(_results);
        }
        ///<summary>
        ///Авторизация пользователя
        ///</summary>
        public void LoginOutput()
        {
            bool   _isAdmin = false;
            string _login   = string.Empty;

            while (_login != "/Назад/")
            {
                _login = Input("Логин (Номер телефона): ");
                string _password = string.Empty;
                if (_login == "/admin/")
                {
                    _isAdmin = true;
                }
                else
                {
                    _password = Input("Пароль: ");
                }

                if (_isAdmin)
                {
                    this.Output("Вы вошли в панель администратора!");
                    string         _adminLogin    = Input("Введите имя: ");
                    string         _adminPassword = Input("Введите пароль: ");
                    Authentication _auth          = new Authentication(_adminLogin, _adminPassword);
                    bool           _isLogged      = _auth.Login("admin_list_table");
                    if (_isLogged)
                    {
                        this.Output("Приветствую вас: " + _adminLogin);
                        this.AdminOutput();
                    }
                    else
                    {
                        this.Output("Не правильный логин или пароль!");
                    }
                }
                else
                {
                    Authentication _auth = new Authentication(_login, _password);
                    _auth.loginUser = int.Parse(_login);
                    bool _isLogged = _auth.Login("users_list_table");
                    if (_isLogged)
                    {
                        SQLManager    _sqlManger = new SQLManager();
                        SqlConnection _sqlConn   = new SqlConnection(_sqlManger.ConnectionString());
                        _sqlConn.Open();
                        if (_sqlConn.State == ConnectionState.Open)
                        {
                            SqlCommand    _sqlCmd         = new SqlCommand($"select _name from users_list_table where _login={_login}", _sqlConn);
                            SqlDataReader _reader         = _sqlCmd.ExecuteReader();
                            string        _loggedUserName = string.Empty;
                            while (_reader.Read())
                            {
                                _loggedUserName = _reader.GetValue(0).ToString().Trim();
                            }
                            this.Output("Приветствую вас: " + _loggedUserName);
                            this.UserOutput(_login);
                            _reader.Close();
                            _sqlConn.Close();
                        }
                    }
                    else
                    {
                        this.Output("Не правильный логин или пароль!");
                    }
                }
            }
        }
        ///<summary>
        ///Личный кабинет пользователя
        ///</summary>
        public void UserOutput(string _name)
        {
            this.Output("Панель пользователя(клиента):\t1.Просмотерть заявок\t2.Остаток кредитов\t3.Детали кредита в виде графика погашения\t4.Подать заявку\t0.Выход");
            string _cmd = string.Empty;

            while (_cmd != "0")
            {
                _cmd = this.Input("Выберите действие(1,2,3,0): ");
                SQLManager _sqlManger = new SQLManager();
                if (_cmd == "1")
                {
                    SqlConnection _sqlConn = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select _user_gender, _user_age, _married, _nationality, _credit_summ_from_general_revenue, _credit_aim, _credit_term, _results from [Faridun].[dbo].[users_application] where _login={_name}", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();
                        while (_reader.Read())
                        {
                            this.Output("Пол: " + _reader.GetValue(0).ToString().Trim());
                            this.Output("Возраст: " + _reader.GetValue(1).ToString().Trim());
                            this.Output("Семейное положение: " + _reader.GetValue(2).ToString().Trim());
                            this.Output("Гражданство: " + _reader.GetValue(3).ToString().Trim());
                            this.Output("Cумма кредита от общего дохода: " + _reader.GetValue(4).ToString().Trim());
                            this.Output("Цель кредита: " + _reader.GetValue(5).ToString().Trim());
                            this.Output("Срок кредита: " + _reader.GetValue(6).ToString().Trim());
                            this.Output("Результат: " + _reader.GetValue(7).ToString().Trim());
                        }
                        _reader.Close();
                        _sqlConn.Close();
                    }
                }
                else if (_cmd == "2")
                {
                    SqlConnection _sqlConn = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select _credit_summ_from_general_revenue, _credit_aim, _credit_term from [Faridun].[dbo].[users_application] where _is_payed = 0", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();
                        while (_reader.Read())
                        {
                            this.Output("Cумма кредита от общего дохода: " + _reader.GetValue(0).ToString().Trim());
                            this.Output("Цель кредита: " + _reader.GetValue(1).ToString().Trim());
                            this.Output("Срок кредита: " + _reader.GetValue(2).ToString().Trim());
                        }
                        _reader.Close();
                        _sqlConn.Close();
                    }
                }
                else if (_cmd == "3")
                {
                    SqlConnection _sqlConn = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select _user_gender, _user_age, _married, _nationality, _credit_summ_from_general_revenue, _credit_aim, _credit_term from [Faridun].[dbo].[users_application] where _login={_name} and _status='OK'", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();
                        while (_reader.Read())
                        {
                            this.Output("Пол: " + _reader.GetValue(0).ToString().Trim());
                            this.Output("Возраст: " + _reader.GetValue(1).ToString().Trim());
                            this.Output("Семейное положение: " + _reader.GetValue(2).ToString().Trim());
                            this.Output("Гражданство: " + _reader.GetValue(3).ToString().Trim());
                            this.Output("Cумма кредита от общего дохода: " + _reader.GetValue(4).ToString().Trim());
                            this.Output("Цель кредита: " + _reader.GetValue(5).ToString().Trim());
                            this.Output("Срок кредита: " + _reader.GetValue(6).ToString().Trim());
                        }
                        _reader.Close();
                        _sqlConn.Close();
                    }

                    _sqlConn = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select _date, _summ from [Faridun].[dbo].[payment_list] where _login={_name}", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();
                        while (_reader.Read())
                        {
                            this.Output("Дата: " + _reader.GetValue(0).ToString().Trim());
                            this.Output("Сумма: " + _reader.GetValue(1).ToString().Trim());
                        }
                        _reader.Close();
                        _sqlConn.Close();
                    }
                }
                else if (_cmd == "4")
                {
                    ApplicationInput(_name);
                }
            }
        }
        ///<summary>
        ///Панель администратора
        ///</summary>
        public void AdminOutput()
        {
            this.Output("Панель администратора:\t1.Просмотр заявок\t2.Просмотр клиентов\t0.Выход");
            string _cmd = string.Empty;

            while (_cmd != "0")
            {
                _cmd = this.Input("Выберите действие(1,2,0): ");
                if (_cmd == "1")
                {
                    string        _name      = this.Input("Введите логин(номер телефона) пользователя: ");
                    SQLManager    _sqlManger = new SQLManager();
                    SqlConnection _sqlConn   = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select _user_gender, _user_age, _married, _nationality, _credit_summ_from_general_revenue, _credit_aim, _credit_term, _results from [Faridun].[dbo].[users_application] where _login={_name}", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();

                        while (_reader.Read())
                        {
                            this.Output("Пол: " + _reader.GetValue(0).ToString().Trim());
                            this.Output("Возраст: " + _reader.GetValue(1).ToString().Trim());
                            this.Output("Семейное положение: " + _reader.GetValue(2).ToString().Trim());
                            this.Output("Гражданство: " + _reader.GetValue(3).ToString().Trim());
                            this.Output("Cумма кредита от общего дохода: " + _reader.GetValue(4).ToString().Trim());
                            this.Output("Цель кредита: " + _reader.GetValue(5).ToString().Trim());
                            this.Output("Срок кредита: " + _reader.GetValue(6).ToString().Trim());
                            this.Output("Результат: " + _reader.GetValue(7).ToString().Trim());
                        }

                        _reader.Close();
                        _sqlConn.Close();
                    }
                }
                else if (_cmd == "2")
                {
                    this.Output("Список всех клиентов: ");
                    SQLManager    _sqlManger = new SQLManager();
                    SqlConnection _sqlConn   = new SqlConnection(_sqlManger.ConnectionString());
                    _sqlConn.Open();
                    if (_sqlConn.State == ConnectionState.Open)
                    {
                        SqlCommand    _sqlCmd = new SqlCommand($"select * from [Faridun].[dbo].[users_list_table]", _sqlConn);
                        SqlDataReader _reader = _sqlCmd.ExecuteReader();

                        while (_reader.Read())
                        {
                            this.Output("ID: " + _reader.GetValue(0));
                            this.Output("Имя: " + _reader.GetValue(1));
                            this.Output("Логин (номер телнфона): " + _reader.GetValue(2));
                            this.Output("Пароль: " + _reader.GetValue(3));
                            this.Output("ДР: " + _reader.GetValue(4));
                            this.Output("Прописка: " + _reader.GetValue(5));
                            this.Output("Серия паспорта: " + _reader.GetValue(6));
                        }

                        _reader.Close();
                        _sqlConn.Close();
                    }
                }
            }
        }
        ///<summary>
        ///Проверка заявки клиента на получение кредита, True если одобрен, иначе Else
        ///</summary>
        public bool AcceptedToCredit()
        {
            int           _balls      = 0;
            SQLManager    _sqlManager = new SQLManager();
            SqlConnection _sqlConn    = new SqlConnection(_sqlManager.ConnectionString());

            _sqlConn.Open();
            if (_sqlConn.State == ConnectionState.Open)
            {
                SqlCommand    _sqlCmd      = new SqlCommand($"select _user_gender, _user_age, _married, _nationality, _credit_summ_from_general_revenue, _credit_history, _arrearage_in_credit_history, _credit_aim, _credit_term from [Faridun].[dbo].[users_application] where _login={_login}", _sqlConn);
                SqlDataReader _sqlReader   = _sqlCmd.ExecuteReader();
                string        _user_gender = string.Empty;
                int           _user_age    = 0;
                string        _married     = string.Empty;
                string        _nationality = string.Empty;
                int           _credit_summ_from_general_revenue = 0;
                int           _credit_history = 0;
                int           _arrearage_in_credit_history = 0;
                string        _credit_aim  = string.Empty;
                int           _credit_term = 0;
                while (_sqlReader.Read())
                {
                    _user_gender = _sqlReader.GetValue(0).ToString().Trim();
                    _user_age    = int.Parse(_sqlReader.GetValue(1).ToString());
                    _married     = _sqlReader.GetValue(2).ToString().Trim();
                    _nationality = _sqlReader.GetValue(3).ToString().Trim();
                    _credit_summ_from_general_revenue = int.Parse(_sqlReader.GetValue(4).ToString());
                    _credit_history = int.Parse(_sqlReader.GetValue(5).ToString());
                    _arrearage_in_credit_history = int.Parse(_sqlReader.GetValue(6).ToString());
                    _credit_aim  = _sqlReader.GetValue(7).ToString().Trim();
                    _credit_term = int.Parse(_sqlReader.GetValue(8).ToString());
                }
                _sqlReader.Close();
                _sqlConn.Close();
                if (_user_gender == "муж")
                {
                    _balls++;
                }
                else if (_user_gender == "жен")
                {
                    _balls += 2;
                }

                if (_married == "холост")
                {
                    _balls++;
                }
                else if (_married == "семеянин")
                {
                    _balls += 2;
                }
                else if (_married == "вразводе")
                {
                    _balls++;
                }
                else if (_married == "вдовец/вдова")
                {
                    _balls += 2;
                }


                if (_user_age < 25)
                {
                    _balls += 0;
                }
                else if (_user_age >= 25 || _user_age <= 35)
                {
                    _balls++;
                }
                else if (_user_age >= 36 || _user_age <= 62)
                {
                    _balls += 2;
                }
                else if (_user_age >= 63)
                {
                    _balls++;
                }

                if (_nationality == "Таджикистан")
                {
                    _balls++;
                }
                else if (_nationality == "Зарубеж")
                {
                    _balls += 0;
                }

                if (_credit_summ_from_general_revenue < 80)
                {
                    _balls += 4;
                }
                else if (_credit_summ_from_general_revenue >= 80 || _credit_summ_from_general_revenue <= 150)
                {
                    _balls += 3;
                }
                else if (_credit_summ_from_general_revenue > 150 || _credit_summ_from_general_revenue <= 250)
                {
                    _balls += 2;
                }
                else if (_credit_summ_from_general_revenue > 250)
                {
                    _balls += 1;
                }

                if (_credit_history > 3)
                {
                    _balls += 2;
                }
                else if (_credit_history == 1 || _credit_history == 2)
                {
                    _balls++;
                }
                else if (_credit_history == 0)
                {
                    _balls -= 1;
                }

                if (_arrearage_in_credit_history > 7)
                {
                    _balls -= 3;
                }
                else if (_arrearage_in_credit_history >= 5 || _arrearage_in_credit_history <= 7)
                {
                    _balls -= 2;
                }
                else if (_arrearage_in_credit_history == 4)
                {
                    _balls -= 1;
                }
                else if (_arrearage_in_credit_history < 3)
                {
                    _balls += 0;
                }


                if (_credit_aim == "бытовая техника")
                {
                    _balls += 2;
                }
                else if (_credit_aim == "ремонт")
                {
                    _balls++;
                }
                else if (_credit_aim == "телефон")
                {
                    _balls += 0;
                }
                else if (_credit_aim == "прочее")
                {
                    _balls -= 1;
                }

                if (_credit_term > 12 || _credit_term <= 12)
                {
                    _balls++;
                }
            }

            if (_balls > 11)
            {
                _sqlManager.UpdateData("users_application", $"_balls={_balls}, _status='OK'", $"_login={_login}");
                return(true);
            }
            else
            {
                _sqlManager.UpdateData("users_application", $"_balls={_balls}, _status='DISOK'", $"_login={_login}");
                return(false);
            }
        }