Exemple #1
0
        private void BindRecommend(ProductDetailModel info)
        {
            if (info.RecommonItems.Count == 0)
            {
                var items = PROD_MASTERService.PROD_MASTERList.Where(t => t.CategoryCode == info.CategoryCode)
                            .AsEnumerable()
                            .Select(t => new ProductModel
                {
                    ID               = t.ID,
                    ProductNo        = t.ProductNo,
                    ProductName      = t.Item03 == "1" ? t.Item02 : t.ProductName,
                    ProductType      = t.ProductType,
                    StockType        = t.StockType,
                    BigPic           = Common.Util.GetProductImgUrl(t.BigPic, false),
                    MiddlePic        = Common.Util.GetProductImgUrl(t.SmallPic).Replace("Small", "Middl"),
                    SmallPic         = Common.Util.GetProductImgUrl(t.SmallPic),
                    ProdCategoryCode = t.CategoryCode,
                    BaseUOFM         = t.BaseUOFM,
                    ListPrice        = Common.Util.TransformObjToDou(t.ListPrice),
                    SellPrice        = PROD_MASTERService.GetSellPrice(t.ProductNo, Common.Util.TransformObjToDou(t.ListPrice), (double)t.SpecialPrice),
                }).Take(4);

                info.RecommonItems = items.ToList();
            }
        }
        protected int _AddCart(string pno, int qty)
        {
            int ret = 0;

            if (!string.IsNullOrEmpty(pno) && CurrentUser != null)
            {
                Domain.Models.Product.PROD_MASTER prod = PROD_MASTERService.GetProduct(pno);
                if (prod != null)
                {
                    if (CurrentUser.AccountInfo != null)
                    {
                        string unitPriceType = string.Empty;
                        double uPrice        = 0;
                        PROD_MASTERService.GetSellingPrice(prod.ProductNo, CurrentUser.AccountInfo.Account_no, out uPrice, out unitPriceType);
                        if (uPrice == 0)
                        {
                            uPrice = (double)prod.ListPrice;
                        }
                        var model = new SALES_EBASKETModel
                        {
                            ID          = Quick.Framework.Tool.CombHelper.NewComb().ToString(),
                            ContactID   = CurrentUser.Id,
                            CreateDate  = DateTime.Now,
                            Creator     = CurrentUser.AccountInfo.Account_no,
                            CustomerID  = CurrentUser.AccountInfo.Account_no,//request
                            ModiDate    = DateTime.Now,
                            Modifier    = CurrentUser.AccountInfo.Account_no,
                            ProductNo   = prod.ProductNo,
                            Quantity    = Convert.ToDouble(qty),
                            Unit        = prod.BaseUOFM,
                            UnitPrice   = uPrice,
                            UnitPType   = unitPriceType,
                            Status      = 0,
                            MakeOrderID = "",
                        };
                        if ((bool)CurrentUser.IsContractLimit && unitPriceType != "L") //only to purchase contract goods
                        {
                            if (unitPriceType == "S")                                  //Special Price
                            {
                                bool hasContractPrice = SALES_CONTRACTPRICEService.IsExist(CurrentUser.AccountInfo.Account_no, prod.ProductNo);
                                if (!hasContractPrice)
                                {
                                    return(-10);
                                    //return Json(new { success = false, message = "You need to purchase contract goods." });
                                }
                            }
                        }
                        ret = SALES_EBASKETService.ModificationCart(model); //成功了
                        //ret = SALES_EBASKETService.ModificationByProce(model);//有问题不可以使用
                    }
                }
            }
            return(ret);
        }
Exemple #3
0
        // GET: Product
        public ActionResult Index(int id = 1)
        {
            //分页控件语言定义
            Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            string tab_type = Common.Util.GetCookie("snell_product_tab_type");

            if (string.IsNullOrEmpty(tab_type))
            {
                Common.Util.SetCookie("snell_product_tab_type", "list");
            }

            var categorycode = Request.Params["categorycode"] ?? "P01";

            if (!string.IsNullOrEmpty(categorycode))
            {
                ViewBag.LeftMenusModel = base.InitNavMenu(categorycode);
            }

            var filterResult = PROD_MASTERService.PROD_MASTERList.Where(t => t.CategoryCode.Equals(categorycode) || t.ProdGroupID.Equals(categorycode) || t.ProdSubclassID.Equals(categorycode))
                               .AsEnumerable()
                               .Select(t => new ProductModel
            {
                ID               = t.ID,
                ProductNo        = t.ProductNo,
                ProductName      = t.Item03 == "1" ? t.Item02 : t.ProductName,
                ProductType      = t.ProductType,
                StockType        = t.StockType,
                BigPic           = Common.Util.GetProductImgUrl(t.BigPic, false),
                MiddlePic        = Common.Util.GetProductImgUrl(t.SmallPic).Replace("Small", "Middl"),
                SmallPic         = Common.Util.GetProductImgUrl(t.SmallPic),
                ProdCategoryCode = t.CategoryCode,
                BaseUOFM         = t.BaseUOFM,
                ListPrice        = Common.Util.TransformObjToDou(t.ListPrice),
                SellPrice        = PROD_MASTERService.GetSellPrice(t.ProductNo, Common.Util.TransformObjToDou(t.ListPrice), (double)t.SpecialPrice),
            }).OrderByDescending(t => t.ID).ToPagedList(id, 24);

            ViewBag.PagedListProductModel = filterResult;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ProductsList"));
            }

            return(View());
        }
Exemple #4
0
        private void GetProductPrice(ProductDetailModel info)
        {
            if (info != null && info.ID != null)
            {
                info.SellPrice = (double)info.ListPrice;
                if (base.CurrentUser != null && base.CurrentUser.AccountInfo != null)
                {
                    string custnmbr = base.CurrentUser.AccountInfo.Account_no;
                    double price    = 0;
                    string ptype    = string.Empty;
                    PROD_MASTERService.GetSellingPrice(info.ProductNo, custnmbr, out price, out ptype);
                    info.PriceType = ptype;
                    info.SellPrice = price;
                }
                else
                {
                    if (info.SpecialPrice > 0 && info.SpecialPrice < info.ListPrice)
                    {
                        info.PriceType = "S";
                        info.SellPrice = (double)info.SpecialPrice;
                    }
                }
                string cla = "";
                switch (info.PriceType)
                {
                case "S":
                    cla = "prod_price_sp";
                    break;

                case "C":
                    cla = "prod_price_cp";
                    break;

                case "I":
                    cla = "prod_price_ip";
                    break;

                case "L":
                    break;
                }
                info.PriceTypeCss = cla;
            }
        }
Exemple #5
0
        public ActionResult Hotspecials(string cate, int id = 1)
        {
            //分页控件语言定义
            Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            string tab_type = Common.Util.GetCookie("snell_product_tab_type");

            if (string.IsNullOrEmpty(tab_type))
            {
                Common.Util.SetCookie("snell_product_tab_type", "list");
            }
            var orderby  = Request.Params["sortModle"] ?? " ProductName asc";
            var category = Request.Params["category"] ?? "";

            if (!string.IsNullOrEmpty(category))
            {
                var cates = JsonConvert.DeserializeObject <List <string> >(category);
                category = string.Join(",", cates.ToArray());
            }
            int pageSize  = 40;
            int pageCount = 0;

            string strWhere = string.Empty;

            if (!string.IsNullOrEmpty(category))
            {
                string cateWhere = string.Empty;

                string[]      cateArr  = category.Split(',');
                List <string> cateList = new List <string>();
                foreach (string c in cateArr)
                {
                    cateList.Add("'" + c + "'");
                }
                cateWhere = string.Join(",", cateList.ToArray());

                strWhere = string.Format(" and {1} in ({0})", cateWhere, "a.CategoryCode");
            }
            //if (condition.Count > 0) strWhere = string.Join(" and ", condition.ToArray());

            var dt = PROD_MASTERService.GetHotSpecials(cate, strWhere, string.Empty);// Ben 2012-12-25

            if (dt != null && dt.Count() > 0)
            {
                pageCount = dt.Count();
                var items = dt.AsEnumerable()
                            .Select(t => new EOF_PAGE_MASTER
                {
                    ProductID    = t.ID,
                    ProductNo    = t.ProductNo,
                    ProductName  = t.ProductName,
                    BigPic       = Common.Util.GetProductImgUrl(t.BigPic, false),
                    SmallPic     = Common.Util.GetProductImgUrl(t.SmallPic),
                    MiddlePic    = Common.Util.GetProductImgUrl(t.SmallPic).Replace("Small", "Middl"),
                    StockType    = t.StockType,
                    SellPrice    = PROD_MASTERService.GetSellPrice(t.ProductNo, Common.Util.TransformObjToDou(t.ListPrice), (double)t.SpecialPrice),          //在EasiorderForm不需要对价格进行处理,因为已经登陆了
                    CategoryName = string.IsNullOrEmpty(t.CategoryName) ? t.CategoryCode : t.CategoryName,
                    CategoryCode = t.CategoryCode,
                    BaseUOFM     = t.BaseUOFM,
                    ListPrice    = t.ListPrice,
                    pCount       = pageCount,
                    altPath      = Common.Util.SiteRootURL + "detailchart.aspx?proNo=" + t.ProductNo
                });

                if (!string.IsNullOrEmpty(orderby) && orderby.IndexOf("SellPrice") > -1)
                {
                    if (orderby.IndexOf("asc") > -1)
                    {
                        items.OrderBy(i => i.SellPrice);
                    }
                    if (orderby.IndexOf("desc") > -1)
                    {
                        items.OrderByDescending(i => i.SellPrice);
                    }
                }
                items = items.Skip((id - 1) * pageSize).Take(pageSize);

                ViewBag.PagedListModel = new PagedList <EOF_PAGE_MASTER>(items, id, pageSize, pageCount);

                EOF_PAGE_Other2_MASTER eof_master = new EOF_PAGE_Other2_MASTER();
                ViewBag.EOF_Model     = eof_master;
                eof_master.Categories = BindHotspecialsCategory(items).ToList();
            }
            if (Request.IsAjaxRequest())
            {
                System.Threading.Thread.Sleep(1000);
                return(PartialView("../Office/_CustomizedProdList"));
            }

            return(View());
        }
Exemple #6
0
        public ActionResult Detail(string id, string ptype = "id")
        {
            if (string.IsNullOrEmpty(id))
            {
                return(View("Error"));
            }

            var model  = new ProductDetailModel();
            var entity = new PROD_MASTER();

            if (ptype == "id")
            {
                entity = PROD_MASTERService.PROD_MASTERList.FirstOrDefault(t => t.ID == id);
            }
            else
            {
                entity = PROD_MASTERService.PROD_MASTERList.FirstOrDefault(t => t.ProductNo == id);
            }

            if (null != entity)
            {
                var photos = PROD_PHOTOService.PROD_PHOTOList.Where(t => t.EntityID == entity.ID)
                             .AsEnumerable()
                             .Select(t => new PROD_PHOTOModel
                {
                    ID           = t.ID,
                    PhotoTitle   = t.PhotoTitle,
                    FilePath     = t.FilePath,
                    IsDefault    = t.IsDefault,
                    PhotoType    = t.PhotoType,
                    EntityID     = t.EntityID,
                    SmallPic     = Common.Util.GetProductImgUrl(t.SmallPic),
                    BigPic       = Common.Util.GetProductImgUrl(t.BigPic),
                    MiddlePic    = t.MiddlePic,
                    CreateDate   = t.CreateDate,
                    ModiDate     = t.ModiDate,
                    Creator      = t.Creator,
                    Modifier     = t.Modifier,
                    DisplayOrder = t.DisplayOrder,
                    Status       = t.Status,
                    Item01       = t.Item01,
                    Item02       = t.Item02,
                    Item03       = t.Item03,
                    Item04       = t.Item04,
                    Item05       = t.Item05,
                }).Take(4);
                var commonItems = PROD_MASTERCOMMONService.PROD_MASTERCOMMONList.Where(t => t.ProductNo == entity.ProductNo)
                                  .Select(t => new PROD_MASTERCOMMONModel
                {
                    ID          = t.ID,
                    ProductNo   = t.ProductNo,
                    CommTitle   = t.CommTitle,
                    CommSummary = t.CommSummary,
                    CommContent = t.CommContent,
                    Creator     = t.Creator,
                    CreateDate  = t.CreateDate,
                    Modifier    = t.Modifier,
                    ModiDate    = t.ModiDate,
                    Status      = t.Status,
                    Item01      = t.Item01,
                    Item02      = t.Item02,
                    Item03      = t.Item03,
                    Item04      = t.Item04,
                    Item05      = t.Item05,
                });
                var subItems = PROD_PROPERTIESService.PROD_PROPERTIESList.Where(t => t.ProductNo == entity.ProductNo)
                               .Select(t => new PROD_PROPERTIESModel
                {
                    ID            = t.ID,
                    ProductNo     = t.ProductNo,
                    PropertyID    = t.PropertyID,
                    PropertyValue = t.PropertyValue,
                    PLevel        = t.PLevel,
                    ParentID      = t.ParentID,
                    RelationCode  = t.RelationCode,
                    RowID         = t.RowID,
                    RealProductNo = t.RealProductNo,
                    DisplayOrder  = t.DisplayOrder,
                    Remark        = t.Remark,
                    Status        = t.Status,
                });
                var recommonItems = PROD_RELATEDITEMService.PROD_RELATEDITEM_MASTERList.Where(t => t.ProductNo == entity.ProductNo)
                                    .AsEnumerable()
                                    .Select(t => new ProductModel
                {
                    ProductNo        = t.ProductNo,
                    ProductName      = t.ProductName,
                    BigPic           = Common.Util.GetProductImgUrl(t.BigPic, false),
                    SmallPic         = Common.Util.GetProductImgUrl(t.SmallPic),
                    ProdCategoryCode = t.CategoryCode,
                    BaseUOFM         = t.BaseUOFM,
                    ListPrice        = Common.Util.TransformObjToDou(t.ListPrice),
                    SellPrice        = PROD_MASTERService.GetSellPrice(t.ProductNo, Common.Util.TransformObjToDou(t.ListPrice), (double)t.SpecialPrice),
                }).Take(10);
                model = new ProductDetailModel
                {
                    ID                 = entity.ID,
                    ProductNo          = entity.ProductNo,
                    ProductName        = entity.ProductName,
                    Description        = entity.Description,
                    ProductType        = entity.ProductType,
                    StndCost           = entity.StndCost,
                    CurrCost           = entity.CurrCost,
                    ListPrice          = entity.ListPrice,
                    SpecialPrice       = entity.SpecialPrice,
                    ClearPrice         = entity.ClearPrice,
                    ProdCategoryID     = entity.ProdCategoryID,
                    CategoryCode       = entity.CategoryCode,
                    SchdlUOM           = entity.SchdlUOM,
                    PriceShed          = entity.PriceShed,
                    BaseUOFM           = entity.BaseUOFM,
                    AvailableQTY       = entity.AvailableQTY,
                    ProdGroupID        = entity.ProdGroupID,
                    ProdSubclassID     = entity.ProdSubclassID,
                    LeadTime           = entity.LeadTime,
                    QtySales           = entity.QtySales,
                    QtyMin             = entity.QtyMin,
                    QtyMax             = entity.QtyMax,
                    CustomerID         = entity.CustomerID,
                    StockType          = entity.StockType,
                    SalesRepID         = entity.SalesRepID,
                    PriceBookItem      = entity.PriceBookItem,
                    PriceLevel         = entity.PriceLevel,
                    BarCode            = entity.BarCode,
                    Ranking            = entity.Ranking,
                    Notes              = entity.Notes,
                    Substitute1        = entity.Substitute1,
                    Substitute2        = entity.Substitute2,
                    Qty1               = entity.Qty1,
                    Qty3               = entity.Qty3,
                    Qty6               = entity.Qty6,
                    Qty12              = entity.Qty12,
                    Sales1             = entity.Sales1,
                    Sales3             = entity.Sales3,
                    Sales6             = entity.Sales6,
                    Sales12            = entity.Sales12,
                    GPD1               = entity.GPD1,
                    GPD3               = entity.GPD3,
                    GPD6               = entity.GPD6,
                    GPD12              = entity.GPD12,
                    LastDate           = entity.LastDate,
                    CreateDate         = entity.CreateDate,
                    Creator            = entity.Creator,
                    Modifier           = entity.Modifier,
                    ModiDate           = entity.ModiDate,
                    Status             = entity.Status,
                    P01                = entity.P01,
                    P02                = entity.P02,
                    P03                = entity.P03,
                    P04                = entity.P04,
                    P05                = entity.P05,
                    P06                = entity.P06,
                    P07                = entity.P07,
                    P08                = entity.P08,
                    P09                = entity.P09,
                    P10                = entity.P10,
                    IsCommend          = entity.IsCommend,
                    IsHot              = entity.IsHot,
                    ExteriorPart       = entity.ExteriorPart,
                    ExteriorPartPrice  = entity.ExteriorPartPrice,
                    ViewTimes          = entity.ViewTimes,
                    BigPic             = Common.Util.GetProductImgUrl(entity.BigPic, false),
                    SmallPic           = Common.Util.GetProductImgUrl(entity.SmallPic),
                    LocationStocks1    = entity.LocationStocks1,
                    LocationStocks2    = entity.LocationStocks2,
                    LocationStocks3    = entity.LocationStocks3,
                    LocationStocks4    = entity.LocationStocks4,
                    LocationStocks5    = entity.LocationStocks5,
                    LocationStocks6    = entity.LocationStocks6,
                    LocationStocks7    = entity.LocationStocks7,
                    LocationStocks8    = entity.LocationStocks8,
                    LocationStocks9    = entity.LocationStocks9,
                    LocationStocks10   = entity.LocationStocks10,
                    LocationStocks11   = entity.LocationStocks11,
                    LocationStocks12   = entity.LocationStocks12,
                    LocationStocks13   = entity.LocationStocks13,
                    LocationStocks14   = entity.LocationStocks14,
                    LocationStocks15   = entity.LocationStocks15,
                    LocationAllocate1  = entity.LocationAllocate1,
                    LocationAllocate2  = entity.LocationAllocate2,
                    LocationAllocate3  = entity.LocationAllocate3,
                    LocationAllocate4  = entity.LocationAllocate4,
                    LocationAllocate5  = entity.LocationAllocate5,
                    LocationAllocate6  = entity.LocationAllocate6,
                    LocationAllocate7  = entity.LocationAllocate7,
                    LocationAllocate8  = entity.LocationAllocate8,
                    LocationAllocate9  = entity.LocationAllocate9,
                    LocationAllocate10 = entity.LocationAllocate10,
                    LocationAllocate11 = entity.LocationAllocate11,
                    LocationAllocate12 = entity.LocationAllocate12,
                    LocationAllocate13 = entity.LocationAllocate13,
                    LocationAllocate14 = entity.LocationAllocate14,
                    LocationAllocate15 = entity.LocationAllocate15,
                    Introduction       = entity.Introduction,
                    Brand              = entity.Brand,
                    Item01             = entity.Item01,
                    Item02             = entity.Item02,
                    Item03             = entity.Item03,
                    Item04             = entity.Item04,
                    Item05             = entity.Item05,

                    PhotoList     = photos.ToList(),
                    CommonItems   = commonItems.ToList(),
                    SubItems      = subItems.ToList(),
                    RecommonItems = recommonItems.ToList(),
                    PDF_file      = BindPDF(entity.Introduction),
                };
            }
            GetProductPrice(model);
            BindInformation(model);
            BindRecommend(model);
            BindDefalultPic(model);
            ViewBag.ProductDetailModel = model;
            var barChart = new BarChart();

            if (CurrentUser != null)
            {
                Chart("Your most recently purchased quantities", model.ProductNo, barChart);
            }
            ViewBag.Chart = barChart;
            return(View());
        }