Exemplo n.º 1
0
 public JsonResult AddFabric()
 {
     string strCraft = Request["craft"];
     string strStyle = Request["style"];
     string strCount = Request["count"];
     string strID = Request["materialid"];
     int id = 0;
     int count = 0;
     int carftID = 0;
     int styleID = 0;
     int.TryParse(strCraft,out carftID);
     int.TryParse(strStyle,out styleID);
     int.TryParse(strCount, out count);
     int.TryParse(strID, out id);
     JsonResult json = new JsonResult();
     json.Data = new { flag = 0 };
     if (count > 0 && carftID > 0 && styleID > 0&&id>0)
     {
         DetailItem item = new DetailItem();
         item.Craft = carftID;
         item.Style=styleID;
         item.Type=CategoryType.Fabric;
         item.MaterialID=id;
         Material model = new Material();
         MaterialOperation mop = new MaterialOperation();
         model = mop.GetModel(id);
         Craft craftModel = new Craft();
         CraftOperation craftOperation = new CraftOperation();
         craftModel = craftOperation.GetModel(carftID);
         item.Count = count;
         if (model != null)
         {
             item.StylePrice = craftModel.Price;
             switch (styleID)
             {
                 case 1:
                     item.Price = model.Price ;
                     break;
                 case 2:
                     item.Price = model.PriceHigh;
                     break;
                 case 3:
                     item.Price = model.PriceFancy;
                     break;
             }
             if (item.Price > 0)
             {
                 MyCart.Add(item);
                 json.Data = new { flag = 1,count=MyCart.Orders.Count,total=MyCart.TotalPrice };
             }
         }
     }
     json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     json.ContentEncoding = System.Text.Encoding.UTF8;
     return json;
 }
Exemplo n.º 2
0
        public bool RefreshDbData()
        {
            bool change = true;
            if (orderList.Count <= 0)
            {
                return false;
            }
            Dictionary<int, Material> models = new Dictionary<int, Material>();
            Dictionary<int, Style> stylePrices = new Dictionary<int, Style>();
            Dictionary<int, Craft> craftPrices = new Dictionary<int, Craft>();
            List<int> ids = new List<int>();
            List<int> styleIDs = new List<int>();
            List<int> craftIDs = new List<int>();

            foreach (DetailItem item in orderList)
            {
                ids.Add(item.MaterialID);
                if (item.Type == CategoryType.Accessory)
                {
                    styleIDs.Add(item.Style);
                }
                else
                {
                    craftIDs.Add(item.Craft);
                }
            }

            MaterialOperation mop = new MaterialOperation();
            List<Material> materials = mop.GetList(ids);
            foreach (Material material in materials)
            {
                models.Add(material.MaterialID, material);
            }

            StyleOperation sop = new StyleOperation();
            List<Style> styles = sop.GetList(styleIDs);
            foreach (Style s in styles)
            {
                stylePrices.Add(s.StyleID, s);
            }

            CraftOperation cop = new CraftOperation();
            List<Craft> crafts = cop.GetMinList();
            foreach (Craft c in crafts)
            {
                craftPrices.Add(c.CraftID, c);
            }

            foreach (DetailItem item in orderList)
            {
                Material m = models[item.MaterialID];
                item.Image = m.MainImage;
                item.Name = m.Name;
                if (item.Type == CategoryType.Fabric)
                {
                    Craft craftObj = craftPrices[item.Craft];
                    item.StylePrice = craftObj.Price;
                    item.CraftName = craftObj.Name;
                    switch (item.Style)
                    {
                        case 1:
                            item.Price = m.Price;
                            item.StyleName = "本色";
                            break;
                        case 2:
                            item.Price = m.PriceHigh;
                            item.StyleName = "高色";
                            break;
                        case 3:
                            item.Price = m.PriceFancy;
                            item.StyleName = "多彩";
                            break;
                    }
                }
                else
                {
                    item.Price = 0.00m;
                    Style styleObj = stylePrices[item.Style];
                    item.StylePrice = styleObj.Price;
                    item.StyleName = styleObj.Name;
                }
            }
            return change;
        }
Exemplo n.º 3
0
        //
        // 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);
            }
        }
Exemplo n.º 4
0
        public ActionResult MaterialList(int categoryid = 1,int page = 1)
        {
            int count = 0;
            MaterialOperation mop = new MaterialOperation();
            List<Material> mateials = new List<Material>();
            mateials = mop.GetMaterialsMin(categoryid, page, out count);
            Pager pager = new Pager(page, count, Common.TextileConfig.MaterialPageSize);
            ViewData["PagerItems"] = pager.CreatePager();
            ViewData["Materials"] = mateials;
            ViewData["CategoryID"] = categoryid;

            return PartialView("list");
        }