Ejemplo n.º 1
0
        protected void gvThongTinKH_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma = gvThongTinKH.Rows[chiso].Cells[0].Text;
                    DataTable dt = XLDL.GetData("select MaKH from KhachHang where MaKH='" + ma + "'");
                    if (dt.Rows.Count > 1)
                    {
                        lbBaoLoi.Text = "Khách hàng đang có bài viết nên không thể xóa.<br/> Bạn cần xóa hết các bài viết của khách hàng này trước";
                    }
                    else
                    {
                        string str = "delete from KhachHang where MaKH='" + ma + "'";
                        XLDL.Excute(str);
                        Response.Redirect("~/AD/KhachHang.aspx");
                    }
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
Ejemplo n.º 2
0
        private int countMess()
        {
            DataTable dt = new DataTable();

            dt = XLDL.GetData("select * from ThongTinLienHe where DaDuyet = 0");
            return(int.Parse(dt.Rows.Count.ToString()));
        }
Ejemplo n.º 3
0
        protected void gvNhaTro_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma = gvNhaTro.Rows[chiso].Cells[0].Text;
                    DataTable dt = XLDL.GetData("select MaNhaTro from NhaTroChoThue where MaNhaTro='" + ma + "'");
                    if (dt.Rows.Count > 1)
                    {
                        lbBaoLoi.Text = "Xóa thất bại";
                    }
                    else
                    {
                        XLDL.Excute("Delete HinhAnhChiTietNhaTro from HinhAnhChiTietNhaTro where HinhAnhChiTietNhaTro.MaNhaTro =" + ma);
                        XLDL.Excute("Delete DanhGia from DanhGia where DanhGia.MaNhaTro=" + ma);
                        XLDL.Excute("Delete NhaTroChoThue from NhaTroChoThue where NhaTroChoThue.MaNhaTro =" + ma);
                        Response.Redirect("~/AD/NhaTro.aspx");
                    }
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
Ejemplo n.º 4
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            String strSearch = txtTimKiem.Text;
            String sql, datenew;
            int    luotTruyCap = 1;

            datenew = DateTime.Now.ToString();
            DataTable dt = XLDL.GetData("select * from TimKiem where TuKhoa = '" + strSearch + "'");

            if (dt.Rows.Count > 0)
            {
                luotTruyCap = int.Parse(dt.Rows[0]["LuotTruyCap"].ToString());
                luotTruyCap++;
                sql = "UPDATE TimKiem SET LuotTruyCap = " + luotTruyCap + "" +
                      ", NgayNhapGanNhat = '" + datenew +
                      "' WHERE TuKhoa = '" + strSearch + "'";
                XLDL.GetData(sql);
            }
            else
            {
                sql = "INSERT INTO TimKiem VALUES('" + strSearch + "'" +
                      "," + luotTruyCap + "" +
                      ",'" + datenew + "')";
                XLDL.GetData(sql);
            }
            Response.Redirect("~/SP_Search.aspx?Search=" + strSearch + "");
        }
Ejemplo n.º 5
0
    private void LayThongTin(string ms)
    {
        string    str = "Select S.*, TenChuDe FROM HOA S INNER JOIN CHUDE C ON S.MaCD=C.MaCD WHERE S.MaHoa=" + int.Parse(ms);
        DataTable dt  = XLDL.GetData(str);

        if (dt.Rows.Count > 0)
        {
            dlChiTietHoa.DataSource = dt;
            dlChiTietHoa.DataBind();
        }
    }
Ejemplo n.º 6
0
        public void GH()
        {
            DataTable dt = new DataTable();

            //maSP = Request.QueryString["MaSP"].ToString();

            dt = XLDL.GetData("select Ma_SP,TenSP,DonGia,Image from San_Pham inner join San_Pham_Image on Ma_SP = MaSP where Ma_SP= '" + maSP + "' and Position = 0 ");
            string TenSP   = dt.Rows[0][1].ToString();
            float  DonGia  = float.Parse(dt.Rows[0][2].ToString());
            String Image   = "/Image/San_Pham/" + dt.Rows[0][3].ToString() + ".jpg";
            int    SoLuong = 1;

            new Product_Des().ThemVaoGioHang(maSP, TenSP, DonGia, SoLuong, Image);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Ma"] != null)
         {
             string    MaQH = Request.QueryString["Ma"].ToString();
             string    sql  = "select [MaTinh],[TenQH] from QuanHuyen where MaQH='" + MaQH + "'";
             DataTable dt   = XLDL.GetData(sql);
             txtMaTinh.Text       = dt.Rows[0]["MaTinh"].ToString();
             txtTenQuanHuyen.Text = dt.Rows[0]["TenQH"].ToString();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Ma"] != null)
         {
             string    MaPX = Request.QueryString["Ma"].ToString();
             string    sql  = "select [MaQH],[TenPhuongXa] from PhuongXa where MaPX='" + MaPX + "'";
             DataTable dt   = XLDL.GetData(sql);
             txtMaQH.Text     = dt.Rows[0]["MaQH"].ToString();
             txtPhuongXa.Text = dt.Rows[0]["TenPhuongXa"].ToString();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Ma"] != null)
         {
             string    MaAD = Request.QueryString["Ma"].ToString();
             string    sql  = "select [TenTK],[MatKhau],[SDT_Admin] from NguoiQuanLi where ID_Admin='" + MaAD + "'";
             DataTable dt   = XLDL.GetData(sql);
             txtTaiKhoanAD.Text = dt.Rows[0]["TenTK"].ToString();
             txtMatKhauAD.Text  = dt.Rows[0]["MatKhau"].ToString();
             txtSDT_AD.Text     = dt.Rows[0]["SDT_Admin"].ToString();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Ma"] != null)
         {
             string    MaKH = Request.QueryString["Ma"].ToString();
             string    sql  = "select [TenKH],[SDT],[Email],[MatKhau],[TenTK] from KhachHang where MaKH='" + MaKH + "'";
             DataTable dt   = XLDL.GetData(sql);
             txtTenKH.Text    = dt.Rows[0]["TenKH"].ToString();
             txtSDT.Text      = dt.Rows[0]["SDT"].ToString();
             txtEmail.Text    = dt.Rows[0]["Email"].ToString();
             txtMatKhau.Text  = dt.Rows[0]["MatKhau"].ToString();
             txtTaiKhoan.Text = dt.Rows[0]["TenTK"].ToString();
         }
     }
 }
Ejemplo n.º 11
0
    protected void btDangKy_Click(object sender, EventArgs e)
    {
        try
        {
            string str1 = @"Select 1 from Khachhang Where tenDN=N'" + txtTenDN.Text + "'";
            if (XLDL.GetData(str1).Rows.Count > 0)
            {
                lbThongBaoLoi.Text = "Tên đăng nhập đã tồn tại.";
                txtTenDN.Focus();
            }
            else
            {
                SqlConnection con = new SqlConnection(XLDL.strCon);
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = con;
                cmd.CommandText = @"INSERT INTO KHACHHANG (HoTenKH,DiaChiKH,DienThoaiKH,Email,TenDN,MatKhau,NgaySinh,GioiTinh) VALUES(@Hoten,@Diachi,@Dienthoai,@Email,@TenDN,@Matkhau,@Ngaysinh,@Gioitinh)";
                cmd.Parameters.Add("@Hoten", SqlDbType.NVarChar, 50);
                cmd.Parameters["@Hoten"].Value = txtHoTen.Text;
                cmd.Parameters.Add("@Diachi", SqlDbType.NVarChar, 50);
                cmd.Parameters["@Diachi"].Value = txtDiaChi.Text;
                cmd.Parameters.Add("@Dienthoai", SqlDbType.VarChar, 10);
                cmd.Parameters["@Dienthoai"].Value = txtDienThoai.Text;
                cmd.Parameters.Add("@Email", SqlDbType.VarChar, 50);
                cmd.Parameters["@Email"].Value = txtEmail.Text;
                cmd.Parameters.Add("@TenDN", SqlDbType.VarChar, 15);
                cmd.Parameters["@TenDN"].Value = txtTenDN.Text;
                cmd.Parameters.Add("@Matkhau", SqlDbType.VarChar, 15);
                cmd.Parameters["@Matkhau"].Value = txtMatKhau.Text;
                cmd.Parameters.Add("@Ngaysinh", SqlDbType.SmallDateTime);
                cmd.Parameters["@Ngaysinh"].Value = DateTime.Parse(ddlThangSinh.Text + "/" + ddlNgaySinh.Text + "/" + txtNamSinh.Text);
                cmd.Parameters.Add("@Gioitinh", SqlDbType.Int);
                cmd.Parameters["@Gioitinh"].Value = Convert.ToInt16(rblGioiTinh.SelectedItem.Value);
                cmd.ExecuteNonQuery();

                con.Close();

                Response.Redirect("~/Dangnhap.aspx");
            }
        }
        catch
        {
            lbThongBaoLoi.Text = "Thất bại!";
        }
    }
Ejemplo n.º 12
0
        private void getSP()
        {
            DataTable dt = new DataTable();

            dt = XLDL.GetData("select * from San_Pham S join San_Pham_Image I on S.Ma_SP = I.MaSP where Position = 0 order by DaBan desc");

            //maSP = dt.Rows[0]["Ma_SP"].ToString();

            p.DataSource       = dt.DefaultView;
            p.PageSize         = 8;
            p.CurrentPageIndex = trang_thu;
            p.AllowPaging      = true;

            btnFirst.Enabled = true;
            btnLast.Enabled  = true;
            btnnext.Enabled  = true;
            btnpre.Enabled   = true;

            if (p.IsFirstPage == true)//neu la dau.

            {
                btnFirst.Enabled = false;//neu la trang dau thi hai nut mo di.

                btnpre.Enabled = false;

                btnnext.Enabled = true;//Hai nut sau sang len.

                btnLast.Enabled = true;
            }
            if (p.IsLastPage == true)//neu la cuoi

            {
                btnFirst.Enabled = true;//nguoc lai

                btnpre.Enabled = true;

                btnnext.Enabled = false;

                btnLast.Enabled = false;
            }
            txtPage.Text      = (trang_thu + 1).ToString();
            txtMaxPage.Text   = p.PageCount.ToString();
            dtSPNB.DataSource = p;
            dtSPNB.DataBind();
        }
Ejemplo n.º 13
0
        protected void gvTinTuc_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int chiso = int.Parse(e.CommandArgument.ToString());
            int ma    = int.Parse(gvTinTuc.Rows[chiso].Cells[0].Text);

            if (e.CommandName == "Xoa")
            {
                try
                {
                    DataTable dt = XLDL.GetData("select * from BLTinTuc where MaTin = " + ma);
                    if (dt.Rows.Count > 0)
                    {
                        Response.Write("<script>alert('Không thể xóa tin này. Bạn cần xóa hêt bình luận có trong tin này trước')</script>");
                    }
                    else
                    {
                        dt = XLDL.GetData("delete from TinTuc where MaTin =" + ma);
                        lbThongBao.Text = "Xóa thành công";
                        capnhat();
                    }
                }
                catch
                {
                    Response.Write("<script>alert('Có lỗi trong quá trình xóa')</script>");
                }
            }
            if (e.CommandName == "Duyet")
            {
                int duyet = 1;
                try
                {
                    string str1 = @"Update TinTuc set Duyet = " + duyet + " where MaTin = " + ma;
                    XLDL.Execute(str1);
                    lbThongBao.Text = "Đã duyệt";
                    capnhat();
                }
                catch
                {
                    lbThongBao.Text = "Cập nhật thất bại";
                }
            }
        }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaNT = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [MaKH],[TinhThanh],[QuanHuyen],[PhuongXa],[SoNha],[DiaChi],[SDTNguoiChoThue],[MoTa],[GiaChoThue],[DienTich],[TieuDe] from NhaTroChoThue where  MaNhaTro='" + MaNT + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update NhaTroChoThue set MaKH=" + txtMaKH.Text + ",TinhThanh=N'" + txtTinhThanh.Text + "',QuanHuyen=N'" + txtQuanHuyen.Text + "',PhuongXa=N'" + txtPhuongXa.Text + "',SoNha=N'" + txtSoNha.Text + "',DiaChi=N'" + txtDiaChi.Text + "',SDTnguoiChoThue='" + txtSDT.Text + "',MoTa=N'" + txtMoTa.Text + "',GiaChoThue='" + txtGiaChoThue.Text + "',DienTich='" + txtDienTich.Text + "',TieuDe=N'" + txtTieuDe.Text + "' where  MaNhaTro='" + MaNT + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaQH = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [MaTinh],[TenQH] from QuanHuyen where  MaQH='" + MaQH + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update QuanHuyen set MaTinh='" + txtMaTinh.Text + "',TenQH=N'" + txtTenQuanHuyen.Text + "' where  MaQH='" + MaQH + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaAD = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [TenTK],[MatKhau],[SDT_Admin] from NguoiQuanLi where  ID_Admin='" + MaAD + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update NguoiQuanLi set TenTK=N'" + txtTaiKhoanAD.Text + "',MatKhau='" + txtMatKhauAD.Text + "',SDT_Admin='" + txtSDT_AD.Text + "' where ID_Admin='" + MaAD + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaKH = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [TenKH],[SDT],[Email],[MatKhau],[TenTK] from KhachHang where  MaKH='" + MaKH + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update KhachHang set TenKH=N'" + txtTenKH.Text + "',SDT='" + txtSDT.Text + "',Email='" + txtEmail.Text + "',MatKhau='" + txtMatKhau.Text + "',TenTK='" + txtTaiKhoan.Text + "' where  MaKH='" + MaKH + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaPX = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select [MaQH],[TenPhuongXa] from PhuongXa where MaPX='" + MaPX + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update PhuongXa set MaQH='" + txtMaQH.Text + "',TenPhuongXa=N'" + txtPhuongXa.Text + "' where  MaPX='" + MaPX + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
        protected void gvQuanTriVIen_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma  = gvQuanTriVIen.Rows[chiso].Cells[0].Text;
                    DataTable dt  = XLDL.GetData("select ID_Admin from NguoiQuanLi where ID_Admin='" + ma + "'");
                    string    str = "delete from NguoiQuanLi where ID_Admin='" + ma + "'";
                    XLDL.Excute(str);
                    Response.Redirect("~/AD/QuanTriVien.aspx");
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["Ma"] != null)
         {
             string    MaNT = Request.QueryString["Ma"].ToString();
             string    sql  = "select [MaKH],[TinhThanh],[QuanHuyen],[PhuongXa],[SoNha],[DiaChi],[SDTNguoiChoThue],[MoTa],[GiaChoThue],[DienTich],[TieuDe] from NhaTroChoThue where MaNhaTro='" + MaNT + "'";
             DataTable dt   = XLDL.GetData(sql);
             txtMaKH.Text       = dt.Rows[0]["MaKH"].ToString();
             txtTinhThanh.Text  = dt.Rows[0]["TinhThanh"].ToString();
             txtQuanHuyen.Text  = dt.Rows[0]["QuanHuyen"].ToString();
             txtPhuongXa.Text   = dt.Rows[0]["PhuongXa"].ToString();
             txtSoNha.Text      = dt.Rows[0]["SoNha"].ToString();
             txtDiaChi.Text     = dt.Rows[0]["DiaChi"].ToString();
             txtSDT.Text        = dt.Rows[0]["SDTNguoiChoThue"].ToString();
             txtMoTa.Text       = dt.Rows[0]["MoTa"].ToString();
             txtGiaChoThue.Text = dt.Rows[0]["GiaChoThue"].ToString();
             txtDienTich.Text   = dt.Rows[0]["DienTich"].ToString();
             txtTieuDe.Text     = dt.Rows[0]["TieuDe"].ToString();
         }
     }
 }
Ejemplo n.º 21
0
 private void chuaduyet()
 {
     gvTinTuc.DataSource = XLDL.GetData("select * from TinTuc where Duyet='0' order by NgayDang DESC ");
     gvTinTuc.DataBind();
 }
Ejemplo n.º 22
0
        private void laylogo()
        {
            DataTable dt1 = XLDL.GetData("select * from LoGo");

            Image1.ImageUrl = "~/Images/Logo/" + dt1.Rows[0][0].ToString();
        }
Ejemplo n.º 23
0
 protected void Page_Load(object sender, EventArgs e)
 {
     dlTinMoi.DataSource = XLDL.GetData("SELECT top 5 [TieuDe], [MaNhaTro] FROM [NhaTroChoThue] ORDER BY [MaNhaTro] DESC");
     dlTinMoi.DataBind();
 }
Ejemplo n.º 24
0
 private void chuaduyet()
 {
     gvDangBan.DataSource = XLDL.GetData("select * from BaiDang where Duyet='0' order by NgayDang DESC ");
     gvDangBan.DataBind();
 }
Ejemplo n.º 25
0
 private void getMenuSP()
 {
     dtMenuSP.DataSource = XLDL.GetData("select * from Hang_San_Xuat");
     dtMenuSP.DataBind();
 }