protected void SignUpButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (UNameTextBox.Text == null || UNameTextBox.Text == " " || Password1.Value == null || Password1.Value == " " || MailIdTextBox.Text == null || MailIdTextBox.Text == " ")
            {
                StatusLabel.Text = "Please enter valid Username, Password and email";
            }
            if (CaptchaStringTextBox.Text == null || CaptchaStringTextBox.Text == "")
            {
                StatusLabel.Text = "Please enter the string size";
            }
            if (ValidateTextBox.Text == null || ValidateTextBox.Text == "")
            {
                StatusLabel.Text = "Please verify the string";
            }
            if (ValidateTextBox.Text == Session["genstr"].ToString())
            {
                String username      = UNameTextBox.Text;
                String password      = Password1.Value;
                string email         = MailIdTextBox.Text;
                string bankaccountno = AccountNoTextBox.Text;
                string bankaddr      = BankAddrTextBox.Text;

                LoginServiceReference.Service1Client login = new LoginServiceReference.Service1Client();
                string pwd   = EncryptionDecryptionObject.Encrypt(password);
                bool   check = login.Login(username, pwd);
                if (!check)
                {
                    login.SignUp(username, pwd, email, bankaccountno, bankaddr);
                    StatusLabel.Text = "Sign Up Successful";
                }
                else
                {
                    StatusLabel.Text = "User already exists..";
                }
            }
            else
            {
                StatusLabel.Text = "Strings do not match. Please try again..";
            }
        }
        catch (Exception ex)
        {
            //  StatusLabel.Text = ex.Message;
        }
    }
Ejemplo n.º 2
0
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        try
        {
            String username = TextBox1.Text;
            String password = Password1.Value;
            String mpwd     = EncrytionDecryptionObject.Encrypt(password);
            if (username == null || username == "" || password == null || password == "")
            {
                Label3.Text = "Please enter valid credentials";
            }
            LoginServiceReference.Service1Client login = new LoginServiceReference.Service1Client();
            // Login.Service1Client login = new Login.Service1Client();
            bool result = login.Login(username, mpwd);

            HttpCookie myCookies = new HttpCookie("myCookieId");
            myCookies["UserName"] = TextBox1.Text;
            myCookies.Expires     = DateTime.Now.AddDays(20);
            Response.Cookies.Add(myCookies);

            if (result)
            {
                Label3.Text = "Login Successful..";
                FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);

                // Response.Redirect("View Stocks Page.aspx");
            }
            else
            {
                Label3.Text = "Please Check The credentials ";
            }
        }
        catch (Exception ex)
        {
            Label3.Text = ex.Message;
        }
    }