Пример #1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Title = "Пользователи - LeadForce";

            if (Page.RouteData.Values["id"] != null)
            {
                _userId = Guid.Parse(Page.RouteData.Values["id"] as string);
            }

            hlCancel.NavigateUrl = UrlsData.AP_Users();

            tagsUser.ObjectID = _userId;

            if ((AccessLevel)CurrentUser.Instance.AccessLevelID == AccessLevel.SystemAdministrator)
            {
                dcbSite.SelectedIndexChanged += dcbSite_SelectedIndexChanged;
                dcbSite.AutoPostBack          = true;
                RadAjaxManager.GetCurrent(Page).AjaxSettings.AddAjaxSetting(dcbSite, rcbContact, null, UpdatePanelRenderMode.Inline);
            }

            if (!Page.IsPostBack)
            {
                BindData();
            }
        }
Пример #2
0
        /// <summary>
        /// Handles the OnClick event of the lbtnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbtnSave_OnClick(object sender, EventArgs e)
        {
            var currentUser = CurrentUser.Instance;

            tbl_User user;

            if ((AccessLevel)currentUser.AccessLevelID == AccessLevel.SystemAdministrator)
            {
                user        = DataManager.User.SelectById(_userId) ?? new tbl_User();
                user.SiteID = dcbSite.SelectedId;
            }
            else
            {
                user        = DataManager.User.SelectById(_userId, SiteId) ?? new tbl_User();
                user.SiteID = SiteId;
            }

            user.Login         = txtEmail.Text;
            user.Password      = txtPassword.Text;
            user.IsActive      = cbIsActive.Checked;
            user.AccessLevelID = int.Parse(ddlAccessLevel.SelectedValue);
            if (rcbContact.SelectedValue != Guid.Empty.ToString())
            {
                user.ContactID = Guid.Parse(rcbContact.SelectedValue);
            }
            else
            {
                user.ContactID = null;
            }

            if (rcbAccessProfile.SelectedValue != Guid.Empty.ToString())
            {
                user.AccessProfileID = Guid.Parse(rcbAccessProfile.SelectedValue);
            }
            else
            {
                user.AccessProfileID = null;
            }

            if (user.ID == Guid.Empty)
            {
                DataManager.User.Add(user);
            }
            else
            {
                DataManager.User.Update(user);
            }

            tagsUser.SaveTags(user.ID);

            CurrentUser.UserInstanceFlush();

            Response.Redirect(UrlsData.AP_Users());
        }