Example #1
0
        public ObservableCollection <Deposit> CreateDeposits(int clientId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM deposits WHERE client_id = @clientId and isconfirm = 1";
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientId")
            {
                Value = clientId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            while (reader.Read())
            {
                Deposit deposit = new Deposit(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetString(3),
                                              reader.GetString(4), reader.GetInt32(5), CheckConfirm(reader.GetInt32(6)), Convert.ToDateTime(reader.GetString(7), CultureInfo.CurrentCulture));
                Deposits.Add(deposit);
            }
            CloseConnection();

            Service.CountServiceClient client = new Service.CountServiceClient("NetTcpBinding_ICountService");
            foreach (Deposit deposit in Deposits)
            {
                double pay = client.CalcDeposit(deposit.Duration, deposit.Number, deposit.DateDeposit);
                if (pay != 0)
                {
                    Card card = new Card(1, deposit.CardNumber, "dffdsfwef", 2355, 544, "03.11.2023", "Visa Classic", 0, 2, true);
                    card = card.GetCurrentCard(card);
                    int newCardMoney = card.Money + (int)pay;
                    card.UpdateCardMoney(card, newCardMoney);
                }
            }
            client.Close();
            return(Deposits);
            //Credits.Remove(credit);
            //DeleteSelectedItem(credit.Id, "credit");
        }
Example #2
0
        public ObservableCollection <Credit> CreateCredits(int clientId)
        {
            OpenConnection();
            SqlCmd.CommandText = @"SELECT * FROM credits WHERE client_id = @clientId and isconfirm = 1";
            SqlCmd.Parameters.Add(new SQLiteParameter("@clientId")
            {
                Value = clientId
            });
            SqlCmd.ExecuteNonQuery();
            SQLiteDataReader reader;

            reader = SqlCmd.ExecuteReader();
            while (reader.Read())
            {
                Credit credit = new Credit(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2),
                                           reader.GetString(3), reader.GetInt32(4), CheckConfirm(reader.GetInt32(5)), Convert.ToDateTime(reader.GetString(6), CultureInfo.CurrentCulture));
                Credits.Add(credit);
            }
            CloseConnection();

            var client = new Service.CountServiceClient("NetTcpBinding_ICountService");

            foreach (Credit credit in Credits)
            {
                int offence = client.CalcCredit(credit.Duration, credit.Number, credit.DateCredit);
                if (offence != 0)
                {
                    Card card = new Card(1, credit.CardNumber, "dffdsfwef", 2355, 544, "03.11.2023", "Visa Classic", 0, 2, true);
                    card = card.GetCurrentCard(card);
                    int newCardMoney = card.Money - offence;
                    card.UpdateCardMoney(card, newCardMoney);
                }
            }
            client.Close();
            return(Credits);
        }