· 8 years ago · Jul 31, 2018, 04:00 AM
1How to organize data from the database?
2CREATE TABLE IF NOT EXISTS Items (
3 itemId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
4 description VARCHAR(256) NOT NULL DEFAULT '',
5 priceBeforeTax DECIMAL(10,2) NOT NULL,
6) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
7
8CREATE TABLE IF NOT EXISTS Stores (
9 storeId INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
10 storeName VARCHAR(128) NOT NULL,
11) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
12
13CREATE TABLE IF NOT EXISTS ItemStores (
14 storeId INT NOT NULL REFERENCES Stores(storeId),
15 itemId INT NOT NULL REFERENCES Items(itemId),
16 quantity INT NOT NULL
17) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
18
19public class Store
20{
21 public int storeId { get; set; }
22 public string storeName { get; set; }
23
24 public override string ToString()
25 {
26 return this.branchName;
27 }
28}
29private static ObservableCollection<Store> _stores = new ObservableCollection<Store>();
30public static ObservableCollection<Store> Stores
31{
32 get { return _stores; }
33}
34
35
36public class Item
37{
38 public int itemId { get; set; }
39 public string description { get; set; }
40 public decimal priceBeforeTax { get; set; }
41
42 public override string ToString()
43 {
44 return this.description;
45 }
46}
47private static ObservableCollection<Item> _items = new ObservableCollection<Item>();
48public static ObservableCollection<Item> Items
49{
50 get { return _items; }
51}