예제 #1
0
        public object Clone()
        {
            ProductTypeList result = new ProductTypeList();

            result.Types.AddRange(this.Types);
            return(result);
        }
예제 #2
0
 public ProductTypeList GetProductTypes()
 {
     if (productTypeList == null)
     {
         productTypeList = ProductTypeLoader.LoadProductTypeList();
     }
     return productTypeList;
 }
예제 #3
0
 public static ProductList LoadProducts(ProductTypeList productTypeList, BrandList brandList)
 {
     if (productTypeList == null || brandList == null)
     {
         return null;
     }
     ProductList productList = LoadProductList(productTypeList, brandList);
     return productList;
 }
예제 #4
0
 public static ProductTypeList LoadProductTypeList()
 {
     DataTable dataTable = DBAccessor.QueryProductTypes();
     if (dataTable == null)
     {
         return null;
     }
     ProductTypeList productTypeList = new ProductTypeList();
     foreach (DataRow dataRow in dataTable.Rows)
     {
         ProductType productType = LoadProductType(dataRow);
         productTypeList.AddType(productType);
     }
     return productTypeList;
 }
예제 #5
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;
 }
예제 #6
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;
 }
예제 #7
0
 private void InitData()
 {
     brandList = controller.GetBrands();
     productTypeList = controller.GetProductTypes();
     productList = controller.GetProducts();
 }
예제 #8
0
 public object Clone()
 {
     ProductTypeList result = new ProductTypeList();
     result.Types.AddRange(this.Types);
     return result;
 }