private void btnThuePhong_Click(object sender, EventArgs e)
 {
     //Kiểm tra thông tin nhập đúng:
     if (ThongTinNhap_PhieuThueHopLe() == true)
     {
         PhieuThue_PhongDangChon.NgayBatDau    = TheHien.Nhap_Chuoi(labelNgayBatDau);
         PhieuThue_PhongDangChon.NgayDuKienTra = TheHien.Nhap_Chuoi(txtbNgayDuKienTra);
         PhieuThue_PhongDangChon.MaPhong       = Phong_DangHienThi.ID;
         for (int i = 0; i < DanhSach_Textbox_TenKhachHang.Count; i++)
         {
             string Ten  = TheHien.Nhap_Chuoi(DanhSach_Textbox_TenKhachHang[i]);
             string CMND = TheHien.Nhap_Chuoi(DanhSach_Textbox_CMNDKhachHang[i]);
             if (Ten.Length != 0)
             {
                 CThongTinKhachHang KhachHang = new CThongTinKhachHang();
                 KhachHang.HoTen = Ten;
                 KhachHang.CMND  = CMND;
                 PhieuThue_PhongDangChon.DSKhachHang.Add(KhachHang);
             }
         }
         LuuTru.GhiDuLieu_ThuePhong(PhieuThue_PhongDangChon); //Gửi dữ liệu lên host
         CapNhat_DuLieuPhong();
     }
     else
     {
         return;
     }
 }
        private List <CPhieuThuePhong> Chuyen_XML_Thanh_Phieu_Thue_Phong(string chuoiXml)
        {
            //MessageBox.Show(chuoiXml);
            List <CPhieuThuePhong> KQ      = new List <CPhieuThuePhong>();
            XmlDocument            TaiLieu = new XmlDocument();

            TaiLieu.LoadXml(chuoiXml);
            XmlElement Goc = TaiLieu.DocumentElement;

            foreach (XmlElement DoiTuong in Goc.ChildNodes)
            {
                CPhieuThuePhong PhieuThue = new CPhieuThuePhong();
                PhieuThue.ID            = Int32.Parse(DoiTuong.GetAttribute("ID"));
                PhieuThue.TenPhong      = DoiTuong.GetAttribute("TenPhong");
                PhieuThue.NgayBatDau    = ChuanHoaChuoiNgayThangNam(DoiTuong.GetAttribute("NgayBatDau"));
                PhieuThue.NgayDuKienTra = ChuanHoaChuoiNgayThangNam(DoiTuong.GetAttribute("NgayDuKienTra"));
                PhieuThue.NgayTra       = ChuanHoaChuoiNgayThangNam(DoiTuong.GetAttribute("NgayTra"));
                PhieuThue.MaPhong       = Int32.Parse(DoiTuong.GetAttribute("ID_Phong"));

                //Chỉ những phiếu thuê đã trả phồng mới có số tiền thuê
                if (PhieuThue.NgayTra.Length != 0)
                {
                    PhieuThue.TienThuePhong = Int32.Parse("0" + DoiTuong.GetAttribute("SoTien"));
                }
                CThongTinKhachHang ThongTin = new CThongTinKhachHang();

                string   DS_TenKhachHang = DoiTuong.GetAttribute("DS_TenKhachHang");
                string[] ChuoiTen        = DS_TenKhachHang.Split(new Char[] { '|' });

                string   DS_CMND   = DoiTuong.GetAttribute("DS_CMND");
                string[] ChuoiCMND = DS_CMND.Split(new Char[] { '|' });


                for (int i = 0; i < ChuoiTen.Count(); i++)
                {
                    if (ChuoiTen[i].Trim() != "")
                    {
                        ThongTin       = new CThongTinKhachHang();
                        ThongTin.HoTen = ChuoiTen[i];
                        ThongTin.CMND  = ChuoiCMND[i];

                        PhieuThue.DSKhachHang.Add(ThongTin);
                    }
                }


                PhieuThue.LoaiPhong = DoiTuong.GetAttribute("LoaiPhong");
                KQ.Add(PhieuThue);
            }


            return(KQ);
        }
        public List <CPhieuThuePhong> Doc_DSCacPhongDangThue(XmlElement Goc)
        {
            List <CPhieuThuePhong> danhSach_PhongDangChoThue = new List <CPhieuThuePhong>();
            string DoiTuong_PhieuThue = "PHIEU_THUE_PHONG";
            string strNgay            = "";

            string dsTenKhachHang = "";
            string dsCMND         = "";


            foreach (XmlElement DoiTuong in Goc.SelectNodes(DoiTuong_PhieuThue))
            {
                CPhieuThuePhong PhieuThue = new CPhieuThuePhong();
                PhieuThue.ID      = Int32.Parse(DoiTuong.GetAttribute("ID").Trim());
                PhieuThue.MaPhong = Int32.Parse(DoiTuong.GetAttribute("ID_Phong").Trim());

                strNgay = DoiTuong.GetAttribute("NgayBatDau").Trim();
                PhieuThue.NgayBatDau = strNgay.Substring(8, 2) + "/" + strNgay.Substring(5, 2) + '/' + strNgay.Substring(0, 4);
                strNgay = DoiTuong.GetAttribute("NgayDuKienTra").Trim();
                PhieuThue.NgayDuKienTra = strNgay.Substring(8, 2) + "/" + strNgay.Substring(5, 2) + '/' + strNgay.Substring(0, 4);

                dsTenKhachHang = DoiTuong.GetAttribute("DS_TenKhachHang").Trim();
                dsCMND         = DoiTuong.GetAttribute("DS_CMND");
                int vitri_ten  = dsTenKhachHang.IndexOf("|");
                int vitri_cmnd = dsCMND.IndexOf("|");

                while (vitri_ten > 0)
                {
                    CThongTinKhachHang KhachHang = new CThongTinKhachHang();
                    KhachHang.HoTen = dsTenKhachHang.Substring(0, vitri_ten);
                    KhachHang.CMND  = dsCMND.Substring(0, vitri_cmnd);
                    dsTenKhachHang  = dsTenKhachHang.Substring(vitri_ten + 1, dsTenKhachHang.Length - vitri_ten - 1);
                    dsCMND          = dsCMND.Substring(vitri_cmnd + 1, dsCMND.Length - vitri_cmnd - 1);

                    PhieuThue.DSKhachHang.Add(KhachHang);

                    vitri_ten  = dsTenKhachHang.IndexOf("|");
                    vitri_cmnd = dsCMND.IndexOf("|");
                }

                danhSach_PhongDangChoThue.Add(PhieuThue);
            }
            return(danhSach_PhongDangChoThue);
        }