예제 #1
0
    public void Initialize(InventoryDTO dto, DeleteType deleteType)
    {
        this.dto    = dto;
        _deleteType = deleteType;

        ItemCfg   item    = ConfigManager.instance.GetItemCfg(dto.itemid);
        Transform content = _transform.Find("EquipInfo/Viewport/Content");
        Text      name    = content.Find("Text").GetComponent <Text>();

        name.text = item.Name;
        Button Btnclose = _transform.Find("BtnClose").GetComponent <Button>();

        Btnclose.onClick.AddListener(OnClickClose);

        Button Btndelete = _transform.Find("BtnDelete").GetComponent <Button>();

        Btndelete.onClick.AddListener(OnClickDelete);

        Button BtnUnload = _transform.Find("BtnUnload").GetComponent <Button>();

        BtnUnload.onClick.AddListener(OnClickUnload);
        BtnUnload.gameObject.SetActive(deleteType == DeleteType.Equip);

        Button BtnEquip = _transform.Find("BtnEquip").GetComponent <Button>();

        BtnEquip.onClick.AddListener(OnClickEquip);
        BtnEquip.gameObject.SetActive(deleteType != DeleteType.Equip);
    }
예제 #2
0
 public void GetResult(string itemName)
 {
     InventoryList.Clear();
     Task.Factory.StartNew(() =>
     {
         return(InventoryService.FindItemByName(itemName));
     }).ContinueWith(task =>
     {
         foreach (Inventory result in task.Result)
         {
             var quantityOnEbay     = InventoryService.FindEBayListingQuantity(result.ItemId);
             bool potentialOversold = false;
             if ((result.ExternalQuantity == 0 && result.AmazonQuantity > 0) || (result.ExternalQuantity == 0 && quantityOnEbay > 0))
             {
                 potentialOversold = true;
             }
             var resultDTO = new InventoryDTO
             {
                 ItemID            = result.ItemId,
                 SKU               = result.Sku,
                 Title             = result.Title,
                 Quantity          = result.ExternalQuantity,
                 Price             = result.FixedPrice,
                 QuantityOnEbay    = quantityOnEbay,
                 QuantityOnAmazon  = result.AmazonQuantity,
                 PotentialOversold = potentialOversold
             };
             InventoryList.Add(resultDTO);
         }
     },
                     System.Threading.CancellationToken.None,
                     TaskContinuationOptions.None,
                     TaskScheduler.FromCurrentSynchronizationContext());
 }
예제 #3
0
        /// <summary>
        /// Saves a new Inventory or updates an already existing Inventory.
        /// </summary>
        /// <param name="Inventory">Inventory to be saved or updated.</param>
        /// <param name="InventoryId">InventoryId of the Inventory creating or updating</param>
        /// <returns>InventoryId</returns>
        public long SaveInventory(InventoryDTO inventoryDTO, string userId)
        {
            long inventoryId = 0;

            if (inventoryDTO.InventoryId == 0)
            {
                var inventory = new Inventory()
                {
                    ItemName             = inventoryDTO.ItemName,
                    Description          = inventoryDTO.Description,
                    Price                = inventoryDTO.Price,
                    Quantity             = inventoryDTO.Quantity,
                    InventoryCategoryId  = inventoryDTO.InventoryCategoryId,
                    StoreId              = inventoryDTO.StoreId,
                    BranchId             = inventoryDTO.BranchId,
                    PurchaseDate         = inventoryDTO.PurchaseDate,
                    SectorId             = inventoryDTO.SectorId,
                    Amount               = inventoryDTO.Amount,
                    TransactionSubTypeId = inventoryDTO.TransactionSubTypeId,
                    CreatedOn            = DateTime.Now,
                    TimeStamp            = DateTime.Now,
                    CreatedBy            = userId,
                    Deleted              = false,
                };

                this.UnitOfWork.Get <Inventory>().AddNew(inventory);
                this.UnitOfWork.SaveChanges();
                inventoryId = inventory.InventoryId;
                return(inventoryId);
            }

            else
            {
                var result = this.UnitOfWork.Get <Inventory>().AsQueryable()
                             .FirstOrDefault(e => e.InventoryId == inventoryDTO.InventoryId);
                if (result != null)
                {
                    result.Description          = inventoryDTO.Description;
                    result.SectorId             = inventoryDTO.SectorId;
                    result.Price                = inventoryDTO.Price;
                    result.Quantity             = inventoryDTO.Quantity;
                    result.InventoryCategoryId  = inventoryDTO.InventoryCategoryId;
                    result.StoreId              = inventoryDTO.StoreId;
                    result.PurchaseDate         = inventoryDTO.PurchaseDate;
                    result.ItemName             = inventoryDTO.ItemName;
                    result.TransactionSubTypeId = inventoryDTO.TransactionSubTypeId;
                    result.BranchId             = inventoryDTO.BranchId;
                    result.Amount               = inventoryDTO.Amount;
                    result.UpdatedBy            = userId;
                    result.TimeStamp            = DateTime.Now;
                    result.Deleted              = inventoryDTO.Deleted;
                    result.DeletedBy            = inventoryDTO.DeletedBy;
                    result.DeletedOn            = inventoryDTO.DeletedOn;

                    this.UnitOfWork.Get <Inventory>().Update(result);
                    this.UnitOfWork.SaveChanges();
                }
                return(inventoryDTO.InventoryId);
            }
        }
예제 #4
0
        private InventoryDTO InsertOrUpdate(OpenNosContext context, InventoryDTO inventory)
        {
            long      InventoryId = inventory.InventoryId;
            byte      Type        = inventory.Type;
            short     Slot        = inventory.Slot;
            long      CharacterId = inventory.CharacterId;
            Inventory entity      = context.Inventory.FirstOrDefault(c => c.InventoryId == InventoryId);

            if (entity == null) //new entity
            {
                Inventory delete = context.Inventory.FirstOrDefault(s => s.CharacterId == CharacterId && s.Slot == Slot && s.Type == Type);
                if (delete != null)
                {
                    ItemInstance deleteItem = context.ItemInstance.FirstOrDefault(s => s.Inventory.InventoryId == delete.InventoryId);
                    context.ItemInstance.Remove(deleteItem);
                    context.Inventory.Remove(delete);
                    context.SaveChanges();
                }
                inventory = Insert(inventory, context);
            }
            else //existing entity
            {
                entity.ItemInstance = context.ItemInstance.FirstOrDefault(c => c.Inventory.InventoryId == entity.InventoryId);
                inventory           = Update(entity, inventory, context);
            }

            return(inventory);
        }
예제 #5
0
        public static string Edit(InventoryDTO inventory)
        {
            using (WarehouseSystemContext db = new WarehouseSystemContext())
            {
                string error = null;

                var toModify = db.Inventory.Where(x => x.Id == inventory.Id).FirstOrDefault();

                toModify.Id            = inventory.Id;
                toModify.ItemFrom      = inventory.ItemFrom;
                toModify.ItemTo        = inventory.ItemTo;
                toModify.DateOfArrival = inventory.DateOfArrival;
                toModify.DateToSend    = inventory.DateToSend;
                toModify.Weight        = inventory.Weight;
                toModify.Status        = inventory.Status;
                toModify.Description   = inventory.Description;

                var context = new ValidationContext(toModify, null, null);
                var result  = new List <ValidationResult>();
                Validator.TryValidateObject(toModify, context, result, true);

                foreach (var x in result)
                {
                    error = error + x.ErrorMessage + "\n";
                }

                if (error == null)
                {
                    db.SaveChanges();
                }
                return(error);
            }
        }
예제 #6
0
        public SaveResult InsertOrUpdate(ref InventoryDTO inventory)
        {
            try
            {
                using (var context = DataAccessHelper.CreateContext())
                {
                    long inventoryId = inventory.InventoryId;

                    Inventory entity = context.inventory.SingleOrDefault(c => c.InventoryId.Equals(inventoryId));

                    if (entity == null) //new entity
                    {
                        inventory = Insert(inventory, context);
                        return(SaveResult.Inserted);
                    }
                    else //existing entity
                    {
                        inventory = Update(entity, inventory, context);
                        return(SaveResult.Updated);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log.ErrorFormat(Language.Instance.GetMessageFromKey("UPDATE_ACCOUNT_ERROR"), inventory.InventoryId, e.Message);
                return(SaveResult.Error);
            }
        }
예제 #7
0
        public void AddNewInventory(InventoryDTO inventoryDto, List <ScanItemDTO> items)
        {
            var inventory = new Core.EntitiesInventory.Inventory
            {
                Description   = inventoryDto.Description,
                InventoryDate = inventoryDto.InventoryDate
            };

            unitOfWork.GetSet <Core.EntitiesInventory.Inventory>().Add(inventory);
            unitOfWork.Commit();
            foreach (var dto in items)
            {
                var item = unitOfWork.GetSet <Item>().FirstOrDefault(i => i.Barcode == dto.Barcode);
                if (item == null)
                {
                    item = new Item
                    {
                        Barcode = dto.Barcode
                    };
                    unitOfWork.GetSet <Item>().Add(item);
                    unitOfWork.Commit();
                }
                Add(new ItemInventoryMapping
                {
                    ItemId      = item.Id,
                    InventoryId = inventory.Id,
                    Quantity    = dto.Quantity
                });
            }
            unitOfWork.Commit();
        }
예제 #8
0
        //Clasificacion de animales por inicio de primer caracter con "b"
        public InventoryDTO classify(List <string> animals)
        {
            try
            {
                var Bovinos = new List <string>();
                var Equinos = new List <string>();

                //Recorremos los animales del inventario
                foreach (var animal in animals)
                {
                    //Validamos si empiezan por "b" son bovinos
                    if (animal.StartsWith("b"))
                    {
                        Bovinos.Add(animal);
                    }
                    else
                    {
                        Equinos.Add(animal);
                    }
                }

                //Armamos el inventario distribuido
                var inventory = new InventoryDTO();
                inventory.Bovinos = Bovinos;
                inventory.Equinos = Equinos;

                return(inventory);
            }
            catch (System.Exception ex)
            {
                throw new InventoryException("Error clasificando el inventario " + ex.Message);
            }
        }
        public void Delete(InventoryDTO ret)
        {
            IWindowManager manager = new WindowManager();

            InventoryService.Delete(ret);
            Reload();
        }
        public async Task CanAddItemToInventory()
        {
            var repo = BuildRepo();

            await repo.AddItemToInventory(1, 3);

            CharacterDTO character = await repo.GetCharacter(1);

            InventoryDTO expected = new InventoryDTO()
            {
                CharacterId = 1,
                ItemId      = 3,
                Item        = new ItemDTO
                {
                    Id    = 3,
                    Name  = "Dungeon Key",
                    Value = "100 cp"
                }
            };
            bool found = false;

            foreach (var item in character.Inventory)
            {
                if (item.ItemId == expected.ItemId)
                {
                    Assert.Equal(expected.CharacterId, item.CharacterId);
                    Assert.Equal(expected.Item.Name, item.Item.Name);
                    found = true;
                }
            }
            Assert.True(found);
        }
예제 #11
0
 protected void imgbtnEdit_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         ModalPopupExtender1.Show();
         ImageButton imb = (ImageButton)sender;
         if (imb != null)
         {
             int objID = ToInt32(imb.CommandArgument);
             List <InventoryDTO> lst = new List <InventoryDTO>();
             InventoryDTO        obj = new InventoryDTO();
             if (Session["OutboundDetail"] != null)
             {
                 lst = (List <InventoryDTO>)Session["OutboundDetail"];
                 if (lst != null && lst.Count > 0)
                 {
                     obj = lst.FirstOrDefault(w => w.TempID.Equals(objID));
                     if (obj != null)
                     {
                         hddDetailID.Value = obj.TempID.ToString();
                         hddItemID.Value   = obj.ItemID.ToString();
                         txtMItem.Text     = obj.ItemName;
                         txtMItemCode.Text = obj.ItemCode;
                         txtMAmount.Text   = obj.AmountStr;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #12
0
        public async Task <Result <int> > Add(InventoryDTO inventory)
        {
            try
            {
                if (inventory.Id > 0)
                {
                    return(Result.Fail <int>("Inventory id should be zero while adding"));
                }
                var validate = ValidateInventory(inventory);
                if (!validate.Value)
                {
                    return(Result.Fail <int>(validate.GetErrorString()));
                }
                var inv    = inventory.GetInventory();
                var result = await _repository.Add(inv.BaseMap());

                if (result.Id > 0)
                {
                    return(Result.Ok(result.Id));
                }
                else
                {
                    return(Result.Fail <int>("Failed to add inventory"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(Result.Fail <int>("Failed to add inventory"));
            }
        }
예제 #13
0
 public void Add()
 {
     if (IsEdit == true)
     {
         toEdit.ItemFrom      = ItemFrom;
         toEdit.ItemTo        = ItemTo;
         toEdit.DateOfArrival = DateOfArrival;
         toEdit.DateToSend    = DateToSend;
         toEdit.Weight        = Weight;
         toEdit.Status        = Status;
         toEdit.Description   = Description;
         InventoryService.Edit(toEdit);
     }
     else
     {
         var newInventory = new InventoryDTO();
         newInventory.ItemFrom      = ItemFrom;
         newInventory.ItemTo        = ItemTo;
         newInventory.DateOfArrival = DateOfArrival;
         newInventory.DateToSend    = DateToSend;
         newInventory.Weight        = Weight;
         newInventory.Status        = Status;
         newInventory.Description   = Description;
         InventoryService.Add(newInventory);
     }
     Close();
 }
예제 #14
0
        public static string Add(InventoryDTO inventory)
        {
            using (WarehouseSystemContext db = new WarehouseSystemContext())
            {
                string    error        = null;
                Inventory newInventory = new Inventory();
                newInventory.Id            = inventory.Id;
                newInventory.ItemFrom      = inventory.ItemFrom;
                newInventory.ItemTo        = inventory.ItemTo;
                newInventory.DateOfArrival = inventory.DateOfArrival;
                newInventory.DateToSend    = inventory.DateToSend;
                newInventory.Weight        = inventory.Weight;
                newInventory.Status        = inventory.Status;
                newInventory.Description   = inventory.Description;

                var context = new ValidationContext(newInventory, null, null);
                var result  = new List <ValidationResult>();
                Validator.TryValidateObject(newInventory, context, result, true);

                foreach (var x in result)
                {
                    error = error + x.ErrorMessage + "\n";
                }

                if (error == null)
                {
                    db.Inventory.Add(newInventory);
                    db.SaveChanges();
                }
                return(error);
            }
        }
예제 #15
0
        public List <InventoryDTO> GetItemInStock()
        {
            List <InventoryDTO> lst = new List <InventoryDTO>();

            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                //DataSet ds = conn.GetDataSet("GetSearchItemInStock", param);
                DataSet ds = conn.GetDataSet("GetSearchItem", param);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    InventoryDTO o = new InventoryDTO();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        o = new InventoryDTO();
                        //o.StockID = Convert.ToInt32(dr["StockID"].ToString());
                        o.ItemID   = Convert.ToInt32(dr["ItemID"].ToString());
                        o.ItemCode = dr["ItemCode"].ToString();
                        o.ItemName = dr["ItemName"].ToString();
                        o.ItemDesc = dr["ItemDesc"].ToString();
                        //o.Serial = dr["Serial"].ToString();
                        o.ItemPrice = Convert.ToDouble(dr["ItemPrice"].ToString());
                        o.UnitName  = dr["UnitName"].ToString();
                        lst.Add(o);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(lst);
        }
예제 #16
0
        public void OnGetInventory(object sender, MessageReceivedEventArgs e)
        {
            using (Message message = e.GetMessage() as Message)
            {
                GetInventoryClientDTO data = message.GetReader().ReadSerializable <GetInventoryClientDTO>();

                using (DarkRiftWriter responseWriter = DarkRiftWriter.Create())
                {
                    InventoryDTO invData = null;/*db.Inventories
                                                 * .Where((x) => x.Id == data.InventoryID)
                                                 * .FirstOrDefault();*/
                    if (invData != null)
                    {
                        InventoryItemDTO[] inventoryItems = null; /* db.InventoryItems
                                                                   * .Where((x) => x._inventoryid == data.InventoryID)
                                                                   * .ToArray();*/

                        GetInventoryServerDTO response = new GetInventoryServerDTO();
                        response.InventoryID    = invData.Id;
                        response.Size           = invData.Size;
                        response.InventoryItems = inventoryItems;

                        responseWriter.Write(response);
                        using (Message responseMessage = Message.Create(Tags.GetInventory, responseWriter))
                            e.Client.SendMessage(responseMessage, SendMode.Reliable);
                    }

                    return; //terminate
                }
            }
        }
예제 #17
0
 public Inventory(InventoryDTO inventory)
 {
     this.CharacterId  = inventory.CharacterId;
     this.Slot         = inventory.Slot;
     this.Type         = inventory.Type;
     this.ItemInstance = inventory.ItemInstance;
     this.InventoryId  = inventory.InventoryId;
 }
예제 #18
0
        private InventoryDTO Insert(InventoryDTO inventory, OpenNosContainer context)
        {
            Inventory entity = Mapper.Map <Inventory>(inventory);

            context.inventory.Add(entity);
            context.SaveChanges();
            return(Mapper.Map <InventoryDTO>(entity));
        }
예제 #19
0
        public AddMaterialRequest()
        {
            Inventory = new InventoryDTO();

            Material = new MaterialDTO();

            ServiceCode = new ServiceCodeDTO();
        }
예제 #20
0
        public AddFoliageRequest()
        {
            Inventory = new InventoryDTO();

            Foliage = new FoliageDTO();

            ServiceCode = new ServiceCodeDTO();
        }
예제 #21
0
        public AddPlantRequest()
        {
            Inventory = new InventoryDTO();

            Plant = new PlantDTO();

            ServiceCode = new ServiceCodeDTO();
        }
예제 #22
0
        public AddContainerRequest()
        {
            Inventory = new InventoryDTO();

            Container = new ContainerDTO();

            ServiceCode = new ServiceCodeDTO();
        }
        public void LoadModifyInventoryPage(InventoryDTO ret)
        {
            IWindowManager        manager = new WindowManager();
            AddInventoryViewModel modify  = new AddInventoryViewModel(ret);

            manager.ShowDialog(modify, null, null);
            Reload();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!check())
            {
                return;
            }
            bool         result = false;
            InventoryDTO inv    = new InventoryDTO {
                BookID      = txtBookID.Text,
                Index       = txtIndex.Text,
                InventoryID = txtInventoryID.Text,
                Status      = 0
            };

            if (inv.InventoryID == String.Empty)
            {
                MessageBox.Show(this, "The New Inventory is added fail. InventoryID Can't empty!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (AddOrEdit == 0)
            {
                if (cbStatus.Checked)
                {
                    inv.Status = 1;
                }
                result = bus.AddNewInventory(inv);
                if (result)
                {
                    MessageBox.Show(this, "The New Inventory is added successful", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dr = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this, "The New Inventory is added fail. InventoryID is existed!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (cbStatus.Checked)
                {
                    inv.Status = 1;
                }
                result = bus.UpdateInventory(inv, inv.Status);
                if (result)
                {
                    MessageBox.Show(this, "The Inventory is updated successful.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dr = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this, "The Inventory is updated fail. Please try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #25
0
        private InventoryDTO Update(Inventory entity, InventoryDTO inventory, OpenNosContext context)
        {
            if (entity != null)
            {
                _mapper.Map(inventory, entity);
                context.SaveChanges();
            }

            return(_mapper.Map <InventoryDTO>(entity));
        }
예제 #26
0
        public static void Delete(InventoryDTO inventory)
        {
            using (WarehouseSystemContext db = new WarehouseSystemContext())
            {
                var toDelete = db.Inventory.Where(x => x.Id == inventory.Id).FirstOrDefault();
                toDelete.IsDisabled = true;

                db.SaveChanges();
            }
        }
예제 #27
0
    public static InventoryDTO GetInvDTO(InventoryData d)
    {
        InventoryDTO dto = new InventoryDTO();

        dto.slot   = d.slot;
        dto.itemid = d.itemid;
        dto.num    = d.num;

        return(dto);
    }
        public async Task <IActionResult> Update(InventoryDTO inventory)
        {
            var result = await _inventoryService.Update(inventory);

            if (!result.IsSucceeded)
            {
                return(BadRequest(result.GetErrorString()));
            }
            return(Ok(result.Value));
        }
예제 #29
0
        public static bool Update(InventoryDTO ac)
        {
            string query = "EXEC UPDATEINVENTORY @ID , @NAME , @NOTE , @PRICEBASE ";

            if (DataProvider.Instance.ExcuteNonQuery(query, new object[] { ac.ID, ac.Name, ac.Note, ac.PriceBase }) == 1)
            {
                return(true);
            }

            return(false);
        }
예제 #30
0
 /// <summary>
 /// Update record
 /// </summary>
 /// <param name="inventoryDTO"></param>
 /// <returns></returns>
 public bool Patch(InventoryDTO inventoryDTO)
 {
     try
     {
         return(inventoryRepository.Update(inventoryDTO.Id, inventoryDTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #31
0
 public Inventory Map(InventoryDTO dto)
 {
     if (dto == null) return null;
     var inventory = Mapper.Map<InventoryDTO, Inventory>(dto);
     inventory.Warehouse = (Warehouse) _costCentreRepository.GetById(dto.WarehouseMasterID);
     inventory.Product = _productRepository.GetById(dto.ProductMasterID);
     return inventory;
 }