Ejemplo n.º 1
0
        private bool FinishCheckBillTask(Task task)
        {
            var checkDetail = CheckBillDetailRepository.GetQueryable()
                              .Where(i => i.BillNo == task.OrderID &&
                                     i.ID == task.AllotID &&
                                     i.Status == "1")
                              .FirstOrDefault();

            if (checkDetail != null &&
                (checkDetail.CheckBillMaster.Status == "2" ||
                 checkDetail.CheckBillMaster.Status == "3"))
            {
                decimal quantity = checkDetail.Quantity;

                checkDetail.Status                 = "2";
                checkDetail.RealQuantity           = quantity;
                checkDetail.Storage.IsLock         = "0";
                checkDetail.CheckBillMaster.Status = "3";
                checkDetail.FinishTime             = DateTime.Now;
                if (checkDetail.CheckBillMaster.CheckBillDetails.All(c => c.Status == "2"))
                {
                    checkDetail.CheckBillMaster.Status = "4";
                }
                CheckBillDetailRepository.SaveChanges();
                return(true);
            }
            else
            {
                //"需确认盘点的数据查询为空或者主单状态不对,完成出错!";
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool EditDetail(string id, string status, string operater, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;

            string[]        ids    = id.Split(',');
            string          strId  = "";
            CheckBillDetail detail = null;

            var employee = EmployeeRepository.GetQueryable().FirstOrDefault(e => e.UserName == operater);

            for (int i = 0; i < ids.Length; i++)
            {
                strId  = ids[i].ToString();
                detail = CheckBillDetailRepository.GetQueryable().ToArray().FirstOrDefault(a => strId == a.ID.ToString());
                if (detail != null)
                {
                    if (detail.Status == "0" && status == "1" ||
                        detail.Status == "1" && status == "0" ||
                        detail.Status == "1" && status == "2")
                    {
                        try
                        {
                            detail.Status = status;
                            if (operater != "")
                            {
                                detail.Operator = employee.EmployeeName;
                            }
                            else
                            {
                                detail.Operator = "";
                            }
                            CheckBillDetailRepository.SaveChanges();
                            result = true;
                        }
                        catch (Exception ex)
                        {
                            strResult = "原因:" + ex.Message;
                        }
                    }
                    else
                    {
                        strResult = "原因:操作错误!";
                    }
                }
                else
                {
                    strResult = "原因:未找到该记录!";
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public bool CellAdd(string BillNo, string ware, string area, string shelf, string cell)
        {
            IQueryable <Storage> storageQuery = StorageRepository.GetQueryable();

            if (ware != null && ware != string.Empty || area != null && area != string.Empty || shelf != null && shelf != string.Empty || cell != null && cell != string.Empty)
            {
                if (ware != string.Empty)
                {
                    ware = ware.Substring(0, ware.Length - 1);
                }
                if (area != string.Empty)
                {
                    area = area.Substring(0, area.Length - 1);
                }
                if (shelf != string.Empty)
                {
                    shelf = shelf.Substring(0, shelf.Length - 1);
                }
                if (cell != string.Empty)
                {
                    cell = cell.Substring(0, cell.Length - 1);
                }
            }
            var storages = storageQuery.Where(s => ware.Contains(s.Cell.Shelf.Area.Warehouse.WarehouseCode) || area.Contains(s.Cell.Shelf.Area.AreaCode) || shelf.Contains(s.Cell.Shelf.ShelfCode) || cell.Contains(s.Cell.CellCode))
                           .OrderBy(s => s.StorageCode).AsEnumerable()
                           .Select(s => new { s.StorageCode, s.Cell.CellCode, s.Cell.CellName, s.Product.ProductCode, s.Product.ProductName, s.Quantity, IsActive = s.IsActive == "1" ? "可用" : "不可用", StorageTime = s.StorageTime.ToString("yyyy-MM-dd"), UpdateTime = s.UpdateTime.ToString("yyyy-MM-dd") });

            foreach (var stor in storages)
            {
                var checkDetail = new CheckBillDetail();
                checkDetail.BillNo          = BillNo;
                checkDetail.CellCode        = stor.CellCode;
                checkDetail.StorageCode     = stor.StorageCode;
                checkDetail.ProductCode     = stor.ProductCode;
                checkDetail.UnitCode        = "";
                checkDetail.Quantity        = stor.Quantity;
                checkDetail.RealProductCode = stor.ProductCode;
                checkDetail.RealUnitCode    = "";
                checkDetail.RealQuantity    = stor.Quantity;
                checkDetail.Status          = "1";
                CheckBillDetailRepository.Add(checkDetail);
                CheckBillDetailRepository.SaveChanges();
            }
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 根据参数生成并保存盘点数据  --异动生成
        /// </summary>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="UserName">登陆用户</param>
        /// <returns></returns>
        public bool ChangedAdd(string beginDate, string endDate, string UserName, string billType, out string info)
        {
            bool result = false;

            info = string.Empty;
            IQueryable <Warehouse>      wareQuery     = WarehouseRepository.GetQueryable();
            IQueryable <Storage>        storageQuery  = StorageRepository.GetQueryable();
            IQueryable <InBillAllot>    inAllotQuery  = InBillAllotRepository.GetQueryable();
            IQueryable <OutBillAllot>   outAllotQuery = OutBillAllotRepository.GetQueryable();
            IQueryable <MoveBillDetail> moveBillQuery = MoveBillDetailRepository.GetQueryable();
            var employee = EmployeeRepository.GetQueryable().FirstOrDefault(e => e.UserName == UserName);

            if (employee != null)
            {
                if (beginDate == string.Empty || beginDate == null)
                {
                    beginDate = DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd");
                }
                if (endDate == string.Empty || endDate == null)
                {
                    endDate = DateTime.Now.ToString("yyyy-MM-dd");
                }
                DateTime begin = Convert.ToDateTime(beginDate);
                DateTime end   = Convert.ToDateTime(endDate);
                try
                {
                    using (var scope = new TransactionScope())
                    {
                        #region 循环所有仓库的订单,一个仓库一个盘点单据
                        var warehouses = wareQuery.OrderBy(w => w.WarehouseCode);
                        foreach (var item in warehouses.ToArray())
                        {
                            var inCells      = inAllotQuery.Where(i => i.FinishTime >= begin && i.FinishTime <= end && i.Cell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode).OrderBy(i => i.CellCode).Select(i => i.CellCode);
                            var outCells     = outAllotQuery.Where(o => o.FinishTime >= begin && o.FinishTime <= end && o.Cell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode).OrderBy(o => o.CellCode).Select(o => o.CellCode);
                            var moveInCells  = moveBillQuery.Where(m => m.FinishTime >= begin && m.FinishTime <= end && m.InCell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode).OrderBy(m => m.InCell.CellCode).Select(m => m.InCell.CellCode);
                            var moveOutCells = moveBillQuery.Where(m => m.FinishTime >= begin && m.FinishTime <= end && m.OutCell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode).OrderBy(m => m.OutCell.CellCode).Select(m => m.OutCell.CellCode);
                            var storages     = storageQuery.ToList().Where(s => s.Quantity > 0 && s.IsLock == "0" && (inCells.Any(i => i == s.CellCode) || outCells.Any(o => o == s.CellCode) || moveInCells.Any(mi => mi == s.CellCode) || moveOutCells.Any(mo => mo == s.CellCode)))
                                               .OrderBy(s => s.ProductCode).AsEnumerable()
                                               .Select(s => new
                            {
                                s.StorageCode,
                                s.Cell.CellCode,
                                s.Cell.CellName,
                                s.Product.ProductCode,
                                s.Product.ProductName,
                                s.Product.Unit.UnitCode,
                                s.Product.Unit.UnitName,
                                Quantity = s.Quantity / s.Product.Unit.Count,
                                s.Product.Unit.Count,
                                IsActive    = s.IsActive == "1" ? "可用" : "不可用",
                                StorageTime = s.StorageTime.ToString("yyyy-MM-dd"),
                                UpdateTime  = s.UpdateTime.ToString("yyyy-MM-dd")
                            });
                            if (storages.Count() > 0)
                            {
                                string billNo = GetCheckBillNo().ToString();
                                var    check  = new CheckBillMaster();
                                check.BillNo          = billNo;
                                check.BillDate        = DateTime.Now;
                                check.BillTypeCode    = billType;
                                check.WarehouseCode   = item.WarehouseCode;
                                check.OperatePersonID = employee.ID;
                                check.Status          = "1";
                                check.IsActive        = "1";
                                check.UpdateTime      = DateTime.Now;

                                CheckBillMasterRepository.Add(check);
                                CheckBillMasterRepository.SaveChanges();

                                foreach (var stor in storages.ToArray())
                                {
                                    var checkDetail = new CheckBillDetail();
                                    checkDetail.BillNo          = billNo;
                                    checkDetail.CellCode        = stor.CellCode;
                                    checkDetail.StorageCode     = stor.StorageCode;
                                    checkDetail.ProductCode     = stor.ProductCode;
                                    checkDetail.UnitCode        = stor.UnitCode;
                                    checkDetail.Quantity        = stor.Quantity * stor.Count;
                                    checkDetail.RealProductCode = stor.ProductCode;
                                    checkDetail.RealUnitCode    = stor.UnitCode;
                                    checkDetail.RealQuantity    = stor.Quantity * stor.Count;
                                    checkDetail.Status          = "1";
                                    CheckBillDetailRepository.Add(checkDetail);
                                    CheckBillDetailRepository.SaveChanges();

                                    var storage = storageQuery.FirstOrDefault(s => s.StorageCode == stor.StorageCode);
                                    storage.IsLock = "1";
                                    StorageRepository.SaveChanges();
                                }
                                result = true;
                            }
                            else
                            {
                                info = "所选择查询的时间无数据!";
                            }
                        }
                        #endregion
                        scope.Complete();
                    }
                }
                catch (Exception e)
                {
                    info = e.Message;
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据参数生成并保存盘点数据  --产品生成
        /// </summary>
        /// <param name="products">产品数据</param>
        /// <param name="UserName">登陆用户</param>
        /// <returns></returns>
        public bool ProductAdd(string products, string UserName, string billType, out string info)
        {
            bool result = false;

            info = string.Empty;
            IQueryable <Warehouse> wareQuery    = WarehouseRepository.GetQueryable();
            IQueryable <Storage>   storageQuery = StorageRepository.GetQueryable();
            var employee = EmployeeRepository.GetQueryable().FirstOrDefault(e => e.UserName == UserName);

            if (employee != null)
            {
                if (products != null && products != string.Empty)
                {
                    products = products.Substring(0, products.Length - 1);
                    try
                    {
                        using (var scope = new TransactionScope())
                        {
                            #region products 这个有值,就把这个值里面所有的卷烟信息所在的仓库的货位的储存信息生成盘点单,一个仓库一个盘点单据
                            var warehouses = wareQuery.OrderBy(w => w.WarehouseCode);
                            foreach (var item in warehouses.ToArray())
                            {
                                var storages = storageQuery.Where(s => s.ProductCode != null && products.Contains(s.ProductCode) && s.Cell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode && s.Quantity > 0 && s.IsLock == "0")
                                               .OrderBy(s => s.StorageCode).AsEnumerable()
                                               .Select(s => new
                                {
                                    s.StorageCode,
                                    s.Cell.CellCode,
                                    s.Cell.CellName,
                                    s.Product.ProductCode,
                                    s.Product.ProductName,
                                    s.Product.Unit.UnitCode,
                                    s.Product.Unit.UnitName,
                                    Quantity = s.Quantity / s.Product.Unit.Count,
                                    s.Product.Unit.Count,
                                    IsActive    = s.IsActive == "1" ? "可用" : "不可用",
                                    StorageTime = s.StorageTime.ToString("yyyy-MM-dd"),
                                    UpdateTime  = s.UpdateTime.ToString("yyyy-MM-dd")
                                });
                                if (storages.Count() > 0)
                                {
                                    string billNo = GetCheckBillNo().ToString();
                                    var    check  = new CheckBillMaster();
                                    check.BillNo          = billNo;
                                    check.BillDate        = DateTime.Now;
                                    check.BillTypeCode    = billType;
                                    check.WarehouseCode   = item.WarehouseCode;
                                    check.OperatePersonID = employee.ID;
                                    check.Status          = "1";
                                    check.IsActive        = "1";
                                    check.UpdateTime      = DateTime.Now;

                                    CheckBillMasterRepository.Add(check);
                                    CheckBillMasterRepository.SaveChanges();

                                    foreach (var stor in storages.ToArray())
                                    {
                                        var checkDetail = new CheckBillDetail();
                                        checkDetail.BillNo          = billNo;
                                        checkDetail.CellCode        = stor.CellCode;
                                        checkDetail.StorageCode     = stor.StorageCode;
                                        checkDetail.ProductCode     = stor.ProductCode;
                                        checkDetail.UnitCode        = stor.UnitCode;
                                        checkDetail.Quantity        = stor.Quantity * stor.Count;
                                        checkDetail.RealProductCode = stor.ProductCode;
                                        checkDetail.RealUnitCode    = stor.UnitCode;
                                        checkDetail.RealQuantity    = stor.Quantity * stor.Count;
                                        checkDetail.Status          = "1";
                                        CheckBillDetailRepository.Add(checkDetail);
                                        CheckBillDetailRepository.SaveChanges();

                                        var storage = storageQuery.FirstOrDefault(s => s.StorageCode == stor.StorageCode);
                                        storage.IsLock = "1";
                                        StorageRepository.SaveChanges();
                                    }
                                    result = true;
                                }
                                else
                                {
                                    info = "所选择的产品无数据!";
                                }
                            }
                            #endregion
                            scope.Complete();
                        }
                    }
                    catch (Exception e)
                    {
                        info = e.Message;
                    }
                }
                else
                {
                    info = "产品信息为空!无法生成!";
                }
            }
            else
            {
                info = "当前登陆用户为空!请重新登陆!";
            }
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据参数生成并保存盘点数据  --货位生成
        /// </summary>
        /// <param name="ware">仓库</param>
        /// <param name="area">库区</param>
        /// <param name="shelf">货架</param>
        /// <param name="cell">货位</param>
        /// <param name="UserName">登陆用户</param>
        /// <returns></returns>
        public bool CellAdd(string ware, string area, string shelf, string cell, string UserName, string billType, out string info)
        {
            bool result = false;

            info = string.Empty;
            IQueryable <Warehouse> wareQuery    = WarehouseRepository.GetQueryable();
            IQueryable <Storage>   storageQuery = StorageRepository.GetQueryable();
            var employee = EmployeeRepository.GetQueryable().FirstOrDefault(e => e.UserName == UserName);

            if (employee != null)
            {
                try
                {
                    using (var scope = new TransactionScope())
                    {
                        #region ware 这个有值,就把这个值里面所有的仓库的货位的储存信息生成盘点单,一个仓库一个盘点单据

                        if (ware != null && ware != string.Empty)
                        {
                            ware = ware.Substring(0, ware.Length - 1);
                            var wares = wareQuery.Where(w => ware.Contains(w.WarehouseCode));

                            foreach (var item in wares.ToArray())
                            {
                                var storages = storageQuery.Where(s => s.Cell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode && s.Quantity > 0 && s.IsLock == "0")
                                               .OrderBy(s => s.StorageCode).AsEnumerable()
                                               .Select(s => new
                                {
                                    s.StorageCode,
                                    s.Cell.CellCode,
                                    s.Cell.CellName,
                                    s.IsLock,
                                    s.Product.ProductCode,
                                    s.Product.ProductName,
                                    s.Product.Unit.UnitCode,
                                    s.Product.Unit.UnitName,
                                    Quantity = s.Quantity / s.Product.Unit.Count,
                                    s.Product.Unit.Count,
                                    IsActive    = s.IsActive == "1" ? "可用" : "不可用",
                                    StorageTime = s.StorageTime.ToString("yyyy-MM-dd"),
                                    UpdateTime  = s.UpdateTime.ToString("yyyy-MM-dd")
                                });
                                if (storages.Count() > 0)
                                {
                                    string billNo = GetCheckBillNo().ToString();
                                    var    check  = new CheckBillMaster();
                                    check.BillNo          = billNo;
                                    check.BillDate        = DateTime.Now;
                                    check.BillTypeCode    = billType;
                                    check.WarehouseCode   = item.WarehouseCode;
                                    check.OperatePersonID = employee.ID;
                                    check.Status          = "1";
                                    check.IsActive        = "1";
                                    check.UpdateTime      = DateTime.Now;

                                    CheckBillMasterRepository.Add(check);
                                    CheckBillMasterRepository.SaveChanges();

                                    foreach (var stor in storages.ToArray())
                                    {
                                        var checkDetail = new CheckBillDetail();
                                        checkDetail.BillNo          = billNo;
                                        checkDetail.CellCode        = stor.CellCode;
                                        checkDetail.StorageCode     = stor.StorageCode;
                                        checkDetail.ProductCode     = stor.ProductCode;
                                        checkDetail.UnitCode        = stor.UnitCode;
                                        checkDetail.Quantity        = stor.Quantity * stor.Count;
                                        checkDetail.RealProductCode = stor.ProductCode;
                                        checkDetail.RealUnitCode    = stor.UnitCode;
                                        checkDetail.RealQuantity    = stor.Quantity * stor.Count;
                                        checkDetail.Status          = "1";

                                        CheckBillDetailRepository.Add(checkDetail);
                                        CheckBillDetailRepository.SaveChanges();

                                        var storage = storageQuery.FirstOrDefault(s => s.StorageCode == stor.StorageCode);
                                        storage.IsLock = "1";
                                        StorageRepository.SaveChanges();
                                        scope.Complete();
                                    }
                                    result = true;
                                }
                                else
                                {
                                    info = "所选择的货位无数据!";
                                }
                            }
                        }
                        #endregion

                        #region ware 这个无值,把全部仓库里面包含area,shelf,cell的数据生成盘点单,一个仓库一个盘点单据

                        if (area != null && area != string.Empty || shelf != null && shelf != string.Empty || cell != null && cell != string.Empty)
                        {
                            if (area != string.Empty)
                            {
                                area = area.Substring(0, area.Length - 1);
                            }
                            if (shelf != string.Empty)
                            {
                                shelf = shelf.Substring(0, shelf.Length - 1);
                            }
                            if (cell != string.Empty)
                            {
                                cell = cell.Substring(0, cell.Length - 1);
                            }

                            var warehouses = wareQuery.OrderBy(w => w.WarehouseCode);

                            foreach (var item in warehouses.ToArray())
                            {
                                var storages = storageQuery.ToList().Where(s => s.Cell.Shelf.Area.Warehouse.WarehouseCode == item.WarehouseCode && (area.Contains(s.Cell.Shelf.Area.AreaCode) || shelf.Contains(s.Cell.Shelf.ShelfCode) || cell.Contains(s.Cell.CellCode)) && s.Quantity > 0 && s.IsLock == "0")
                                               .OrderBy(s => s.StorageCode).AsEnumerable()
                                               .Select(s => new
                                {
                                    s.StorageCode,
                                    s.Cell.CellCode,
                                    s.Cell.CellName,
                                    s.Product.ProductCode,
                                    s.Product.ProductName,
                                    s.Product.Unit.UnitCode,
                                    s.Product.Unit.UnitName,
                                    Quantity = s.Quantity / s.Product.Unit.Count,
                                    s.Product.Unit.Count,
                                    IsActive    = s.IsActive == "1" ? "可用" : "不可用",
                                    StorageTime = s.StorageTime.ToString("yyyy-MM-dd"),
                                    UpdateTime  = s.UpdateTime.ToString("yyyy-MM-dd")
                                });
                                if (storages.Count() > 0)
                                {
                                    string billNo = GetCheckBillNo().ToString();
                                    var    check  = new CheckBillMaster();
                                    check.BillNo          = billNo;
                                    check.BillDate        = DateTime.Now;
                                    check.BillTypeCode    = billType;
                                    check.WarehouseCode   = item.WarehouseCode;
                                    check.OperatePersonID = employee.ID;
                                    check.Status          = "1";
                                    check.IsActive        = "1";
                                    check.UpdateTime      = DateTime.Now;

                                    CheckBillMasterRepository.Add(check);
                                    CheckBillMasterRepository.SaveChanges();

                                    foreach (var stor in storages.ToArray())
                                    {
                                        var checkDetail = new CheckBillDetail();
                                        checkDetail.BillNo          = billNo;
                                        checkDetail.CellCode        = stor.CellCode;
                                        checkDetail.StorageCode     = stor.StorageCode;
                                        checkDetail.ProductCode     = stor.ProductCode;
                                        checkDetail.UnitCode        = stor.UnitCode;
                                        checkDetail.Quantity        = stor.Quantity * stor.Count;
                                        checkDetail.RealProductCode = stor.ProductCode;
                                        checkDetail.RealUnitCode    = stor.UnitCode;
                                        checkDetail.RealQuantity    = stor.Quantity * stor.Count;
                                        checkDetail.Status          = "1";
                                        CheckBillDetailRepository.Add(checkDetail);
                                        CheckBillDetailRepository.SaveChanges();

                                        var storage = storageQuery.FirstOrDefault(s => s.StorageCode == stor.StorageCode);
                                        storage.IsLock = "1";
                                        StorageRepository.SaveChanges();
                                        scope.Complete();
                                    }
                                    result = true;
                                }
                            }
                        }
                        #endregion

                        scope.Complete();
                    }
                }
                catch (Exception e)
                {
                    info = e.Message;
                }
            }
            else
            {
                info = "当前登陆用户为空!请重新登陆!";
            }
            return(result);
        }