コード例 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            MySessionVariables x           = new MySessionVariables();
            string             UserName    = x.UserName;
            string             Password    = x.Password;
            string             oldPassword = TextBox1.Text;

            if (Password.Equals(oldPassword))
            {
                string      NewPassword = TextBox2.Text;
                UserDetails x           = new UserDetails();
                x.UserName = UserName;
                x.Password = NewPassword;
                int Counter = x.ChangePass();

                if (Counter.Equals(1))
                {
                    // Password Changed - Logout from all other users and login back
                    Session.Abandon();
                    Response.Redirect("Login.aspx");
                }
                else
                {
                    Label3.Text = "<H1> Your Password Couldnt be Updated </h1>";
                }
            }
            else
            {
                Label3.Text = "Incorrect Old Password !!";
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                UserDetails        x    = new UserDetails();
                MySessionVariables sess = new MySessionVariables();
                x.UserName = sess.UserName;

                DataSet dSet = x.GetUserInfo();
                TextBox1.Text = sess.UserName;
                TextBox2.Text = dSet.Tables[0].Rows[0]["Password"].ToString();

                string   Country = dSet.Tables[0].Rows[0]["Country"].ToString();
                ListItem li      = DropDownList1.Items.FindByText(Country);
                int      index   = DropDownList1.Items.IndexOf(li);
                DropDownList1.SelectedIndex = index;

                TextBox3.Text = dSet.Tables[0].Rows[0]["Email"].ToString();
            }
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            UserDetails        x    = new UserDetails();
            MySessionVariables sess = new MySessionVariables();

            x.UserName = sess.UserName;
            x.Password = TextBox2.Text;
            x.Country  = DropDownList1.SelectedItem.Text;
            x.Email    = TextBox3.Text;

            int Counter = x.UpdateUser();

            if (Counter.Equals(1))
            {
                Label5.Text = "Updated Successfully";
                sess.Abandon();
                Response.Redirect("Login");
            }
            else
            {
                Label5.Text = "There seems to be a Problem !!";
            }
        }
コード例 #4
0
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            MySessionVariables sess     = new MySessionVariables();
            string             userName = sess.UserName;
            string             password = sess.Password;

            UserDetails x = new UserDetails();

            x.UserName = userName;
            x.Password = password;
            int Counter = x.UnSub();

            if (Counter == 1)
            {
                // Successfull
                Session.Abandon();
                Response.Redirect("SignUp.aspx");
            }
            else
            {
                // Failed
                Label1.Text = "<H1>Unsubscribe Failed </H1>";
            }
        }
コード例 #5
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            MySessionVariables x = new MySessionVariables();

            TextBox2.Text = x.UserName;
        }
コード例 #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            MySessionVariables x = new MySessionVariables();

            x.UserName = TextBox1.Text.ToString();
        }
コード例 #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            // int Counter = 0;
            UserDetails x = new UserDetails();

            x.UserName = TextBox1.Text;
            x.Password = TextBox2.Text;

            /* Counter = x.CheckCred();
             *
             * if (Counter.Equals(1))
             * {
             *  // Label3.Text = "Successfully Logged";
             *  // Redirect to Home Page
             *
             * Session["Sess_UserName"] = TextBox1.Text;
             *  Session["Sess_Password"] = TextBox2.Text;
             *
             *  MySessionVariables x = new MySessionVariables();
             *  x.UserName = TextBox1.Text;
             *  x.Password = TextBox2.Text;
             *
             *  Response.Redirect("Home.aspx");
             *
             * }
             * else
             * {
             *  Label3.Text = "Sorry Wrong Combination !!";
             * } */

            DataSet dSet = x.CheckCred();

            int Status = Convert.ToInt32(dSet.Tables[0].Rows[0]["Status"].ToString()); // 1 success , 0 failed, -1 username failed, -3 locked - Check Procedure

            switch (Status)
            {
            case 1:
                MySessionVariables x = new MySessionVariables();
                x.UserName = TextBox1.Text;
                x.Password = TextBox2.Text;
                Response.Redirect("Home.aspx");
                break;

            case -1:     // Invalid User
                Label3.Text = "<H1> No such User Exist !!</H1>";
                break;

            case -2:     // Inactive User
                Label3.Text = "<H1> You have unsubscribed </H1>";
                break;

            case -3:     // Locked
                Label3.Text = "<H1> Your account is Locked because of too many failed attempts </H1>";
                break;

            case 0:     // Wrong Password, Increase the NOFA value till 5 and display maximum attempts reached
                int NOFA = Convert.ToInt32(dSet.Tables[0].Rows[0]["NOFA"].ToString());
                if (NOFA.Equals(5))
                {
                    Label3.Text = "<H1> You have exceeded maximum failed attempts </H1>";
                    break;
                }
                Label3.Text = "<H1> Wrong Password !! You are left with " + (5 - NOFA) + " Attempts <H1>";
                break;
            }
        }