Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 3
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;
            }
        }