Ejemplo n.º 1
0
 protected void btnGui_Click(object sender, EventArgs e)
 {
     if (taBinhLuan.Text.Trim() != "")
     {
         string    tendn = XLDL.MaHoa(Session["TenDN"].ToString());
         DataTable dt    = XLDL.LayDuLieu("select * from khachhang where TenDN='" + tendn + "'");
         if (dt.Rows.Count > 0)
         {
             int makh = int.Parse(dt.Rows[0][0].ToString());
             try
             {
                 SqlConnection con = new SqlConnection(XLDL.strcon);
                 SqlCommand    cmd = new SqlCommand("insert into binhluan(masp,makh,binhluan,thoigian) values('" + Request.QueryString["MaSP"] + "'," + makh + ",N'" + taBinhLuan.Text.Trim() + "',@thoigian)", con);
                 cmd.Parameters.Add("@thoigian", SqlDbType.DateTime);
                 cmd.Parameters["@thoigian"].Value = DateTime.Now;
                 con.Open();
                 cmd.ExecuteNonQuery();
                 con.Close();
             }
             catch { }
             taBinhLuan.Text = "";
             binhluan();
             slbl();
             CreateBanner();
         }
     }
     else
     {
         taBinhLuan.Text = "";
         CreateBanner();
     }
 }
Ejemplo n.º 2
0
 protected void LuuDN()
 {
     if (cbLuu.Checked)
     {
         HttpCookie cookie = new HttpCookie("Luu", "yes");
         Response.Cookies.Add(cookie);
         cookie = new HttpCookie("TenDNandPass");
         cookie.Values.Add("TenDN", XLDL.MaHoa(txtTen.Text.Trim().ToLower()));
         cookie.Values.Add("Pass", XLDL.MaHoa(txtMatkhau.Text.Trim()));
         Response.Cookies.Add(cookie);
     }
 }
Ejemplo n.º 3
0
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        string    chuoi = XLDL.MaHoa(txten.Text.Trim().ToLower());
        DataTable dt    = XLDL.LayDuLieu("select TenDN from khachhang where TenDN='" + chuoi + "'");

        if (dt.Rows.Count > 0)
        {
            string str1 = dt.Rows[0][0].ToString();
            if (chuoi == str1)
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
    }
Ejemplo n.º 4
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = XLDL.LayDuLieu("select * from admin where TenDN='" + XLDL.MaHoa(txtTenDN.Value.Trim().ToLower()) + "' and MatKhau = '" + XLDL.MaHoa(txtMatKhau.Value) + "'");
         if (dt.Rows.Count > 0)
         {
             Session["DNAdmin"] = txtTenDN.Value.Trim().ToLower();
             Response.Redirect("~/home.aspx");
         }
         else
         {
             lbThongbaoloi.Text = "Sai tên đăng nhập hoặc mật khẩu";
         }
     }
     catch
     {
         lbThongbaoloi.Text = "Đăng nhập thất bại";
     }
 }
Ejemplo n.º 5
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = XLDL.LayDuLieu("select * from khachhang where TenDN='" + XLDL.MaHoa(txtTen.Text.ToLower()) + "' and MatKhau = '" + XLDL.MaHoa(txtMatkhau.Text) + "'");
         if (dt.Rows.Count > 0)
         {
             Session["TenDN"] = txtTen.Text.Trim().ToLower();
             LuuDN();
             Response.Redirect(Session["url"].ToString());
         }
         else
         {
             lbThongbaoloi.Text = "Sai tên đăng nhập hoặc mật khẩu";
         }
     }
     catch
     {
         lbThongbaoloi.Text = "Đăng nhập thất bại";
     }
 }
Ejemplo n.º 6
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         XLDL.Chaylenh("insert into admin(HoTen,DiaChi,sdt,email,TenDN,MatKhau) values(N'" + txtHoTen.Text.Trim() + "',N'" + txtDiaChi.Text.Trim() + "','" + txtSDT.Text.Trim() + "','" + txtEmail.Text.Trim() + "','" + XLDL.MaHoa(txtTenDN.Text.ToLower().Trim()) + "','" + XLDL.MaHoa(txtMatKhau.Text.Trim()) + "')");
         Response.Redirect("~/quantrivien.aspx");
     }
     catch
     {
         lbThongbaoloi.Text = "Tên đăng nhập đã tồn tại, vui lòng thử lại với tên khác !";
     }
 }
Ejemplo n.º 7
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = new SqlConnection(XLDL.strcon);
         SqlCommand    cmd = new SqlCommand("insert into khachhang(HoTen,DiaChi,DienThoai,TenDN,MatKhau,email) values(N'" + txtHoTen.Text.Trim() + "',N'" + txtDiachi.Text.Trim() + "','" + txtSDT.Text.Trim() + "','" + XLDL.MaHoa(txten.Text.ToLower().Trim()) + "','" + XLDL.MaHoa(txtMatkhau.Text.Trim()) + "','" + txtEmail.Text.Trim() + "')", con);
         con.Open();
         cmd.ExecuteNonQuery();
         con.Close();
         XLDL.urlDangKy = HttpContext.Current.Request.Url.AbsoluteUri.ToString();
         Response.Redirect("~/Dangnhap.aspx");
     }
     catch
     {
         lbThongbaoloi.Text = "Lỗi, vui lòng thử lại !";
     }
 }
Ejemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["DNAdmin"] != null)
         {
             DataTable dt = XLDL.LayDuLieu("select hoten from admin where tendn='" + XLDL.MaHoa(Session["DNAdmin"].ToString()) + "'");
             if (dt.Rows.Count > 0)
             {
                 lbTenDN.Text = "Xin chào, " + dt.Rows[0][0].ToString();
             }
         }
         else
         {
             Response.Redirect("~/DangNhapAdMin.aspx");
         }
     }
 }
Ejemplo n.º 9
0
 protected void LuuThanhToan()
 {
     try
     {
         int           makh = int.Parse(XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0].ToString());
         SqlConnection con  = new SqlConnection(XLDL.strcon);
         SqlCommand    cmd  = new SqlCommand("insert into donhang(makh,ngaydh,tennguoinhan,diachinhan,sdtnhan,thanhtoan) values(" + makh + ",@ngaydh,N'" + txtTen.Text.Trim() + "',N'" + txtDiaChi.Text.Trim() + "','" + txtSDT.Text.Trim() + "'," + thanhtoan + ")", con);
         con.Open();
         cmd.Parameters.Add("@ngaydh", SqlDbType.DateTime);
         cmd.Parameters["@ngaydh"].Value = DateTime.Now;
         cmd.ExecuteNonQuery();
         con.Close();
         int       sodh = int.Parse(XLDL.LayDuLieu("select max(sodh) from donhang where makh=" + XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0]).Rows[0][0].ToString());
         DataTable dt   = (DataTable)Session["Giohang"];
         string    Masp;
         int       soluong;
         double    dongia, giamgia;
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             Masp    = XLDL.LayDuLieu("select masp from dienthoai where tensp='" + dt.Rows[i]["TenSP"].ToString().Trim() + "'").Rows[0][0].ToString();
             soluong = int.Parse(dt.Rows[i]["SoLuong"].ToString());
             dongia  = double.Parse(dt.Rows[i]["GiaBan"].ToString());
             if (dt.Rows[i]["GiamGia"].ToString() != "")
             {
                 giamgia = double.Parse(dt.Rows[i]["GiamGia"].ToString());
             }
             else
             {
                 giamgia = 0;
             }
             if (i == dt.Rows.Count - 1)
             {
                 mota += soluong.ToString() + " x " + dt.Rows[i]["TenSP"].ToString().Trim();
             }
             else
             {
                 mota += soluong.ToString() + "x" + dt.Rows[i]["TenSP"].ToString().Trim() + ", ";
             }
             XLDL.Chaylenh("insert into ctdonhang(sodh,masp,soluong,dongia,giamgia) values(" + sodh + ",'" + Masp + "'," + soluong + "," + dongia + "," + giamgia + ")");
         }
     }
     catch
     {
         Response.Write("<script>alert('Không thể đặt đơn hàng này')</script>");
     }
 }
Ejemplo n.º 10
0
 protected void LinkButton2_Click(object sender, EventArgs e)
 {
     if (Session["TenDN"] != null)
     {
         BaoKimPayment bk = new BaoKimPayment();
         thanhtoan = 1;
         LuuThanhToan();
         string   sodh      = XLDL.LayDuLieu("select max(sodh) from donhang where makh=" + XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0]).Rows[0][0].ToString();
         string   str       = lbTongCong.Text;
         string[] a         = str.Split(' ');
         double   thanhtien = Convert.ToDouble(a[2].Substring(0, a[2].Length - 1));
         string   chuoibk   = bk.createRequestUrl(sodh, SessionKey.Business, Convert.ToString(thanhtien), "0", "0", mota, "http://nguyenhoang.ga/thanhcong.aspx", "http://nguyenhoang.ga/thanhcong.aspx", "");
         Session["MHtoTC"]  = true;
         Session["Giohang"] = null;
         Response.Redirect(chuoibk);
     }
 }
Ejemplo n.º 11
0
 private void thongtin()
 {
     if (Session["TenDN"] != null)
     {
         DataTable dt = XLDL.LayDuLieu("select hoten, diachi, dienthoai, email from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'");
         if (dt.Rows.Count > 0)
         {
             txtTen.Text    = dt.Rows[0][0].ToString();
             txtDiaChi.Text = dt.Rows[0][1].ToString();
             txtSDT.Text    = dt.Rows[0][2].ToString();
             txtEmail.Text  = dt.Rows[0][3].ToString();
         }
     }
 }
Ejemplo n.º 12
0
 private void load()
 {
     lbmadh.Text = "#" + XLDL.LayDuLieu("select max(sodh) from donhang where makh=" + XLDL.LayDuLieu("select makh from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'").Rows[0][0]).Rows[0][0].ToString();
 }
Ejemplo n.º 13
0
    protected void dlBinhLuan_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Label      Label35 = (Label)e.Item.FindControl("Label35");
        LinkButton lThich  = (LinkButton)e.Item.FindControl("lThich");
        string     sl      = Label35.Text.Trim();

        if (e.CommandName == "Thich")
        {
            string chuoi;
            if (Session["TenDN"] != null)
            {
                DataTable dt = XLDL.LayDuLieu("select maKH from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'");
                string[]  a  = sl.Split(',');
                if (sl.Contains(dt.Rows[0][0].ToString()) == false)
                {
                    chuoi = dt.Rows[0][0].ToString();
                }
                else
                {
                    chuoi = "";
                }
                if (a.Length > 1)
                {
                    for (int i = 0; i < a.Length; i++)
                    {
                        if (a[i] == dt.Rows[0][0].ToString())
                        {
                            continue;
                        }
                        if (chuoi == "")
                        {
                            chuoi = a[i];
                            continue;
                        }
                        chuoi = chuoi + "," + a[i];
                    }
                }
                else
                {
                    if (a[0] != "")
                    {
                        if (chuoi != "")
                        {
                            chuoi = chuoi + "," + a[0];
                        }
                        else
                        {
                            chuoi = "";
                        }
                    }
                }
                XLDL.Chaylenh("update binhluan set thich='" + chuoi + "' where ID=" + (int)dlBinhLuan.DataKeys[e.Item.ItemIndex]);
            }
            binhluan();
            CreateBanner();
        }
    }
Ejemplo n.º 14
0
    protected void dlBinhLuan_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        Label lbHinh  = (Label)e.Item.FindControl("lbHinh");
        Label lbTen   = (Label)e.Item.FindControl("lbTenKH");
        Label lbSL    = (Label)e.Item.FindControl("lbSLThich");
        Label lbThich = (Label)e.Item.FindControl("lbThich");
        Label lbDot   = (Label)e.Item.FindControl("lbDot");
        Label Label35 = (Label)e.Item.FindControl("Label35");

        Label35.Visible = false;
        LinkButton lThich = (LinkButton)e.Item.FindControl("lThich");
        LinkButton lXoa   = (LinkButton)e.Item.FindControl("lXoa");
        string     sl     = lbSL.Text.Trim();

        if (sl != "")
        {
            string[] b = sl.Split(',');
            if (Session["TenDN"] != null)
            {
                DataTable dt = XLDL.LayDuLieu("select maKH from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'");
                for (int i = 0; i < b.Length; i++)
                {
                    if (b[i] == dt.Rows[0][0].ToString())
                    {
                        lThich.ForeColor = System.Drawing.Color.Blue;
                        lThich.Font.Bold = true;
                        break;
                    }
                }
                lThich.Visible  = true;
                lbThich.Visible = false;
            }
            else
            {
                lThich.Visible  = false;
                lbThich.Visible = true;
            }
            lbSL.Text = "(" + b.Length.ToString() + ")";
        }
        else
        {
            lbThich.Visible = false;
        }
        if (Session["TenDN"] != null)
        {
            DataTable dt   = XLDL.LayDuLieu("select maKH from khachhang where tendn='" + XLDL.MaHoa(Session["TenDN"].ToString()) + "'");
            int       id   = int.Parse(dlBinhLuan.DataKeys[e.Item.ItemIndex].ToString());
            int       makh = int.Parse(XLDL.LayDuLieu("select makh from binhluan where id=" + id).Rows[0][0].ToString());
            if (int.Parse(dt.Rows[0][0].ToString()) == makh)
            {
                lXoa.Visible  = true;
                lbDot.Visible = true;
            }
            else
            {
                lXoa.Visible  = false;
                lbDot.Visible = false;
            }
        }
        else
        {
            lXoa.Visible  = false;
            lbDot.Visible = false;
        }
        string str = lbTen.Text;

        string[] a = str.Split(' ');
        lbHinh.Text = a[a.Length - 1].Substring(0, 1);
    }