Пример #1
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);
        }
    }