public bool SaveItemType(ItemTypeDTO itemTypeDTO, long userId, long orgId)
        {
            ItemType itemType = new ItemType();

            if (itemTypeDTO.ItemId == 0)
            {
                itemType.ItemName       = itemTypeDTO.ItemName;
                itemType.Remarks        = itemTypeDTO.Remarks;
                itemType.IsActive       = itemTypeDTO.IsActive;
                itemType.EUserId        = userId;
                itemType.EntryDate      = DateTime.Now;
                itemType.OrganizationId = orgId;
                itemType.WarehouseId    = itemTypeDTO.WarehouseId;
                itemTypeRepository.Insert(itemType);
            }
            else
            {
                itemType                = GetItemTypeOneByOrgId(itemTypeDTO.ItemId, itemTypeDTO.WarehouseId, orgId);
                itemType.ItemName       = itemTypeDTO.ItemName;
                itemType.Remarks        = itemTypeDTO.Remarks;
                itemType.IsActive       = itemTypeDTO.IsActive;
                itemType.UpUserId       = itemTypeDTO.UpUserId;
                itemType.UpdateDate     = DateTime.Now;
                itemType.OrganizationId = orgId;
                itemTypeRepository.Update(itemType);
            }
            return(itemTypeRepository.Save());
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateItemType(int id, ItemTypeDTO objItemTypeDTO)
        {
            if (id != objItemTypeDTO.Id)
            {
                return(BadRequest());
            }

            var objItemType = await _context.MItemType.FindAsync(id);

            if (objItemType == null)
            {
                return(NotFound());
            }

            objItemType.It_Description = objItemTypeDTO.Description;
            objItemType.it_UserId      = objItemTypeDTO.UserId;
            objItemType.it_BranchId    = objItemTypeDTO.BranchId;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!ItemExists(id))
            {
                return(NotFound());
            }
            return(CreatedAtAction(
                       nameof(GetItemType),
                       new { id = objItemType.it_Id },
                       ItemTypeAssignDTO(objItemType)));
            //return NoContent();
        }
Beispiel #3
0
        private void SetItemTypeObject(ItemTypeDTO pObjItemType)
        {
            LoadComboBoxes();

            mLonId = pObjItemType.Id;
            //chkPrice.IsChecked = pObjItemType.PerPrice;
            cbSellType.SelectValue(pObjItemType.SellTypeid);
            txtCode.Text = pObjItemType.Code;
            txtName.Text = pObjItemType.Name;
            cbLevel.SelectValue(pObjItemType.Level);
            cbGender.SelectValue(pObjItemType.GenderId);

            switch (pObjItemType.Level)
            {
            case 2:
                cbCategory.SelectValue((int)pObjItemType.CategoryId);
                cbCategory.IsEnabled = true;
                break;

            case 3:
                cbCategory.SelectValue((int)pObjItemType.CategoryId);
                cbCategory.IsEnabled = true;
                cbParentSubCategory.SelectValue((int)pObjItemType.SubCategoryId);
                cbParentSubCategory.IsEnabled = true;
                break;
            }
        }
Beispiel #4
0
 public ItemTypeBM(ItemTypeDTO itemTypeDto)
 {
     this.id         = itemTypeDto.id;
     this.name       = itemTypeDto.name;
     this.category   = itemTypeDto.category;
     this.comment    = itemTypeDto.comment;
     this.perishable = itemTypeDto.perishable;
 }
Beispiel #5
0
 private void SetItemTypeObject(ItemTypeDTO pObjItemType)
 {
     if (pObjItemType != null)
     {
         mObjItemType     = pObjItemType;
         txtItemType.Text = pObjItemType.Code;
         tbItemType.Text  = pObjItemType.Name;
         txtItemType.Focus();
     }
 }
Beispiel #6
0
        private ItemTypeDTO Resolve(List <String> item)
        {
            ItemTypeDTO result = new ItemTypeDTO();

            result.id         = int.Parse(item[0]);
            result.name       = item[1];
            result.category   = item[2];
            result.comment    = item[3];
            result.perishable = bool.Parse(item[4]);
            return(result);
        }
Beispiel #7
0
        private void ReturnItem()
        {
            Window lObjWindowParent = Window.GetWindow(this);

            lObjWindowParent.Close();
            WindowDialog lObjWindowDialog = lObjWindowParent as WindowDialog;

            ItemTypeDTO lobjItem = dgItemType.SelectedItem as ItemTypeDTO;

            lObjWindowDialog.gObject = lobjItem as object;
        }
Beispiel #8
0
        public bool UpdateItemType(ItemTypeDTO itemTypeDto)
        {
            DBSql  dbsql = new DBSql();
            String sql;

            sql  = "UPDATE item_type SET ";
            sql += "name = '" + itemTypeDto.name + "',  ";
            sql += "category = '" + itemTypeDto.category + "', ";
            sql += "comment = '" + itemTypeDto.comment + "',  ";
            sql += "perishable = '" + itemTypeDto.perishable + "' ";
            sql += "WHERE id = " + itemTypeDto.id;
            dbsql.ExecuteNonQuery(sql);
            return(true);
        }
Beispiel #9
0
        public bool SaveItemType(ItemTypeDTO itemTypeDto)
        {
            DBSql  dbsql = new DBSql();
            String sql;

            sql            = "INSERT INTO item_type (name, category, comment, perishable) VALUES (";
            sql           += "'" + itemTypeDto.name + "', ";
            sql           += "'" + itemTypeDto.category + "', ";
            sql           += "'" + itemTypeDto.comment + "', ";
            sql           += "'" + itemTypeDto.perishable + "'";
            sql           += ");SELECT @@IDENTITY";
            itemTypeDto.id = dbsql.ExecuteNonQuery(sql);
            return(true);
        }
Beispiel #10
0
        public static ItemType ConvertToItemType(ItemTypeDTO item)
        {
            ItemType ItemType = new ItemType();

            ItemType.ItemTypeID  = item.id;
            ItemType.Categoria   = item.categoria;
            ItemType.Marca       = item.marca;
            ItemType.Modello     = item.modello;
            ItemType.Descrizione = item.descrizione;
            if (item.customer != null)
            {
                ItemType.Customer = CustomerConverter.convertToCustomer(item.customer);
            }
            return(ItemType);
        }
Beispiel #11
0
        public static ItemTypeDTO ConverToDTO(ItemType item)
        {
            ItemTypeDTO ItemType = new ItemTypeDTO();

            ItemType.id          = item.ItemTypeID;
            ItemType.categoria   = item.Categoria;
            ItemType.marca       = item.Marca;
            ItemType.modello     = item.Modello;
            ItemType.descrizione = item.Descrizione;
            if (item.Customer != null)
            {
                ItemType.customer = CustomerConverter.convertToDto(item.Customer);
            }
            return(ItemType);
        }
Beispiel #12
0
        public async Task <ActionResult <ItemType> > CreateItemType(ItemTypeDTO objItemTypeDTO)
        {
            var objItemType = new ItemType
            {
                It_Description = objItemTypeDTO.Description,
                it_UserId      = objItemTypeDTO.UserId,
                it_BranchId    = objItemTypeDTO.BranchId
            };

            _context.MItemType.Add(objItemType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(
                       nameof(GetItemType),
                       new { id = objItemType.it_Id },
                       ItemTypeAssignDTO(objItemType)));
        }
Beispiel #13
0
        /// <summary>
        /// Carga los datos al dar doble clic en en el DataGrid.
        /// </summary>
        private void dgAuctionType_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (mBolReadOnly)
            {
                ReturnItem();
            }
            else
            {
                ItemTypeDTO lObjItemType = dgItemType.SelectedItem as ItemTypeDTO;
                lblMessage.Visibility = Visibility.Collapsed;
                btnSave.Content       = "Modificar";
                lbltitle.Content      = "Modificar registro";
                btnNew.Visibility     = Visibility.Visible;
                btnDelete.Visibility  = Visibility.Visible;

                SetItemTypeObject(lObjItemType);
            }
        }
        public ActionResult SaveItemType(ItemTypeViewModel itemTypeViewModel)
        {
            bool isSuccess = false;

            if (ModelState.IsValid)
            {
                try
                {
                    ItemTypeDTO dto = new ItemTypeDTO();
                    AutoMapper.Mapper.Map(itemTypeViewModel, dto);
                    isSuccess = _itemTypeBusiness.SaveItemType(dto, UserId, OrgId);
                }
                catch (Exception ex)
                {
                    isSuccess = false;
                }
            }
            return(Json(isSuccess));
        }
Beispiel #15
0
        public ResultBM GetItemType(int itemTypeId)
        {
            try
            {
                ItemTypeDAL itemTypeDal = new ItemTypeDAL();
                ItemTypeBM  itemTypeBm  = null;
                ItemTypeDTO itemTypeDto = itemTypeDal.GetItemType(itemTypeId);

                if (itemTypeDto != null)
                {
                    itemTypeBm = new ItemTypeBM(itemTypeDto);
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", itemTypeBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }
Beispiel #16
0
        private ItemTypeDTO ShowItemTypeDialog(object pObjSender, KeyEventArgs pObjEventsArgs)
        {
            ItemTypeDTO lObjItemType = null;

            if (pObjEventsArgs.Key == Key.Enter & ((pObjSender as TextBox).AcceptsReturn == false) && (pObjSender as TextBox).Focus())
            {
                List <ItemTypeDTO> lLstItemType = SearchItemType((pObjSender as TextBox).Text);
                if (lLstItemType.Count == 1)
                {
                    lObjItemType = lLstItemType[0];
                }
                else
                {
                    (pObjSender as TextBox).Focusable = false;
                    UserControl lUCItemType = new UCItemTypes(true, lLstItemType, (pObjSender as TextBox).Text);
                    lObjItemType = FunctionsUI.ShowWindowDialog(lUCItemType, Window.GetWindow(this)) as ItemTypeDTO;
                    (pObjSender as TextBox).Focusable = true;
                }
            }

            return(lObjItemType);
        }
Beispiel #17
0
        public ResultBM UpdateItemType(ItemTypeBM itemTypeBm)
        {
            try
            {
                ItemTypeDAL itemTypeDal = new ItemTypeDAL();
                ItemTypeDTO itemTypeDto = null;

                ResultBM validationResult = IsValid(itemTypeBm);
                if (!validationResult.IsValid())
                {
                    return(validationResult);
                }

                itemTypeDto = new ItemTypeDTO(itemTypeBm.id, itemTypeBm.Name, itemTypeBm.category, itemTypeBm.Comment, itemTypeBm.Perishable);
                itemTypeDal.UpdateItemType(itemTypeDto);

                return(new ResultBM(ResultBM.Type.OK, "Se ha creado el ítem " + itemTypeBm.Name + ".", itemTypeBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("UPDATING_ERROR") + " " + exception.Message, exception));
            }
        }