protected void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt  = XLDL.GetData("select TenKH,MaKH from KhachHang where TenTK='" + txtDangNhap.Text + "'and MatKhau='" + txtMatKhau.Text + "'");
         DataTable dt1 = XLDL.GetData("select * from NguoiQuanLi where TenTK='" + txtDangNhap.Text + "'and MatKhau='" + txtMatKhau.Text + "'");
         if (dt.Rows.Count > 0)
         {
             Session["TenKH"]  = dt.Rows[0]["TenKH"];
             Session["MaKH"]   = dt.Rows[0]["MaKH"];
             Session["TenTK"]  = txtDangNhap.Text;
             Session["LoaiTK"] = 1;
             Response.Redirect("~/Default.aspx");
         }
         else
         {
             if (dt1.Rows.Count > 0)
             {
                 Session["TenTK"]  = txtDangNhap.Text;
                 Session["LoaiTK"] = 0;
                 Response.Redirect("~/Default.aspx");
             }
             else
             {
                 lbThongBaoLoi.Text = "Tên đăng nhập hoặc mật khẩu không hợp lệ!";
             }
         }
     }
     catch
     {
         lbThongBaoLoi.Text = "Thất bại!";
     }
 }
 public void load_data()
 {
     p.DataSource        = XLDL.GetData(sql).DefaultView;
     p.PageSize          = 10;
     p.CurrentPageIndex  = trang_thu;
     p.AllowPaging       = true;
     btnTrangDau.Enabled = true; btnTruoc.Enabled = true; btnSau.Enabled = true; btnTrangCuoi.Enabled = true;
     if (p.IsFirstPage == true && p.IsLastPage == true)
     {
         btnTrangDau.Enabled  = false;
         btnTruoc.Enabled     = false;
         btnSau.Enabled       = false;
         btnTrangCuoi.Enabled = false;
     }
     else
     {
         if (p.IsFirstPage == true)
         {
             btnTrangDau.Enabled  = false;
             btnTruoc.Enabled     = false;
             btnSau.Enabled       = true;
             btnTrangCuoi.Enabled = true;
         }
         if (p.IsLastPage == true)
         {
             btnTrangDau.Enabled  = true;
             btnTruoc.Enabled     = true;
             btnSau.Enabled       = false;
             btnTrangCuoi.Enabled = false;
         }
     }
     lbTrang.Text          = (trang_thu + 1) + " / " + p.PageCount;
     dlPhongTro.DataSource = p;
     dlPhongTro.DataBind();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["TenTK"] != null)
            {
                int MaKH = int.Parse(Session["MaKH"].ToString());
                if (!IsPostBack)
                {
                    drpTinhThanh_Load();
                    drpQuanHuyen_Load();
                    drpPhuongXa_Load();
                    DataTable dt = XLDL.GetData("select MaKH,TenKH,SDT from KhachHang where MaKH=" + MaKH);
                    dlTTKH.DataSource = dt;
                    dlTTKH.DataBind();
                    txtThongTinLienHe.Text = dt.Rows[0][2].ToString();
                }
                if (txtSoNgay.Text != "")
                {
                    int s = int.Parse(txtSoNgay.Text) * 2000;
                    lbThanhTien.Text = s.ToString();
                }
                else
                {
                    lbThanhTien.Text = "0";
                }


                if (drpTinhThanh.SelectedItem.Text == "Tất cả")
                {
                    txtDiaChiChinhXac.Text = "";
                }
                else
                {
                    if (drpQuanHuyen.SelectedItem.Text == "Quận/Huyện" || drpQuanHuyen.SelectedItem.Text == "Tất cả")
                    {
                        txtDiaChiChinhXac.Text = drpTinhThanh.SelectedItem.Text;
                    }
                    else
                    {
                        if (drpPhuongXa.SelectedItem.Text == "Phường/Xã")
                        {
                            txtDiaChiChinhXac.Text = drpQuanHuyen.SelectedItem.Text + "," + txtDiaChiChinhXac.Text;
                        }
                        else if (drpPhuongXa.SelectedItem.Text != "Tất cả")
                        {
                            txtDiaChiChinhXac.Text = drpPhuongXa.SelectedItem.Text + "," + drpQuanHuyen.SelectedItem.Text + "," + drpTinhThanh.SelectedItem.Text;
                        }
                    }
                }
                txtDuong_TextChanged(sender, e);
                txtSoNha_TextChanged(sender, e);
            }
            else
            {
                Response.Redirect("~/DangNhap.aspx");
            }
        }
        protected void drpTinhThanh_Load()
        {
            DataTable dt = XLDL.GetData("Select * from TinhThanh");

            dt.Rows.Add(0, "Tất cả");
            drpTinhThanh.DataSource     = dt;
            drpTinhThanh.DataTextField  = "TenTinh";
            drpTinhThanh.DataValueField = "MaTinh";
            drpTinhThanh.DataBind();
            drpTinhThanh.SelectedIndex = dt.Rows.Count - 1;
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string MaNT = Request.QueryString["MaNT"];

            dlHinhChiTietNhaTro.DataSource = XLDL.GetData("select HinhAnh from HinhAnhChiTietNhaTro where MaNhaTro='" + MaNT + "'");
            dlHinhChiTietNhaTro.DataBind();
            dlDanhGia.DataSource = XLDL.GetData("SELECT DanhGia, TenKH FROM DanhGia WHERE MaNhaTro='" + MaNT + "'");
            dlDanhGia.DataBind();
            dlChiTietPhongTro.DataSource = XLDL.GetData("select kh.TenKH,nt.SDTNguoiChoThue,nt.DiaChi,nt.MoTa,nt.GiaChoThue,nt.DienTich,nt.TieuDe from KhachHang kh, NhaTroChoThue nt where nt.MaNhaTro ='" + MaNT + "' and nt.MaKH = kh.MaKH");
            dlChiTietPhongTro.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["TenTK"] != null)
     {
         int       MaKH = int.Parse(Session["MaKH"].ToString());
         DataTable dt   = XLDL.GetData("select MaKH,TenKH,SDT from KhachHang where MaKH=" + MaKH);
         dlTTKH.DataSource = dt;
         dlTTKH.DataBind();
         dlPhongTro.DataSource = XLDL.GetData("SELECT[TieuDe], [DiaChi], [DienTich], [GiaChoThue], [HinhAnh], [MaNhaTro] FROM [NhaTroChoThue] WHERE MaKH=" + MaKH);
         dlPhongTro.DataBind();
     }
 }
Beispiel #7
0
 protected void btnXoaBNai_Click(object sender, EventArgs e)
 {
     try
     {
         int MaKH = int.Parse(Session["MaKH"].ToString());
         int MaNT = int.Parse(Request.QueryString["MaNT"]);
         XLDL.Excute("Delete HinhAnhChiTietNhaTro from HinhAnhChiTietNhaTro where HinhAnhChiTietNhaTro.MaNhaTro =" + MaNT);
         XLDL.Excute("Delete DanhGia from DanhGia where DanhGia.MaNhaTro=" + MaNT);
         XLDL.Excute("Delete NhaTroChoThue from NhaTroChoThue where NhaTroChoThue.MaNhaTro =" + MaNT);
         Response.Redirect("~/QuanLiBaiDang.aspx");
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
Beispiel #8
0
 protected void btnCapNhat_Click(object sender, EventArgs e)
 {
     try
     {
         int       MaNT = int.Parse(Request.QueryString["MaNT"]);
         DataTable dt   = XLDL.GetData("select [TinhThanh],[QuanHuyen],[PhuongXa],[TenDuong],[LoaiNT],[SoNha],[DiaChi],[SDTNguoiChoThue],[MoTa],[GiaChoThue],[DienTich],[TieuDe] from NhaTroChoThue where  MaNhaTro='" + MaNT + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update NhaTroChoThue set TenDuong=N'" + txtDuong.Text + "',SoNha=N'" + txtSoNha.Text + "', DiaChi=N'" + txtDiaChiChinhXac.Text + "',LoaiNT='" + drpLoaiNT.SelectedValue + "',TieuDe=N'" + txtTieuDe.Text + "',MoTa=N'" + txtMoTa.Text + "',SDTNguoiChoThue='" + txtThongTinLienHe.Text + "',GiaChoThue='" + txtGiaChoThue.Text + "',DienTich='" + txtDienTich.Text + "' where  MaNhaTro='" + MaNT + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["MaKH"] != null)
         {
             string MaKH = Session["MaKH"].ToString();
             dlTTKH.DataSource = XLDL.GetData("select MaKH,TenKH,SDT,Email from KhachHang where MaKH='" + MaKH + "'");;
             dlTTKH.DataBind();
             string    sql = "select [MaKH],[TenKH],[SDT],[Email] from KhachHang where MaKH='" + MaKH + "'";
             DataTable dt  = XLDL.GetData(sql);
             txtMaKH.Text  = dt.Rows[0]["MaKH"].ToString();
             txtSDT.Text   = dt.Rows[0]["SDT"].ToString();
             txtTenKH.Text = dt.Rows[0]["TenKH"].ToString();
             txtEmail.Text = dt.Rows[0]["Email"].ToString();
         }
     }
 }
Beispiel #10
0
        public void XLNgayHetHan()
        {
            DataTable dt    = XLDL.GetData("SELECT [MaNhaTro], [NgayHetHan] FROM [NhaTroChoThue]");
            DateTime  dtNow = DateTime.Now;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                int      MaNT = (int)dt.Rows[i][0];
                DateTime NHH  = (DateTime)dt.Rows[i]["NgayHetHan"];
                if (DateTime.Compare(NHH, dtNow) < 0)
                {
                    XLDL.Excute("Delete HinhAnhChiTietNhaTro from HinhAnhChiTietNhaTro where HinhAnhChiTietNhaTro.MaNhaTro =" + MaNT);
                    XLDL.Excute("Delete DanhGia from DanhGia where DanhGia.MaNhaTro=" + MaNT);
                    XLDL.Excute("Delete NhaTroChoThue from NhaTroChoThue where NhaTroChoThue.MaNhaTro =" + MaNT);
                }
                ;
            }
        }
        protected void drpQuanHuyen_Load()
        {
            int MaTinh = int.Parse(drpTinhThanh.SelectedValue.ToString());

            if (MaTinh == 0)
            {
                drpQuanHuyen.Items.Add("Tất cả");
            }
            else
            {
                DataTable dt = XLDL.GetData("Select * from QuanHuyen where MaTinh=" + MaTinh);
                dt.Rows.Add(0, 0, "Quận/Huyện");
                drpQuanHuyen.DataSource     = dt;
                drpQuanHuyen.DataValueField = "MaQH";
                drpQuanHuyen.DataTextField  = "TenQH";
                drpQuanHuyen.DataBind();
                drpQuanHuyen.SelectedIndex = dt.Rows.Count - 1;
            }
        }
Beispiel #12
0
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = XLDL.GetData("select TenTK from KhachHang where TenTK='" + txtTenDN.Text + "' and MatKhau='" + txtMatKhauCu.Text + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute("UPDATE KhachHang set MatKhau='" + txtMatKhauMoi.Text + "'where TenTK='" + txtTenDN.Text + "'");
             lbThongBaoLoi.Text = "Đổi mật khẩu thành công";
         }
         else
         {
             lbThongBaoLoi.Text = "Tên đăng nhập hoặc mật khẩu cũ không hợp lệ!";
         }
     }
     catch
     {
         lbThongBaoLoi.Text = "Thất bại";
     }
 }
        protected void drpPhuongXa_Load()
        {
            string str = drpQuanHuyen.SelectedItem.Text;

            if (str != "Tất cả")
            {
                int       MaQH = int.Parse(drpQuanHuyen.SelectedValue.ToString());
                DataTable dt   = XLDL.GetData("Select * from PhuongXa where MaQH=" + MaQH);
                dt.Rows.Add(0, 0, "Phường/Xã");
                drpPhuongXa.DataSource     = dt;
                drpPhuongXa.DataValueField = "MaPX";
                drpPhuongXa.DataTextField  = "TenPhuongXa";
                drpPhuongXa.DataBind();
                drpPhuongXa.SelectedIndex = dt.Rows.Count - 1;
            }
            else
            {
                drpPhuongXa.Items.Add("Tất cả");
            }
        }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaKH = Session["MaKH"].ToString();
         DataTable dt   = XLDL.GetData("select  [TenKH],[Email] from KhachHang where  MaKH='" + MaKH + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update KhachHang set TenKH=N'" + txtTenKH.Text + "',Email='" + txtEmail.Text + "' where  MaKH='" + MaKH + "'");
             Session["TenKH"] = txtTenKH.Text;
             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";
     }
 }
Beispiel #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["TenTK"] != null)
     {
         int MaKH = int.Parse(Session["MaKH"].ToString());
         int MaNT = int.Parse(Request.QueryString["MaNT"]);
         if (!IsPostBack)
         {
             DataTable dt = XLDL.GetData("select MaKH,TenKH,SDT from KhachHang where MaKH=" + MaKH);
             dlTTKH.DataSource = dt;
             dlTTKH.DataBind();
             DataTable dtNT = XLDL.GetData("select * from NhaTroChoThue where MaNhaTro= " + MaNT);
             txtTinhThanh.Text      = dtNT.Rows[0]["TinhThanh"].ToString();
             txtQuanHuyen.Text      = dtNT.Rows[0]["QuanHuyen"].ToString();
             txtPhuongXa.Text       = dtNT.Rows[0]["PhuongXa"].ToString();
             txtSoNha.Text          = dtNT.Rows[0]["SoNha"].ToString();
             txtDuong.Text          = dtNT.Rows[0]["TenDuong"].ToString();
             txtDiaChiChinhXac.Text = dtNT.Rows[0]["DiaChi"].ToString();
             if (dtNT.Rows[0]["LoaiNT"].ToString() == "Phòng trọ cho thuê")
             {
                 drpLoaiNT.SelectedIndex = 1;
             }
             else
             {
                 drpLoaiNT.SelectedIndex = 0;
             }
             txtTieuDe.Text         = dtNT.Rows[0]["TieuDe"].ToString();
             txtMoTa.Text           = dtNT.Rows[0]["MoTa"].ToString();
             txtThongTinLienHe.Text = dtNT.Rows[0]["SDTNguoiChoThue"].ToString();
             txtGiaChoThue.Text     = dtNT.Rows[0]["GiaChoThue"].ToString();
             txtDienTich.Text       = dtNT.Rows[0]["DienTich"].ToString();
         }
     }
     else
     {
         Response.Redirect("~/DangNhap.aspx");
     }
 }
Beispiel #16
0
 protected void btnDangKy_Click(object sender, EventArgs e)
 {
     try
     {
         string strl = @"select 1 from KhachHang where TenTK='" + txtTenTK.Text + "'";
         if (XLDL.GetData(strl).Rows.Count > 0)
         {
             lbThongBaoLoi.Text = "Tên đăng nhập đã tồn tại.";
             txtTenTK.Focus();
         }
         else
         {
             SqlConnection con = new SqlConnection(XLDL.strCon);
             con.Open();
             SqlCommand cmd = new SqlCommand();
             cmd.CommandType = System.Data.CommandType.Text;
             cmd.Connection  = con;
             cmd.CommandText = @"INSERT INTO KhachHang(TenKH,SDT,Email,MatKhau,TenTK) values (@TenKH,@SDT,@Email,@MatKhau,@TenTK)";
             cmd.Parameters.Add("@TenKH", SqlDbType.NVarChar, 50);
             cmd.Parameters["@TenKH"].Value = txtHoTen.Text;
             cmd.Parameters.Add("@SDT", SqlDbType.VarChar, 12);
             cmd.Parameters["@SDT"].Value = txtDienthoai.Text;
             cmd.Parameters.Add("@Email", SqlDbType.VarChar, 30);
             cmd.Parameters["@Email"].Value = txtEmail.Text;
             cmd.Parameters.Add("@MatKhau", SqlDbType.VarChar, 20);
             cmd.Parameters["@MatKhau"].Value = txtMatKhau.Text;
             cmd.Parameters.Add("@TenTK", SqlDbType.VarChar, 15);
             cmd.Parameters["@TenTK"].Value = txtTenTK.Text;
             cmd.ExecuteNonQuery();
             con.Close();
             Response.Redirect("~/DangNhap.aspx");
         }
     }
     catch
     {
         lbThongBaoLoi.Text = "Thất bại!";
     }
 }
        protected void btnDangBai_Click(object sender, EventArgs e)
        {
            HttpFileCollection _HttpFileCollection = Request.Files;
            HttpPostedFile     HttpPostedFile      = _HttpFileCollection[0];
            int           MaKH = int.Parse(Session["MaKH"].ToString());
            DateTime      NgayDang = DateTime.Now, NgayHetHan = NgayDang.AddDays(int.Parse(txtSoNgay.Text));
            SqlConnection con = new SqlConnection(XLDL.strCon);

            con.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con;
            cmd.CommandText = @"Insert into NhaTroChoThue(MaKH,TinhThanh,QuanHuyen,PhuongXa,TenDuong,SoNha,DiaChi,LoaiNT,SDTNguoiChoThue,MoTa,GiaChoThue,DienTich,HinhAnh,NgayDang,NgayHetHan,TieuDe)
                                values(@MaKH,@TinhThanh,@QuanHuyen,@PhuongXa,@TenDuong,@SoNha,@DiaChi,@LoaiNT,@SDTNguoiChoThue,@MoTa,@GiaChoThue,@DienTich,@HinhAnh,@NgayDang,@NgayHetHan,@TieuDe)";
            cmd.Parameters.Add("@MaKH", SqlDbType.Int);
            cmd.Parameters["@MaKH"].Value = MaKH;
            cmd.Parameters.Add("@TinhThanh", SqlDbType.NVarChar, 25);
            cmd.Parameters["@TinhThanh"].Value = drpTinhThanh.SelectedItem.Text;
            cmd.Parameters.Add("@QuanHuyen", SqlDbType.NVarChar, 25);
            cmd.Parameters["@QuanHuyen"].Value = drpQuanHuyen.SelectedItem.Text;
            cmd.Parameters.Add("@PhuongXa", SqlDbType.NVarChar, 50);
            cmd.Parameters["@PhuongXa"].Value = drpPhuongXa.SelectedItem.Text;
            cmd.Parameters.Add("@TenDuong", SqlDbType.NVarChar, 25);
            cmd.Parameters["@TenDuong"].Value = txtDuong.Text;
            cmd.Parameters.Add("@SoNha", SqlDbType.NVarChar, 50);
            cmd.Parameters["@SoNha"].Value = txtSoNha.Text;
            cmd.Parameters.Add("@DiaChi", SqlDbType.NVarChar, 100);
            cmd.Parameters["@DiaChi"].Value = txtDiaChiChinhXac.Text;;
            cmd.Parameters.Add("@LoaiNT", SqlDbType.NVarChar, 30);
            cmd.Parameters["@LoaiNT"].Value = drpLoaiNT.SelectedItem.Text;
            cmd.Parameters.Add("@SDTNguoiChoThue", SqlDbType.NVarChar, 12);
            cmd.Parameters["@SDTNguoiChoThue"].Value = txtThongTinLienHe.Text;
            cmd.Parameters.Add("@MoTa", SqlDbType.NText);
            cmd.Parameters["@MoTa"].Value = txtMoTa.Text;
            cmd.Parameters.Add("@GiaChoThue", SqlDbType.Int);
            cmd.Parameters["@GiaChoThue"].Value = int.Parse(txtGiaChoThue.Text);
            cmd.Parameters.Add("@DienTich", SqlDbType.Int);
            cmd.Parameters["@DienTich"].Value = int.Parse(txtDienTich.Text);
            cmd.Parameters.Add("@HinhAnh", SqlDbType.NVarChar, 50);
            cmd.Parameters["@HinhAnh"].Value = HttpPostedFile.FileName.ToString();
            cmd.Parameters.Add("@NgayDang", SqlDbType.SmallDateTime);
            cmd.Parameters["@NgayDang"].Value = NgayDang;
            cmd.Parameters.Add("@NgayHetHan", SqlDbType.SmallDateTime);
            cmd.Parameters["@NgayHetHan"].Value = NgayHetHan;
            cmd.Parameters.Add("@TieuDe", SqlDbType.NVarChar, 100);
            cmd.Parameters["@TieuDe"].Value = txtTieuDe.Text;
            cmd.ExecuteNonQuery();
            con.Close();
            DataTable     dt   = XLDL.GetData("select max(MaNhaTro) from NhaTroChoThue ");
            int           MaNT = int.Parse(dt.Rows[0][0].ToString());
            SqlConnection con1 = new SqlConnection(XLDL.strCon);

            con1.Open();
            SqlCommand cmd1 = new SqlCommand();

            cmd1.CommandType = CommandType.Text;
            cmd1.Connection  = con1;
            cmd1.CommandText = @"Insert into HinhAnhChiTietNhaTro(MaNhaTro,HinhAnh) values(@MaNT,@HinhAnh) ";
            cmd1.Parameters.Add("@MaNT", SqlDbType.Int);
            cmd1.Parameters["@MaNT"].Value = MaNT;
            cmd1.Parameters.Add("@HinhAnh", SqlDbType.NVarChar, 50);
            for (int i = 0; i < _HttpFileCollection.Count; i++)
            {
                HttpPostedFile _HttpPostedFile = _HttpFileCollection[i];
                if (_HttpPostedFile.ContentLength > 0)
                {
                    string filepath = MapPath("Images/" + Path.GetFileName(_HttpPostedFile.FileName));
                    _HttpPostedFile.SaveAs(filepath);
                    cmd1.Parameters["@HinhAnh"].Value = _HttpPostedFile.FileName.ToString();
                    cmd1.ExecuteNonQuery();
                }
            }
            con1.Close();
            Response.Redirect("~/CamOn.aspx");
        }