예제 #1
0
    protected void btndangky_Click(object sender, EventArgs e)
    {
        clDangKyTT dangky = new clDangKyTT();

        if (dangky.Kiemtradangnhap(txttendangnhap.Text))
        {
            Response.Write("<script> alert('Tên đăng nhập đã tồn tai!!!!Vui lòng đăng ký lai.')</script>");
            txttendangnhap.Focus();
            txttendangnhap.Text = "";
        }
        else if (dangky.kiemtraemail(txtemail.Text))
        {
            Response.Write("<script> alert('Email đã tồn tại !!Vui lòng đăng ký Email mới!')</script>");
            txtemail.Focus();
            txtemail.Text = "";
        }
        else
        {
            dangky.Dlkhachhang(int.Parse("1"), txttendangnhap.Text, txtpassword.Text, txtsdt.Text, txtemail.Text, txtdiachi.Text);
            txttendangnhap.Text = "";
            txtdiachi.Text      = "";
            txtemail.Text       = "";
            txtpassword.Text    = "";
            txtpassword1.Text   = "";
            txtsdt.Text         = "";
            Response.Write("<script> alert('Đăng ký thành công')</script>");
        }
    }
예제 #2
0
    protected void btndangnhap_Click(object sender, EventArgs e)
    {
        clDangKyTT dangky = new clDangKyTT();

        ketnoi.cmd             = new System.Data.SqlClient.SqlCommand("login_form", ketnoi.getconn());
        ketnoi.cmd.CommandType = System.Data.CommandType.StoredProcedure;
        ketnoi.cmd.Parameters.AddWithValue("@taikhoan", txttendangnhap.Text);
        ketnoi.cmd.Parameters.AddWithValue("@matkhau", txtpassword.Text);
        ketnoi.rd = ketnoi.cmd.ExecuteReader();
        bool login = ketnoi.rd.Read();

        if (login)
        {
            int check = phanquyen(txttendangnhap.Text);
            switch (check)
            {
            case 2:
                Response.Write("<script> alert('Đăng nhập thành công')</script>");
                Response.Redirect("~/admin/trangadmin.aspx");
                txttendangnhap.Focus();
                txttendangnhap.Text = "";
                break;

            case 1:
                Response.Write("<script>alert('Đăng nhập thành công')");
                Response.Redirect("Default.aspx");
                break;
            }
        }
        else
        {
            Response.Write("<script> alert('Sai tên đăng nhập hoặc mật khẩu')</script>");
            return;
        }

        //clDangKyTT dangky = new clDangKyTT();
        //if(dangky.kiemtraid(int value("1"))
        //{
        //    Response.Write("<script> alert('user')</script>");

        //}

        //else
        //{
        //    dangky.getID(txttendangnhap.Text,txtpassword.Text);
        //    Response.Redirect("tranguser.aspx");
        //}
    }