Esempio n. 1
0
        protected void load_data()
        {
            WEBBANHANG.Connect sp  = new WEBBANHANG.Connect();
            string             sql = "select * from TaiKhoan where KieuKH = '0'";

            sp.conect();
            sp.get(sql);
            spLoadAdmin.DataSource = sp.get(sql);
            spLoadAdmin.DataBind();
        }
Esempio n. 2
0
        protected void load_data()
        {
            WEBBANHANG.Connect sp  = new WEBBANHANG.Connect();
            string             sql = "select * from SanPham";

            sp.conect();
            sp.get(sql);
            spLoadAdmin.DataSource = sp.get(sql);
            spLoadAdmin.DataBind();
        }
        protected void btnDangky_Click(object sender, EventArgs e)
        {
            WEBBANHANG.Connect con = new WEBBANHANG.Connect();
            con.conect();
            string    sql  = "select * from TaiKhoan";
            DataTable tb   = con.getTK(sql);
            int       n    = int.Parse(tb.Rows.Count.ToString());
            bool      flag = true;

            for (int i = 0; i < n; i++)
            {
                if (tb.Rows[i]["TenKH"].ToString() == rsUser.Text)
                {
                    flag = false;
                    Response.Write("<script>alert('User đã tồn tại')</script>");
                    break;
                }
            }
            if (flag == true)
            {
                if (rsPass.Text != "" && rePass.Text != "")
                {
                    if (rsPass.Text == rePass.Text)
                    {
                        string _type  = "0";
                        string cmdStr = "insert into TaiKhoan(TenKH,Pass,Email,KieuKH)  values(N'" + rsUser.Text + "','" + rsPass.Text + "','" + email.Text + "','" + _type + "')";
                        con.ExeCuteNonQuery(cmdStr);
                        Response.Write("<script>alert('Đăng Ký thành công')</script>");
                        Response.Redirect("DangNhap.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('Đăng Ký Thất Bại')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Password/nhập lại password không được bỏ trống')</script>");
                }
            }
        }
        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            WEBBANHANG.Connect con = new WEBBANHANG.Connect();
            con.conect();
            string    cmdStr = "select * from TaiKhoan where tenKH='" + user.Text + "' and Pass='******'";
            DataTable tb     = con.getTK(cmdStr);
            string    _type  = "0";

            if (tb.Rows.Count > 0)
            {
                _type = tb.Rows[0]["kieuKH"].ToString();
                if (_type == "0")
                {
                    Session["IsLogin"] = 1;
                    Response.Write("<script>alert('Đăng nhập thành công')</script>");
                    Response.Redirect("Default.aspx");
                }
            }
            else
            {
                Response.Write("<script>alert('Username/Password chưa đúng " + _type + "')</script>");
            }
        }