Exemplo n.º 1
0
        public StainlessForm(ProductSalesForm quantityForm, ProductSalesQuantityModel2 model)
        {
            InitializeComponent();

            QuantityForm = quantityForm;
            Model        = model;
        }
Exemplo n.º 2
0
        public List <ProductSalesQuantityModel2> GetModels()
        {
            {
                using (var context = DbContextCreator.Create())
                {
                    var productNames = context.Products.ToDictionary(x => x.ProductId, x => x.Name);

                    var query = from p in context.ProductDetails
                                select new { Amounts = p.Sales.Sum(s => s.Amount), ProductId = p.ProductId };

                    var query2 = from x in query
                                 group x by x.ProductId into g
                                 select g;

                    var models = new List <ProductSalesQuantityModel2>();
                    foreach (var group in query2)
                    {
                        ProductSalesQuantityModel2 model = new ProductSalesQuantityModel2();
                        model.ProductId   = group.Key;
                        model.Amount      = group.Sum(g => g.Amounts);
                        model.ProductName = productNames[group.Key];

                        models.Add(model);
                    }

                    return(models);
                }
            }
        }
Exemplo n.º 3
0
        private void chartControl1_SelectedItemsChanged(object sender, SelectedItemsChangedEventArgs e)
        {
            ProductSalesQuantityModel2 selectedItem = chartControl1.SelectedItems[0] as ProductSalesQuantityModel2;

            if (selectedItem == null)
            {
                return;
            }

            StainlessForm newStainless = new StainlessForm(this, selectedItem);

            newStainless.Show();
        }