public CellSelectionPropertyDescriptor(CellSelectionList list, string propertyName, Type propertyType) : base(propertyName, null) { this.propertyName = propertyName; this.list = list; this.propertyType = propertyType; }
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); }
public static IList GetSalesByEmployee() { List <ColumnDescription> columns = new List <ColumnDescription>(); columns.Add(new ColumnDescription() { PropertyName = "Employee", PropertyType = typeof(string), Attributes = new Attribute[] { new DisplayAttribute() { GroupName = "Employee" } } }); for (int yearIndex = 10; yearIndex > 0; yearIndex--) { int year = DateTime.Now.Year - yearIndex; for (int month = 1; month <= 12; month++) { columns.Add(new ColumnDescription() { PropertyName = year + "-" + month, PropertyType = typeof(int), DisplayName = DateTimeFormatInfo.CurrentInfo.GetMonthName(month), Attributes = new Attribute[] { new DisplayAttribute() { GroupName = year + "/Q" + Math.Floor((double)(month + 2) / 3) } } }); } } Random random = new Random(); CellSelectionList source = new CellSelectionList(columns, true); foreach (Employee employee in NWindContext.Create().Employees) { var row = new Dictionary <string, object>(); row["Employee"] = employee.FirstName + " " + employee.LastName; for (int columnIndex = 1; columnIndex < columns.Count; columnIndex++) { row[columns[columnIndex].PropertyName] = random.Next(30000); } source.Add(row); } return(source); }
public CellSelectionPropertyDescriptor(CellSelectionList list, ColumnDescription columnDescription) : base(columnDescription.PropertyName, columnDescription.Attributes) { this.columnDescription = columnDescription; this.list = list; }
public static IList GetSalesByYearData(bool includeMonth, bool includeYear, bool includeTotalSales) { List <string> columns = new List <string>(); if (includeYear) { columns.Add("Date"); } if (includeMonth) { columns.Add("DateMonth"); } if (includeTotalSales) { columns.Add("Sales"); } foreach (Employee employee in DataStorage.Employees) { string name = employee.FirstName + " " + employee.LastName; if (!columns.Contains(name)) { columns.Add(name); } } CellSelectionList table = new CellSelectionList(columns); 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 = includeMonth ? DateTime.DaysInMonth(year, month) : 1; for (int day = 1; day <= daysCount; day++) { Dictionary <string, object> row = new Dictionary <string, object>(); int startColumnIndex = 0; if (includeYear) { row["Date"] = new DateTime(year, month, day); startColumnIndex++; } if (includeMonth) { row["DateMonth"] = row["Date"]; startColumnIndex++; } if (includeTotalSales) { columns.Add("Sales"); row[columns[2]] = (int)0; startColumnIndex++; } for (int columnIndex = startColumnIndex; columnIndex < columns.Count; columnIndex++) { row[columns[columnIndex]] = random.Next(30000 / daysCount); if (includeTotalSales) { row[columns[2]] = (int)row[columns[2]] + (int)row[columns[columnIndex]]; } } table.Add(row); } } } return(table); }