Esempio n. 1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string loginName = username.Text;
        string pass      = EncryptSecurity.EncryptMD5Hash(password.Text);

        DataUtils data = new DataUtils();
        User      user = data.checkLogin(loginName, pass);

        if (user == null)
        {
            txtErr.Text = "Tên người dùng hoặc mật khẩu không đúng";
        }
        else
        {
            Session["userName"] = user.Username;
            if (user.Permission == 0)
            {
                Response.Redirect("Default.aspx");
            }
            else
            {
                Response.Redirect("~/Dashboard.aspx");
            }
        }
    }
Esempio n. 2
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        try
        {
            string gioitinhid = "3";
            if (drpGender.SelectedValue.Equals("Nam"))
            {
                gioitinhid = "1";
            }
            if (drpGender.SelectedValue.Equals("Nữ"))
            {
                gioitinhid = "2";
            }

            string pass = EncryptSecurity.EncryptMD5Hash(txtPass.Text);
            if (Session["avaImg"] != null)
            {
                avafile = (string)Session["avaImg"];

                string path       = (string)Session["tempPath"];
                string src        = Server.MapPath("~/");
                string sourceFile = System.IO.Path.Combine(src + "temp\\" + (string)Session["source"], avafile);
                System.IO.Directory.CreateDirectory(src + "anh\\" + txtTen.Text);
                string destFile = System.IO.Path.Combine(src + "anh\\" + txtTen.Text, avafile);
                System.IO.File.Copy(sourceFile, destFile, true);
            }
            else
            {
                avafile = "noavatar.png";
            }

            DataUtils data = new DataUtils();
            data.AddUser(txtTen.Text, pass, txtFullname.Text, gioitinhid, txtEmail.Text, avafile);

            Thread.Sleep(5000);

            Response.Redirect("DangNhap.aspx");
        }
        catch
        {
            string script = "alert('Error services')";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertMessage", script, true);
        }
    }