示例#1
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());
        }
示例#2
0
        public OperationResult Insert(PROD_MASTERModel model)
        {
            var entity = new PROD_MASTER
            {
                ID                 = model.ID,
                ProductNo          = model.ProductNo,
                ProductName        = model.ProductName,
                Description        = model.Description,
                ProductType        = model.ProductType,
                StndCost           = model.StndCost,
                CurrCost           = model.CurrCost,
                ListPrice          = model.ListPrice,
                SpecialPrice       = model.SpecialPrice,
                ClearPrice         = model.ClearPrice,
                ProdCategoryID     = model.ProdCategoryID,
                CategoryCode       = model.CategoryCode,
                SchdlUOM           = model.SchdlUOM,
                PriceShed          = model.PriceShed,
                BaseUOFM           = model.BaseUOFM,
                AvailableQTY       = model.AvailableQTY,
                ProdGroupID        = model.ProdGroupID,
                ProdSubclassID     = model.ProdSubclassID,
                LeadTime           = model.LeadTime,
                QtySales           = model.QtySales,
                QtyMin             = model.QtyMin,
                QtyMax             = model.QtyMax,
                CustomerID         = model.CustomerID,
                StockType          = model.StockType,
                SalesRepID         = model.SalesRepID,
                PriceBookItem      = model.PriceBookItem,
                PriceLevel         = model.PriceLevel,
                BarCode            = model.BarCode,
                Ranking            = model.Ranking,
                Notes              = model.Notes,
                Substitute1        = model.Substitute1,
                Substitute2        = model.Substitute2,
                Qty1               = model.Qty1,
                Qty3               = model.Qty3,
                Qty6               = model.Qty6,
                Qty12              = model.Qty12,
                Sales1             = model.Sales1,
                Sales3             = model.Sales3,
                Sales6             = model.Sales6,
                Sales12            = model.Sales12,
                GPD1               = model.GPD1,
                GPD3               = model.GPD3,
                GPD6               = model.GPD6,
                GPD12              = model.GPD12,
                LastDate           = model.LastDate,
                CreateDate         = model.CreateDate,
                Creator            = model.Creator,
                Modifier           = model.Modifier,
                ModiDate           = model.ModiDate,
                Status             = model.Status,
                P01                = model.P01,
                P02                = model.P02,
                P03                = model.P03,
                P04                = model.P04,
                P05                = model.P05,
                P06                = model.P06,
                P07                = model.P07,
                P08                = model.P08,
                P09                = model.P09,
                P10                = model.P10,
                IsCommend          = model.IsCommend,
                IsHot              = model.IsHot,
                ExteriorPart       = model.ExteriorPart,
                ExteriorPartPrice  = model.ExteriorPartPrice,
                ViewTimes          = model.ViewTimes,
                SmallPic           = model.SmallPic,
                BigPic             = model.BigPic,
                LocationStocks1    = model.LocationStocks1,
                LocationStocks2    = model.LocationStocks2,
                LocationStocks3    = model.LocationStocks3,
                LocationStocks4    = model.LocationStocks4,
                LocationStocks5    = model.LocationStocks5,
                LocationStocks6    = model.LocationStocks6,
                LocationStocks7    = model.LocationStocks7,
                LocationStocks8    = model.LocationStocks8,
                LocationStocks9    = model.LocationStocks9,
                LocationStocks10   = model.LocationStocks10,
                LocationStocks11   = model.LocationStocks11,
                LocationStocks12   = model.LocationStocks12,
                LocationStocks13   = model.LocationStocks13,
                LocationStocks14   = model.LocationStocks14,
                LocationStocks15   = model.LocationStocks15,
                LocationAllocate1  = model.LocationAllocate1,
                LocationAllocate2  = model.LocationAllocate2,
                LocationAllocate3  = model.LocationAllocate3,
                LocationAllocate4  = model.LocationAllocate4,
                LocationAllocate5  = model.LocationAllocate5,
                LocationAllocate6  = model.LocationAllocate6,
                LocationAllocate7  = model.LocationAllocate7,
                LocationAllocate8  = model.LocationAllocate8,
                LocationAllocate9  = model.LocationAllocate9,
                LocationAllocate10 = model.LocationAllocate10,
                LocationAllocate11 = model.LocationAllocate11,
                LocationAllocate12 = model.LocationAllocate12,
                LocationAllocate13 = model.LocationAllocate13,
                LocationAllocate14 = model.LocationAllocate14,
                LocationAllocate15 = model.LocationAllocate15,
                Introduction       = model.Introduction,
                Brand              = model.Brand,
                Item01             = model.Item01,
                Item02             = model.Item02,
                Item03             = model.Item03,
                Item04             = model.Item04,
                Item05             = model.Item05,
            };

            PROD_MASTERRepository.Insert(entity);
            return(new OperationResult(OperationResultType.Success, "Added successfully"));
        }