public static void LoadClientsList() { if (Discounts == null) { Discounts = new DiscountSystem(); string queryDiscounts = "SELECT \"Sum\", \"Size\" FROM \"Discount\";"; NpgsqlCommand CommandDiscounts = new NpgsqlCommand(queryDiscounts, Connection); var readerDiscounts = CommandDiscounts.ExecuteReader(); if (readerDiscounts.HasRows) { while (readerDiscounts.Read()) { Discounts.AddDiscount(readerDiscounts.GetDouble(0), readerDiscounts.GetDouble(1)); } } readerDiscounts.Close(); } ClientsInfo = new Clients(); string queryClients = "SELECT \"Id\", \"Name\", \"DateBirth\", \"Phone\", \"Sum\" FROM \"Client\";"; NpgsqlCommand CommandClients = new NpgsqlCommand(queryClients, Connection); var readerClients = CommandClients.ExecuteReader(); if (readerClients.HasRows) { while (readerClients.Read()) { ClientsInfo.AddClient(readerClients["Id"].ToString(), readerClients["Name"].ToString(), readerClients["DateBirth"].ToString(), readerClients["Phone"].ToString(), readerClients["Sum"].ToString(), Discounts); Console.WriteLine(readerClients["DateBirth"].ToString()); } } readerClients.Close(); }
public void AddClient(string id, string name, string dateBirth, string phone, string sum, DiscountSystem discounts) { clients.Add(new Client(id, name, dateBirth, phone, sum, discounts)); }
public Client(string id, string name, string dateBirth, string phone, string sum, DiscountSystem discounts) { Id = id; Name = name; DateBirth = dateBirth; Phone = phone; double.TryParse(sum, out Sum); Discount = discounts.DiscountSize(Sum); }