示例#1
0
 void PivotGridDemoModule_Loaded(object sender, RoutedEventArgs e)
 {
     ChartFactory.InitComboBox(cbChartType, null);
     pivotGrid.DataSource = NWindContext.Create().SalesPersons.ToList();
     SetFilter();
     SetSelection();
 }
 public KPIDashboard()
 {
     InitializeComponent();
     pivotGrid.DataSource = NWindContext.Create().ProductReports.ToList();
     SalesTarget          = GetSalesTarget();
     UpdateKPIs();
 }
 public PrintTemplates()
 {
     InitializeComponent();
     pivotGrid.DataSource = NWindContext.Create().ProductReports.ToList();
     SaveDefaultTemplates();
     ResetItems();
 }
示例#4
0
文件: Program.cs 项目: Je5e/ejer101
        static void Main(string[] args)
        {
            Order nueva = new Order
            {
                CreatedAt    = DateTime.Today,
                CustomerName = "Juan Perez",
            };

            nueva.Items = new System.Collections.Generic.List <OrderDetail>();
            nueva.Items.Add(
                new OrderDetail {
                Cantidad = 2,
                Product  = new Product {
                    ProductName = "Pasta"
                }
            });
            nueva.Items.Add(
                new OrderDetail
            {
                Cantidad = 1,
                Product  = new Product {
                    ProductName = "Coffe"
                }
            });

            NWindContext context = new NWindContext();

            context.Orders.Add(nueva);
            context.SaveChanges();
            Console.ReadLine();
            Console.WriteLine("Hello World!");
        }
示例#5
0
 protected MainViewModel()
 {
     if (this.IsInDesignMode())
     {
         return;
     }
     Employees = NWindContext.Create().Employees.ToList();
 }
示例#6
0
 public ConditionalFormatting()
 {
     InitializeComponent();
     fieldOrderYear.FilterValues.FilterType = FieldFilterType.Included;
     fieldOrderYear.FilterValues.Add(1996);
     fieldOrderYear.FilterValues.Add(1997);
     pivotGrid.DataSource = NWindContext.Create().SalesPersons.ToList();
 }
示例#7
0
        public List <ProductSaleData> GenerateSales(int count)
        {
            List <ProductSaleData> sales = new List <ProductSaleData>();
            var countries = NWindContext.Create().CountriesArray;

            return(Enumerable.Range(0, count).Select(index => {
                return CreateSale(countries[index % countries.Length], products[index % products.Count], DateTime.Today.Year - index % 9);
            }).ToList());
        }
示例#8
0
 public static List <Tuple <string, string> > ExtractAddressAndCity()
 {
     return(NWindContext.Create().Customers
            .Select(c => new { c.Address, c.City })
            .Distinct()
            .ToList()
            .Select(p => Tuple.Create(p.Address, p.City))
            .ToList());
 }
 ImageSource GetPhoto(int i)
 {
     if (random.Next(8) > 5)
     {
         return(null);
     }
     i = i % NWindContext.Create().Categories.Count();
     byte[] bytes = NWindContext.Create().Categories.OrderBy(c => c.CategoryName).Skip(i).First().Picture;
     return(DevExpress.Xpf.Core.Native.ImageHelper.CreateImageFromStream(new MemoryStream(bytes)));
 }
        void InitSources()
        {
            edit.ItemsSource = NWindContext.Create().CountriesArray;

            List <SelectionMode> modes = new List <SelectionMode>();

            modes.Add(SelectionMode.Single);
            modes.Add(SelectionMode.Multiple);
            modes.Add(SelectionMode.Extended);
            selectionModeSelector.ItemsSource = modes;
        }
        static List <CategoryData> ExtractCategoryDataList(int count)
        {
            List <CategoryData> categoryData = new List <CategoryData>(count);
            var categories = NWindContext.Create().Categories.Take(count).ToList();

            foreach (var row in categories)
            {
                categoryData.Add(new CategoryData(row.CategoryName, row.Description, row.Icon17));
            }
            return(categoryData);
        }
示例#12
0
        public static IList GetSalesByYearData(bool byMonthReport = false)
        {
            List <ColumnDescription> columns = new List <ColumnDescription>();

            columns.Add(new ColumnDescription()
            {
                PropertyName = "Date", PropertyType = typeof(DateTime)
            });
            if (byMonthReport)
            {
                columns.Add(new ColumnDescription()
                {
                    PropertyName = "DateMonth", PropertyType = typeof(DateTime)
                });
            }
            foreach (Employee employee in NWindContext.Create().Employees)
            {
                string name = employee.FirstName + " " + employee.LastName;
                columns.Add(new ColumnDescription()
                {
                    PropertyName = name, PropertyType = typeof(int)
                });
            }

            CellSelectionList source = new CellSelectionList(columns, false);

            Random random = new Random();

            for (int yearIndex = 10; yearIndex > 0; yearIndex--)
            {
                int year = DateTime.Now.Year - yearIndex;
                for (int month = 1; month <= 12; month++)
                {
                    int daysCount = byMonthReport ? DateTime.DaysInMonth(year, month) : 1;
                    for (int day = 1; day <= daysCount; day++)
                    {
                        Dictionary <string, object> row = new Dictionary <string, object>();
                        row["Date"] = new DateTime(year, month, day);
                        int startColumnIndex = 1;
                        if (byMonthReport)
                        {
                            row["DateMonth"] = row["Date"];
                            startColumnIndex++;
                        }
                        for (int columnIndex = startColumnIndex; columnIndex < columns.Count; columnIndex++)
                        {
                            row[columns[columnIndex].PropertyName] = random.Next(30000 / daysCount);
                        }
                        source.Add(row);
                    }
                }
            }
            return(source);
        }
        static List <CustomerData> ExtractCustomers(int count)
        {
            var customers    = NWindContext.Create().Customers.Take(count).ToList();
            var customerData = new List <CustomerData>(count);

            foreach (var row in customers)
            {
                customerData.Add(new CustomerData(row.ContactName, row.CompanyName, row.Phone, row.City));
            }
            return(customerData);
        }
 private object GenerateRandomCategories(int i)
 {
     if (random.Next(8) > 5)
     {
         return(null);
     }
     i = i % NWindContext.Create().Categories.Count();
     return(new List <object>()
     {
         NWindContext.Create().Categories.OrderBy(c => c.CategoryName).Skip(i).First().CategoryID
     });
 }
示例#15
0
 static List <string> ExtractCustomerNames()
 {
     if (customerNames.Count == 0)
     {
         var customers = NWindContext.Create().Customers.ToList();
         customerNames.Capacity = customers.Count;
         foreach (var row in customers)
         {
             customerNames.Add(row.ContactName);
         }
     }
     return(customerNames);
 }
示例#16
0
 public CustomChartData()
 {
     InitializeComponent();
     ChartFactory.InitComboBox(cbChartType, new Type[] { InitDiagram() });
     RowExportRule = RowFieldValueExportRule.ProductName;
     pivotGrid.ChartProvideRowFieldValuesAsType = typeof(string);
     cbRowFieldValuesExportRule.Items.AddRange(new string[] { "ProductName", "Category/ProductName",
                                                              "Encoded Product Category" });
     cbRowFieldValuesExportRule.SelectedIndex = 0;
     pivotGrid.DataSource = NWindContext.Create().SalesPersons.ToList();
     pivotGrid.MultiSelection.SetSelection(CreateSelectedPoints());
     SetMeasureUnits(DateTimeMeasurementUnit.Year, DateTimeMeasurementUnit.Quarter, DateTimeMeasurementUnit.Month);
     CollapseValues();
 }
 public CustomAppearance()
 {
     InitializeComponent();
     pivotGrid.DataSource = NWindContext.Create().SalesPersons.ToList();
     pivotGrid.BeginUpdate();
     fieldCategoryName.FilterValues.FilterType = FieldFilterType.Included;
     fieldCategoryName.FilterValues.Add("Grains/Cereals");
     fieldCategoryName.FilterValues.Add("Meat/Poultry");
     fieldCategoryName.FilterValues.Add("Produce");
     fieldSalesPerson.FilterValues.Add("Robert King");
     fieldSalesPerson.FilterValues.Add("Steven Buchanan");
     pivotGrid.EndUpdate();
     pivotGrid.FocusedCellChanged += new RoutedEventHandler(OnFocusedCellChanged);
     Loaded += new RoutedEventHandler(OnModuleLoaded);
 }
        public TableOfContents()
        {
            InitializeComponent();
            ribbon.SelectedPage = pageReferences;
            isFirstLoad         = true;

            OpenXmlLoadHelper.Load("TableOfContents.docx", sourceRichEditControl);
            NWind   = Resources["NWindDataLoader"] as NWindDataLoader;
            this.ds = NWindContext.Create().Employees.ToList();

            IUriStreamService uriService = (IUriStreamService)sourceRichEditControl.GetService(typeof(IUriStreamService));

            uriService.RegisterProvider(new DBUriStreamProviderBase <DevExpress.DemoData.Models.Employee>(NWindContext.Create().Employees.ToList(),
                                                                                                          (es, id) => es.First(e => e.EmployeeID == id).Photo));
        }
        protected override void CreateDataTable()
        {
            base.CreateDataTable();
            var rows = NWindContext.Create().Products.ToList();

            for (int i = 0; i < rows.Count; i++)
            {
                var dict = Table[i];
                dict["Category1"] = rows[i].CategoryID;
                dict["Category2"] = rows[i].CategoryID;
                dict["Brush"]     = new SolidColorBrush((Color)dict["Color"]);
                dict["Date1"]     = DateTime.Today;
                dict["Date2"]     = DateTime.Today;
            }
        }
示例#20
0
        public static List <CategoryData> ExtractCategoryDataList()
        {
            List <CategoryData> categoryData = new List <CategoryData>();
            var categories = NWindContext.Create().Categories.ToList();

            foreach (Category category in categories)
            {
                categoryData.Add(new CategoryData()
                {
                    Name    = category.CategoryName,
                    Picture = category.Picture
                });
            }
            return(categoryData);
        }
示例#21
0
        public static List <string> ExtractEmployers()
        {
            List <string> employers = new List <string>();
            var           customers = NWindContext.Create().Customers.ToList();

            foreach (Customer customer in customers)
            {
                string employer = customer.CompanyName;
                if (!employers.Contains(employer))
                {
                    employers.Add(employer);
                }
            }
            return(employers);
        }
示例#22
0
        public static List <Tuple <string, string> > ExtractAddressAndCity()
        {
            List <Tuple <string, string> > addrList = new List <Tuple <string, string> >();
            var customers = NWindContext.Create().Customers.ToList();

            foreach (Customer customer in customers)
            {
                var addr = Tuple.Create(customer.Address, customer.City);
                if (!addrList.Contains(addr))
                {
                    addrList.Add(addr);
                }
            }
            return(addrList);
        }
示例#23
0
 public CustomGroupInterval()
 {
     selectedDemo = 0;
     InitializeComponent();
     pivotGrid.DataSource = NWindContext.Create().ProductReports.ToList();
     cbGroup.Items.Add(new ComboBoxEditItem()
     {
         Content = "Group Products by First Characters", Tag = 0
     });
     cbGroup.Items.Add(new ComboBoxEditItem()
     {
         Content = "Group Sales by Year and Quarter", Tag = 1
     });
     cbGroup.SelectedIndex = 0;
 }
示例#24
0
        public static List <string> ExtractTitles()
        {
            List <string> titles    = new List <string>();
            var           employees = NWindContext.Create().Employees.ToList();

            foreach (Employee employee in employees)
            {
                string title = employee.Title;
                if (!titles.Contains(title))
                {
                    titles.Add(title);
                }
            }
            return(titles);
        }
示例#25
0
        void InitDataSource()
        {
            Employees =
                NWindContext.Create().Employees.ToList()
                .Select(x => EmployeeWrapper.Create(x)).ToList();

            int i = 0;

            foreach (var employee in Employees)
            {
                employee.BackgroundColor        = ColorPalette.GetColor(i, 100);
                employee.BackgroundColor        = ColorHelper.Brightness(employee.BackgroundColor, 0.3);
                employee.BackgroundColorOpacity = 180;
                i++;
            }
        }
 public SingleTotal()
 {
     InitializeComponent();
     pivotGrid.BeginUpdate();
     pivotGrid.AllowCrossGroupVariation = false;
     pivotGrid.DataSource = NWindContext.Create().SalesPersons.ToList();
     fieldYear.FilterValues.FilterType = FieldFilterType.Included;
     object[] values = fieldYear.GetUniqueValues();
     fieldYear.FilterValues.Add(values[0]);
     fieldYear.FilterValues.Add(values[1]);
     fieldCategory.FilterValues.FilterType = FieldFilterType.Included;
     fieldCategory.FilterValues.Add("Beverages");
     fieldCategory.FilterValues.Add("Condiments");
     pivotGrid.EndUpdate();
     InitComboBoxes();
 }
        static DataTable CreateInvoicesDataTable()
        {
            var       invoices = NWindContext.Create().Invoices.ToList();
            DataTable tbl      = new DataTable("GroupInterval");

            tbl.Columns.Add("Country", typeof(string));
            tbl.Columns.Add("City", typeof(string));
            tbl.Columns.Add("OrderDate", typeof(DateTime));
            tbl.Columns.Add("UnitPrice", typeof(decimal));
            tbl.Columns.Add("Region", typeof(string));
            foreach (var invoice in invoices)
            {
                tbl.Rows.Add(new object[] { invoice.Country, invoice.City, GetDate(true), invoice.UnitPrice, invoice.Region });
            }
            return(tbl);
        }
示例#28
0
 public static List <CategoryData> ExtractCategoryDataList()
 {
     if (categoryData.Count == 0)
     {
         var categories = NWindContext.Create().Categories.ToList();
         categoryData.Capacity = categories.Count;
         foreach (var row in categories)
         {
             categoryData.Add(new CategoryData()
             {
                 Name    = row.CategoryName,
                 Picture = row.Icon25
             });
         }
     }
     return(categoryData);
 }
示例#29
0
        public static List <ProductData> ExtractProductDataList(List <CategoryData> categoriesList)
        {
            List <ProductData> productData = new List <ProductData>();

            var    categoryProducts = NWindContext.Create().CategoryProducts.ToList();
            Random rand             = new Random();

            foreach (CategoryProduct cp in categoryProducts)
            {
                productData.Add(new ProductData()
                {
                    Category = FindCategory(categoriesList, cp.CategoryName),
                    Name     = cp.ProductName,
                    Price    = (decimal)rand.Next(20) + (decimal)rand.Next(99) / 100m
                });
            }
            return(productData);
        }
        static DataTable CreateProductsDataTable()
        {
            const int rowCount = 1000;
            var       products = NWindContext.Create().Products.ToList();
            DataTable tbl      = new DataTable("GroupInterval");

            tbl.Columns.Add("ProductName", typeof(string));
            tbl.Columns.Add("UnitPrice", typeof(decimal));
            tbl.Columns.Add("Count", typeof(int));
            tbl.Columns.Add("OrderDate", typeof(DateTime));
            tbl.Columns.Add("OrderSum", typeof(decimal), "[UnitPrice] * [Count]");
            for (int i = 0; i < rowCount; i++)
            {
                Product product = products[rnd.Next(products.Count - 1)];
                tbl.Rows.Add(new object[] { product.ProductName, product.UnitPrice, GetCount(), GetDate(false) });
            }
            return(tbl);
        }