/// <summary>
        /// Saves the value of a survey checkbox control. Should only be called when the control is visible.
        /// </summary>
        /// <param name="control"></param>
        public static void SaveValue(SurveyCheckBox control)
        {
            //Get value from postback
            bool postValue = (!String.IsNullOrEmpty(RequestVars.Post <string>(control.UniqueID, null)));

            control.Checked = postValue;
            SessionWrapper.Add(control.SessionKey, new SurveySessionControl <bool>(postValue));
            //if ( control.Checked ) {
            //    if ( !SessionWrapper.Get( control.SessionKey, new SurveySessionControl<bool>( false ) ).Value || postValue ) {
            //        //If it wasn't checked already or it's the same one as before, check it.
            //        SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( true ) );
            //        control.Checked = true;
            //    } else {
            //        //Uncheck other radio buttons that may have been flagged as checked if we know that we've already found a checked one.
            //        SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( false ) );
            //        control.Checked = false;
            //    }
            //} else {
            //    SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( false ) );
            //    control.Checked = false;
            //}
            //SurveyRadioButton rad = control as SurveyRadioButton;
            //if ( rad != null ) {

            //    return;
            //}
            //SaveValue<bool>( control );
        }
示例#2
0
        /// <summary>
        ///     Checks for valid login credentials. Returns 0 if successful, 1 if the username or password is empty, 2 if there was a SQL error, 3 if the user is locked out or 4 if the username or password is invalid.
        /// </summary>
        private static LoginErrorCode TryLogUserIn()
        {
            string username = RequestVars.Post("inputUsername", String.Empty).Trim(),
                   password = RequestVars.Post("inputPassword", String.Empty).Trim();

            int outputVal;

            UserInfo ui = UserInformation.LogUserIn <UserInfo>(
                username,
                password,
                true, //email logins allowed
                Config.ClientID, out outputVal);

            LoginErrorCode loginCode = (LoginErrorCode)outputVal;

            return(loginCode);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.HideAllFilters = true;
            if (RequestVars.Get("a", 0) == 1)
            {
                Response.Clear();
                switch (RequestVars.Get("t", 0))
                {
                case 1:                         //Remove
                    int propSurvReaID = RequestVars.Post("p", -1);
                    int userID        = RequestVars.Post("u", -1);
                    int sendType      = RequestVars.Post("s", -1);
                    if (propSurvReaID != -1 && userID != -1 && sendType != -1)
                    {
                        SQLDatabase sql  = new SQLDatabase();    sql.CommandTimeout = 120;
                        int         rows = sql.NonQuery(
                            @"DELETE FROM [tblNotificationUsers] WHERE [PropertySurveyReasonID] = @PropertySurveyReasonID AND [UserID] = @UserID AND [SendType] = @SendType",
                            new SQLParamList().Add("@PropertySurveyReasonID", propSurvReaID)
                            .Add("@UserID", userID)
                            .Add("@SendType", sendType)
                            );
                        if (!sql.HasError)
                        {
                            if (rows != 0)
                            {
                                Response.Write(new JSONBuilder().AddInt("s", 0));
                            }
                            else
                            {
                                Response.Write(new JSONBuilder().AddInt("s", 4).AddString("msg", "No matching records found. Refresh the page to see the most up to date information."));
                            }
                        }
                        else
                        {
                            Response.Write(new JSONBuilder().AddInt("s", 3).AddString("msg", "There was a problem contacting the database. Please try again. (ENM105)"));
                        }
                    }
                    else
                    {
                        Response.Write(new JSONBuilder().AddInt("s", 2).AddString("msg", "Invalid values specified."));
                    }
                    break;

                case 2:                         //Get user list
                    propSurvReaID = RequestVars.Get("p", -1);
                    if (propSurvReaID != -1)
                    {
                        SQLDatabase sql = new SQLDatabase();    sql.CommandTimeout = 120;
                        DataTable   dt  = sql.QueryDataTable(@"
SELECT [UserID],[FirstName],[LastName]
FROM [tblCOM_Users]
WHERE [UserID] NOT IN (SELECT [UserID] FROM [tblNotificationUsers] WHERE [PropertySurveyReasonID] = @PSRID )
	AND [Active] = 1
ORDER BY [FirstName], [LastName]",
                                                             new SqlParameter("@PSRID", propSurvReaID));

                        if (!sql.HasError)
                        {
                            JSONBuilder jb = new JSONBuilder().AddInt("s", 0);
                            jb.AddArray("ubh");
                            foreach (DataRow dr in dt.Rows)
                            {
                                jb.AddObject()
                                .AddInt("i", (int)dr["UserID"])
                                .AddString("n", dr["FirstName"].ToString() + " " + dr["LastName"].ToString())
                                .CloseObject();
                            }
                            jb.CloseArray();
                            Response.Write(jb);
                        }
                        else
                        {
                            Response.Write(new JSONBuilder().AddInt("s", 3).AddString("msg", "There was a problem contacting the database. Please try again. (ENM106)"));
                        }
                    }
                    else
                    {
                        Response.Write(new JSONBuilder().AddInt("s", 2).AddString("msg", "Invalid values specified."));
                    }
                    break;

                default:
                    Response.Write(new JSONBuilder().AddInt("s", 1).AddString("msg", "Invalid type specified."));
                    break;
                }
                Response.End();
                return;
            }

            if (!IsPostBack)
            {
                //Hide reason by default. Can only be shown if Property and Survey are changed.
                ddlReason.Visible = false;
            }
            else
            {
                lblReasonError.Text = String.Empty;
            }
        }