コード例 #1
0
        public ActionResult Detail(int?id)
        {
            var obj = new Members();

            if (id.HasValue)
            {
                obj = MembersService.FindById(id.Value);
                if (obj.CurrentCityId > 0)
                {
                    var area = BaseService <Area> .FindById(obj.CurrentCityId);

                    if (area != null)
                    {
                        var parentArea = BaseService <Area> .FindById(area.AreaPID);

                        var text = area.Title;
                        if (parentArea != null && parentArea.Type != 1)
                        {
                            text = parentArea.Title + "/" + text;
                        }
                        ViewBag.city = text;
                    }
                }
                if (!obj.StoreId.IsNullOrEmpty())
                {
                    var store = WarehouseService.Find(o => o.StoreId == obj.StoreId);
                    if (store != null)
                    {
                        ViewBag.Store = store.Title;
                    }
                }
            }
            return(View(obj.IsNullThrow()));
        }
コード例 #2
0
        public override IEnumerable <ProductRecord> Download(string storeId, string entityType)
        {
            var date = DateTime.Now.Date;

            var entity     = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
            var Categories = ProductCategoryService.CurrentRepository._context.Database.SqlQuery <int>(
                @"with my1 as(select * from ProductCategory where ProductCategory.CategoryPSN =0 and CategorySN in (" + entity == null || string.IsNullOrEmpty(entity.CategorySN) ? "''" : entity.CategorySN + @")
                 union all select ProductCategory.* from my1, ProductCategory where my1.CategorySN = ProductCategory.CategoryPSN)
                select CategorySN from my1"
                );
            var serverRepository = CurrentRepository;
            var sources          = serverRepository.FindList(o => Categories.Contains(o.CategorySN)).OrderBy(o => o.CategorySN).ToList();
            var query            = (from a in BaseService <ProductChangePriceList> .CurrentRepository.Entities
                                    from b in BaseService <ProductChangePrice> .CurrentRepository.Entities
                                    where a.ChangePriceId == b.Id && b.State == 1 && b.CompanyId == CommonService.CompanyId
                                    select new { a, b }).ToList();

            sources.ForEach(o =>
            {
                var ranges = query.Where(p => p.a.Barcode == o.Barcode).OrderByDescending(p => p.b.CreateDT);
                var info   = ranges.FirstOrDefault();
                if (info != null)
                {
                    o.SysPrice = info.a.CurSysPrice;
                }
            });
            return(sources);
        }
コード例 #3
0
        public ActionResult GetStoreAddress(string storeId)
        {
            var obj = WarehouseService.Find(o => o.StoreId == storeId);

            if (obj == null)
            {
                return(Content(""));
            }
            return(Content(obj.Address));
        }
コード例 #4
0
        public override IEnumerable <dynamic> Export(string storeId, string entityType)
        {
            var date = DateTime.Now.Date;

            var entity     = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
            var Categories = ProductCategoryService.CurrentRepository._context.Database.SqlQuery <int>(string.Format(@"with my1 as(select * from ProductCategory where ProductCategory.CategoryPSN =0 and CategorySN in ({0})
                 union all select ProductCategory.* from my1, ProductCategory where my1.CategorySN = ProductCategory.CategoryPSN)
                select CategorySN from my1", entity == null || string.IsNullOrEmpty(entity.CategorySN) ? "''" : entity.CategorySN)
                                                                                                       ).ToList();
            var cates          = System.Web.HttpContext.Current.Request["selectCategorySN"];
            var selectBarcodes = System.Web.HttpContext.Current.Request["selectBarcodes"];

            if (!string.IsNullOrWhiteSpace(cates))
            {
                var cs = cates.Split(',').Select(i => int.Parse(i)).ToList();
                cs         = ProductCategoryService.GetChildSNs(cs, true);
                Categories = Categories.Where(o => cs.Contains(o)).ToList();
            }
            var selectBars = new List <string>();

            if (!string.IsNullOrWhiteSpace(selectBarcodes))
            {
                selectBars = selectBarcodes.Split(',').ToList();
            }
            var express = Pharos.Utility.Helpers.DynamicallyLinqHelper.True <ProductRecord>()
                          .And(o => Categories.Contains(o.CategorySN), cates.IsNullOrEmpty())
                          .And(o => selectBars.Contains(o.Barcode), selectBarcodes.IsNullOrEmpty())
                          .And(o => o.ValuationType == 2).And(o => o.CompanyId == CommonService.CompanyId);
            var serverRepository = CurrentRepository;
            var sources          = serverRepository.FindList(express).OrderBy(o => o.CategorySN).ToList();

            //var query = (from a in BaseService<ProductChangePriceList>.CurrentRepository.Entities
            //             from b in BaseService<ProductChangePrice>.CurrentRepository.Entities
            //             where a.ChangePriceId == b.Id && b.State == 1
            //             select new { a, b }).ToList();

            //sources.ForEach(o =>
            //{
            //    var ranges = query.Where(p => p.a.Barcode == o.Barcode).OrderByDescending(p => p.b.CreateDT);
            //    var info = ranges.FirstOrDefault();
            //    if (info != null)
            //    {
            //        o.SysPrice = info.a.CurSysPrice;
            //    }
            //});
            ProductService.SetSysPrice(storeId, sources);
            return(sources);
        }
コード例 #5
0
 public ActionResult GetNumByCatesn(int?catesn, string storeId)
 {
     if (catesn.HasValue)
     {
         var catesns = ProductCategoryService.GetChildSNs(new List <int>()
         {
             catesn.Value
         }, true);
         if (!storeId.IsNullOrEmpty())
         {
             var entity = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
             var allsns = ProductCategoryService.GetChildSNs(entity.CategorySN.Split(',').Select(o => int.Parse(o)).ToList(), true);
             catesns = allsns.Where(o => catesns.Contains(o)).ToList();
         }
         return(Content(ProductService.FindList(o => catesns.Contains(o.CategorySN) && o.ValuationType == 2 && o.CompanyId == CommonService.CompanyId).Count.ToString()));
     }
     return(Content("0"));
 }
コード例 #6
0
 public override IEnumerable<ProductCategory> Download(string storeId, string entityType)
 {
     var entity = WarehouseService.Find(o => o.StoreId == storeId);
     var CategorySN = new List<int>();
     if (entity != null)
     {
         try
         {
             CategorySN = entity.CategorySN.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries).Select(o => Convert.ToInt32(o)).ToList();
         }
         catch
         {
         }
     }
     var sources = CurrentRepository.FindList(o => CategorySN.Contains(o.CategorySN) && o.Grade == 1).ToList();
     sources = sources.Concat(GetCategory(CategorySN, 2)).ToList();
     return sources;
 }
コード例 #7
0
        public ActionResult GetProductInput(string searchName, string supplierID, string zp, string storeId, string order, short?getStockNum)
        {
            if (searchName.IsNullOrEmpty())
            {
                return(new EmptyResult());
            }
            var express = DynamicallyLinqHelper.Empty <VwProduct>()
                          .And(o => (o.Barcode != null && o.Barcode.StartsWith(searchName)) || o.Title.Contains(searchName) || (o.Barcodes != null && o.Barcodes.Contains(searchName)))
                          .And(o => o.IsAcceptOrder == 1, order.IsNullOrEmpty()).And(o => o.CompanyId == CommonService.CompanyId);

            if (!supplierID.IsNullOrEmpty())
            {
                var sp   = supplierID.Split(',').ToList();
                var bars = BaseService <ProductMultSupplier> .FindList(o => sp.Contains(o.SupplierId)).Select(o => o.Barcode).Distinct().ToList();

                express = express.And(o => (sp.Contains(o.SupplierId) || bars.Contains(o.Barcode)), supplierID.IsNullOrEmpty());
            }
            if (!storeId.IsNullOrEmpty())
            {
                var ware = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
                if (ware != null)
                {
                    var categorySNs = ware.CategorySN.Split(',').Select(o => int.Parse(o)).ToList();
                    var childs      = ProductCategoryService.GetChildSNs(categorySNs, true);
                    express = express.And(o => childs.Contains(o.CategorySN));
                }
            }
            var list = BaseService <VwProduct> .FindList(express, takeNum : 20);

            list = ProductService.SetAssistBarcode(list);
            ProductService.SetSysPrice <VwProduct>(storeId, list, supplierId: supplierID);
            if (getStockNum == 1)
            {
                ProductService.SetStockNum(storeId, list);
            }
            return(ToDataGrid(list, 20));
        }
コード例 #8
0
        public ActionResult CheckProductInStock(NoteViewModel model)
        {
            Request.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
            var DeNote = _note.Queryable().Include(x => x.Details.Select(t => t.Product)).Where(x => (x.Source.Id != null) && (x.Source.Id == model.SourceId) &&
                                                                                                x.Delete.Equals(false)).Select(x => new NoteViewModel()
            {
                Id = x.Id,
                SourceWarehouse = x.Source.Name,
                Details         = x.Details.Select(y => new NoteDetailViewModel()
                {
                    Id          = y.Id,
                    ProductName = y.Product.ProductName,
                    Quantity    = y.Quantity
                }).ToList()
            });

            var ReNote = _note.Queryable().Include(x => x.Details.Select(t => t.Product)).Where(x => (x.Destination.Id != null) && x.Delete.Equals(false))
                         .Select(x => new NoteViewModel()
            {
                Id = x.Id,
                DestinationWarehouse = x.Destination.Name,
                Details = x.Details.Select(y => new NoteDetailViewModel()
                {
                    Id          = y.Id,
                    ProductName = y.Product.ProductName,
                    Quantity    = y.Quantity
                }).ToList()
            });
            var ReDetails = new List <StockViewModel>();
            var DeDetails = new List <StockViewModel>();

            foreach (var item in DeNote)
            {
                foreach (var smallitem in item.Details)
                {
                    DeDetails.Add(new StockViewModel()
                    {
                        ProductName = smallitem.ProductName,
                        Warehouse   = item.SourceWarehouse,
                        Quantity    = smallitem.Quantity
                    });
                }
            }
            foreach (var item in ReNote)
            {
                foreach (var smallitem in item.Details)
                {
                    ReDetails.Add(new StockViewModel()
                    {
                        ProductName = smallitem.ProductName,
                        Warehouse   = item.DestinationWarehouse,
                        Quantity    = smallitem.Quantity
                    });
                }
            }
            var filterDeNote = DeDetails.Where(x => x.Warehouse != null).GroupBy(x => x.Warehouse).Select(x => new
            {
                warehouse = x.Key,
                listItem  = x.GroupBy(y => y.ProductName).Select(y => new {
                    productname = y.Key,
                    quantity    = y.Sum(t => t.Quantity)
                }).ToList()
            });
            var filterReNote = ReDetails.Where(x => x.Warehouse != null).GroupBy(x => x.Warehouse).Select(x => new
            {
                warehouse = x.Key,
                listItem  = x.GroupBy(y => y.ProductName).Select(y => new {
                    productname = y.Key,
                    quantity    = y.Sum(t => t.Quantity)
                }).ToList()
            });
            var currentStorage = new List <StockGroupViewModel>();

            foreach (var item in filterReNote)
            {
                var currentStorageItem = new StockGroupViewModel();

                currentStorageItem.Warehouse = item.warehouse;

                if (filterDeNote.Where(x => x.warehouse == item.warehouse).Any())
                {
                    var gooditem = filterDeNote.Where(x => x.warehouse == item.warehouse).FirstOrDefault();
                    foreach (var smallitem in item.listItem)
                    {
                        var detailItem = new StockDetailViewModel();
                        if (gooditem.listItem.Where(t => t.productname == smallitem.productname).Any())
                        {
                            var caughtDetail = gooditem.listItem.Where(t => t.productname == smallitem.productname).FirstOrDefault();
                            detailItem.ProductName = smallitem.productname;
                            detailItem.Quantity    = smallitem.quantity - caughtDetail.quantity;
                            currentStorageItem.StockList.Add(detailItem);
                        }
                        else
                        {
                            detailItem.ProductName = smallitem.productname;
                            detailItem.Quantity    = smallitem.quantity;
                            currentStorageItem.StockList.Add(detailItem);
                        }
                    }
                    currentStorage.Add(currentStorageItem);
                }
                else
                {
                    foreach (var smallitem in item.listItem)
                    {
                        var detailItem = new StockDetailViewModel();
                        detailItem.ProductName = smallitem.productname;
                        detailItem.Quantity    = smallitem.quantity;
                        currentStorageItem.StockList.Add(detailItem);
                    }
                    currentStorage.Add(currentStorageItem);
                }
            }
            var flagWrong        = false;
            var WrongName        = "";
            var requestWarehouse = _warehouse.Find((Guid)model.SourceId).Name;
            var matchWarehouse   = currentStorage.Where(x => x.Warehouse == requestWarehouse).FirstOrDefault();

            if (matchWarehouse != null)
            {
                foreach (var item in model.Details)
                {
                    var productName = _product.Find((Guid)item.ProductId).ProductName;
                    if (!matchWarehouse.StockList.Where(x => x.ProductName == productName).Any())
                    {
                        flagWrong = true;
                        WrongName = productName;
                        break;
                    }
                    else
                    {
                        var quantity = matchWarehouse.StockList.Where(x => x.ProductName == productName).FirstOrDefault().Quantity;
                        if (item.Quantity > quantity)
                        {
                            flagWrong = true;
                            WrongName = productName;
                            break;
                        }
                    }
                }
            }
            else
            {
                flagWrong = true;
                WrongName = requestWarehouse;
            }

            if (flagWrong == true)
            {
                var objects = new
                {
                    result = "Kho không đủ số lượng sản phẩm " + WrongName
                };
                return(Json(objects, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var objects = new
                {
                    result = "Ok"
                };
                return(Json(objects, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #9
0
        public ActionResult FollowUp(int id)
        {
            var member = MembersService.FindById(id);

            if (member == null)
            {
                return(Content("查无此会员!若连续发生此错误请联系技术管理员。"));
            }
            ViewBag.SourceStore = WarehouseService.IsExist(a => a.StoreId == member.StoreId) ? WarehouseService.Find(a => a.StoreId == member.StoreId).Title : "";
            return(View(member));
        }