コード例 #1
0
ファイル: Postgre.cs プロジェクト: yesrolya/Kursach_ISU_7sem
        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();
        }
コード例 #2
0
 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));
 }
コード例 #3
0
 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);
 }