public List<Material> GetMaterialsMin(int categoryID, int page, out int count)
 {
     count = 0;
     List<Material> materials = new List<Material>();
     DataSet ds = null;
     Category category = new Category();
     CategoryOperation cop = new CategoryOperation();
     category = cop.GetModel(categoryID);
     if (category != null)
     {
         if (category.ParentID == 0)
         {
             List<int> ids = cop.GetChildIdList(category.CategoryID);
             ds = dal.GetMaterialsMin(ids, page, Common.TextileConfig.MaterialPageSize, out count);
         }
         else
         {
             ds = dal.GetMaterialsMin(categoryID, page, Common.TextileConfig.MaterialPageSize, out count);
         }
         if (ds != null && ds.Tables.Count > 0)
         {
             materials = DataTableToList(ds.Tables[0]);
         }
     }
     return materials;
 }
        //
        // GET: /Material/
        public ActionResult Index(int id=0)
        {
            if (id > 0)
            {
                try
                {
                    MaterialOperation mop = new MaterialOperation();
                    Material material = mop.GetModel(id);
                    if (material != null)
                    {
                        ViewData["DataModel"] = material;
                        CategoryOperation cop = new CategoryOperation();
                        Category category = cop.GetModel(material.CategoryID);
                        if (category != null)
                        {
                            ViewData["CategoryName"] = category.Name;
                        }
                        ViewBag.Title = material.Name;
                        string categoryUrl = "fabric";
                        switch (material.CategoryType)
                        {
                            case CategoryType.Fabric:
                                categoryUrl = "fabric";
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Fabric;
                                List<Craft> crafts = new List<Craft>();
                                CraftOperation craftOper = new CraftOperation();
                                crafts = craftOper.GetMinList();
                                ViewData["Crafts"] = crafts;
                                break;
                            case CategoryType.Accessory:
                                categoryUrl = "accessory";
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Accessory;
                                StyleOperation styleOper = new StyleOperation();
                                List<Style> styles = styleOper.GetStyles(material.MaterialID);
                                if(styles.Count>0)
                                    ViewData["Styles"] = styles;
                                break;
                        }
                        ViewData["CategoryTypeUrl"] = categoryUrl;
                        string[] images = material.Images.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        List<string> imageList = new List<string>();
                        if (images != null && images.Length > 0)
                        {
                            foreach (string image in images)
                            {
                                imageList.Add(image);
                            }
                            ViewData["Images"] = imageList;
                        }

                        return View("material");
                    }
                    else
                    {
                        return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
                    }
                }
                catch
                {
                    return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
                }
            }
            else
            {
                return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
            }
        }
        //
        // GET: /Textile/
        public ActionResult Index(string type = "fabric",int id=0)
        {
            type = type.ToLower();
            if (type == "fabric" || type == "accessory")
            {
                try
                {
                    CategoryOperation gop = new CategoryOperation();
                    int parentID = 1;
                    int childID = -1;
                    int currentID = 0;
                    if (id > 0)
                    {
                        Category category = gop.GetModel(id);
                        if (category == null)
                        {
                            return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
                        }
                        if (category.ParentID > 0)
                        {
                            parentID = category.ParentID;
                            childID = category.CategoryID;
                            currentID = childID;
                        }
                        else
                        {
                            parentID = category.CategoryID;
                            childID = -1;
                            currentID = parentID;
                        }
                        ViewBag.Title = string.Format("{0}-广州国际轻纺城", category.Name);
                        string strCategoryType = "";
                        switch (category.Type)
                        {
                            case CategoryType.Fabric:
                                strCategoryType = "fabric";
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Fabric;
                                break;
                            case CategoryType.Accessory:
                                strCategoryType = "accessory";
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Accessory;
                                break;
                        }
                        if (type != strCategoryType)
                        {
                            return new RedirectResult(string.Format("/textile/{0}/{1}", strCategoryType, id));
                        }
                    }
                    else
                    {
                        Category category = null;
                        switch (type)
                        {
                            case "fabric":
                                category = gop.FirstFabricParent();
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Fabric;
                                break;
                            case "accessory":
                                category = gop.FirstAccessoryParent();
                                ViewBag.NaviCss.Current = TextileCity.Models.Navigation.Accessory;
                                break;
                        }
                        if (category != null)
                        {
                            parentID = category.CategoryID;
                            childID = -1;
                            currentID = parentID;
                            ViewBag.Title = string.Format("{0}-广州国际轻纺城", category.Name);
                        }
                    }

                    ViewData["CurrentParentID"] = parentID;
                    ViewData["CurrentChildID"] = childID;
                    ViewData["CurrentType"] = type;
                    ViewData["FabricCategories"] = gop.GetFabricCategories();
                    ViewData["AccessoryCategories"] = gop.GetAccessoryCategories();
                    ViewData["CurrentID"] = currentID;
                    return View();
                }
                catch
                {
                    return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
                }
            }
            else
            {
                return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
            }
        }