Esempio n. 1
0
    private void Save()
    {
        lbError.Visible = false;

        //if (checkPassword())
        //{
        bool newUser = false;

        if (SessionState.EditedUser == null)
        {
            SessionState.EditedUser = new HyperCatalog.Business.User();
            newUser = true;
        }

        if (SessionState.EditedUser != null)
        {
            SessionState.EditedUser.FirstName = txtFirstName.Text;
            SessionState.EditedUser.LastName  = txtLastName.Text;
            SessionState.EditedUser.Email     = txtEmail.Text;
            SessionState.EditedUser.Pseudo    = txtPseudo.Text;
            //if (newUser || txtPassword.Text != emptyPassword)
            // SessionState.EditedUser.ClearPassword = newUser && useDefaultPwd.Checked ? HyperCatalog.Business.User.DefaultPassword : txtPassword.Text;
            SessionState.EditedUser.OrgId            = Convert.ToInt32(cbOrgs.SelectedValue);
            SessionState.EditedUser.IsActive         = cbIsActive.Checked;
            SessionState.EditedUser.IsReadOnly       = cbIsReadOnly.Checked;
            SessionState.EditedUser.FormatDate       = ddlFormatDate.SelectedValue;
            SessionState.EditedUser.FormatTime       = ddlFormatTime.SelectedValue;
            SessionState.EditedUser.GMTTimeZoneIndex = DDL_TimeZone.SelectedValue;
            SessionState.EditedUser.RoleId           = Convert.ToInt32(ddlRoles.SelectedValue);
            if (SessionState.EditedUser.Save())
            {
                SessionState.ClearAppUsers();
                if (SessionState.EditedUser.Id == SessionState.User.Id)
                {
                    SessionState.User = SessionState.EditedUser;
                }
                if (newUser)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>parent.window.location = '../Users.aspx?u=" + SessionState.EditedUser.Id + "';</script>");
                }
                else
                {
                    //ClientScript.RegisterStartupScript(GetType(), "passText", "var passBox=document.getElementById('" + txtPassword.ClientID + "');passBox.value='" + emptyPassword + "';noSavePassword = 1;", true);

                    lbError.Text     = "Data saved!";
                    lbError.CssClass = "hc_success";
                    lbError.Visible  = true;
                }
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = "Error while updating user: "******"hc_error";
            lbError.Text     = "Error: User is null";
            lbError.Visible  = true;
        }
    }