Пример #1
0
        private void ordersBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ordersBox.SelectedIndex == -1)
            {
                return;
            }

            selectedOrder = selectedCustomerOrders[ordersBox.SelectedIndex];
            orderDate.Value = (DateTime)selectedCustomerOrders[ordersBox.SelectedIndex].Date;
            selectedProductsOrders = unitOfWork.ProductsOrdersRepository.GetProductsOrdersByOrderId(selectedCustomerOrders[ordersBox.SelectedIndex].ID).ToList();

            if (selectedProductsOrders != null && selectedProductsOrders.Count > 0)
            {
                int i = 0;
                foreach (ProductOrder po in selectedProductsOrders)
                {
                    i++;
                }
                selectedProducts = unitOfWork.ProductsRepository.GetProductsByProductOrderId(selectedProductsOrders[0].ID).ToList();
            }

            PopulateProductsData();
        }
Пример #2
0
        private void insertBtn_Click(object sender, EventArgs e)
        {
            Random random = new Random();
            List<Product> randomProducts = new List<Product>();
            int numberOfRecords;
            bool isParseSucessfull = int.TryParse(numberOfRecordsField.Text, out numberOfRecords);
            if (isParseSucessfull)
            {

                //Create all users
                progressBar.Minimum = 1;
                progressBar.Maximum = numberOfRecords;
                var newUnit = new UnitOfWork();
                // Task.Run(() =>
                //     {
                //      Parallel.For(0, numberOfRecords, (i) =>
                //      {
                //          //var newUnit = new UnitOfWork();
                //
                //          Console.WriteLine("N: " + i);
                //          Customer randomCustomer = new Customer
                //          {
                //              Bulstat = random.Next(1000000),
                //              MOL = "NEW " + random.Next(1000000).ToString(),
                //              Name = "NEW NAME",
                //              Address = "NEW ADDRESS",
                //              Password = GeneratePassword(),
                //              RegisteredOnVAT = true,
                //              IsDeleted = false
                //          };
                //          Order randomOrder = new Order
                //          {
                //              Date = DateTime.Now
                //          };
                //
                //          for (int j = 0; j < 250; j++)
                //          {
                //              ProductOrder randomProductOrder = new ProductOrder
                //              {
                //                  Quantity = 250
                //              };
                //
                //              randomProductOrder.ProductID = 5;
                //              randomOrder.ProductOrders.Add(randomProductOrder);
                //          }
                //          randomCustomer.Orders.Add(randomOrder);
                //          newUnit.CustomerRepository.Add(randomCustomer);
                //          if (newUnit.TrySave() == false)
                //          {
                //              Console.WriteLine("ERROR SAVING");
                //          }
                //
                //      });
                //   });

                FDebug.Start();
                for (int i = 0; i < numberOfRecords; i++)
                {

                    Console.WriteLine("N: " + i);
                    Customer randomCustomer = new Customer
                    {
                        Bulstat = random.Next(1000000),
                        MOL = "NEW " + random.Next(1000000).ToString(),
                        Name = "NEW NAME",
                        Address = "NEW ADDRESS",
                        Password = GeneratePassword(),
                        RegisteredOnVAT = true,
                        IsDeleted = false
                    };
                    Order randomOrder = new Order
                    {
                        Date = DateTime.Now
                    };

                    for (int j = 0; j < 250; j++)
                    {
                        ProductOrder randomProductOrder = new ProductOrder
                        {
                            Quantity = 250
                        };

                        randomProductOrder.ProductID = 5;
                        randomOrder.ProductOrders.Add(randomProductOrder);
                    }
                    randomCustomer.Orders.Add(randomOrder);
                    newUnit.CustomerRepository.Add(randomCustomer);
                    if (newUnit.TrySave() == false)
                    {

                    }
                    progressBar.PerformStep();
                }
                FDebug.End();
                timeLabel.Text = FDebug.TimeElapsed();
                //IsAnythignInserted = true;
            }
        }