Example #1
0
 public void FillTestData(int n)
 {
     for (int i = 0; i < n; ++i)
     {
         var noImage = new Bitmap(Path.GetFullPath("image.png"));
         var rnd     = new Random();
         var dep     = new List <Product>();
         for (int j = 0; j < 3; ++j)
         {
             var     weight = rnd.Next(1000, 5000);
             Product A      = new Product()
             {
                 Name   = $"Product{j}",
                 Price  = (i + 1) * 10,
                 Type   = (j % 2 == 0) ? "золото" : "серебро",
                 Weight = weight,
                 Sample = 999,
                 Image  = noImage
             };
             Products.Add(A);
             dep.Add(A);
         }
         Client B = new Client()
         {
             Rank     = (i % 2 == 0) ? -6 : 7,
             Name     = $"Client{i}",
             Password = "******",
             Age      = rnd.Next(18, 60),
             Email    = $"Client{i}@gmail.com"
         };
         Clients.Add(B);
         Deposits.Add(new Deposit(dep, B, DateTime.Now + TimeSpan.FromDays(i), true));
         Deposits[i].Name = $"Deposit{i}";
     }
 }
Example #2
0
        public void FillTestData(int n)
        {
            Random rnd = new Random();

            // Clients
            for (int i = 1; i <= n; ++i)
            {
                Clients.Add(new Client
                {
                    Name     = $"Client{i}",
                    Password = "******",
                    Age      = rnd.Next(18, 60),
                    Email    = $"Client{i}@gmail.com"
                });
            }
            // Deposits
            for (int i = 0; i < n - 5; ++i)
            {
                var dep = new List <Product>();
                for (int j = 0; j < 5; ++j)
                {
                    var id     = rnd.Next(1, 1000);
                    var weight = rnd.Next(1000, 5000);
                    Products.Add(new Product()
                    {
                        Id     = id,
                        Name   = $"Product{j}",
                        Price  = i * 10,
                        Unit   = "g",
                        Type   = (j % 2 == 0) ? "gold" : "silver",
                        Weight = weight,
                        Sample = 999
                    });
                    dep.Add(new Product()
                    {
                        Id     = id,
                        Name   = $"Product{j}",
                        Price  = i * 10,
                        Unit   = "g",
                        Type   = (j % 2 == 0) ? "gold" : "silver",
                        Weight = weight,
                        Sample = 999
                    });
                }
                Deposits.Add(new Deposit(dep, Clients[i], DateTime.Now + TimeSpan.FromDays(i)));
            }
            // ForSale
            foreach (var dep in Deposits)
            {
                if (dep.DateTime.Day % 2 == 0)
                {
                    ForSales.Add(new ForSale(dep));
                }
            }
        }
        public void ProcessFile(FileStream f, StreamReader sr)
        {
            string temp;

            Iban      = sr.ReadLine();
            StartTime = DateTime.ParseExact(sr.ReadLine(), "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
            EndTime   = DateTime.ParseExact(sr.ReadLine(), "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);

            NumberOfDeposits = int.Parse(sr.ReadLine());
            for (int i = 0; i < NumberOfDeposits; i++)
            {
                temp = sr.ReadLine();
                Deposits.Add(new Tuple <int, string>(int.Parse(temp.Split(' ')[0]), temp.Split(' ')[1].Replace(',', '.')));
            }
        }
        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);
                        }
                    }
                }
            }
        }
Example #5
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");
        }
 public void Standard(DepositOutput output)
 {
     Deposits.Add(output);
 }
Example #7
0
 public void Handle(Application.Boundaries.Deposit.Output output)
 {
     Deposits.Add(output);
 }
 public void Default(Application.Boundaries.Deposit.DepositOutput output)
 {
     Deposits.Add(output);
 }