Example #1
0
 public override bool UpdateAttribute(Attribute attribute)
 {
     using (SqlConnection cn = new SqlConnection(LayerObjectsConnection))
     {
         SqlCommand cmd = new SqlCommand("Attributes_UpdateAttribute", cn);
         //cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value = attribute.Id;
         //cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = attribute.Name;
         //cmd.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = attribute.Phone;
         //cmd.Parameters.Add("@StateId", SqlDbType.Int).Value = attribute.ItemState;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return(ret == 1);
     }
 }
Example #2
0
 public override int InsertAttribute(Attribute attribute)
 {
     using (SqlConnection cn = new SqlConnection(LayerObjectsConnection))
     {
         SqlCommand cmd = new SqlCommand("Attributes_InsertAttribute", cn);
         cmd.CommandType = CommandType.Text;
         //cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = attribute.Name;
         //cmd.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = attribute.Phone;
         //cmd.Parameters.Add("@StateId", SqlDbType.Int).Value = attribute.ItemState;
         cmd.Parameters.Add("@Id", SqlDbType.Int).Direction = ParameterDirection.Output;
         cn.Open();
         int ret = ExecuteNonQuery(cmd);
         return((int)cmd.Parameters["@Id"].Value);
     }
 }
Example #3
0
        public static Attribute GetAttributeByAttributeId(Guid attributeId)
        {
            Attribute attribute = null;
            string    key       = "Attributes_GetAttributeByAttributeId_" + attributeId;

            if (Cache[key] != null)
            {
                attribute = (Attribute)Cache[key];
            }
            else
            {
                attribute = DataAccess.Attributes.GetAttributeByAttributeId(attributeId);
                CacheData(key, attribute);
            }
            return(attribute);
        }
        protected virtual Attribute GetAttributeFromReader(IDataReader reader)
        {
            Attribute attribute = new Attribute()
            {
                Id = (Guid)reader["Id"],
                AttributeTypeId = (Guid)reader["AttributeTypeId"],
                Description     = reader["Description"].ToString(),
                Caption         = reader["Caption"].ToString(),
                Searchable      = (bool)reader["Searchable"]
            };

            if (reader["Code"] != DBNull.Value)
            {
                attribute.Code = reader["Code"].ToString();
            }
            return(attribute);
        }
 public abstract bool UpdateAttribute(Attribute attribute);
 public abstract int InsertAttribute(Attribute attribute);
Example #7
0
        public static bool DeleteElementTypeByElementTypeId(Guid elementTypeId)
        {
            List <ElementTypeAttribute> elementTypeAttributes = ElementTypeAttributes.GetAttributesByElementTypeId(elementTypeId);

            List <LayerConditionsElement> layerConditionsElements = new List <LayerConditionsElement>();
            List <AttributeValue>         attributeValues         = new List <AttributeValue>();

            foreach (ElementTypeAttribute eta in elementTypeAttributes)
            {
                List <AttributeValue> attValues = Attributes.GetAttributeValuesByAttributeId(eta.AttributeId);

                foreach (AttributeValue av in attValues)
                {
                    if (av != null)
                    {
                        attributeValues.Add(av);
                    }
                }
            }

            List <Element> elements = GetElementsByElementTypeId(elementTypeId);

            foreach (Element el in elements)
            {
                List <LayerConditionsElement> layerElements = Layers.GetLayerConditionsElementsByElementId(el.Id);

                foreach (LayerConditionsElement lce in layerElements)
                {
                    if (lce != null)
                    {
                        layerConditionsElements.Add(lce);
                    }
                }
            }

            foreach (LayerConditionsElement lce in layerConditionsElements)
            {
                Layers.DeleteLayerConditionsElementsByElementId(lce.ElementId);
            }


            foreach (AttributeValue av in attributeValues)
            {
                Attributes.DeleteAttributeValueByAttributeId(av.AttributeId);
            }

            ElementTypeAttributes.DeleteElementTypeAttributesByElementTypeId(elementTypeId);

            List <DrawingTypeAttribute> drawingTypeAttributes = new List <DrawingTypeAttribute>();

            foreach (ElementTypeAttribute eta in elementTypeAttributes)
            {
                List <DrawingTypeAttribute> attValues = DrawingTypes.GetDrawingTypeAttributesByAttributeId(eta.AttributeId);

                foreach (DrawingTypeAttribute av in attValues)
                {
                    if (av != null)
                    {
                        drawingTypeAttributes.Add(av);
                    }
                }
            }

            foreach (DrawingTypeAttribute dta in drawingTypeAttributes)
            {
                DrawingTypes.DeleteDrawingTypeAttributeValueByDrawingTypeAttributeId(dta.Id);
            }

            List <Attribute> attributes = new List <Attribute>();

            foreach (ElementTypeAttribute eta in elementTypeAttributes)
            {
                Attribute attribute = Attributes.GetAttributeByAttributeId(eta.AttributeId);
                if (attribute != null)
                {
                    attributes.Add(attribute);
                }
            }

            List <LayerElementType> layerElementTypes = Layers.GetLayerElementTypesByElementTypeId(elementTypeId);

            foreach (LayerElementType let in layerElementTypes)
            {
                Layers.DeleteFilterByLayerElementTypeId(let.Id);
            }

            Layers.DeleteLayerElementTypeByElementTypeId(elementTypeId);


            DrawingTypes.DeleteDrawingTypeAttributeValueByElementTypeId(elementTypeId);

            foreach (Attribute av in attributes)
            {
                Layers.DeleteFilterByAttributeId(av.Id);
                DrawingTypes.DeleteDrawingTypeAttributeByAttributeId(av.Id);
                ElementTypeAttributes.DeleteElementTypeAttributeByAttributeId(av.Id);
                Attributes.DeleteAttributeByAttributeId(av.Id);
            }

            Roles.DeleteRoleElementTypeByElementTypeId(elementTypeId);
            bool result = DataAccess.ElementTypes.DeleteElementTypeByElementTypeId(elementTypeId);

            RemoveFromCache("ElementTypes_");
            return(result);
        }
Example #8
0
        //public static Attribute InsertAttribute(Attribute attribute)
        //{
        //    RemoveFromCache("Attributes_");
        //    int attributeId = DataAccess.Attributes.InsertAttribute(attribute);
        //    attribute = DataAccess.Attributes.GetAttributeByAttributeId(attributeId);
        //    return attribute;
        //}

        public static bool UpdateAttribute(Attribute attribute)
        {
            RemoveFromCache("Attributes_");
            return(DataAccess.Attributes.UpdateAttribute(attribute));
        }