public bool Cap_Nhat_Tra_Phong(CPhieuThuePhong ptp)
        {
            XmlDocument file = new XmlDocument();

            file.Load(connection);

            XmlElement restaurant = file.DocumentElement;

            XmlNode oldnode = file.SelectSingleNode("/CNXML_SV_QLKS_2_Cach_1/PHIEU_THUE" + "[@ID ='" + ptp._ID + "']");

            XmlElement updatenode = file.CreateElement("PHIEU_THUE");

            updatenode.SetAttribute("ID", ptp._ID.ToString());
            updatenode.SetAttribute("ID_PHONG", ptp._ID_Phong.ToString());
            updatenode.SetAttribute("Ngay_Bat_dau", ptp._Ngay_Bat_Dau.ToString());
            updatenode.SetAttribute("Ngay_Du_kien_Tra", ptp._Ngay_Du_Kien_Tra.ToString());
            updatenode.SetAttribute("Ngay_Ket_thuc", ptp._Ngay_Ket_Thuc.ToString());
            updatenode.SetAttribute("Tien_Tra", ptp._Tien_Tra.ToString());
            try
            {
                restaurant.ReplaceChild(updatenode, oldnode);
            }
            catch
            {
                return(false);
            }

            file.Save(connection);
            return(true);
        }
        public bool Them_Phieu_Thue_Phong(CPhieuThuePhong ptp)
        {
            XmlDocument file = new XmlDocument();

            file.Load(connection);

            XmlElement doc     = file.DocumentElement; //CNXML_SV_QLKS_2_Cach_1
            XmlElement ptpnode = file.CreateElement("");

            //ptpnode.SetAttribute("ID", ptp._ID.ToString());
            //Tự phát sinh ID
            ptpnode.SetAttribute("ID", Phat_Sinh_ID_Phieu_Thue().ToString());
            ptpnode.SetAttribute("ID_PHONG", ptp._ID_Phong.ToString());
            ptpnode.SetAttribute("Ngay_Bat_dau", ptp._Ngay_Bat_Dau.ToString());
            ptpnode.SetAttribute("Ngay_Du_kien_Tra", ptp._Ngay_Du_Kien_Tra.ToString());
            ptpnode.SetAttribute("Ngay_Ket_thuc", ptp._Ngay_Ket_Thuc.ToString());
            ptpnode.SetAttribute("Tien_Tra", ptp._Tien_Tra.ToString());
            try
            {
                doc.AppendChild(ptpnode);
            }
            catch
            {
                return(false);
            }

            file.Save(connection);
            return(true);
        }
        public List <CPhieuThuePhong> Tai_DS_Phieu_Thue()
        {
            List <CPhieuThuePhong> list = new List <CPhieuThuePhong>();
            CPhieuThuePhong        ptp;
            XmlDocument            file = new XmlDocument();

            file.Load(connection);
            XmlNodeList ksnodelist = file.SelectNodes("/CNXML_SV_QLKS_2_Cach_1/PHIEU_THUE");

            for (int i = 0; i < ksnodelist.Count; i++)
            {
                XmlElement node = (XmlElement)ksnodelist[i];
                ptp                   = new CPhieuThuePhong();
                ptp._ID               = int.Parse(node.GetAttribute("ID"));
                ptp._ID_Phong         = int.Parse(node.GetAttribute("ID_PHONG"));
                ptp._Ngay_Bat_Dau     = DateTime.Parse(node.GetAttribute("Ngay_Bat_dau"));
                ptp._Ngay_Du_Kien_Tra = DateTime.Parse(node.GetAttribute("Ngay_Du_kien_Tra"));
                ptp._Ngay_Ket_Thuc    = DateTime.Parse(node.GetAttribute("Ngay_Ket_thuc"));
                ptp._Tien_Tra         = double.Parse(node.GetAttribute("Tien_Tra"));

                list.Add(ptp);
            }
            return(list);
        }