Beispiel #1
0
        public async Task <IHttpActionResult> AddFnishedProductRoom(FnishedProductRoomIntDto fnishedProductRoomInt)
        {
            try
            {
                FnishedProductRoom fnishedProductRoom = new FnishedProductRoom
                {
                    Id = IdentityManager.NewId(),
                    FnishedProductId  = fnishedProductRoomInt.FnishedProductId,
                    User_id           = fnishedProductRoomInt.User_id,
                    EntrepotId        = fnishedProductRoomInt.EntrepotId,
                    RawNumber         = fnishedProductRoomInt.RawNumber == null?0: fnishedProductRoomInt.RawNumber,
                    RawOutNumber      = fnishedProductRoomInt.RawOutNumber == null ? 0 : fnishedProductRoomInt.RawNumber,
                    Warning_RawNumber = fnishedProductRoomInt.Warning_RawNumber == null ? 0 : fnishedProductRoomInt.RawNumber,
                    RoomDes           = fnishedProductRoomInt.RoomDes,
                };
                db.FnishedProductRooms.Add(fnishedProductRoom);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "添加成功" }));
                }

                return(Json(new { code = 201, msg = "添加失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
 public async Task <IHttpActionResult> RemoveFnishedProductRoom(FnishedProductRoomIntDto fnishedProductRoomInt)
 {
     try
     {
         if (fnishedProductRoomInt.del_Id != null)
         {
             foreach (var item in fnishedProductRoomInt.del_Id)
             {
                 var result = new FnishedProductRoom {
                     Id = item
                 };
                 //  var result = Task.Run(() => (db.Z_Office.AsNoTracking().FirstOrDefault(m => m.Id == item)));
                 db.Entry(result).State = System.Data.Entity.EntityState.Deleted;
             }
             if (await db.SaveChangesAsync() > 0)
             {
                 return(Json(new { code = 200, msg = "删除成功" }));
             }
             else
             {
                 return(Json(new { code = 400, msg = "删除失败" }));
             }
         }
         else
         {
             return(Json(new { code = 201, msg = "请勿传递空数据" }));
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <IHttpActionResult> AddFnishedProduct(Z_FnishedProductDto z_FnishedProductDto)
        {
            try
            {
                var userId = ((UserIdentity)User.Identity).UserId;
                Z_FnishedProduct z_FnishedProduct = new Z_FnishedProduct
                {
                    Id                     = IdentityManager.NewId(),
                    Name                   = z_FnishedProductDto.Name,
                    Encoding               = z_FnishedProductDto.Encoding,
                    EntryPersonId          = z_FnishedProductDto.EntryPersonId,
                    CompanyId              = z_FnishedProductDto.Companyid,
                    Desc                   = z_FnishedProductDto.Desc,
                    Z_FinshedProductTypeid = z_FnishedProductDto.Z_FinshedProductTypeid,
                    Finshed_Sign           = z_FnishedProductDto.Finshed_Sign,
                    EnglishName            = z_FnishedProductDto.EnglishName,
                    Abbreviation           = z_FnishedProductDto.Abbreviation,
                    BeCommonlyCalled1      = z_FnishedProductDto.BeCommonlyCalled1,
                    BeCommonlyCalled2      = z_FnishedProductDto.BeCommonlyCalled2,
                    CASNumber              = z_FnishedProductDto.CASNumber,
                    MolecularWeight        = z_FnishedProductDto.MolecularWeight,
                    MolecularFormula       = z_FnishedProductDto.MolecularFormula,
                    StructuralFormula      = z_FnishedProductDto.StructuralFormula,
                    Density                = z_FnishedProductDto.Density,
                    Statement              = z_FnishedProductDto.Statement,
                    Number                 = z_FnishedProductDto.Number,
                    Caution                = z_FnishedProductDto.Caution,
                    AppearanceState        = z_FnishedProductDto.AppearanceState,
                    WarehousingTypeId      = z_FnishedProductDto.WarehousingTypeId,
                };
                var result = await Task.Run(() => db.Entrepots.AsNoTracking().FirstOrDefaultAsync(p => p.Id > 0));

                FnishedProductRoom fnishedProductRoom = new FnishedProductRoom
                {
                    Id = IdentityManager.NewId(),
                    FnishedProductId = z_FnishedProduct.Id,
                    User_id          = userId,
                    RawNumber        = 0,
                    EntrepotId       = result.Id
                };
                db.FnishedProductRooms.Add(fnishedProductRoom);
                db.Z_FnishedProduct.Add(z_FnishedProduct);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "添加成功" }));
                }
                else
                {
                    return(Json(new { code = 400, msg = "添加失败" }));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #4
0
        public async Task <IHttpActionResult> EditFnishedProductRoom(FnishedProductRoomIntDto fnishedProductRoomInt)
        {
            try
            {
                var FnishedProductRoom = new FnishedProductRoom {
                    Id = fnishedProductRoomInt.Id
                };
                db.Entry(FnishedProductRoom).State = System.Data.Entity.EntityState.Unchanged;
                if (fnishedProductRoomInt.FnishedProductId != null)
                {
                    FnishedProductRoom.FnishedProductId = fnishedProductRoomInt.FnishedProductId;
                }
                if (fnishedProductRoomInt.User_id != null)
                {
                    FnishedProductRoom.User_id = fnishedProductRoomInt.User_id;
                }
                if (fnishedProductRoomInt.EntrepotId != null)
                {
                    FnishedProductRoom.EntrepotId = fnishedProductRoomInt.EntrepotId;
                }
                if (fnishedProductRoomInt.RawNumber != null)
                {
                    FnishedProductRoom.RawNumber = fnishedProductRoomInt.RawNumber;
                }
                if (fnishedProductRoomInt.RawOutNumber != null)
                {
                    FnishedProductRoom.RawOutNumber = fnishedProductRoomInt.RawOutNumber;
                }
                if (fnishedProductRoomInt.Warning_RawNumber != null)
                {
                    FnishedProductRoom.Warning_RawNumber = fnishedProductRoomInt.Warning_RawNumber;
                }

                if (!string.IsNullOrWhiteSpace(fnishedProductRoomInt.RoomDes))
                {
                    FnishedProductRoom.RoomDes = fnishedProductRoomInt.RoomDes;
                }

                if (await db.SaveChangesAsync() > 0)
                {
                    return(Json(new { code = 200, msg = "修改成功" }));
                }

                return(Json(new { code = 201, msg = "修改失败" }));
            }
            catch (Exception)
            {
                throw;
            }
        }