public bool Cap_Nhat_Gia_Loai_Phong(CLoaiPhong lp) { XmlDocument file = new XmlDocument(); file.Load(connection); XmlElement restaurant = file.DocumentElement; XmlNode oldnode = file.SelectSingleNode("/CNXML_SV_QLKS_2_Cach_1/LOAI_PHONG" + "[@ID ='" + lp._ID + "']"); XmlElement updatenode = file.CreateElement("LOAI_PHONG"); updatenode.SetAttribute("ID", lp._ID.ToString()); updatenode.SetAttribute("Ten", lp._Ten); updatenode.SetAttribute("Ma_so", lp._Ma_So); updatenode.SetAttribute("Don_gia", lp._Don_Gia.ToString()); updatenode.SetAttribute("Tien_nghi", lp._Tien_Nghi.ToString()); updatenode.SetAttribute("So_Khach_Toi_da", lp._So_Khach_Toi_Da.ToString()); try { restaurant.ReplaceChild(updatenode, oldnode); } catch { return(false); } file.Save(connection); return(true); }
public List <CLoaiPhong> Tai_DS_Loai_Phong() { List <CLoaiPhong> list = new List <CLoaiPhong>(); CLoaiPhong lp; XmlDocument file = new XmlDocument(); file.Load(connection); XmlNodeList ksnodelist = file.SelectNodes("/CNXML_SV_QLKS_2_Cach_1/LOAI_PHONG"); for (int i = 0; i < ksnodelist.Count; i++) { XmlElement node = (XmlElement)ksnodelist[i]; lp = new CLoaiPhong(); lp._ID = int.Parse(node.GetAttribute("ID")); lp._Ten = node.GetAttribute("Ten"); lp._Ma_So = node.GetAttribute("Ma_so"); lp._So_Khach_Toi_Da = int.Parse(node.GetAttribute("So_Khach_Toi_da")); lp._Tien_Nghi = node.GetAttribute("Tien_nghi"); lp._Don_Gia = int.Parse(node.GetAttribute("Don_gia")); list.Add(lp); } return(list); }