Exemplo n.º 1
0
 public void AddClient(AClient client)
 {
     if (client.Account == default(long) || client.Amount == default)
     {
         throw new UnfilledInstanceExeption();
     }
     Clients.Add(client);
 }
 public Credit(AClient Holder, SqlMoney Amount, int Month = 12)
 {
     this.Holder = Holder;
     Percent     = (int)Holder.CreditHistory;
     this.Amount = Amount * (1 + (SqlMoney)(Percent) / 100);
     this.Month  = Month;
     Payment     = Amount / Month;
 }
Exemplo n.º 3
0
        private async void Deposit_DepositOpend(AClient arg1, Deposit arg2)
        {
            var pattern = $"Клиент {arg1} открыл депозит:\nСрок: {arg2.Month}\nСумма: {arg2.Amount}\nПроцент: {arg2.Percent}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 4
0
        private async void Credit_CreditClosed(AClient arg1, Credit arg2)
        {
            var pattern = $"Клиент {arg1} закрыл кредит.";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 5
0
        private async void Deposit_MakedPayment(AClient arg1, Deposit arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} закрыл депозит.\nСумма: {arg2.Amount}\nПроцент: {arg2.Percent}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            // transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 6
0
 private void DeleteAClietnFromDB(AClient client)
 {
     if (client is Client)
     {
         BankDB.DeleteClient(connectionStringBuilder, (Client)client);
     }
     else if (client is Entity)
     {
         BankDB.DeleteEntity(connectionStringBuilder, (Entity)client);
     }
 }
Exemplo n.º 7
0
        private async void AClient_MoneySent(AClient arg1, AClient arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} отправил\n{arg3} руб.\nклиенту {arg2}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 8
0
        private async void AClient_MoneyReceived(AClient arg1, AClient arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var pattern = $"Клиент {arg1} \nполучил {arg3} руб. \nот клиента {arg2}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 9
0
        private async void Credit_CreditOpend(AClient arg1, Credit arg2)
        {
            var creditInfo = $"Сумма: {arg2.Amount} \nСрок: {arg2.Month}";
            var pattern    = $"Клиент {arg1} Открыл кредит. Credit: \n{creditInfo}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
Exemplo n.º 10
0
        private async void Credit_MakedPayment(AClient arg1, Credit arg2, System.Data.SqlTypes.SqlMoney arg3)
        {
            var creditInfo = $"Сумма: {arg2.Amount} \nСрок: {arg2.Month} \nПроцент: {arg2.Percent}";
            var pattern    = $"Клиент {arg1} сделал взнос по кредиту\nна сумму {arg3}. Credit: \n{creditInfo}";

            await dispatcher.InvokeAsync(() => Logs.Add(new Log()
            {
                Text = pattern
            }));

            //transactionListBox.Items.Add(pattern);
        }
 public void RequestMoneyFrom(AClient client, SqlMoney money)
 {
     if (client.Amount >= money)
     {
         InputMoney(money);
         client.WithdrawMoney(money);
         MoneyReceived?.Invoke(this, client, money);
     }
     else
     {
         MessageBox.Show("На счете данного клиента недостаточно средств.");
     }
 }
 public void SendMoneyTo(AClient client, SqlMoney money)
 {
     try
     {
         WithdrawMoney(money);
         client.InputMoney(money);
         MoneySent?.Invoke(this, client, money);
     }
     catch (NotEnoughtMoneyExeption)
     {
         var msg = $"У Клиента{this}\nНедостаточно средств, \nдля перевода клиенту{client}";
         NotEnoughMoney?.Invoke(msg);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Конвертирует данные в депозит
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="holder"></param>
        /// <returns></returns>
        public static Deposit ToDeposit(SqlDataReader reader, AClient holder)
        {
            try
            {
                int id     = (int)reader[0];
                var Amount = (decimal)reader[2];
                var Month  = (int)reader[3];

                return(new Deposit(holder, Amount, id, Month));
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return(null);
        }
Exemplo n.º 14
0
        public static void AddDeposit(SqlConnectionStringBuilder stringBuilder, AClient holder, decimal amount, int month)
        {
            int isEntity = 0;

            if (holder is Entity)
            {
                isEntity = 1;
            }
            else if (holder is Client)
            {
                isEntity = 0;
            }

            var sqlQuery = $@"INSERT INTO Deposits (HolderId, Amount, DepositMonth, isEntity)
                              VALUES ({holder.Id}, @amount, {month}, {isEntity})";

            using (SqlConnector connector = new SqlConnector(stringBuilder))
            {
                var con     = connector.GetConnection();
                var command = new SqlCommand(sqlQuery, con);
                command.Parameters.Add(new SqlParameter("@amount", SqlDbType.Money)).Value = amount;
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 15
0
        public static IEnumerable <Deposit> GetDepositsByHolder(SqlConnectionStringBuilder stringBuilder, AClient holder)
        {
            var sqlQuery = $@"SELECT * FROM Deposits
                             WHERE HolderId = {holder.Id}";

            List <Deposit> deposits = new List <Deposit>();

            using (var connector = new SqlConnector(stringBuilder))
            {
                var reader = connector.GetData(sqlQuery);
                while (reader.Read())
                {
                    var deposit = ConvertSqlData.ToDeposit(reader, holder);

                    deposits.Add(deposit);
                }
            }

            return(deposits);
        }
Exemplo n.º 16
0
        public static Deposit GetLastDerpositByHolder(SqlConnectionStringBuilder stringBuilder, AClient holder)
        {
            int isEntity = 0;

            if (holder is Entity)
            {
                isEntity = 1;
            }
            else if (holder is Client)
            {
                isEntity = 0;
            }

            var     sqlQuery    = $@"SELECT TOP 1 *
                              FROM Deposits
                              WHERE HolderId = {holder.Id} and isEntity = {isEntity}
                              ORDER BY ID DESC";
            Deposit lastDeposit = null;

            using (var connector = new SqlConnector(stringBuilder))
            {
                var reader = connector.GetData(sqlQuery);
                while (reader.Read())
                {
                    lastDeposit = ConvertSqlData.ToDeposit(reader, holder);
                }
            }

            return(lastDeposit);
        }
Exemplo n.º 17
0
 public void AddClient(AClient client)
 {
     Clients.Add(client);
 }
Exemplo n.º 18
0
 public void DeleteClient(AClient client)
 {
     DeleteAClietnFromDB(client);
     Clients.Remove(client);
 }
Exemplo n.º 19
0
 public void DeleteClient(AClient client)
 {
     Clients.Remove(client);
 }
Exemplo n.º 20
0
        private void GetDeposits(int index, SqlConnectionStringBuilder connectionStringBuilder, AClient holder, int entity = 0)
        {
            var sqlDepositQuery = $@"SELECT * FROM Deposits
                                        WHERE HolderId = {index} AND isEntity = {entity}";

            using (var connector = new SqlConnector(connectionStringBuilder))
            {
                using (var depositReader = connector.GetData(sqlDepositQuery))
                {
                    while (depositReader.Read())
                    {
                        var deposit = ConvertSqlData.ToDeposit(depositReader, holder);
                        if (deposit != null)
                        {
                            holder.Deposits.Add(deposit);
                            Deposits.Add(deposit);
                        }
                    }
                }
            }
        }