Exemplo n.º 1
0
        public RouteData <Wms_StockInMaterialDetailDto> SearchMaterial(long storeId, long stockInId, string materialNo)
        {
            Wms_material material = _client.Queryable <Wms_material>().First(x => x.MaterialNo == materialNo);

            if (material == null)
            {
                return(RouteData <Wms_StockInMaterialDetailDto> .From(PubMessages.E1005_MATERIALNO_NOTFOUND));
            }
            Wms_stockindetail detail = _stockindetailServices.QueryableToEntity(x => x.StockInId == stockInId && x.MaterialId == material.MaterialId);

            if (detail == null)
            {
                return(RouteData <Wms_StockInMaterialDetailDto> .From(PubMessages.E2015_STOCKIN_HASNOT_MATERIAL));
            }
            Wms_StockInMaterialDetailDto detailDto = new Wms_StockInMaterialDetailDto()
            {
                StockInId       = detail.StockInId.ToString(),
                StockInDetailId = detail.StockInDetailId.ToString(),
                MaterialId      = material.MaterialId.ToString(),
                MaterialNo      = material.MaterialNo,
                MaterialName    = material.MaterialName,
                PlanInQty       = (int)detail.PlanInQty,
                ActInQty        = (int)detail.ActInQty,
                Qty             = 0
            };

            return(RouteData <Wms_StockInMaterialDetailDto> .From(detailDto));
        }
Exemplo n.º 2
0
        public IActionResult AddOrUpdate([FromForm] Wms_material model, [FromForm] string id)
        {
            var validator = new MaterialFluent();
            var results   = validator.Validate(model);
            var success   = results.IsValid;

            if (!success)
            {
                string msg = results.Errors.Aggregate("", (current, item) => (current + item.ErrorMessage + "</br>"));
                return(BootJsonH((PubEnum.Failed.ToInt32(), msg)));
            }
            if (id.IsEmptyZero())
            {
                if (_materialServices.IsAny(c => c.MaterialNo == model.MaterialNo || c.MaterialName == model.MaterialName))
                {
                    return(BootJsonH((false, PubConst.Material1)));
                }
                model.MaterialId = PubId.SnowflakeId;
                model.CreateBy   = UserDtoCache.UserId;
                bool flag = _materialServices.Insert(model);
                return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2)));
            }
            else
            {
                model.MaterialId   = id.ToInt64();
                model.ModifiedBy   = UserDtoCache.UserId;
                model.ModifiedDate = DateTimeExt.DateTime;
                var flag = _materialServices.Update(model);
                return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2)));
            }
        }
Exemplo n.º 3
0
        public async Task <RouteData <Wms_StockOutMaterialDetailDto> > SearchMaterial(long storeId, long stockOutId, string materialNo)
        {
            Wms_material material = await _client.Queryable <Wms_material>().FirstAsync(x => x.MaterialNo == materialNo);

            if (material == null)
            {
                return(RouteData <Wms_StockOutMaterialDetailDto> .From(PubMessages.E1005_MATERIALNO_NOTFOUND));
            }
            Wms_stockout stockout = await _client.Queryable <Wms_stockout>().FirstAsync(x => x.StockOutId == stockOutId);

            if (stockout == null)
            {
                return(RouteData <Wms_StockOutMaterialDetailDto> .From(PubMessages.E2115_STOCKOUT_HASNOT_MATERIAL));
            }
            Wms_stockoutdetail detail = await _client.Queryable <Wms_stockoutdetail>().FirstAsync(x => x.StockOutId == stockOutId && x.MaterialId == material.MaterialId);

            if (detail == null)
            {
                return(RouteData <Wms_StockOutMaterialDetailDto> .From(PubMessages.E2115_STOCKOUT_HASNOT_MATERIAL));
            }
            Wms_StockOutMaterialDetailDto detailDto = new Wms_StockOutMaterialDetailDto()
            {
                StockOutId       = detail.StockOutId.ToString(),
                StockOutDetailId = detail.StockOutDetailId.ToString(),
                MaterialId       = material.MaterialId.ToString(),
                MaterialNo       = material.MaterialNo,
                MaterialName     = material.MaterialName,
                OrderNo          = stockout.OrderNo,
                PlanOutQty       = (int)detail.PlanOutQty,
                ActOutQty        = (int)detail.ActOutQty,
                Qty = 0
            };

            return(RouteData <Wms_StockOutMaterialDetailDto> .From(detailDto));
        }
Exemplo n.º 4
0
        public IActionResult AddOrUpdate([FromForm] Wms_material model, [FromForm] string id)
        {
            var validator = new MaterialFluent();
            var results   = validator.Validate(model);
            var success   = results.IsValid;

            if (!success)
            {
                string msg = results.Errors.Aggregate("", (current, item) => (current + item.ErrorMessage + "</br>"));
                return(BootJsonH((PubEnum.Failed.ToInt32(), msg)));
            }


            Sys_dict unitDict = _client.Queryable <Sys_dict>().First(x => x.DictId == model.Unit && x.DictType == PubDictType.unit.ToInt32().ToString());

            if (unitDict == null)
            {
                return(BootJsonH((false, PubConst.UnitNotFound)));
            }
            Sys_dict typeDict = _client.Queryable <Sys_dict>().First(x => x.DictId == model.MaterialType && x.DictType == PubDictType.material.ToInt32().ToString());

            if (typeDict == null)
            {
                return(BootJsonH((false, PubConst.MaterialTypeNotFound)));
            }

            if (id.IsEmptyZero())
            {
                if (_materialServices.IsAny(c => c.MaterialNo == model.MaterialNo || c.MaterialName == model.MaterialName))
                {
                    return(BootJsonH((false, PubConst.Material1)));
                }

                model.MaterialId       = PubId.SnowflakeId;
                model.UnitName         = unitDict.DictName;
                model.MaterialTypeName = typeDict.DictName;
                model.CreateBy         = UserDtoCache.UserId;
                model.CreateDate       = DateTime.Now;
                model.CreateUser       = UserDtoCache.UserName;
                model.ModifiedBy       = UserDtoCache.UserId;
                model.ModifiedDate     = DateTime.Now;
                model.ModifiedUser     = UserDtoCache.UserName;

                bool flag = _materialServices.Insert(model);
                return(BootJsonH(flag ? (flag, PubConst.Add1) : (flag, PubConst.Add2)));
            }
            else
            {
                model.MaterialId       = id.ToInt64();
                model.UnitName         = unitDict.DictName;
                model.MaterialTypeName = typeDict.DictName;
                model.ModifiedBy       = UserDtoCache.UserId;
                model.ModifiedDate     = DateTimeExt.DateTime;
                var flag = _materialServices.Update(model);
                return(BootJsonH(flag ? (flag, PubConst.Update1) : (flag, PubConst.Update2)));
            }
        }
Exemplo n.º 5
0
        public async Task <RouteData <Wms_material> > SearchMaterialNo(long storeId, string materialNo)
        {
            Wms_material material = await _materialServices.Queryable().FirstAsync(x => x.WarehouseId == storeId && x.MaterialNo == materialNo);

            if (material == null)
            {
                return(RouteData <Wms_material> .From(PubMessages.E1005_MATERIALNO_NOTFOUND));
            }
            return(RouteData <Wms_material> .From(material));
        }
Exemplo n.º 6
0
        public IActionResult Add(string id)
        {
            var model = new Wms_material();

            if (id.IsEmpty())
            {
                return(View(model));
            }
            else
            {
                model = _materialServices.QueryableToEntity(c => c.MaterialId == SqlFunc.ToInt64(id));
                return(View(model));
            }
        }