예제 #1
0
        private ResultBM IsValid(ItemTypeBM itemTypeBm)
        {
            if (itemTypeBm.Name == null || itemTypeBm.Name.Length == 0)
            {
                return(new ResultBM(ResultBM.Type.INCOMPLETE_FIELDS, SessionHelper.GetTranslation("EMPTY_FIELD_ERROR") + " (NAME)"));
            }

            if (itemTypeBm.category == null || itemTypeBm.category.Length == 0)
            {
                return(new ResultBM(ResultBM.Type.INCOMPLETE_FIELDS, SessionHelper.GetTranslation("EMPTY_FIELD_ERROR") + " (CATEGORY)"));
            }

            return(new ResultBM(ResultBM.Type.OK));
        }
예제 #2
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));
            }
        }
예제 #3
0
        public ResultBM Delete(object entity)
        {
            try
            {
                ItemTypeDAL itemTypeDal = new ItemTypeDAL();
                ItemTypeBM  itemTypeBm  = entity as ItemTypeBM;

                if (!itemTypeDal.IsInUse(itemTypeBm.id))
                {
                    itemTypeDal.DeleteItemType(itemTypeBm.id);
                    return(new ResultBM(ResultBM.Type.OK, "Se ha eliminado el registro.", itemTypeBm));
                }
                else
                {
                    return(new ResultBM(ResultBM.Type.FAIL, SessionHelper.GetTranslation("ARTICLE_TYPE_UNDELETEABLE_ERROR"), itemTypeBm));
                }
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("DELETING_ERROR") + " " + exception.Message, exception));
            }
        }
예제 #4
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));
            }
        }
예제 #5
0
        private void cmbItemType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ItemTypeBM itemType = (ItemTypeBM)((ComboBox)sender).SelectedItem;

            dtDueDate.Visible = itemType.Perishable;
        }