예제 #1
0
        public void UpdateContract(Contract c)
        {
            DataSource_XML.LoadData("Contracts");
            XElement temp = ((from e in DataSource_XML.Contracts.Elements() // check if the contract exist
                              where e.Element("ChildID").Value == c.ChildID
                              select e).FirstOrDefault());

            if (temp == null)
            {
                throw new Exception("This Contract not exist");
            }
            temp.ReplaceWith(DAL_Converts.ContractToXml(c)); // replace between the contract details
            DataSource_XML.SaveData("Contracts");
        }
예제 #2
0
        public void AddContract(Contract c)
        {
            DataSource_XML.LoadData("Contracts");                           //load the contract file
            XElement temp = ((from e in DataSource_XML.Contracts.Elements() // check if there is contract for this child
                              where e.Element("ChildID").Value == c.ChildID
                              select e).FirstOrDefault());

            if (temp != null)
            {
                throw new Exception("Cannot add another Contract to same child");
            }
            XElement contract = DAL_Converts.ContractToXml(c);

            contract.Element("ContractNumber").Value = (getContractNumber() + 1).ToString(); // add the new contract number
            DataSource_XML.Contracts.Add(contract);
            DataSource_XML.SaveData("Contracts");                                            // save the file
        }