コード例 #1
0
        public ActionResult AddWhInventoryReporList(WhInventoryRepor model, string productCode, string ProductName, string CSysId, string CSysName, string CErpCode, string CZCount, string ShiSum, string DanJia, string PanYingCount, string PanYingJinE, string BeiZhu, int pdStatus)
        {
            Result <object> result = new Result <object>();

            model.Status        = pdStatus == 5 ? (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhInventoryReporStatus.盘盈入库 : (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhInventoryReporStatus.盘亏入库;
            model.WarehouseCode = CSysId.Trim(',');
            model.AddUser       = CurrentUser.Base.SysNo;
            model.YingKuiStatus = pdStatus == 5 ? 1 : 2;
            model.AddTime       = DateTime.Now;

            List <WhIReporPrDetails> productModelList = new List <WhIReporPrDetails>();

            for (int i = 0; i < productCode.Trim(',').Split(',').Length; i++)
            {
                var productModel = new WhIReporPrDetails()
                {
                    ProduceCode        = productCode.Trim(',').Split(',')[i],
                    ProductName        = ProductName.Trim(',').Split(',')[i],
                    Specification      = "",
                    AuxiliaryAttribute = "",
                    BatchNumber        = "",
                    Unit               = "",
                    ADQuantity         = Convert.ToDecimal(CZCount.Trim(',').Split(',')[i]),
                    RealityQuantity    = Convert.ToDecimal(ShiSum.Trim(',').Split(',')[i]),
                    PlanPrice          = Convert.ToDecimal(DanJia.Trim(',').Split(',')[i]),
                    UnitPrice          = Convert.ToDecimal(DanJia.Trim(',').Split(',')[i]),
                    ProfitAndLoss      = Convert.ToDecimal(PanYingCount.Trim(',').Split(',')[i]),
                    ProfitAndLossPrice = Convert.ToDecimal(PanYingJinE.Trim(',').Split(',')[i]),
                    Remark             = BeiZhu.Trim('^').Split('^')[i],
                    WarehouseName      = CSysName.Split(',')[i],
                    WarehouseSysNo     = Convert.ToInt32(CSysId.Trim(',').Split(',')[i])
                };
                productModelList.Add(productModel);
            }
            if (!Hyt.BLL.InventorySheet.WhInventoryBo.Instance.AddWhInventoryRepor(model, productModelList))
            {
                result.Status  = false;
                result.Message = "错误,生成失败!";
                return(Json(result));
            }
            else
            {
                result.Status  = true;
                result.Message = "成功!";
                return(Json(result));
            }
        }
コード例 #2
0
        public ActionResult AddWhInventoryRepor(int id, int pdStatus)
        {
            Result <object> result = new Result <object>();

            #region 生成盘点报告单
            //获取盘点单信息
            var whlist = Hyt.BLL.InventorySheet.WhInventoryBo.Instance.GetWhInventoryDetail((int)id);
            if (whlist == null || whlist.dataList == null || whlist.dataList.Count == 0)
            {
                result.Status  = false;
                result.Message = "没有适合盘点的商品信息,报告单生成失败!";
                return(Json(result));
            }
            if (pdStatus == 1)
            { //生成盘盈
                if (!Hyt.BLL.InventorySheet.WhInventoryBo.Instance.GetIsWhInventoryRepor(whlist.Code, pdStatus))
                {
                    whlist.dataList = whlist.dataList.Where(p => p.InventoryQuantity > p.ZhangCunQuantity).ToList();
                }
                else
                {
                    result.Status  = false;
                    result.Message = "已生成过盘盈报告单,生成失败!";
                    return(Json(result));
                }
            }
            else
            { //生成盘亏
                if (!Hyt.BLL.InventorySheet.WhInventoryBo.Instance.GetIsWhInventoryRepor(whlist.Code, pdStatus))
                {
                    whlist.dataList = whlist.dataList.Where(p => p.InventoryQuantity < p.ZhangCunQuantity).ToList();
                }
                else
                {
                    result.Status  = false;
                    result.Message = "已生成过盘亏报告单,生成失败!";
                    return(Json(result));
                }
            }
            if (whlist.dataList == null || whlist.dataList.Count == 0)
            {
                result.Status  = false;
                result.Message = "没有适合盘点的商品信息,报告单生成失败!";
                return(Json(result));
            }

            #region 盘点报告单信息
            WhInventoryRepor model = new WhInventoryRepor()
            {
                WhInventoryCode = whlist.Code,
                Remarks         = "",
                ReportType      = 0,
                PrintCount      = 0,
                WarehouseCode   = whlist.WhInventorySysNo,
                WarehouseName   = "",
                Time            = DateTime.Now,
                Make            = CurrentUser.Base.UserName,
                Audit           = "",
                Tally           = "",
                CustodySysNo    = "",
                HeadSysNo       = "",
                AgentSysNo      = "",
                AddUser         = CurrentUser.Base.SysNo,
                AuditTime       = null,
                YingKuiStatus   = pdStatus,
                Status          = pdStatus == 1 ? (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhInventoryReporStatus.盘盈入库 : (int)Hyt.Model.InventorySheet.WhlnventoryEnum.WhInventoryReporStatus.盘亏入库,
                AddTime         = DateTime.Now
            };
            #endregion

            #region 盘点报告单商品信息
            List <WhIReporPrDetails> WhIReporPrDetailsList = new List <WhIReporPrDetails>();
            foreach (var item in whlist.dataList)
            {
                WhIReporPrDetails productList = new WhIReporPrDetails()
                {
                    WarehouseSysNo     = item.WarehouseSysNo,
                    ProduceCode        = item.ErpCode,
                    ProductName        = item.ProductName,
                    Specification      = "",
                    AuxiliaryAttribute = "",
                    BatchNumber        = "",
                    Unit            = "",
                    ADQuantity      = item.ZhangCunQuantity,
                    RealityQuantity = item.InventoryQuantity,
                    PlanPrice       = item.CostPrice,
                    //UnitPrice = 0,
                    ProfitAndLoss      = item.adjustmenQuantity,
                    ProfitAndLossPrice = (item.CostPrice * item.adjustmenQuantity) - (item.CostPrice * item.ZhangCunQuantity),
                    Remark             = "",
                    ProcurementTime    = null,
                    //ShelfLife=
                    ValidityTime  = null,
                    WarehouseName = item.WarehouseNameDate
                };
                WhIReporPrDetailsList.Add(productList);
            }
            #endregion
            if (!Hyt.BLL.InventorySheet.WhInventoryBo.Instance.AddWhInventoryRepor(model, WhIReporPrDetailsList))
            {
                result.Status  = false;
                result.Message = "错误,生成失败!";
                return(Json(result));
            }
            else
            {
                result.Status  = true;
                result.Message = "成功!";
                return(Json(result));
            }
            #endregion
        }