예제 #1
0
        public void Setup()
        {
            repository = new Mock<IRepository<Product>>();
            priceRepository = new Mock<IRepository<Price>>();

            service = new ProductService(repository.Object, priceRepository.Object);
        }
예제 #2
0
        public void 取得ProductByImageCodeTest()
        {
            // arrange
            var products = this.GetProduct().AsQueryable();
            var productPictures = this.GetProductPicture().AsQueryable();
            var mockProduct = products.ElementAt(0);

            var mockProductDbSet = Substitute.For<IDbSet<Product>>().Initialize(products);
            var mockProductPictureDbSet = Substitute.For<IDbSet<ProductPicture>>().Initialize(productPictures);
            var mockDbContext = Substitute.For<ICMSDbContext>();

            mockDbContext.Products = mockProductDbSet;
            mockDbContext.ProductPictures = mockProductPictureDbSet;

            var productService = new ProductService(mockDbContext);

            // act
            var result = productService.GetProductByItemCode(mockProduct.ItemCode);

            // assert
            result.Should().NotBeNull();
            result.Id.Should().Be(1);
            result.ItemCode.Should().Be("1000000100101");
            result.ProductPictures.Count.Should().Be(1);
            result.ProductPictures.ElementAt(0).Id.Should().Be(1);
        }
예제 #3
0
 public ActionResult Index()
 {
     ProductService productService = new ProductService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     var model = new List<ProductModel>();
     productService.GetAll().ForEach(p => model.Add(new ProductModel(p)));
     return View(model);
 }
        public void CreateIndex()
        {
            IProductService productService = new ProductService();
            int count = productService.GetProductCount(string.Empty);
            var data = productService.GetProducts(count, 1, string.Empty);

            //设置为多文件索引的格式,默认情况下为true,会建立复合索引的文件结构,这里为了分析,先设置为false,生成多文件的索引结构
            //this.indexWriter.SetUseCompoundFile(false);

            foreach (var productInfo in data)
            {
                var doc = new Document();
                var field1 = new Field("title", productInfo.Title, Field.Store.YES, Field.Index.ANALYZED);
                // 向文档中添加域
                doc.Add(field1);
                field1 = new Field("Category", productInfo.CategoryName, Field.Store.YES, Field.Index.ANALYZED);
                doc.Add(field1);
                field1 = new Field("Desc", productInfo.Desc??"", Field.Store.YES, Field.Index.ANALYZED);
                doc.Add(field1);
                this.indexWriter.AddDocument(doc);
            }

            // 优化索引结构
            this.indexWriter.Optimize();

            this.indexWriter.Commit();
            // 关闭写入
            this.indexWriter.Close();
        }
예제 #5
0
 public ActionResult Index()
 {
     var products = new ProductService(db).GetByCustomer(
                                             db.Users.Where(u => u.UserName == User.Identity.Name)
                                             .FirstOrDefault()
                                             .Id);
     return View(products);
 }
 public string AddReview(string prodId, ProductService.Model.Review review)
 {
     review.Id = ObjectId.GenerateNewId().ToString();
     review.ProdId = prodId;
     review.ReviewDate = DateTime.UtcNow;
     MongoHelper.ReviewsCollection.Insert(review);
     return review.Id;
 }
예제 #7
0
 public TransferManager(IronBankEntities context)
 {
     if (context == null)
         throw new ArgumentNullException("TransferManager: context can not be null.");
     db = context;
     productsManager = new ProductService(db);
     transactionManager = new TransactionService(db);
 }
        private bool disposedValue = false; // To detect redundant calls

        #endregion Fields

        #region Constructors

        public ServiceManager()
        {
            context = new TankshopDbContext();
            Categories = new CategoryService(new CategoryRepository(context));
            Products = new ProductService(new ProductRepository(context));
            Images = new ImageBLL();
            Accounts = new AccountBLL();
        }
예제 #9
0
 static void AddProduct(Default.Container container, ProductService.Models.Product product)
 {
     container.AddToProducts(product);
     var serviceResponse = container.SaveChanges();
     foreach (var operationResponse in serviceResponse)
     {
         Console.WriteLine("Response: {0}", operationResponse.StatusCode);
     }
 }
예제 #10
0
        public void GetProductWithInValidIDThrowsException()
        {
            // Arrange
            IProductRepository productRepository = Mock.Create<IProductRepository>();
            ProductService productService = new ProductService(productRepository);

            // Act & Assert
            Assert.Throws<ProductNotFoundException>(() => productService.GetByID("invalid-id"));
        }
예제 #11
0
 public ProductsVM(ProductService productsService, MainWindowVM mainVM)
 {
     _productsService = productsService;
     _mainVM = mainVM;
     _addProductCommand = new Command(() => AddProduct());
     _saveProductsCommand = new Command(async () => await SaveProductsAsync());
     _loadProductsCommand = new Command(async () => await LoadProductsAsync());
     _deleteSelectedCommand = new Command(async () => await DeleteSelectedItemAsync());
 }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            // Get the BudgetSuggestionService.
              BudgetSuggestionService budgetSuggestionService = (BudgetSuggestionService)
              user.GetService(AdWordsService.v201601.BudgetSuggestionService);

              BudgetSuggestionSelector selector = new BudgetSuggestionSelector();

              List<Criterion> criteria = new List<Criterion>();

              // Criterion - Travel Agency product/service. See GetProductServices.cs for an example
              // of how to get valid product/service settings.
              ProductService productService = new ProductService();
              productService.text = "Travel Agency";
              productService.locale = "en_US";
              criteria.Add(productService);

              // Criterion - English language.
              // The ID can be found in the documentation:
              // https://developers.google.com/adwords/api/docs/appendix/languagecodes
              Language language = new Language();
              language.id = 1000L;
              criteria.Add(language);

              // Criterion - Mountain View, California location.
              // The ID can be found in the documentation:
              // https://developers.google.com/adwords/api/docs/appendix/geotargeting
              // https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions
              Location location = new Location();
              location.id = 1014044L;
              criteria.Add(location);

              selector.criteria = criteria.ToArray();

              try {
            BudgetSuggestion budgetSuggestion = budgetSuggestionService.get(selector);

            Console.WriteLine("Budget suggestion for criteria is:\n" +
            "  SuggestedBudget={0}\n" +
            "  Min/MaxBudget={1}/{2}\n" +
            "  Min/MaxCpc={3}/{4}\n" +
            "  CPM={5}\n" +
            "  CPC={6}\n" +
            "  Impressions={7}\n",
            budgetSuggestion.suggestedBudget.microAmount,
            budgetSuggestion.minBudget.microAmount, budgetSuggestion.maxBudget.microAmount,
            budgetSuggestion.minCpc.microAmount, budgetSuggestion.maxCpc.microAmount,
            budgetSuggestion.cpm.microAmount,
            budgetSuggestion.cpc.microAmount,
            budgetSuggestion.impressions);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to get budget suggestion.", e);
              }
        }
예제 #13
0
        public void 儲存一張主要的產品圖片而且原本沒有圖片Test()
        {
            // arrange

            var mockProduct = new Product
            {
                Id = 1,
                ItemCode = "1000000100101"
            };

            var mockUploadImage = new UploadIamge
            {
                ItemCode = mockProduct.ItemCode,
                PictureType = ProductPictureType.Product,
                BlobPath = "",
                Seq = "01"
            };

            var mockProductPicture = new ProductPicture
            {
                Id = 1,
                ProductId = 1,
                ProductPictureType = 1,
                IsMainPicture = true,
                ImageUrl = "imageUrl"
            };

            var mockProductPictures = new List<ProductPicture>()
            {
                mockProductPicture
            }.AsQueryable();

            var mockProductPictureDbSet = Substitute.For<IDbSet<ProductPicture>>().Initialize(mockProductPictures);
            var mockDbContext = Substitute.For<ICMSDbContext>();

            var productService = new ProductService(mockDbContext);
            mockProductPictureDbSet.Add(mockProductPicture).Returns(mockProductPicture);

            mockDbContext.ProductPictures = mockProductPictureDbSet;

            // act
            productService.SaveProductImageData(mockProduct, mockUploadImage, mockProductPicture.ImageUrl);

            // assert
            mockDbContext.ProductPictures.Should().NotBeNull();

            var productPictureResut = mockDbContext.ProductPictures.ElementAt(0);

            productPictureResut.Should().NotBeNull();
            productPictureResut.Id.Should().Be(mockProductPicture.Id);
            productPictureResut.ImageUrl.Should().Be(mockProductPicture.ImageUrl);
            productPictureResut.IsMainPicture.Should().BeTrue();
            productPictureResut.ProductPictureType.Should().Be(mockProductPicture.ProductPictureType);
        }
예제 #14
0
        public void GetProductWithValidIDReturnsProduct()
        {
            // Arrange
            IProductRepository productRepository = new FakeProductRepository();
            ProductService productService = new ProductService(productRepository);

            // Act
            Product product = productService.GetByID("spr-product");

            // Assert
            Assert.IsNotNull(product);
        }
예제 #15
0
        public ActionResult Index()
        {
            ProductService productService = new ProductService();
            NewProductModel model = productService.GetNewProduct(0, RecordPerPage);
            int totalPage = model.count / RecordPerPage;
            if (totalPage * RecordPerPage < model.count)
            {
                totalPage++;
            }
            ViewBag.TotalPage = totalPage;

            return View(model.data);
        }
예제 #16
0
        public void GetProductWithValidIDReturnsProduct()
        {
            // Arrange
            IProductRepository productRepository = Mock.Create<IProductRepository>();
            Mock.Arrange(() => productRepository.GetByID("spr-product")).Returns(new Product());
            ProductService productService = new ProductService(productRepository);

            // Act
            Product product = productService.GetByID("spr-product");

            // Assert
            Assert.IsNotNull(product);
        }
예제 #17
0
        //
        // GET: /Order/Details/5
        public ActionResult Details(int id)
        {
            DonDatHang dh = service.GetOrder(id);
            if (dh != null)
            {
                ProductService pService = new ProductService();
                foreach (ChiTietDonHang ctdh in dh.ChiTietDonHangs)
                {
                    ctdh.SanPham = pService.GetProduct(ctdh.MaSP);
                }
            }

            return View(dh);
        }
예제 #18
0
        static void Main(string[] args)
        {
            var service = new ProductService(new ProductEFRepository());
            Console.WriteLine(service.GenerateCode());

            //var product = service.New();

            var product = new Product { Id = 1, Code = "P01", Name = "Test" };
            var product1 = new Product { Id = 1, Code = "P01", Name = "Test" };

            Console.WriteLine(product == product1);
            Console.WriteLine(product.Equals(product1));
            Console.WriteLine(product.GetHashCode());
            Console.WriteLine(product1.GetHashCode());
        }
예제 #19
0
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     var productsDataProxy = new ProductRepository();
     var inventoryDataProxy = new InventoryItemRepository();
     var customerDataProxy = new CustomerRepository();
     var orderItemDataProxy = new OrderItemRepository();
     var orderRepository = new OrderRepository(customerDataProxy, orderItemDataProxy);
     _inventoryService = new InventoryItemService(inventoryDataProxy);
     _orderItemsService = new OrderItemService(orderItemDataProxy, productsDataProxy, inventoryDataProxy, new DTCTransactionContext());
     _ordersService = new OrderService(orderRepository, _orderItemsService, new DTCTransactionContext());
     _customersService = new CustomerService(customerDataProxy, _ordersService);
     _productsService = new ProductService(productsDataProxy, _ordersService, _inventoryService, new DTCTransactionContext());
     _categoriesService = new CategoryService(new CategoryRepository(), _productsService);
     this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService);
 }
예제 #20
0
 private void ConfigureEFUsage()
 {
     var productsDataProxy = new DAL.EF.ProductRepository();
     var inventoryDataProxy = new DAL.EF.InventoryItemRepository();
     var customerDataProxy = new DAL.EF.CustomerRepository();
     var orderItemDataProxy = new DAL.EF.OrderItemRepository();
     var orderRepository = new DAL.EF.OrderRepository();
     var categoriesDataProxy = new DAL.EF.CategoryRepository();
     _inventoryService = new InventoryItemService(inventoryDataProxy);
     _orderItemsService = new OrderItemService(orderItemDataProxy, productsDataProxy, inventoryDataProxy, new DTCTransactionContext());
     _ordersService = new OrderService(orderRepository, _orderItemsService, new DTCTransactionContext());
     _customersService = new CustomerService(customerDataProxy, _ordersService);
     _productsService = new ProductService(productsDataProxy, orderRepository, _inventoryService, new DTCTransactionContext());
     _categoriesService = new CategoryService(categoriesDataProxy, productsDataProxy);
     this.DataContext = new MainWindowVM(_eventAggregator, _customersService, _productsService, _categoriesService, _ordersService, _inventoryService);
 }
        public void GetPropertyGroupSum_4筆一組_取Revenue總和Test()
        {
            //arrange
            var size = 4;
            var property = ProductProperty.Revenue;

            var stubDataDao = Substitute.For<IProductDataDao>();
            stubDataDao.GetProducts().Returns(_products);
            var target = new ProductService(stubDataDao);
            var excepted = new int[] { 50, 66, 60 };

            //act
            var actual = target.GetPropertyGroupSum(property, size);

            //assert
            excepted.ToExpectedObject().ShouldEqual(actual);
        }
예제 #22
0
 public MainWindowVM(EventAggregator eventAggregator,
                     CustomerService customerService,
                     ProductService productService,
                     CategoryService categoryService,
                     OrderService orderService,
                     InventoryItemService inventoryService)
 {
     _customersVM = new CustomersVM(customerService);
     _customersVM.LoadCustomersCommand.Execute(null);
     _productsVM = new ProductsVM(productService, this);
     _productsVM.LoadProductsCommand.Execute(null);
     _categoriesVM = new CategoriesVM(categoryService);
     _categoriesVM.LoadCategoriesCommand.Execute(null);
     _ordersVM = new OrdersVM(orderService, this, eventAggregator);
     _ordersVM.LoadOrdersCommand.Execute(null);
     _inventoryItemsVM = new InventoryItemsVM(inventoryService, this);
     _inventoryItemsVM.LoadInventoryCommand.Execute(null);
 }
예제 #23
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="businessId">The AdWords Express business id.</param>
        public void Run(AdWordsUser user, long businessId)
        {
            // Get the PromotionService
              PromotionService promotionService = (PromotionService)
              user.GetService(AdWordsService.v201601.PromotionService);

              // Set the business ID to the service.
              promotionService.RequestHeader.expressBusinessId = businessId;

              // First promotion
              Promotion marsTourPromotion = new Promotion();
              Money budget = new Money();
              budget.microAmount = 1000000L;
              marsTourPromotion.name = "Mars Tour Promotion " + ExampleUtilities.GetShortRandomString();
              marsTourPromotion.status = PromotionStatus.PAUSED;
              marsTourPromotion.destinationUrl = "http://www.example.com";
              marsTourPromotion.budget = budget;
              marsTourPromotion.callTrackingEnabled = true;

              // Criteria

              // Criterion - Travel Agency product service
              ProductService productService = new ProductService();
              productService.text = "Travel Agency";

              // Criterion - English language
              // The ID can be found in the documentation:
              // https://developers.google.com/adwords/api/docs/appendix/languagecodes
              Language language = new Language();
              language.id = 1000L;

              // Criterion - State of California
              Location location = new Location();
              location.id = 21137L;

              marsTourPromotion.criteria = new Criterion[] { productService, language, location };

              // Creative
              Creative creative = new Creative();
              creative.headline = "Standard Mars Trip";
              creative.line1 = "Fly coach to Mars";
              creative.line2 = "Free in-flight pretzels";

              marsTourPromotion.creatives = new Creative[] { creative };

              PromotionOperation operation = new PromotionOperation();
              operation.@operator = Operator.ADD;
              operation.operand = marsTourPromotion;

              try {
            Promotion[] addedPromotions = promotionService.mutate(
            new PromotionOperation[] { operation });

            Console.WriteLine("Added promotion ID {0} with name {1} to business ID {2}.",
            addedPromotions[0].id, addedPromotions[0].name, businessId);
              } catch (Exception e) {
            throw new System.ApplicationException("Failed to add promotions.", e);
              }
        }
 public ProductController(ProductService service, IMapper mapper)
 {
     this.service = service;
     this.mapper  = mapper;
 }
예제 #25
0
        public void FindOrderPurchasersTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a purchase
            var poh           = GetTestPurchaseOrderHeader(testCompany, testUser, 10);
            var brandCategory = ProductService.FindBrandCategoryModel(poh.BrandCategoryId.Value, testCompany, false);

            string userGroup = brandCategory.CategoryName + " purchasing";

            MembershipManagementService.AddUserToGroup(userGroup, testUser);

            // Get the users
            string errorMsg = "";
            var    users    = PurchasingService.FindOrderPurchasers(poh,
                                                                    testCompany,
                                                                    poh.OrderNumber.Value,
                                                                    ref errorMsg);

            Assert.IsTrue(users != null, errorMsg);
            int expected = 1,
                actual   = users.Count();

            Assert.IsTrue(actual == expected, $"Error: {actual} user(s) were returned when {expected} were expected");

            // Add some more users
            var testUser2 = GetTestUser();

            MembershipManagementService.AddUserToGroup(userGroup, testUser2);
            var testUser3 = GetTestUser();

            MembershipManagementService.AddUserToGroup(userGroup, testUser3);

            users = PurchasingService.FindOrderPurchasers(poh,
                                                          testCompany,
                                                          poh.OrderNumber.Value,
                                                          ref errorMsg);
            Assert.IsTrue(users != null, errorMsg);
            expected = 3;
            actual   = users.Count();
            Assert.IsTrue(actual >= expected, $"Error: {actual} user(s) were returned when {expected} were expected");

            // Now remove one and try again
            MembershipManagementService.DeleteUser(testUser2);

            users = PurchasingService.FindOrderPurchasers(poh,
                                                          testCompany,
                                                          poh.OrderNumber.Value,
                                                          ref errorMsg);
            Assert.IsTrue(users != null, errorMsg);
            expected = 2;
            actual   = users.Count();
            Assert.IsTrue(actual >= expected, $"Error: {actual} user(s) were returned when {expected} were expected");

            // Now delete another and try again
            MembershipManagementService.DeleteUser(testUser3);

            users = PurchasingService.FindOrderPurchasers(poh,
                                                          testCompany,
                                                          poh.OrderNumber.Value,
                                                          ref errorMsg);
            Assert.IsTrue(users != null, errorMsg);
            expected = 1;
            actual   = users.Count();
            Assert.IsTrue(actual >= expected, $"Error: {actual} user(s) were returned when {expected} were expected");
        }
예제 #26
0
 public ProductController()
 {
     this.service = new ProductService(new ProductEFRepository());
 }
예제 #27
0
        public void SetUp()
        {
            this.productRepository = A.Fake <IProductRepository>();

            this.productService = new ProductService(this.productRepository);
        }
예제 #28
0
 private void InitialData()
 {
     var cmd = new ProductService();
     DataSouce = cmd.GetALL();
     gridProduct.DataSource = DataSouce;
     gridProduct.DataBind();
 }
예제 #29
0
 public ProductDetailActivity()
 {
     _productService = new ProductService();
 }
예제 #30
0
 public OrderController()
 {
     _appUserService = new AppUserService();
     _productService = new ProductService();
     _orderService   = new OrderService();
 }
예제 #31
0
 public EditModel(ProductService productService)
 {
     _productService = productService;
 }
        public JsonResult GetProductDetailJson(int ProductId, int StockId)
        {
            ProductViewModel product = new ProductService(_unitOfWork).GetProduct(ProductId);

            return(Json(new { ProductId = product.ProductId, StandardCost = product.StandardCost, UnitId = product.UnitId }));
        }
예제 #33
0
 public ProductController(IMapper mapper, ProductService productService, CategoryService categoryService)
 {
     _mapper          = mapper;
     _productService  = productService;
     _categoryService = categoryService;
 }
예제 #34
0
 public void OnGet()
 {
     Products = ProductService.GetProducts();
 }
예제 #35
0
 public ProductsController(ProductService productService)
 {
     this._productService = productService;
 }
예제 #36
0
        //  ProductService pss = new ProductService();


        public ProductController()
        {
            ps = new ProductService();
            serviceCategory = new CategoryService();
        }
예제 #37
0
        /// <summary>
        /// 统一影响库存方法
        /// </summary>
        /// <param name="records"></param>
        public static void SaveLog(List <InventoryRecord> records)
        {
            if (records == null || !records.Any())
            {
                return;
            }
            InventCache.Clear();
            var storeIds = records.Select(o => o.StoreId).Distinct();
            var barcodes = records.Select(o => o.Barcode).Distinct();
            var procs    = ProductService.FindList(o => !(o.Barcodes == null || o.Barcodes == "") || barcodes.Contains(o.Barcode));
            var rds      = new List <InventoryRecord>();
            var storeDal = new DAL.StoreDAL();

            foreach (var rd in records)
            {
                rd.CreateDT  = DateTime.Now;
                rd.CreateUID = Sys.CurrentUser.UID;
                storeDal.AffectInventory(rd);//调用存储过程
                continue;
                rds.Add(rd);
                if (rd.Source == 13)//批发 (含一品多码,组合,拆分,单品)
                {
                    OutboundUpdateProduct(rd.Number, rd.Barcode, rd.StoreId, rd.OperatId, procs);
                    continue;
                }
                var info = procs.FirstOrDefault(o => o.Barcode == rd.Barcode || ("," + o.Barcodes + ",").Contains("," + rd.Barcode + ","));
                if (info.Nature == 1)//组合
                {
                    var groups = BaseService <ProductGroup> .CurrentRepository.Entities.Where(o => o.Barcode == info.Barcode).ToList();

                    barcodes = groups.Select(o => o.GroupBarcode).ToList();
                    var inventList2 = BaseService <Inventory> .FindList(o => barcodes.Contains(o.Barcode) && o.StoreId == rd.StoreId);

                    rds.Remove(rd);
                    foreach (var g in groups)
                    {
                        var ir = new InventoryRecord()
                        {
                            Number = g.Number * rd.Number, Barcode = g.GroupBarcode, StoreId = rd.StoreId, Source = rd.Source, OperatId = rd.OperatId, CreateDT = rd.CreateDT, CreateUID = rd.CreateUID
                        };
                        UpdateInvent(inventList2, ir);
                        rds.Add(ir);
                    }
                    continue;
                }
                var inventList = BaseService <Inventory> .FindList(o => (o.Barcode == rd.Barcode || o.Barcode == info.Barcode) && o.StoreId == rd.StoreId);

                if (rd.Barcode != info.Barcode && !info.Barcodes.IsNullOrEmpty())//一品多码
                {
                    rd.Barcode = info.Barcode;
                    UpdateInvent(inventList, rd);
                }
                else if (info.Nature == 2 && outSources.Contains(rd.Source))//出库存拆分
                {
                    var purchaseNumber        = rd.Number;
                    var storeId               = rd.StoreId;
                    var childProductInventory = inventList.FirstOrDefault(o => o.StockNumber > 0 && o.Barcode == info.Barcode);
                    if (childProductInventory != null)
                    {
                        var stockNum = childProductInventory.StockNumber;
                        if (stockNum >= purchaseNumber)
                        {
                            UpdateInvent(inventList, rd);
                        }
                        else if (stockNum < purchaseNumber)
                        {
                            var ir = new InventoryRecord()
                            {
                                Number = stockNum, Barcode = rd.Barcode, StoreId = storeId, Source = rd.Source, OperatId = rd.OperatId, CreateDT = rd.CreateDT, CreateUID = rd.CreateUID
                            };
                            UpdateInvent(inventList, ir);
                            SplitSingleProduct(purchaseNumber - stockNum, storeId, info, ref rds);
                        }
                    }
                    else
                    {
                        SplitSingleProduct(purchaseNumber, storeId, info, ref rds);
                    }
                }
                else
                {
                    UpdateInvent(inventList, rd);//单品
                }
            }
            AddRange(rds.Where(o => o.Number > 0 && o.Source != 13).ToList(), false);
        }
예제 #38
0
        public HttpResponseMessage UpdateProduct(ProductTemplate product)
        {
            var result = ProductService.UpdateProduct(product);

            return(ControllerHelper.GetJsonResponseMessage(result));
        }
예제 #39
0
 public ProductController(ProductService productService, IHostingEnvironment env)
 {
     _productService = productService;
     _env            = env;
 }
 public ProductController(ProductService productService)
 {
     _productService = productService;
 }
예제 #41
0
        private void InitialDataPopup()
        {
            var cmdCat = new CategoryService();
            var list = cmdCat.GetALL();
            foreach (var item in list)
            {
                ddlCategory.Items.Add(new ListItem(item.CATEGORY_NAME, item.CATEGORY_ID.ToString()));
            }
            var cmdPro = new ProductService();
            var listddlPakUDesc = cmdPro.GetUDescPacking();
            foreach (var item in listddlPakUDesc)
            {
                ddlPakUDesc.Items.Add(new ListItem(item, item));
            }

            var listddlPakPDesc = cmdPro.GetPDescPacking();
            foreach (var item in listddlPakPDesc)
            {
                ddlPakPDesc.Items.Add(new ListItem(item, item));
            }

            var cmd = new ZoneService();
            var listZone = cmd.GetALL();
            DataSouceList = new List<PRODUCT_PRICELIST>();
            foreach (var item in listZone)
            {
                PRODUCT_PRICELIST pd = new PRODUCT_PRICELIST();
                pd.ZONE_ID = item.ZONE_ID;
                pd.ZONE = new ZONE();
                pd.ZONE.ZONE_CODE = item.ZONE_CODE;
                pd.ZONE.ZONE_NAME = item.ZONE_NAME;
                DataSouceList.Add(pd);
            }

            if (ViewState["proId"] != null)
            {
                _product = cmdPro.Select(Convert.ToInt32(ViewState["proId"].ToString()));
                popTxtProductCode.Text = _product.PRODUCT_CODE;
                poptxtProductName.Text = _product.PRODUCT_NAME;
                txtPacking.Text = _product.PRODUCT_PACKING_QTY.ToString();
                //txtPackingDesc.Text = _product.PRODUCT_PACKING_DESC;
                txtWeight.Text = _product.PRODUCT_WEIGHT.ToString();
                txtUnit.Text = _product.PRODUCT_WEIGHT_DEFINE;
                ddlCategory.SelectedValue = _product.CATEGORY_ID.ToString();
                ddlkind.SelectedValue = _product.PRODUCT_TYPE_CODE.ToString();
                //txtSize.Text = _product.PRODUCT_SIZE;
                ddlPakUDesc.SelectedValue = _product.PRODUCT_PACKING_PER_UDESC;
                ddlPakPDesc.SelectedValue = _product.PRODUCT_PACKING_PER_PDESC;
                var cmdPD = new ProductPriceListService();
                var listPD = cmdPD.Select(Convert.ToInt32(ViewState["proId"].ToString()));
                foreach (var itemPD in listPD)
                {
                    foreach (var itemDST in DataSouceList)
                    {
                        if (itemDST.ZONE_ID == itemPD.ZONE_ID)
                        {
                            itemDST.PRODUCT_PRICE = itemPD.PRODUCT_PRICE;
                            itemDST.PRODUCT_ID = itemPD.PRODUCT_ID;
                            break;
                        }
                    }
                }

                List<PRODUCT_PROMOTION> listPromotionItem = new List<PRODUCT_PROMOTION>();
                var cmdPromotion = new ProductPromotionService();
                DataSoucePromotion = cmdPromotion.GetALLIncludeZone(Convert.ToInt32(ViewState["proId"].ToString()));
                listPromotionItem.AddRange(DataSoucePromotion);

                listPromotionItem.AddRange(listPromotion);

                gridPromotion.DataSource = listPromotionItem;
                gridPromotion.DataBind();

                flag.Text = "Edit";
            }
            gridProductDetail.DataSource = DataSouceList;
            gridProductDetail.DataBind();
        }
        public IHttpActionResult GetProducts()
        {
            var products = ProductService.GetProducts();

            return(Ok(products));
        }
예제 #43
0
 public CarrosselController()
 {
     this.productService = new ProductService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.reviewService = new PublishingService<Review, DraftReview, ReviewRepository>(ContextFactory.GetContext(System.Web.HttpContext.Current));
 }
예제 #44
0
        /// <summary>
        /// 绑定信息
        /// </summary>
        private void BindData()
        {
            Product item = ProductService.GetModel(id);

            if (item != null)
            {
                this.hidStoreCount.Value = item.proType.ToString();
                ViewState["proName"]     = item.proName;
                ViewState["proDesc"]     = item.proDesc;
                if (item.detailImg1 != "")
                {
                    ViewState["imgInfo"] = "<div class=\"guige\" style=\"text-align:center;\"> <img src='" + item.detailImg1 + "'></div>";
                }
                ViewState["productInfo"] = item.proContent;
                ViewState["specialInfo"] = item.advantage;

                ViewState["unitInfo"] = item.unit1;

                ViewState["price1"] = item.price1.ToString("0.00");
                if (item.proDesc != "")
                {
                    ViewState["goodInfo"] = "<div class=\"guige\">" + item.proDesc + ":" + item.stopTypeName + "</div>";
                }

                ViewState["productContent"] = item.ImgDesc;

                UserInfo user = UserInfoService.GetModel(item.useId);
                if (user != null)
                {
                    ViewState["shoperId"]   = user.id;
                    ViewState["shoperName"] = user.comName;
                }
                //相关产品
                DataSet ds = ProductService.GetList(16, "productType = " + item.productType, "id");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //repXG.DataSource = ds;
                    //repXG.DataBind();
                }

                //推荐购买
                ProductType pt = ProductTypeService.GetModel(item.productType);
                if (pt != null)
                {
                    ds = ProductService.GetList(10, "productType in(select id from ProductType where parentId = " + pt.parentId + ") and id <> " + id, "id");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        repTj.DataSource = ds;
                        repTj.DataBind();
                    }
                }
                else
                {
                    ds = ProductService.GetList(10, "productType = " + item.productType + " and id <> " + id, "id");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        repTj.DataSource = ds;
                        repTj.DataBind();
                    }
                }

                ///bannner
                ds = ProductImgMobileService.GetList("productId = " + item.id + " and infoType = 1");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    repBanner.DataSource = ds;
                    repBanner.DataBind();
                }
            }
        }
예제 #45
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_counter >= 1)
            {
                MessageBox.Show("cannot have more than one of the same location selected");
                return;
            }
            int locationID = 0;
            int quantity   = 0;

            if (GetProductState == ProductState.New)
            {
                if (dgvLocation.Rows[0].Cells[0].Value == null || lblQty.Text == "")
                {
                    Helper.ShowMessage("Select product location or enter the quanty of the product at the selected location",
                                       "Error in location or product quantity", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {
                    locationID = (int)dgvLocation.Rows[0].Cells[0].Value;
                    quantity   = (int)dgvLocation.Rows[0].Cells[1].Value;
                }
            }

            if (cmbMeasurement.SelectedIndex == -1)
            {
                Helper.ShowMessage("Please select product measurement",
                                   "Select Product Measurement", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!Helper.ValidateTexBox(txtSupplier))
            {
                return;
            }
            if (!Helper.ValidateTexBox(txtCategory))
            {
                return;
            }
            if (!Helper.ValidateTexBox(txtItemName))
            {
                return;
            }
            //if (!UtilityClass.ValidateTexBox(txtPurchasePrice))
            //    return;
            if (!Helper.ValidateTexBox(txtSalePrice))
            {
                return;
            }
            //if (!UtilityClass.ValidateTexBox(txtSalePrice))
            //    return;

            Product product = new Product();

            product.SupplierID      = txtSupplier.Tag == null ? DEFAULT_SUPPLIERID : txtSupplier.Tag.ToString().ToInt();
            product.CategoryID      = txtCategory.Tag == null ? DEFAULT_CATEGORYID : int.Parse(txtCategory.Tag.ToString());
            product.ProductNum      = txtItemNumber.Text;
            product.ProductName     = txtItemName.Text;
            product.Barcode         = txtBarCode.Text;
            product.Commission      = txtCommission.Text == "" ? 0 : decimal.Parse(txtCommission.Text);
            product.PurchasePrice   = txtPurchasePrice.Text == "" ? 0 : decimal.Parse(txtPurchasePrice.Text);
            product.SellingPrice    = decimal.Parse(txtSalePrice.Text);
            product.ExpiryDate      = DateTime.Parse(dtpExpiryDate.Value.ToLongDateString());
            product.ManufactureDate = DateTime.Parse(dtpManufactureDate.Value.ToLongDateString());
            product.OnSale          = chkOnSale.Checked;
            product.ExpiryDate      = dtpExpiryDate.Value;
            product.ProductImage    = pictureBoxProduct.Image == null ? null : Helper.ImageToByteArray(pictureBoxProduct.Image);
            product.Discount        = txtDiscount.Text == "" ? 0 : decimal.Parse(txtDiscount.Text);
            product.ReorderLevel    = txtReOrderLevel.Text == "" ? 0 : int.Parse(txtReOrderLevel.Text);
            product.BrandID         = txtBrand.Tag == null ? DEFAULT_BRANDID : int.Parse(txtBrand.Tag.ToString());
            product.Description     = txtDescription.Text;
            product.UnitPrice       = decimal.Parse(txtSalePrice.Text);
            product.DateAdded       = DateTime.Now;
            product.MeasurementID   = cmbMeasurement.SelectedValue.ToInt();
            product.LocationID      = locationID;
            product.Quantity        = quantity;
            //product.EmployeeID = 0;
            //product.AdjustmentReason = "asdasd";

            try
            {
                switch (GetProductState)
                {
                case ProductState.New:
                    product = new ProductService().FindByID(new ProductService().Add(product));
                    SaveLocationQuantity(product.ProductID);
                    Helper.ShowMessage("Product was added successfully", "Product Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;

                case ProductState.Dirty:
                    product.ProductID = txtItemName.Tag.ToInt();
                    _pruduct.Update(product);
                    Helper.ShowMessage("Product was updated successfully", "Product Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ConfigureForm("Save");

                    break;
                }

                Helper.ClearForm(this);
                ResetPicture();
                SetUpDefaults();
                dgvLocation.Rows.Clear();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, OperationStatus.FAILURE, "ucNewProduct", "btnSave");
                Helper.ShowMessage(OperationStatus.FAILURE + "\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #46
0
 public AdminController()
 {
     this.categoryService = new CategoryService();
     this.pictureService  = new PictureService();
     this.productService  = new ProductService();
 }
예제 #47
0
 public GetAllBidQueryHandler(ApplicationDbContext dbContext, ProductService productService, UserService userService)
 {
     _dbContext      = dbContext;
     _productService = productService;
     _userService    = userService;
 }
예제 #48
0
        public HttpResponseMessage GetProductList()
        {
            var result = ProductService.GetAllProductByRedis();

            return(ControllerHelper.GetJsonResponseMessage(result));
        }
예제 #49
0
 public ProductController()
 {
     _productService  = new ProductService();
     _categoryService = new CategoryService();
 }
예제 #50
0
        /// <summary>
        /// 获取详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        protected string GetDetail(object id, object status)
        {
            int           s  = Convert.ToInt32(status);
            StringBuilder sb = new StringBuilder();
            DataSet       ds = OrderDetailService.GetList("orderId = " + id);

            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    sb.Append("<li>");
                    sb.Append("<ol class=\"ord_01\">");
                    Product item = ProductService.GetModel(Convert.ToInt32(ds.Tables[0].Rows[i]["productId"]));
                    if (item != null)
                    {
                        sb.Append("<li><a href=\"/project_list_" + item.id + ".html\"><img src=\"" + item.listImgUrl + "\" style=\"width:122px; height:120px;\" alt=\"" + item.proName + "\"/></a></li>");
                        sb.Append("<li class=\"shop02\">");
                        sb.Append("<p>" + item.proName + "</p>");
                        sb.Append("<p>" + item.proDesc + "</p>");
                        sb.Append("</li>");
                        sb.Append("<li class=\"shop03\">× <span>" + ds.Tables[0].Rows[i]["productCount"] + "</span></li>");
                        sb.Append("<li class=\"shop04\">$" + Convert.ToDouble(ds.Tables[0].Rows[i]["total"]).ToString("0.00") + "</li>");
                        if (s == 0)
                        {
                            sb.Append("<li class=\"shop05\"><a href=\"/zhifu_" + id + ".html\">去付款</a></li>");
                            sb.Append("<li class=\"shop06\">");
                            sb.Append("<p class=\"remove\" onclick=\"return cancelOrder(" + id + ");\">取消订单</p>");
                            sb.Append("<p><a href=\"/order_detail_" + id + ".html\">订单详情</a></p>");
                            sb.Append("</li>");
                        }
                        if (s == 1)
                        {
                            sb.Append("<li class=\"shop05\">");
                            sb.Append("<a class=\"remove\">待发货</a>");
                            sb.Append("</li>");
                        }
                        if (s == 2)
                        {
                            sb.Append("<li class=\"shop05\">");
                            sb.Append("<a class=\"remove\" onclick=\"return recieveOrder(" + id + ");\">确认收货</a>");
                            sb.Append("</li>");
                        }


                        if (s == 100)
                        {
                            sb.Append("<li class=\"shop05\">");
                            sb.Append("<a href=\"javascript:void(0);\">已取消</a>");
                            sb.Append("</li>");
                        }
                        if (s == 3)
                        {
                            if (!CommentService.Exists(Convert.ToInt32(id), item.id))
                            {
                                sb.Append("<li class=\"shop05\">");
                                sb.Append("<a href=\"judge_" + id + "_" + item.id + ".html\">去评价</a>");
                                sb.Append("</li>");
                            }
                        }
                        if (s == 4)
                        {
                            if (!CommentService.Exists(Convert.ToInt32(id), item.id))
                            {
                                sb.Append("<li class=\"shop05\">");
                                sb.Append("<a href=\"javascript:void(0);\">Order Delivered</a>");
                                sb.Append("</li>");
                            }
                            else
                            {
                                sb.Append("<li class=\"shop05\">");
                                sb.Append("<a href=\"javascript:void(0);\">Order Delivered</a>");
                                sb.Append("</li>");
                            }
                        }
                    }
                    sb.Append("</ol>");
                    sb.Append("</li>");
                }
            }
            return(sb.ToString());
        }
 public bool UpdateReview(string reviewId, ProductService.Model.Review review)
 {
     ObjectId objectId;
     if (ObjectId.TryParse(reviewId, out objectId))
     {
         var query = Query<Review>.EQ(r => r.Id, objectId.ToString());
         var updates = Update<Review>.Combine(
             Update<Review>.Set(r => r.ReviewDate, DateTime.UtcNow),
             Update<Review>.Set(r => r.Rating, review.Rating),
             Update<Review>.Set(r => r.Comments, review.Comments));
         var result = MongoHelper.ReviewsCollection.Update(query, updates);
         return result.Ok;
     }
     else
         return false;
 }
예제 #52
0
 public ProductController(ProductService productService, ILogger <ProductController> logger)
 {
     _productService = productService;
     _logger         = logger;
 }
예제 #53
0
 public CartController()
 {
     _productService = new ProductService();
 }
예제 #54
0
        static bool SplitSingleProduct(ProductRecord product, decimal purchaseNumber, string barcode, string storeId, string outboundId, string saleBarcode, string uid)
        {
            var oldProductNum = Math.Ceiling(purchaseNumber / (product.SaleNum ?? 1m));
            var result        = UpdateSingleProduct(oldProductNum, product.OldBarcode, storeId, outboundId, saleBarcode, 2, uid);

            if (!result)
            {
                return(false);
            }

            var InventoryDict = ProductService.FindList(o => o.OldBarcode == product.OldBarcode).ToDictionary(o => o.Barcode, o => o.SaleNum ?? 1 * oldProductNum);

            InventoryDict[barcode] -= purchaseNumber;

            foreach (var item in InventoryDict)
            {
                var childInventory = BaseService <Inventory> .CurrentRepository.Find(o => o.Barcode == item.Key && o.StoreId == storeId);

                if (childInventory != null)
                {
                    childInventory.StockNumber = childInventory.StockNumber + item.Value;
                    BaseService <Inventory> .CurrentRepository.Update(childInventory);
                }
                else
                {
                    childInventory = new Inventory()
                    {
                        StoreId     = storeId,
                        StockNumber = item.Value,
                        Barcode     = item.Key
                    };
                    BaseService <Inventory> .CurrentRepository.Add(childInventory);
                }
                if (item.Key == barcode)
                {
                    BaseService <OutboundGoodsHistory> .CurrentRepository.Add(new OutboundGoodsHistory()
                    {
                        CreateDt       = DateTime.Now,
                        Mode           = 4,
                        Number         = (item.Value + purchaseNumber),
                        SaleBarcode    = saleBarcode,
                        StorageBarcode = item.Key,
                        OutboundId     = outboundId,
                        CreateUid      = uid,
                        StoreId        = storeId,
                    }, false);

                    BaseService <OutboundGoodsHistory> .CurrentRepository.Add(new OutboundGoodsHistory()
                    {
                        CreateDt       = DateTime.Now,
                        Mode           = 1,
                        Number         = purchaseNumber,
                        SaleBarcode    = saleBarcode,
                        StorageBarcode = item.Key,
                        OutboundId     = outboundId,
                        CreateUid      = uid,
                        StoreId        = storeId,
                    }, false);
                }
                else
                {
                    BaseService <OutboundGoodsHistory> .CurrentRepository.Add(new OutboundGoodsHistory()
                    {
                        CreateDt       = DateTime.Now,
                        Mode           = 4,
                        Number         = item.Value,
                        SaleBarcode    = saleBarcode,
                        StorageBarcode = item.Key,
                        OutboundId     = outboundId,
                        CreateUid      = uid,
                        StoreId        = storeId,
                    }, false);
                }
            }

            //BaseService<Inventory>.CurrentRepository.Update(new Inventory());
            return(true);
        }
예제 #55
0
 private void InitModel()
 {
     ProductService.RetrieveAllSupplierAsync();
 }
예제 #56
0
        protected void GetProduct(long id)
        {
            var result = ProductService.Get(id);

            result.Match(ShowEditModal, DisplayError);
        }
예제 #57
0
 public ReviewController()
 {
     this.publishingService = new PublishingService<Review, DraftReview, ReviewRepository>(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.productService = new ProductService(ContextFactory.GetContext(System.Web.HttpContext.Current));
     this.publicationStatusRepository = new PublicationStatusRepository(ContextFactory.GetContext(System.Web.HttpContext.Current));
 }
예제 #58
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var obj = new PRODUCT();
            obj.PRODUCT_CODE = popTxtProductCode.Text;
            obj.PRODUCT_NAME = poptxtProductName.Text;
            obj.PRODUCT_PACKING_QTY = Convert.ToInt32(txtPacking.Text);

            if (ddlPakUDesc.SelectedValue != "กรุณาเลือก")
                obj.PRODUCT_PACKING_PER_UDESC = ddlPakUDesc.SelectedValue;

            if (ddlPakPDesc.SelectedValue != "กรุณาเลือก")
                obj.PRODUCT_PACKING_PER_PDESC = ddlPakPDesc.SelectedValue;

            obj.PRODUCT_PACKING_DESC = "(" + obj.PRODUCT_PACKING_QTY + " " + obj.PRODUCT_PACKING_PER_UDESC + "/" + obj.PRODUCT_PACKING_PER_PDESC + ")";
            obj.PRODUCT_WEIGHT = Convert.ToDecimal(txtWeight.Text);
            obj.PRODUCT_WEIGHT_DEFINE = txtUnit.Text;
            obj.CATEGORY_ID = Convert.ToInt32(ddlCategory.SelectedValue);
            obj.PRODUCT_TYPE_CODE = Convert.ToInt32(ddlkind.SelectedValue);

            var cmd = new ProductService(obj);

            if (flag.Text.Equals("Add"))
            {
                obj.Action = ActionEnum.Create;
                obj.CREATE_DATE = DateTime.Now;
                obj.CREATE_EMPLOYEE_ID = 0;
                obj.UPDATE_DATE = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL = true;
                cmd.Add();
            }
            else
            {
                obj.Action = ActionEnum.Update;
                obj.PRODUCT_ID = Convert.ToInt32(ViewState["proId"].ToString());
                obj.UPDATE_DATE = DateTime.Now;
                obj.UPDATE_EMPLOYEE_ID = 0;
                obj.SYE_DEL = true;
                cmd.Edit();
            }

            if (FileUpload1.HasFile)
            {
                Stream fs = FileUpload1.PostedFile.InputStream;
                if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~") + "ImageProduct"))
                    System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~") + "ImageProduct");
                obj.PRODUCT_IMAGE_PATH = "~/ImageProduct/" + obj.PRODUCT_ID + "." + FileUpload1.FileName.Split('.').ToArray()[1];
                FileUpload1.PostedFile.SaveAs(HttpContext.Current.Server.MapPath("~") + "ImageProduct\\" + obj.PRODUCT_ID + "." + FileUpload1.FileName.Split('.').ToArray()[1]);
            }
            cmd = new ProductService(obj);
            cmd.Edit();

            var listDetail = new List<PRODUCT_PRICELIST>();
            int i = 0;
            foreach (var item in DataSouceList)
            {
                var objDetail = new PRODUCT_PRICELIST();
                objDetail.ZONE_ID = item.ZONE_ID;
                objDetail.PRODUCT_PRICE = Convert.ToDecimal(((TextBox)(gridProductDetail.Rows[i++].Cells[2].FindControl("txtPrice"))).Text);
                objDetail.SYE_DEL = true;
                objDetail.UPDATE_DATE = DateTime.Now;
                objDetail.UPDATE_EMPLOYEE_ID = 0;
                if (item.PRODUCT_ID == 0)
                {
                    objDetail.Action = ActionEnum.Create;
                    objDetail.PRODUCT_ID = obj.PRODUCT_ID;
                    objDetail.CREATE_DATE = DateTime.Now;
                    objDetail.CREATE_EMPLOYEE_ID = 0;
                }
                else
                {
                    objDetail.Action = ActionEnum.Update;
                    objDetail.PRODUCT_ID = item.PRODUCT_ID;
                }
                listDetail.Add(objDetail);
            }

            if (listPromotion.Count > 0)
            {
                foreach (PRODUCT_PROMOTION item in listPromotion)
                {
                    item.PRODUCT_ID = obj.PRODUCT_ID;
                }
                var cmdPromotion = new ProductPromotionService(listPromotion);
                cmdPromotion.AddList();
            }

            var cmdDetail = new ProductPriceListService(listDetail);
            cmdDetail.AddUpdateList();
            ViewState["proId"] = null;
            Response.Redirect("SearchProduct.aspx");
        }
예제 #59
0
 public HomeController()
 {
     _categoryService = new CategoryService();
     _appUserService  = new AppUserService();
     _productService  = new ProductService();
 }
        public ActionResult QuotationDetail(int QuotationID = 0, string QuotationCode = "")
        {
            int CompID    = 0;
            int ProductID = 0;

            RememberURL();
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }
            else
            {
                if (CheckIsAdmin(9))
                {
                    GetStatusUser();
                    if (QuotationID > 0)
                    {
                        Ouikum.Quotation.QuotationService svQuotation = new Ouikum.Quotation.QuotationService();
                        var Quotation = svQuotation.SelectData <view_Quotation>("*", "IsDelete = 0 AND QuotationID =" + QuotationID).First();
                        ViewBag.Quotation = Quotation;
                        if (Quotation.QuotationStatus == "Q")
                        {
                            CompID = Convert.ToInt32(Quotation.FromCompID);
                        }
                        else
                        {
                            CompID = Convert.ToInt32(Quotation.ToCompID);
                        }
                        if (Quotation.ProductID != 0)
                        {
                            ProductID = Convert.ToInt32(Quotation.ProductID);
                        }

                        #region ProductName
                        var svProduct   = new ProductService();
                        var ProductName = svProduct.SelectData <view_SearchProduct>("ProductID,ProductName", "ProductID = " + ProductID, "ProductName", 1, 0, false).First().ProductName;
                        if (ProductName.Length >= 40)
                        {
                            ViewBag.ProductName = ProductName.Substring(0, 40) + "...";
                        }
                        else
                        {
                            ViewBag.ProductName = ProductName;
                        }
                        #endregion

                        #region Company
                        var svCompany = new CompanyService();
                        if (CompID != 0)
                        {
                            var ToComp = svCompany.SelectData <view_Company>("CompID,CompName,CompImgPath,BizTypeName,ProvinceName,ContactEmail", "CompID = " + CompID, null, 1, 0, false).First();
                            ViewBag.ReqEmail = ToComp.ContactEmail;
                            ViewBag.ReqPhone = ToComp.ContactPhone;
                        }
                        else
                        {
                            ViewBag.ReqEmail = null;
                            ViewBag.ReqPhone = null;
                        }

                        #endregion

                        #region File Attach
                        var svQuotationAttach = new QuotationAttachService();
                        var AttachFile        = svQuotationAttach.SelectData <b2bQuotationAttach>("*", "QuotationID = " + QuotationID, null, 0, 0, false);
                        if (AttachFile.Count() > 0)
                        {
                            ViewBag.AttachFile   = AttachFile.First();
                            ViewBag.AttachRemark = AttachFile.First().Remark;
                        }
                        #endregion

                        return(View());
                    }
                    else
                    {
                        return(Redirect("~/Report/List"));
                    }
                }
                else
                {
                    return(Redirect(res.Pageviews.PvAccessDenied));
                }
            }
        }