Example #1
0
        /// <summary>
        /// 用于datagrid列表
        /// </summary>
        /// <param name="nvl">传递条件</param>
        /// <param name="recordCount">返回总行数</param>
        /// <returns>list</returns>
        public static object FindStoragePageList(NameValueCollection nvl, out int recordCount)
        {
            var query = CurrentRepository.QueryEntity.Where(o => o.CompanyId == CommonService.CompanyId);
            var state = nvl["State"].IsNullOrEmpty() ? -1 : short.Parse(nvl["State"]);

            if (state != -1)
            {
                query = query.Where(o => o.State == state);
            }
            recordCount = query.Count();
            var list        = query.ToList();
            var parentTypes = ProductCategoryService.GetParentTypes();
            var ls          = list.Select(o => new
            {
                o.Id,
                o.State,
                o.Title,
                o.StoreId,
                o.CategorySN,
                CategoryTitle = GetCategoryTitle(parentTypes, o.CategorySN),
                StateTitle    = o.State == 0 ? "停业" : "经营",
                AdminTitle    = o.AdminState == 0 ? "关闭" : "开放"
            }).ToList();

            return(ls);
        }
Example #2
0
        public static IEnumerable <dynamic> DetailPageList(NameValueCollection dicts, out int recordCount)
        {
            var categorys = new List <int>();
            var suppliers = new List <string>();

            if (!dicts["parentType"].IsNullOrEmpty())
            {
                var categorysn = dicts["parentType"].Split(',').Select(o => int.Parse(o)).ToList();
                categorys = ProductCategoryService.GetChildSNs(categorysn, true);
            }
            if (!dicts["supplierId"].IsNullOrEmpty())
            {
                suppliers = dicts["supplierId"].Split(',').ToList();
            }
            var start        = dicts["StartDate"].ToType <DateTime?>();
            var end          = dicts["EndDate"].ToType <DateTime?>();
            var bar          = dicts["Barcode"];
            var store        = dicts["store"];
            var balanceWhere = DynamicallyLinqHelper.Empty <InventoryBalance>().And(o => o.StoreId == store, store.IsNullOrEmpty()).And(o => o.CompanyId == CommonService.CompanyId)
                               .And(o => o.BalanceDate >= start, !start.HasValue).And(o => o.BalanceDate <= end, !end.HasValue);
            var productWhere = DynamicallyLinqHelper.Empty <VwProduct>().And(o => categorys.Contains(o.CategorySN), !categorys.Any()).And(o => suppliers.Contains(o.SupplierId), !suppliers.Any())
                               .And(o => o.CompanyId == CommonService.CompanyId);
            var query1 = from x in BaseService <InventoryBalance> .CurrentRepository.QueryEntity.Where(balanceWhere)
                         from y in BaseService <VwProduct> .CurrentRepository.QueryEntity.Where(productWhere)
                             where (y.Barcode == x.Barcode || ("," + y.Barcodes + ",").Contains("," + x.Barcode + ",")) &&
                         x.Barcode == bar
                         select new {
                x.Id,
                StoreTitle = WarehouseService.CurrentRepository.QueryEntity.Where(o => o.StoreId == x.StoreId && o.CompanyId == x.CompanyId).Select(o => o.Title).FirstOrDefault(),
                x.Barcode,
                y.Title,
                y.CategoryTitle,
                y.SubUnit,
                x.BalanceDate,
                x.StockAmount,
                x.Number,
                x.SaleAmount
            };
            var query2 = from x in BaseService <InventoryBalance> .CurrentRepository.QueryEntity.Where(balanceWhere)
                         join y in BaseService <Bundling> .CurrentRepository.QueryEntity on new { x.Barcode, x.CompanyId } equals new { Barcode = y.NewBarcode, y.CompanyId }
            where x.Barcode == bar
            select new
            {
                x.Id,
                StoreTitle = WarehouseService.CurrentRepository.QueryEntity.Where(o => o.StoreId == x.StoreId && o.CompanyId == x.CompanyId).Select(o => o.Title).FirstOrDefault(),
                x.Barcode,
                y.Title,
                CategoryTitle = "",
                SubUnit       = "捆",
                x.BalanceDate,
                x.StockAmount,
                x.Number,
                x.SaleAmount
            };
            var query = query1.Union(query2);

            recordCount = query.Count();
            return(query.ToPageList());
        }
        public IEnumerable <string> GetProductRanges(int category, int depth, int brandSn)
        {
            var lastDepthStoreCategories = ProductCategoryService.GetLastDepthStoreCategories(StoreId, category, depth, CompanyId);
            var categories = lastDepthStoreCategories.Select(o => o.CategorySN).ToList();
            var ranges     = ProductService.CurrentRepository.Entities.Where(o => o.CompanyId == CompanyId && categories.Contains(o.CategorySN) && o.BrandSN == brandSn).Select(o => o.Barcode).ToList();

            return(ranges);
        }
        public static List <ProductCategory> GetParentTypes(bool isAll = false)
        {
            if (isAll)
            {
                var all = FindList(o => o.CategoryPSN == 0 && o.CompanyId == CommonService.CompanyId);
                all.ForEach(a => { if (a.State == 0)
                                   {
                                       a.Title = "*" + a.Title;
                                   }
                            });
                return(all.OrderByDescending(a => a.State).ThenBy(o => o.OrderNum).ToList());
            }
            var list = ProductCategoryService.FindList(o => o.CategoryPSN == 0 && o.State == 1 && o.CompanyId == CommonService.CompanyId).OrderBy(o => o.OrderNum).ToList();

            return(list);
        }
        /// <summary>
        /// 获取批次
        /// </summary>
        /// <param name="storeId">门店</param>
        /// <returns></returns>
        public static string GetBatchAndCategory(string storeId)
        {
            var obj    = WarehouseService.Find(o => o.StoreId == storeId && o.CompanyId == CommonService.CompanyId);
            var prefix = obj.StoreId.PadLeft(2, '0') + DateTime.Now.ToString("yyMMdd");
            var max    = BaseService <TreasuryLocks> .CurrentRepository.QueryEntity.Where(o => o.CheckBatch.StartsWith(prefix) && o.CompanyId == CommonService.CompanyId).Max(o => o.CheckBatch);

            var sns   = obj.CategorySN.Split(',').Where(o => !o.IsNullOrEmpty()).Select(o => int.Parse(o)).ToList();
            var items = ProductCategoryService.GetParentCategorys(false).Select(o => new DropdownItem(o.CategorySN.ToString(), o.Title)).ToList();

            items.Insert(0, new DropdownItem("", "请选择"));
            int num = 1;

            if (!max.IsNullOrEmpty())
            {
                num = int.Parse(max.Replace(prefix, "")) + 1;
            }
            var msg  = new Pharos.Logic.DAL.CommonDAL().StockLockValidMsg(storeId);
            var item = new { batch = prefix + num.ToString("00"), items = items, msg = msg };

            return(item.ToJson());
        }
        public static OpResult OutboundImport(ImportSet obj, System.Web.HttpFileCollectionBase httpFiles, string fieldName, string columnName)
        {
            var op    = new OpResult();
            var errLs = new List <string>();
            int count = 0;
            var list  = new List <OutboundList>();

            try
            {
                Dictionary <string, char> fieldCols = null;
                DataTable dt = null;
                op = ImportSetService.ImportSet(obj, httpFiles, fieldName, columnName, ref fieldCols, ref dt);
                if (!op.Successed)
                {
                    return(op);
                }
                var storeId  = System.Web.HttpContext.Current.Request["StoreId"];
                var products = new List <VwProduct>();
                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);
                        var pros        = BaseService <VwProduct> .FindList(o => o.CompanyId == CommonService.CompanyId && childs.Contains(o.CategorySN));

                        products.AddRange(pros);
                    }
                }
                var barcodeIdx  = fieldCols.GetValue("Barcode").ToType <int>() - 65;
                var outPriceIdx = fieldCols.GetValue("OutPrice").ToType <int>() - 65;
                var numberIdx   = fieldCols.GetValue("OutboundNumber").ToType <int>() - 65;
                var memoIdx     = fieldCols.GetValue("Memo").ToType <int>() - 65;
                count = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var pos     = i + obj.MinRow;
                    var dr      = dt.Rows[i];
                    var barcode = dr.GetValue(barcodeIdx).ToString().Trim();
                    if (barcode.IsNullOrEmpty())
                    {
                        errLs.Add("行号[" + pos + "]条码为空!");
                        continue;
                    }
                    var pro = products.FirstOrDefault(o => o.Barcode == barcode || ("," + o.Barcodes + ",").Contains("," + barcode + ","));
                    if (pro == null)
                    {
                        errLs.Add("行号[" + pos + "]该门店下无此条码!");
                        continue;
                    }
                    var outPrice = dr.GetValue(outPriceIdx).ToType <decimal?>();
                    if (!outPrice.HasValue && outPriceIdx >= 0)
                    {
                        errLs.Add("行号[" + pos + "]该条码价格为空!");
                        continue;
                    }
                    var number = dr.GetValue(numberIdx).ToType <decimal?>();
                    if (!number.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码出库数量为空!");
                        continue;
                    }

                    list.Add(new OutboundList()
                    {
                        Barcode        = barcode,
                        ProductTitle   = pro.Title,
                        BuyPrice       = pro.BuyPrice,
                        OutboundNumber = number.Value,
                        Unit           = pro.SubUnit,
                        SysPrice       = pro.SysPrice,
                        OutPrice       = outPrice ?? pro.SysPrice,
                        Memo           = dr.GetValue(memoIdx).ToString()
                    });
                }
            }
            catch (Exception ex)
            {
                op.Message   = ex.Message;
                op.Successed = false;
                Log.WriteError(ex);
                errLs.Add("导入出现异常!");
            }
            return(CommonService.GenerateImportHtml(errLs, count, data: list, isSuccess: false));
        }
Example #7
0
        public static OpResult InboundImport(ImportSet obj, System.Web.HttpFileCollectionBase httpFiles, string fieldName, string columnName)
        {
            var op    = new OpResult();
            var errLs = new List <string>();
            int count = 0;
            var list  = new List <InboundList>();

            try
            {
                Dictionary <string, char> fieldCols = null;
                DataTable dt = null;
                op = ImportSetService.ImportSet(obj, httpFiles, fieldName, columnName, ref fieldCols, ref dt);
                if (!op.Successed)
                {
                    return(op);
                }
                var supplierId       = System.Web.HttpContext.Current.Request["SupplierID"];
                var storeId          = System.Web.HttpContext.Current.Request["StoreId"];
                var supplierBarcodes = new List <string>();
                var storeBarcodes    = new List <string>();
                var products         = new List <VwProduct>();
                if (!supplierId.IsNullOrEmpty())
                {
                    var bars = BaseService <ProductMultSupplier> .FindList(o => o.SupplierId == supplierId).Select(o => o.Barcode).Distinct().ToList();

                    var pros = BaseService <VwProduct> .FindList(o => o.SupplierId == supplierId || bars.Contains(o.Barcode));

                    products.AddRange(pros);
                    supplierBarcodes = pros.Select(o => o.Barcode).ToList();
                    supplierBarcodes.AddRange(pros.Where(o => !o.Barcodes.IsNullOrEmpty()).SelectMany(o => o.Barcodes.Split(',')));
                }
                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);
                        var pros        = BaseService <VwProduct> .FindList(o => o.CompanyId == CommonService.CompanyId && childs.Contains(o.CategorySN));

                        storeBarcodes = pros.Select(o => o.Barcode).ToList();
                        storeBarcodes.AddRange(pros.Where(o => !o.Barcodes.IsNullOrEmpty()).SelectMany(o => o.Barcodes.Split(',')));
                        products.AddRange(pros);
                    }
                }
                var barcodeIdx  = fieldCols.GetValue("Barcode").ToType <int>() - 65;
                var buyPriceIdx = fieldCols.GetValue("BuyPrice").ToType <int>() - 65;
                var numberIdx   = fieldCols.GetValue("InboundNumber").ToType <int>() - 65;
                var proDateIdx  = fieldCols.GetValue("ProducedDate").ToType <int>() - 65;
                var giftIdx     = fieldCols.GetValue("IsGift").ToType <int>() - 65;
                var memoIdx     = fieldCols.GetValue("Memo").ToType <int>() - 65;
                count = dt.Rows.Count;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var pos     = i + obj.MinRow;
                    var dr      = dt.Rows[i];
                    var barcode = dr.GetValue(barcodeIdx).ToString().Trim();
                    if (barcode.IsNullOrEmpty())
                    {
                        errLs.Add("行号[" + pos + "]条码为空!");
                        continue;
                    }
                    if (!supplierBarcodes.Any(o => o == barcode))
                    {
                        errLs.Add("行号[" + pos + "]该供应单位下无此条码!");
                        continue;
                    }
                    if (!storeBarcodes.Any(o => o == barcode))
                    {
                        errLs.Add("行号[" + pos + "]该门店下无此条码!");
                        continue;
                    }
                    var buyPrice = dr.GetValue(buyPriceIdx).ToType <decimal?>();
                    if (!buyPrice.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码进价为空!");
                        continue;
                    }
                    var number = dr.GetValue(numberIdx).ToType <decimal?>();
                    if (!number.HasValue)
                    {
                        errLs.Add("行号[" + pos + "]该条码入库数量为空!");
                        continue;
                    }
                    var      gift    = dr.GetValue(giftIdx).ToString();
                    var      proDate = dr.GetValue(proDateIdx).ToString().Trim();
                    DateTime t       = DateTime.Now;
                    if (!proDate.IsNullOrEmpty() && DateTime.TryParse(proDate, out t))
                    {
                        proDate = t.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        proDate = string.Empty;
                    }
                    var pro = products.FirstOrDefault(o => o.Barcode == barcode || ("," + o.Barcodes + ",").Contains("," + barcode + ","));
                    list.Add(new InboundList()
                    {
                        Barcode       = barcode,
                        ProductTitle  = pro.Title,
                        BuyPrice      = buyPrice.Value,
                        InboundNumber = number.Value,
                        Unit          = pro.SubUnit,
                        ProducedDate  = proDate,
                        SysPrice      = pro.SysPrice,
                        Memo          = dr.GetValue(memoIdx).ToString(),
                        IsGift        = (short)(gift == "赠品"?1:0)
                    });
                }
            }
            catch (Exception ex)
            {
                op.Message   = ex.Message;
                op.Successed = false;
                Log.WriteError(ex);
                errLs.Add("导入出现异常!");
            }
            return(CommonService.GenerateImportHtml(errLs, count, data: list, isSuccess: false));
        }
Example #8
0
        /// <summary>
        /// 库存查询列表
        /// </summary>
        /// <param name="nvl"></param>
        /// <param name="recordCount"></param>
        /// <returns></returns>
        public static DataTable QueryInventoryPageList(NameValueCollection nvl, out int recordCount, ref object footer)
        {
            var nl = new NameValueCollection()
            {
                nvl
            };
            DataTable dt = null;

            if (Sys.CurrentUser.IsStore)
            {
                nl["store"] = Sys.CurrentUser.StoreId;
                var store  = WarehouseService.Find(o => o.CompanyId == CommonService.CompanyId && o.StoreId == Sys.CurrentUser.StoreId);
                var childs = ProductCategoryService.GetChildSNs(store.CategorySN.Split(',').Select(o => int.Parse(o)).ToList(), true);
                if (!nl["parentType"].IsNullOrEmpty())
                {
                    var childs2 = ProductCategoryService.GetChildSNs(new List <int>()
                    {
                        int.Parse(nl["parentType"])
                    }, true);
                    childs = childs.Where(o => childs2.Contains(o)).ToList();
                }
                nl["parentType"] = childs.Any() ? string.Join(",", childs) : "";
                //dt = dal.QueryStoreInventorys(nl, out recordCount);
                dt = dal.QueryInventorys(nl);
            }
            else
            {
                if (!nl["store"].IsNullOrEmpty())
                {
                    var storeId = nl["store"];
                    var store   = WarehouseService.Find(o => o.CompanyId == CommonService.CompanyId && o.StoreId == storeId);
                    var childs  = ProductCategoryService.GetChildSNs(store.CategorySN.Split(',').Select(o => int.Parse(o)).ToList(), true);
                    if (!nl["parentType"].IsNullOrEmpty())
                    {
                        var childs2 = ProductCategoryService.GetChildSNs(new List <int>()
                        {
                            int.Parse(nl["parentType"])
                        }, true);
                        childs = childs.Where(o => childs2.Contains(o)).ToList();
                    }
                    nl["parentType"] = childs.Any() ? string.Join(",", childs) : "0";
                }
                else if (!nl["parentType"].IsNullOrEmpty())
                {
                    var childs = ProductCategoryService.GetChildSNs(new List <int>()
                    {
                        int.Parse(nl["parentType"])
                    }, true);
                    nl["parentType"] = string.Join(",", childs);
                }
                dt = dal.QueryInventorys(nl);
            }
            recordCount = 0;
            if (nl["ispage"] != "0")//分页
            {
                if (dt.Rows.Count > 0)
                {
                    recordCount = Convert.ToInt32(dt.Rows[0]["RecordTotal"]);
                }
            }
            decimal stockNumbers = 0, saleAmounts = 0, stockAmounts = 0;

            if (dt.Rows.Count > 0)
            {
                var dr = dt.Rows[0];
                stockNumbers += Convert.ToDecimal(dr["StockNumbers"]);
                saleAmounts  += Convert.ToDecimal(dr["SaleAmounts"]);
                stockAmounts += Convert.ToDecimal(dr["StockAmounts"]);
            }
            footer = new List <object>()
            {
                new { StockNumber = stockNumbers, SaleAmount = saleAmounts, StockAmount = stockAmounts, Title = "合计:" }
            };
            ProductService.SetSysPrice(nl["store"], dt);
            return(dt);
        }
        public static DataTable ReportList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount, ref object footer, bool isPage = true)
        {
            var nl = new System.Collections.Specialized.NameValueCollection()
            {
                nvl
            };

            if (!nl["categorysn"].IsNullOrEmpty())
            {
                var childs = ProductCategoryService.GetChildSNs(new List <int>()
                {
                    int.Parse(nl["categorysn"])
                });
                nl["categorysn"] = string.Join(",", childs);
            }
            if (!isPage)
            {
                nl["rows"] = int.MaxValue.ToString();
            }
            var     ds = dal.FindTakeStockPages(nl, out recordCount);
            var     dt = ds.Tables[0];
            decimal ActualNumber = 0, LockNumber = 0, SubstractNum = 0, SubstractTotal = 0, ActualTotal = 0;

            if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
            {
                var dttotal = ds.Tables[1];
                ActualNumber   = Math.Round(dttotal.Rows[0]["ActualNumbers"].ToType <decimal>(), 3);
                LockNumber     = Math.Round(dttotal.Rows[0]["LockNumbers"].ToType <decimal>(), 3);
                SubstractNum   = Math.Round(dttotal.Rows[0]["SubstractNums"].ToType <decimal>(), 3);
                SubstractTotal = Math.Round(dttotal.Rows[0]["SubstractTotals"].ToType <decimal>(), 3);
                ActualTotal    = Math.Round(dttotal.Rows[0]["ActualTotals"].ToType <decimal>(), 3);
            }
            footer = new List <object>()
            {
                new { ActualNumber = ActualNumber, LockNumber = LockNumber, SubstractNum = SubstractNum, SubstractTotal = SubstractTotal, ActualTotal = ActualTotal, SubUnit = "合计:" }
            };
            return(dt);

            /*
             * var query = from a in CurrentRepository.Entities
             *          join b in BaseService<VwProduct>.CurrentRepository.Entities on a.Barcode equals b.Barcode
             *          join c in BaseService<TreasuryLocks>.CurrentRepository.Entities on a.CheckBatch equals c.CheckBatch
             *          join d in WarehouseService.CurrentRepository.Entities.DefaultIfEmpty() on c.LockStoreID equals d.StoreId
             *          let o = from x in BaseService<StockTakingLog>.CurrentRepository.QueryEntity where x.CheckBatch == a.CheckBatch && x.Barcode == a.Barcode && x.State == 0 select (decimal?)x.Number
             *          //where c.State==1
             *          orderby c.CheckBatch descending, b.CategorySN ascending
             *          select new
             *          {
             *              a.Id,
             *              a.CheckBatch,
             *              c.LockStoreID,
             *              StoreTitle= d.Title,
             *              c.LockDate,
             *              Pro=b,
             *              a.LockNumber,
             *              ActualNumber=a.ActualNumber??o.Sum(),
             *              b.SysPrice,
             *              BuyTotal="",
             *              c.State
             *          };
             * if (!storeId.IsNullOrEmpty())
             *  query = query.Where(o => o.LockStoreID == storeId);
             * if(!checkBatch.IsNullOrEmpty())
             *  query = query.Where(o => o.CheckBatch == checkBatch);
             ||||||| .r6102
             |||||||public static DataTable ReportList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount, bool isPage = true)
             |||||||{
             |||||||return dal.FindTakeStockPages(nvl, out recordCount, isPage);
             |||||||/*
             |||||||var query = from a in CurrentRepository.Entities
             |||||||    join b in BaseService<VwProduct>.CurrentRepository.Entities on a.Barcode equals b.Barcode
             |||||||    join c in BaseService<TreasuryLocks>.CurrentRepository.Entities on a.CheckBatch equals c.CheckBatch
             |||||||    join d in WarehouseService.CurrentRepository.Entities.DefaultIfEmpty() on c.LockStoreID equals d.StoreId
             |||||||    let o = from x in BaseService<StockTakingLog>.CurrentRepository.QueryEntity where x.CheckBatch == a.CheckBatch && x.Barcode == a.Barcode && x.State == 0 select (decimal?)x.Number
             |||||||    //where c.State==1
             |||||||    orderby c.CheckBatch descending, b.CategorySN ascending
             |||||||    select new
             |||||||    {
             |||||||        a.Id,
             |||||||        a.CheckBatch,
             |||||||        c.LockStoreID,
             |||||||        StoreTitle= d.Title,
             |||||||        c.LockDate,
             |||||||        Pro=b,
             |||||||        a.LockNumber,
             |||||||        ActualNumber=a.ActualNumber??o.Sum(),
             |||||||        b.SysPrice,
             |||||||        BuyTotal="",
             |||||||        c.State
             |||||||    };
             |||||||if (!storeId.IsNullOrEmpty())
             |||||||query = query.Where(o => o.LockStoreID == storeId);
             |||||||if(!checkBatch.IsNullOrEmpty())
             |||||||query = query.Where(o => o.CheckBatch == checkBatch);
             |||||||=======
             |||||||public static DataTable ReportList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount, ref object footer, bool isPage = true)
             |||||||{
             |||||||var dt = dal.FindTakeStockPages(nvl, out recordCount, isPage);
             |||||||int countNotPage = 0;
             |||||||var dtNotPage = dal.FindTakeStockPages(nvl, out countNotPage, false);
             |||||||var lockNumber = dtNotPage.AsEnumerable().Sum(o => o["LockNumber"].ToType<decimal>());
             |||||||var actualNumber = dtNotPage.AsEnumerable().Sum(o => o["ActualNumber"].ToType<decimal>());
             |||||||var substractNum = dtNotPage.AsEnumerable().Sum(o => o["SubstractNum"].ToType<decimal>());
             |||||||var substractTotal = dtNotPage.AsEnumerable().Sum(o => o["SubstractTotal"].ToType<decimal>());
             |||||||var actualTotal = dtNotPage.AsEnumerable().Sum(o => o["ActualTotal"].ToType<decimal>());
             |||||||footer = new List<object>() {
             |||||||new {
             |||||||SysPrice="所有合计:",
             |||||||State=-1,
             |||||||LockNumber=lockNumber,
             |||||||ActualNumber=actualNumber,
             |||||||SubstractNum=substractNum,
             |||||||SubstractTotal=substractTotal,
             |||||||ActualTotal=actualTotal
             |||||||}
             |||||||};
             |||||||return dt;
             |||||||
             |||||||/*
             |||||||var query = from a in CurrentRepository.Entities
             |||||||     join b in BaseService<VwProduct>.CurrentRepository.Entities on a.Barcode equals b.Barcode
             |||||||     join c in BaseService<TreasuryLocks>.CurrentRepository.Entities on a.CheckBatch equals c.CheckBatch
             |||||||     join d in WarehouseService.CurrentRepository.Entities.DefaultIfEmpty() on c.LockStoreID equals d.StoreId
             |||||||     let o = from x in BaseService<StockTakingLog>.CurrentRepository.QueryEntity where x.CheckBatch == a.CheckBatch && x.Barcode == a.Barcode && x.State == 0 select (decimal?)x.Number
             |||||||     //where c.State==1
             |||||||     orderby c.CheckBatch descending, b.CategorySN ascending
             |||||||     select new
             |||||||     {
             |||||||         a.Id,
             |||||||         a.CheckBatch,
             |||||||         c.LockStoreID,
             |||||||         StoreTitle= d.Title,
             |||||||         c.LockDate,
             |||||||         Pro=b,
             |||||||         a.LockNumber,
             |||||||         ActualNumber=a.ActualNumber??o.Sum(),
             |||||||         b.SysPrice,
             |||||||         BuyTotal="",
             |||||||         c.State
             |||||||     };
             |||||||if (!storeId.IsNullOrEmpty())
             |||||||query = query.Where(o => o.LockStoreID == storeId);
             |||||||if(!checkBatch.IsNullOrEmpty())
             |||||||query = query.Where(o => o.CheckBatch == checkBatch);
             |||||||>>>>>>> .r6246
             |||||||
             |||||||if (isPage)
             |||||||{
             |||||||recordCount = query.Count();
             |||||||var list= query.ToPageList();
             |||||||ProductService.SetSysPrice(storeId, list.Select(o => o.Pro).ToList());
             |||||||return list.Select(o=>new{
             ||||||| o.Id,
             ||||||| o.CheckBatch,
             ||||||| o.LockStoreID,
             ||||||| o.StoreTitle,
             ||||||| o.LockDate,
             ||||||| o.LockNumber,
             ||||||| o.ActualNumber,
             ||||||| SubstractNum=o.ActualNumber-o.LockNumber,
             ||||||| SubstractTotal=(o.ActualNumber-o.LockNumber)*o.Pro.BuyPrice,
             ||||||| ActualTotal = o.ActualNumber * o.Pro.SysPrice,
             ||||||| o.BuyTotal,
             ||||||| o.Pro.State,
             ||||||| o.Pro.ProductCode,
             ||||||| o.Pro.Barcode,
             ||||||| o.Pro.Title,
             ||||||| o.Pro.CategoryTitle,
             ||||||| o.Pro.SubUnit,
             ||||||| o.Pro.Size,
             ||||||| o.Pro.SupplierTitle,
             ||||||| o.Pro.SysPrice
             |||||||});
             |||||||}
             |||||||else
             |||||||{
             |||||||recordCount = 0;
             |||||||var list= query.Where(o=>o.State==1).ToList();
             |||||||ProductService.SetSysPrice(storeId, list.Select(o => o.Pro).ToList());
             |||||||return list.Select(o => new
             |||||||{
             ||||||| o.Id,
             ||||||| o.CheckBatch,
             ||||||| o.LockStoreID,
             ||||||| o.StoreTitle,
             ||||||| o.LockDate,
             ||||||| o.LockNumber,
             ||||||| o.ActualNumber,
             ||||||| SubstractNum = o.ActualNumber - o.LockNumber,
             ||||||| SubstractTotal = (o.ActualNumber - o.LockNumber) * o.Pro.BuyPrice,
             ||||||| ActualTotal = o.ActualNumber * o.Pro.SysPrice,
             ||||||| o.BuyTotal,
             ||||||| o.Pro.State,
             ||||||| o.Pro.ProductCode,
             ||||||| o.Pro.Barcode,
             ||||||| o.Pro.Title,
             ||||||| o.Pro.CategoryTitle,
             ||||||| o.Pro.SubUnit,
             ||||||| o.Pro.Size,
             ||||||| o.Pro.SupplierTitle,
             ||||||| o.Pro.SysPrice
             |||||||});
             |||||||}*/
        }
Example #10
0
        public static OpResult AddStockLock(TreasuryLocks obj)
        {
            var op = new OpResult();

            try
            {
                obj.LockStoreID.IsNullThrow();
                var xh = obj.CheckBatch.Substring(obj.CheckBatch.Length - 2);
                if (int.Parse(xh) > 20)
                {
                    op.Message = "每月最多只能锁定20次"; return(op);
                }
                var selectBarcodes = HttpContext.Current.Request["selectBarcodes"];
                var barcodes       = new string[] { };
                if (selectBarcodes.IsNullOrEmpty())
                {
                    List <int> childsns = null;
                    if (!obj.LockCategorySN.IsNullOrEmpty())
                    {
                        var parsns = obj.LockCategorySN.Split(',').Select(o => int.Parse(o)).ToList();
                        childsns = ProductCategoryService.GetChildSNs(parsns, true);
                    }
                    else
                    {
                        var ware   = WarehouseService.Find(o => o.StoreId == obj.LockStoreID && o.CompanyId == CommonService.CompanyId);
                        var parsns = ware.CategorySN.Split(',').Where(o => !o.IsNullOrEmpty()).Select(o => int.Parse(o)).ToList();
                        childsns = ProductCategoryService.GetChildSNs(parsns);
                    }
                    barcodes = ProductService.FindList(o => childsns.Contains(o.CategorySN) && o.CompanyId == CommonService.CompanyId).Select(o => o.Barcode).Distinct().ToArray();
                }
                else
                {
                    barcodes = selectBarcodes.Split(',');
                }

                var dt = dal.GetInventoryBalanceLast(CommonService.CompanyId, obj.LockStoreID, string.Join(",", barcodes));
                if (dt == null || dt.Rows.Count <= 0)
                {
                    op.Message = "该门店暂无库存信息";
                }
                else
                {
                    obj.LockDate  = DateTime.Now;
                    obj.LockUID   = Sys.CurrentUser.UID;
                    obj.CompanyId = CommonService.CompanyId;
                    var stocks = new List <StockTaking>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (stocks.Any(o => o.Barcode == dr["Barcode"].ToString()))
                        {
                            continue;
                        }
                        stocks.Add(new StockTaking()
                        {
                            Barcode    = dr["Barcode"].ToString(),
                            LockNumber = dr["Number"].ToType <decimal>(),
                            CheckBatch = obj.CheckBatch,
                            CreateDT   = obj.LockDate,
                            CreateUID  = obj.LockUID,
                            CompanyId  = obj.CompanyId
                        });
                    }
                    BaseService <TreasuryLocks> .Add(obj, false);

                    op = AddRange(stocks);
                }
            }
            catch (Exception ex)
            {
                op.Message = ex.Message;
                Log.WriteError(ex);
            }
            return(op);
        }
Example #11
0
        public static DataTable FindPageList(System.Collections.Specialized.NameValueCollection nvl, out int recordCount, ref object footer, bool ispage = true)
        {
            var nl = new System.Collections.Specialized.NameValueCollection()
            {
                nvl
            };

            if (!nl["categorysn"].IsNullOrEmpty())
            {
                var childs = ProductCategoryService.GetChildSNs(new List <int>()
                {
                    int.Parse(nl["categorysn"])
                });
                nl["categorysn"] = string.Join(",", childs);
            }
            if (!ispage)
            {
                nl["rows"] = int.MaxValue.ToString();
            }
            var ds = dal.FindTakeStockPages(nl, out recordCount);
            //var num = dt.AsEnumerable().Sum(o => o["ActualNumber"].ToType<decimal>());
            decimal ActualNumber = 0, LockNumber = 0;
            var     dt = ds.Tables[0];

            if (ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
            {
                var dttotal = ds.Tables[1];
                ActualNumber = dttotal.Rows[0]["ActualNumbers"].ToType <decimal>();
                LockNumber   = dttotal.Rows[0]["LockNumbers"].ToType <decimal>();
            }
            footer = new List <object>()
            {
                new {
                    SubUnit      = "合计:",
                    ActualNumber = Math.Round(ActualNumber, 3),
                    LockNumber   = Math.Round(LockNumber, 3)
                }
            };
            return(dt);

            /*var storeId = nvl["storeId"];
             * var userId = nvl["userId"];
             * var date1 = nvl["date1"].IsNullOrEmpty()?new Nullable<DateTime>():DateTime.Parse(nvl["date1"]);
             * var date2 = nvl["date2"].IsNullOrEmpty()?new Nullable<DateTime>():DateTime.Parse(nvl["date2"]).AddDays(1);
             * var searchText = nvl["searchText"];
             * var express = DynamicallyLinqHelper.True<TreasuryLocks>().And(o => o.LockStoreID == storeId, storeId.IsNullOrEmpty())
             *  .And(o => o.LockDate >= date1, !date1.HasValue).And(o => o.LockDate < date2, !date2.HasValue);
             * var queryLock = BaseService<TreasuryLocks>.CurrentRepository.QueryEntity.Where(express);
             * var queryWare = WarehouseService.CurrentRepository.QueryEntity;
             * var queryProduct = BaseService<VwProduct>.CurrentRepository.QueryEntity;
             * var queryStock= CurrentRepository.QueryEntity;
             * if (!userId.IsNullOrEmpty())
             *  queryStock = queryStock.Where(o => o.CheckUID == userId);
             * var queryUser = UserInfoService.CurrentRepository.QueryEntity;
             * var query = from a in queryStock
             *          join b in queryLock on a.CheckBatch equals b.CheckBatch
             *          join c in queryWare on b.LockStoreID equals c.StoreId
             *          join d in queryProduct on a.Barcode equals d.Barcode
             *          join e in queryUser on a.CheckUID equals e.UID into g
             *          join e in queryUser on a.CreateUID equals e.UID into h
             *          from f in g.DefaultIfEmpty()
             *          from y in h.DefaultIfEmpty()
             *          let o=from x in BaseService<StockTakingLog>.CurrentRepository.QueryEntity where x.CheckBatch==a.CheckBatch && x.Barcode==a.Barcode && x.State==0 select (decimal?)x.Number
             *          where b.State==0
             *          select new
             *          {
             *              a.Id,
             *              b.CheckBatch,
             *              StoreTitle = c.Title,
             *              b.LockDate,
             *              d.ProductCode,
             *              d.Barcode,
             *              d.Title,
             *              d.BrandTitle,
             *              d.SubUnit,
             *              ActualNumber=a.ActualNumber??o.Sum(),
             *              f.FullName,
             *              CreateName=y.FullName,
             *              d.CategorySN,
             *              a.LockNumber
             *          };
             * if(!searchText.IsNullOrEmpty())
             *  query=query.Where(o=>(o.CheckBatch.StartsWith(searchText) || o.Barcode.StartsWith(searchText) || o.Title.Contains(searchText)));
             * var ls = new List<object>();
             * recordCount = 0;
             * if (ispage)
             * {
             *  recordCount = query.Count();
             *  var list = query.ToPageList();
             *  ls.AddRange(list);
             * }
             * else
             * {
             *  ls.AddRange(query.ToList());
             * }
             * return ls;*/
        }