Files
EnvelopeGenerator/EnvelopeGenerator.WebUI/EnvelopeGenerator.WebUI.Client/Data/Customer.cs
TekH 150fca5f47 Add data models, randomization, and report factory setup
Introduced several new classes in the `EnvelopeGenerator.WebUI.Client` namespace:
- Added `Adjustment` class for financial adjustments with deterministic randomization.
- Added `Customer` class to load customer data from a SQL data source with fallback.
- Added `DataItem` class to represent detailed billing data, including adjustments.
- Added `DataItemList` class implementing `IList` for dynamic `DataItem` generation.
- Added `DeterministicRandom` class for reproducible random value generation.
- Added `Term` struct to define payment terms.
- Added `ReportsFactory` class to manage predefined reports.

Updated `MIGRATION_CONTEXT.md` to document the completion of Phase 5 (Data & PredefinedReports Migration) and outline next steps for resolving DevExpress-related errors in Phase 7.
2026-06-12 14:04:37 +02:00

65 lines
2.7 KiB
C#

using DevExpress.DataAccess.Sql;
using DevExpress.DataAccess.Sql.DataApi;
namespace EnvelopeGenerator.WebUI.Client.Data {
public class Customer {
static List<Customer> currentCustomers = new List<Customer>();
public static List<Customer> Customers { get { return currentCustomers; } }
static Customer() {
try {
SqlDataSource ds = new SqlDataSource("NWindConnectionString");
SelectQuery query = SelectQueryFluentBuilder
.AddTable("Customers")
.SelectAllColumns()
.Build("Customers");
ds.Queries.Add(query);
ds.RebuildResultSchema();
ds.Fill();
ITable src = ds.Result["Customers"];
foreach(var row in src) {
currentCustomers.Add(new Customer() {
CustomerID = row.GetValue<string>("CustomerID"),
Address = row.GetValue<string>("Address"),
CompanyName = row.GetValue<string>("CompanyName"),
ContactName = row.GetValue<string>("ContactName"),
ContactTitle = row.GetValue<string>("ContactTitle"),
Country = row.GetValue<string>("Country"),
City = row.GetValue<string>("City"),
Fax = row.GetValue<string>("Fax"),
Phone = row.GetValue<string>("Phone"),
PostalCode = row.GetValue<string>("PostalCode"),
Region = row.GetValue<string>("Region")
});
}
} catch {
currentCustomers.Add(new Customer() {
Address = "Obere Str. 57",
City = "Berlin",
CompanyName = "Alfreds Futterkiste",
ContactName = "Maria Anders",
ContactTitle = "Sales Representative",
Country = "Germany",
CustomerID = "ALFKI",
Fax = "030-0076545",
Phone = "030-0074321",
PostalCode = "12209"
});
}
}
public string CustomerID { get; set; }
public string CompanyName { get; set; }
public string ContactName { get; set; }
public string ContactTitle { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string PostalCode { get; set; }
public string Region { get; set; }
public string Country { get; set; }
public string Phone { get; set; }
public string Fax { get; set; }
}
}