Beispiel #1
0
    protected void btn_Click(object sender, EventArgs e)
    {
        string id          = ((Control)sender).ID;
        int    question_id = 0;

        switch (id)
        {
        case "btn_check":
            int exist_indicator = BusinessLayer.Check_Username_Existence(txt_forgot_password.Text);

            if (exist_indicator == 0)
            {
                question_id          = LoadQuestions(txt_forgot_password.Text);
                pnl_email.Visible    = false;
                pnl_question.Visible = true;
                pnl_confirm.Visible  = false;
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<p class='error bold'>Your account does not exist. Please check email address again.</p>");
                lit_error.Text = sb.ToString();
            }
            break;

        case "btn_submit":
            tblQuestion       q = ModelLayer.GetQuestion(question_id);
            tblQuestionAnswer a = ModelLayer.GetQuestionAnswer(q.iQuestionAnswer);

            if (a.vQuestionAnswer == txt_question_answer.Text)
            {
                string result = SendEmail(txt_forgot_password.Text);

                if (result == "Success")
                {
                    pnl_email.Visible    = false;
                    pnl_question.Visible = false;
                    pnl_confirm.Visible  = true;
                }
                else
                {
                    Common.ErrorLog(@"c:\logs\debug.txt", result);
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<p class='error bold'>Your security question answer does not match with our records. Please check your answer again.</p>");
                lit_error.Text = sb.ToString();
            }
            break;

        case "btn_confirm":
            Response.RedirectToRoute("Login");
            break;

        default:
            break;
        }
    }
Beispiel #2
0
    public static tblQuestion Forgot_Password_Questions()
    {
        tblQuestion q = new tblQuestion();
        int         question_set_type = 0;

        List <int>         q_ids     = new List <int>();
        tblQuestionSet     qs        = ModelLayer.GetQuestionSet(0, question_set_type);
        List <tblQuestion> questions = ModelLayer.GetQuestions(qs.iQuestionSet);

        foreach (tblQuestion question in questions)
        {
            q_ids.Add(question.iQuestion);
        }

        Random ranNum      = new Random();
        int    question_id = q_ids[ranNum.Next(q_ids.Count)];

        q = ModelLayer.GetQuestion(question_id);

        return(q);
    }