C# |
Copy Code
|
---|---|
public static class DataSource { private static Random _random = new Random(); public static BindingList<SalesInfo> GetSalesInfo() { var countries = "US,Germany,UK,Japan,Italy,Greece".Split(','); var products = "Phones,Cars,Stereos,Watches,Computers".Split(','); BindingList<SalesInfo> data = new(); for (var i = 0; i < 50; i++) { data.Add(new SalesInfo { Id = i, Country = countries[_random.Next(0, countries.Length)], Product = products[_random.Next(0, products.Length)], Date = DateTime.Now.AddDays(i), Sales = Math.Round(_random.NextDouble() * 10000, 2), Expenses = Math.Round(_random.NextDouble() * 5000, 2), }); } return data; } } public class SalesInfo { public int Id { get; set; } public string Country { get; set; } public string Product { get; set; } public DateTime Date { get; set; } public double Sales { get; set; } public double Expenses { get; set; } } |