Exemple #1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Label1.Visible = false;
     if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "" || TextBox4.Text == "")
     {
         Label1.Text = " Необходимо заполнить все поля! "; Label1.Visible = true;
     }
     else
     {
         Label1.Visible = false;
         string answer = request.Pasword_and_status_by_login(TextBox1.Text);
         if (answer == "")
         {
             request.Add_user(TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text);
             HttpCookie login = new HttpCookie("login", TextBox1.Text);
             HttpCookie sign  = new HttpCookie("sign", SignGeneration.GetSign(TextBox1.Text + "sign"));
             Response.Cookies.Add(login); Response.Cookies.Add(sign);
             Response.Redirect("UserPage.aspx", false);
         }
         else
         {
             Label1.Text = "Пользователь с таким логином уже существует !"; Label1.Visible = true;
         }
     }
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string answer = request.Pasword_and_status_by_login(TextBox1.Text);

        if (answer == "")
        {
            Label1.Text = "Пользователь с таким логином не существует !"; Label1.Visible = true;
        }
        else
        {
            string[] answ = answer.Split('#');
            if (answ[1] == "Blocked")
            {
                Label1.Text = " Пользователь с данным логином заблокирован !"; Label1.Visible = true;
            }
            else
            {
                if (answ[0] == TextBox2.Text)
                {
                    HttpCookie login = new HttpCookie("login", TextBox1.Text);
                    HttpCookie sign  = new HttpCookie("sign", SignGeneration.GetSign(TextBox1.Text + "sign"));
                    Response.Cookies.Add(login); Response.Cookies.Add(sign);
                    Response.Redirect("UserPage.aspx", false);
                }
                else
                {
                    Label1.Text    = "Неправильно введённый пароль !";
                    Label1.Visible = true;
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        a1.ServerClick += new EventHandler(a1_ServerClick);
        a2.ServerClick += new EventHandler(a2_ServerClick);
        a3.ServerClick += new EventHandler(a3_ServerClick);

        HttpCookie login = Request.Cookies["login"];
        HttpCookie sign  = Request.Cookies["sign"];

        if (login != null && sign != null)
        {
            if (sign.Value == SignGeneration.GetSign(login.Value + "sign"))
            {
                request.Update_last_login(login.Value);
                Label1.Text = " Welcome, " + login.Value + " !";
                return;
            }
        }
        Response.Redirect("Login.aspx");
    }