// Insert Record public void InsertBilling(Billing billing) { billing.ID = (int)(from b in billingData.Descendants("item") orderby (int)b.Element("id") descending select (int)b.Element("id")).FirstOrDefault() + 1; billingData.Root.Add(new XElement("item", new XElement("id", billing.ID), new XElement("customer", billing.Customer), new XElement("JobType", billing.JobType), new XElement("date", billing.Date.ToShortDateString()), new XElement("description", billing.Description), new XElement("hours", billing.Hours))); billingData.Save(HttpContext.Current.Server.MapPath("~/App_Data/Billings.xml")); }
// Edit Record public void EditBilling(Billing billing) { XElement node = billingData.Root.Elements("item").Where(i => (int)i.Element("id") == billing.ID).FirstOrDefault(); node.SetElementValue("customer", billing.Customer); node.SetElementValue("JobType", billing.JobType); node.SetElementValue("date", billing.Date.ToShortDateString()); node.SetElementValue("description", billing.Description); node.SetElementValue("hours", billing.Hours); billingData.Save(HttpContext.Current.Server.MapPath("~/App_Data/Billings.xml")); }