Exemplo n.º 1
0
        public async Task <IActionResult> Update([FromBody] ReceiveTypeGetDto GetDto, string Id)
        {
            try
            {
                var position = await _service.QueryByIdAsync(Id);

                var positions = await _service.QueryAsync(u => u.EnCode == GetDto.EnCode);

                if (positions.Count > 0 && position.EnCode != GetDto.EnCode)
                {
                    return(Ok(new { Status = true, Message = "此编码已存在,请重新修改" }));
                }

                GetDto.Id = Id;
                var result = await _service.Update(GetDto);

                if (result > 0)
                {
                    return(Ok(new { Status = true, Message = "修改成功" }));
                }
                return(Ok(new { Status = false, Message = "修改失败,请刷新后重试" }));
            }
            catch (Exception ex)
            {
                return(Ok(new { Status = false, Message = ex.ToString() }));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GatPagerListByWhere(string keyword, int rows, int page, string sidx, string sord, string Id)
        {
            if (string.IsNullOrEmpty(sidx))
            {
                sidx = "SortCode";
            }
            if (string.IsNullOrEmpty(sord))
            {
                sord = "ASC";
            }

            PagerEntity <InStockHeadGetDto> entity = await _service.QueryByPagesAsync(rows, page,
                                                                                      t => t.OrderNo.Contains((keyword ?? t.OrderNo)),
                                                                                      _service.Expression(sidx), sord.ToUpper().Equals("ASC"));

            List <InStockHeadGetDto> list = await _service.QueryAsync();


            if (entity.Entity != null && entity.Entity.Count() > 0)
            {
                foreach (var item in entity.Entity)
                {
                    var customer = await _customerService.QueryByIdAsync(item.CustomId);

                    var warehouse = await _warehouseService.QueryByIdAsync(item.WarehouseId);

                    var owner = await _ownerService.QueryByIdAsync(item.OwnerId);

                    var receivetype = await _receivetypeService.QueryByIdAsync(item.SrTypeId);

                    //item.WarehouseCode = warehouse == null ? "" : warehouse.EnCode;
                    //item.WarehouseName = warehouse == null ? "" : warehouse.FullName;
                    //item.CustomerCode = customer == null ? "" : customer.EnCode;
                    //item.CustomerName = customer == null ? "" : customer.FullName;
                    //item.OwnnerCode = owner == null ? "" : owner.EnCode;
                    //item.OwnnerName = owner == null ? "" : owner.FullName;
                    //item.StrTypeCode = receivetype == null ? "" : receivetype.EnCode;
                    //item.StrTypeName = receivetype == null ? "" : receivetype.FullName;
                }
            }

            //设置返回格式
            ReturnEntity RtEntity = new ReturnEntity();

            RtEntity.rows    = entity.Entity;
            RtEntity.page    = page;
            RtEntity.records = entity.Total;
            int Count = entity.Total / rows; //获取除数
            int yu    = entity.Total % rows; //获取余数

            if (yu > 0)                      //如果余数大于0则加一页,否则不加
            {
                RtEntity.total = Count + 1;
            }
            else
            {
                RtEntity.total = Count + 0;
            }
            return(Ok(Extensions.ToJson(RtEntity)));
        }