예제 #1
0
        /// <summary>
        /// removes a contract
        /// </summary>
        /// <param name="contract"></param>
        public void deleteContract(Contract contract)
        {
            XElement contractElement = (from n in DataSourceXml.Contracts.Elements()
                                        where Convert.ToInt32(n.Element("numberOfContract").Value) == contract.numberOfContract
                                        select n).FirstOrDefault();

            if (contractElement != null)
            {
                contractElement.Remove();
                DataSourceXml.SaveContracts();
            }
            else
            {
                throw new Exception("the contract is not in the system.\n");
            }
        }
예제 #2
0
        /// <summary>
        /// updates contract info
        /// </summary>
        /// <param name="contract"></param>
        public void updateContract(Contract contract)
        {
            var temp = (from c in DataSourceXml.Contracts.Elements()
                        where Convert.ToInt32(c.Element("numberOfContract").Value) == contract.numberOfContract
                        select c).FirstOrDefault();

            if (temp != null)
            {
                temp.ReplaceWith(contract.toXML());
                DataSourceXml.SaveContracts();
            }
            else
            {
                throw new Exception("the contract is not in the system.\n");
            }
        }
예제 #3
0
        /// <summary>
        /// adds a contract to list
        /// </summary>
        /// <param name="contract"></param>
        public void addContract(Contract contract)
        {
            var temp = (from c in DataSourceXml.Contracts.Elements()
                        where Convert.ToInt32(c.Element("numberOfContract").Value) == contract.numberOfContract
                        select c).FirstOrDefault();

            if (temp == null)
            {
                DataSourceXml.Contracts.Add(contract.toXML());
                DataSourceXml.SaveContracts();
            }
            else
            {
                throw new Exception("the contract is already in the system.\n");
            }
        }