示例#1
0
        public StainlessForm(ProductSalesForm quantityForm, ProductSalesQuantityModel2 model)
        {
            InitializeComponent();

            QuantityForm = quantityForm;
            Model        = model;
        }
示例#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);
                }
            }
        }
示例#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();
        }