private void Edit(int EditID)
        {
            ClearProfilepropertyForm();
            ProfileManagementController objController = new ProfileManagementController();
            ProfileManagementInfo objinfo = objController.GetProfileByProfileID(EditID);
            if (objinfo != null)
            {
                txtCaption.Text = objinfo.Name;
                ddlPropertyType.SelectedIndex = ddlPropertyType.Items.IndexOf(ddlPropertyType.Items.FindByValue(objinfo.PropertyTypeID.ToString()));
                chkIsRequred.Checked = bool.Parse(objinfo.IsRequired.ToString());
                ddlDataType.SelectedIndex = ddlDataType.Items.IndexOf(ddlDataType.Items.FindByValue(objinfo.DataType));

                if (objinfo.PropertyTypeID != 1 && objinfo.PropertyTypeID != 5 && objinfo.PropertyTypeID != 6 && objinfo.PropertyTypeID != 7 && objinfo.PropertyTypeID != 8 && Session[SessionKeys.PropertyValueDataTable] != null)
                {
                    List<ProfileManagementInfo> dtActual = objController.GetActiveProfileValueByProfileID(EditID, GetPortalID);
                    CommonFunction LToDCon = new CommonFunction();
                    if (dtActual != null && dtActual.Count > 0)
                    {
                        DataTable dt = (DataTable)Session[SessionKeys.PropertyValueDataTable];
                        for (int i = 0; i < dtActual.Count; i++)
                        {
                            DataRow newrow1 = dt.NewRow();
                            dt.Rows.Add(newrow1);
                            dt.Rows[dt.Rows.Count - 1]["ProfileValueID"] = dtActual[i].ProfileValueID.ToString();
                            dt.Rows[dt.Rows.Count - 1]["Name"] = dtActual[i].Name;
                            dt.AcceptChanges();

                        }
                        lstvPropertyValue.DataSource = dt;
                        lstvPropertyValue.DataTextField = "Name";
                        lstvPropertyValue.DataValueField = "ProfileValueID";
                        lstvPropertyValue.DataBind();
                        trListPropertyValue.Style.Add("display", "");
                    }
                }
                else
                {
                    lstvPropertyValue.DataSource = null;
                    lstvPropertyValue.DataBind();
                    trListPropertyValue.Style.Add("display", "none");
                }
            }
            HideAll();
            divForm.Style.Add("display", "block");
            Session[SessionKeys.EditProfileID] = EditID;
        }
 private void Delete(int DeleteID)
 {
     ProfileManagementController objController = new ProfileManagementController();
     objController.DeleteProfileValueByProfileID(DeleteID, GetPortalID, GetUsername);
     objController.DeleteProfileByProfileID(DeleteID, GetUsername);
     RefreshGrid();
     ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "ProfileDeletedSuccessfully"), "", SageMessageType.Success);
 }
 private void SaveProfileDefination()
 {
     try
     {
         if (ValidateProfilepropertyForm())
         {
             if (Session[SessionKeys.EditProfileID] != null)
             {
                 int PropertyTypeID = Int32.Parse(ddlPropertyType.SelectedValue);
                 int ProfileID = Int32.Parse(Session[SessionKeys.EditProfileID].ToString());
                 ProfileManagementController objController = new ProfileManagementController();
                 if (ProfileID != 0)
                 {
                     objController.UpdateProfile(ProfileID, txtCaption.Text.Trim(), PropertyTypeID, ddlDataType.SelectedItem.Value, chkIsRequred.Checked, true, true, DateTime.Now, GetPortalID, GetUsername);
                     if (ProfileID != 0 && PropertyTypeID != 1 && PropertyTypeID != 5 && PropertyTypeID != 6 && PropertyTypeID != 7 && PropertyTypeID != 8 && lstvPropertyValue.Items.Count > 0)
                     {                                
                         objController.DeleteProfileValueByProfileID(ProfileID, GetPortalID, GetUsername);
                         for (int i = 0; i < lstvPropertyValue.Items.Count; i++)
                         {
                             int ProfileValueID = 0;
                             ProfileValueID = objController.AddProfileValue(ProfileID, lstvPropertyValue.Items[i].Text, true, DateTime.Now, GetPortalID, GetUsername);
                         }
                     }
                     ShowMessage("", GetSageMessage("UserManagement", "ProfileUpdatedSuccessfully"), "", SageMessageType.Success);
                     ClearProfilepropertyForm();
                     RefreshGrid();
                 }
             }
             else
             {
                 ProfileManagementController objController = new ProfileManagementController();
                 int PropertyTypeID = Int32.Parse(ddlPropertyType.SelectedValue);
                 int ProfileID = 0;
                 ProfileID = objController.AddProfile(txtCaption.Text.Trim(), PropertyTypeID, ddlDataType.SelectedItem.Value, chkIsRequred.Checked, true, DateTime.Now, GetPortalID, GetUsername);
                 if (ProfileID != 0 && PropertyTypeID != 1 && PropertyTypeID != 5 && PropertyTypeID != 6 && PropertyTypeID != 7 && PropertyTypeID != 8 && lstvPropertyValue.Items.Count > 0)
                 {
                     for (int i = 0; i < lstvPropertyValue.Items.Count; i++)
                     {
                         int ProfileValueID = 0;
                         ProfileValueID = objController.AddProfileValue(ProfileID, lstvPropertyValue.Items[i].Text, true, DateTime.Now, GetPortalID, GetUsername);
                     }
                 }
                 ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "ProfileAddedSuccessfully"), "", SageMessageType.Success);
                 ClearProfilepropertyForm();
                 RefreshGrid();
             }
         }
         else
         {
             ShowMessage(SageMessageTitle.Information.ToString(), strMessage.ToString(), "", SageMessageType.Success);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
 private void SaveChanges()
 {
     try
     {
         for (int i = 0; i < gdvList.Rows.Count; i++)
         {
             ImageButton imbKey = (ImageButton)gdvList.Rows[i].FindControl("imgDelete");
             int ProfileID = Int32.Parse(imbKey.CommandArgument.ToString());
             ImageButton imbDisplayOrder = (ImageButton)gdvList.Rows[i].FindControl("imgUp");
             Int32 DisplayOrder = Int32.Parse(imbDisplayOrder.CommandArgument.ToString());
             CheckBox chk = (CheckBox)gdvList.Rows[i].FindControl("chkIsActive");
             bool IsActive = false;
             if (chk != null && chk.Checked == true)
             {
                 IsActive = true;
             }
             ProfileManagementController objController = new ProfileManagementController();
             objController.UpdateProfileDisplayOrderAndIsActiveOnly(ProfileID, DisplayOrder, IsActive, DateTime.Now, GetPortalID, GetUsername);
         }
         ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "ChangesSavedSuccessfully"), "", SageMessageType.Success);
         RefreshGrid();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        private void BindDdlList()
        {
            try
            {
                ProfileManagementController objController = new ProfileManagementController();
                ddlPropertyType.DataSource = objController.GetPropertyTypeList();
                ddlPropertyType.DataTextField = "Name";
                ddlPropertyType.DataValueField = "PropertyTypeID";
                ddlPropertyType.DataBind();
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }

        }