Exemplo n.º 1
0
 public BrandList GetBrands()
 {
     if (brandList == null)
     {
         brandList = BrandLoader.LoadBrands();
     }
     return brandList;
 }
Exemplo n.º 2
0
 public static ProductList LoadProducts(ProductTypeList productTypeList, BrandList brandList)
 {
     if (productTypeList == null || brandList == null)
     {
         return null;
     }
     ProductList productList = LoadProductList(productTypeList, brandList);
     return productList;
 }
Exemplo n.º 3
0
 public static BrandList LoadBrands()
 {
     DataTable dataTable = DBAccessor.QueryBrands();
     if (dataTable == null)
     {
         return null;
     }
     BrandList brandList = new BrandList();
     foreach (DataRow dataRow in dataTable.Rows)
     {
         Brand brand = LoadBrand(dataRow);
         brandList.AddBrand(brand);
     }
     return brandList;
 }
Exemplo n.º 4
0
 private static ProductList LoadProductList(ProductTypeList productTypeList, BrandList brandList)
 {
     DataTable dataTable = DBAccessor.QueryProducts();
     if (dataTable == null)
     {
         return null;
     }
     ProductList productList = new ProductList();
     foreach (DataRow dataRow in dataTable.Rows)
     {
         Product product = LoadProduct(dataRow, productTypeList, brandList);
         if (product == null)
         {
             continue;
         }
         productList.AddProduct(product);
     }
     return productList;
 }
Exemplo n.º 5
0
 private static Product LoadProduct(DataRow dataRow, ProductTypeList productTypeList, BrandList brandList)
 {
     int id = Convert.ToInt32(dataRow["PID"]);
     int typeID = Convert.ToInt32(dataRow["ProductType"]);
     int brandID = Convert.ToInt32(dataRow["Brand"]);
     string name = dataRow["ProductName"].ToString();
     string remark = dataRow["Remark"].ToString();
     ProductType type = productTypeList.GetType(typeID);
     if (type == null)
     {
         Log.Write("LoadProduct failed. Can't find type:" + typeID.ToString());
         return null;
     }
     Brand brand = brandList.GetBrand(brandID);
     if (brand == null)
     {
         Log.Write("LoadProduct failed. Can't find brand:" + brandID.ToString());
         return null;
     }
     Product result = new Product(id, type, name, brand, remark);
     return result;
 }
Exemplo n.º 6
0
 private void InitData()
 {
     brandList = controller.GetBrands();
     productTypeList = controller.GetProductTypes();
     productList = controller.GetProducts();
 }