Exemplo n.º 1
0
    protected void btnAddAttribute_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(tbAttrName.Text))
        {
            lbErrorText.Text = (string)GetLocalResourceObject("noAttrNameData");
            lbErrorText.Visible = true;
            return;
        }

        PersonAttributeType attr = new PersonAttributeType();
        if (UserAttributeId > 0)
        {
            attr.Load(UserAttributeId);
            UserAttributeId = -1;
        }
        else
        {
            if (PersonAttributeType.GetAttributeType(tbAttrName.Text) != null)
            {
                lbErrorText.Text = (string) GetLocalResourceObject("isAttrError");
                lbErrorText.Visible = true;
                return;
            }
        }

        attr.AttributeName = tbAttrName.Text;
        attr.ShowToUsers = cbShowToUsers.Checked;
        attr.Save();

        clearData();
    }
Exemplo n.º 2
0
    private void gvAttributes_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int id = (int)gridViewAttributes.DataKeys[e.RowIndex].Value;
        PersonAttributeType attr = new PersonAttributeType();
        if (!attr.Load(id))
            return;

        attr.Delete();
        //bindAttributesGridView();
    }
Exemplo n.º 3
0
    public string AllUserInfoPrint(string SrtringField, int AttributeID)
    {
        string typeAtr = ddlTypeSelect.SelectedItem.ToString();
        if (typeAtr.Equals("All"))
        {
            PersonAttributeType attr = new PersonAttributeType();
            attr.Load(AttributeID);
            return string.Format("{0} - {1}"
                                 , attr.AttributeName
                                 , SrtringField);
        }

        return SrtringField;
    }
Exemplo n.º 4
0
    protected void attributeBinding()
    {
        PersonAttributeType attr = new PersonAttributeType();
        attr.Load(UserAttributeId);

        tbAttrName.Text = attr.AttributeName.Trim();
        cbShowToUsers.Checked = attr.ShowToUsers;

        tbAttrName.Enabled = Enum.IsDefined(typeof (PersonAttributeTypes), attr.AttributeName.Trim())
                                 ? false
                                 : true;

        lbErrorText.Visible = false;
    }
Exemplo n.º 5
0
        /// <summary>
        /// Removes all attributes of given type.
        /// </summary>
        /// <param name="type">Type of attribute.</param>
        public void RemoveStandardAttributes(PersonAttributeType type)
        {
            if (ID == null)
                return;

            try
            {
                var attrs = PersonAttributes.GetPersonAttributesByKeyword(ID.Value, type);
                if (attrs == null)
                    return;

                foreach (var pa in attrs)
                {
                    pa.Delete();
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex.Message, ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds standard string attribute.
        /// </summary>
        /// <param name="type">Type of attribute.</param>
        /// <param name="value">Value of attribute.</param>
        /// <returns>Created attribute.</returns>
        public PersonAttribute AddStandardStringAttribute(PersonAttributeType type, string value)
        {
            if (ID == null || string.IsNullOrEmpty(value))
                return null;

            try
            {
                var pa = new PersonAttribute
                         	{
                         		PersonID = ID.Value,
                         		InsertionDate = DateTime.Now,
                         		AttributeID = type.ID.Value,
                         		ValueType = typeof (string).AssemblyQualifiedName,
                         		StringField = value
                         	};
                pa.Save();
                return pa;
            }
            catch( Exception ex )
            {
                Logger.Log.Error( ex.Message, ex );
                return null;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds standard string attribute.
        /// </summary>
        /// <param name="typeName">Type name of attribute.</param>
        /// <param name="value">Value of attribute.</param>
        /// <returns>Created attribute.</returns>
        public PersonAttribute AddStandardStringAttribute(string typeName, string value)
        {
            if (ID == null || string.IsNullOrEmpty(value))
                return null;

            try
            {
                PersonAttributeType type = PersonAttributeType.GetAttributeType(typeName);
                if (type == null)
                {
                    type = new PersonAttributeType() { AttributeName = typeName, ShowToUsers = false };
                    type.Save();
                }

                return AddStandardStringAttribute(type, value);

            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex.Message, ex);
                return null;
            }
        }
Exemplo n.º 8
0
    public string UserKeyWordPrint(int AttributeID)
    {
        string typeAtr = ddlTypeSelect.SelectedItem.ToString();
        PersonAttributeType attr = new PersonAttributeType();

        if (!attr.Load(AttributeID))
            return string.Empty;

        return typeAtr.Equals("All")
                   ? attr.AttributeName
                   : string.Empty;
    }
Exemplo n.º 9
0
    /// <summary>
    /// Заполняет информацию о контактах.
    /// </summary>
    private void bindAttributesGridView()
    {
        try
        {
            if (UserID == null)
                return;

            string typeAtr = ddlTypeSelect.SelectedItem.ToString();
            IList<PersonAttribute> dnAttribs = new List<PersonAttribute>();

            if(typeAtr.Equals("All"))
                dnAttribs = getAllPublicPersonAttibutes();
            else
            {
                PersonAttributeType attrtype = new PersonAttributeType();
                attrtype.LoadByReference("AttributeName", typeAtr);
                dnAttribs = PersonAttributes.GetPersonAttributesByKeyword(UserID.Value, attrtype);
            }

            gvContact.DataSource = dnAttribs;
            gvContact.DataBind();

            if (!IsCurrentUserCanEditData)
            {
                for (int i = 0; i < gvContact.Rows.Count; i++)
                {
                    HoverMenuExtender hoverMenu = (HoverMenuExtender) gvContact.Rows[i].FindControl("hoverMenuView");
                    hoverMenu.Enabled = false;
                }
                dvAddInfo.Visible = false;
            }
            if (typeAtr.Equals("All"))
                //dvAddInfo.Disabled = true;
            {
                tbContInfo.Enabled = false;
                btnAddContact.Enabled = false;
            }
        }
        catch (Exception ex)
        {
            Logger.Log.Error(ex.Message, ex);
        }
    }
Exemplo n.º 10
0
 /// <summary>
 /// Returns all attributes with given keyword.
 /// </summary>
 /// <param name="attr">Attribute.</param>
 /// <returns>All attributes with given keyword.</returns>
 public static IList<PersonAttribute> GetPersonAttributesByKeyword(PersonAttributeType attr)
 {
     if (string.IsNullOrEmpty(attr.AttributeName))
         return new List<PersonAttribute>();
     return getAttributesByParams("AttributeID", attr.ID);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Returns all attributes with given keyword.
        /// </summary>
        /// <param name="keyword">Keyword.</param>
        /// <returns>All attributes with given keyword.</returns>
        public static IList<PersonAttribute> GetPersonAttributesByKeyword(string keyword)
        {
            if (string.IsNullOrEmpty(keyword))
                return new List<PersonAttribute>();

            PersonAttributeType attr = new PersonAttributeType();
            attr.LoadByReference("AttributeName", keyword);
            return GetPersonAttributesByKeyword(attr);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Returns all person attributes with given keyword.
        /// </summary>
        /// <param name="personID">ID of person.</param>
        /// <param name="attr">Attribute.</param>
        /// <param name="param">Additiona params.</param>>
        /// <returns>Filtered person attributes with given keyword.</returns>
        public static IList<PersonAttribute> GetPersonAttributesByKeyword(int personID, PersonAttributeType attr, params string[] param)
        {
            if (string.IsNullOrEmpty(attr.AttributeName))
                return new List<PersonAttribute>();
            if (param != null)
                return getAttributesByParams("PersonID", personID, "AttributeID", attr.ID, param);

            return getAttributesByParams("PersonID", personID, "AttributeID", attr.ID);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Returns all person attributes with given keyword.
        /// </summary>
        /// <param name="personID">ID of person.</param>
        /// <param name="keyword">Keyword.</param>
        /// <param name="param">Additiona params.</param>
        /// <returns>Filtered person attributes with given keyword.</returns>
        public static IList<PersonAttribute> GetPersonAttributesByKeyword(int personID, string keyword, params string[] param)
        {
            if (string.IsNullOrEmpty(keyword))
                return new List<PersonAttribute>();

            PersonAttributeType attr = new PersonAttributeType();
            attr.LoadByReference("AttributeName", keyword);
            return GetPersonAttributesByKeyword(personID, attr, param);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Returns all person attributes with given keyword.
 /// </summary>
 /// <param name="personID">ID of person.</param>
 /// <param name="attr">Attribute.</param>
 /// <returns>All person attributes with given keyword.</returns>
 public static IList<PersonAttribute> GetPersonAttributesByKeyword(int personID, PersonAttributeType attr)
 {
     if (string.IsNullOrEmpty(attr.AttributeName))
         return new List<PersonAttribute>();
     return GetPersonAttributesByKeyword(personID, attr, null);
 }