public bool RemoveContract(int code) { XElement ContractElement; try { ContractElement = (from p in ContractRoot.Elements() where Convert.ToInt32(p.Element("Code").Value) == code select p).FirstOrDefault(); ContractElement.Remove(); ContractRoot.Save(ContractPath); return(true); } catch { return(false); } }
/// <summary> /// remove contract from XML dataBase /// </summary> /// <param name="transactionNumber"></param> /// <returns></returns> public bool RemoveContract(int transactionNumber) { XElement ContractElement; try { ContractElement = (from myContract in contractsRoot.Elements() where int.Parse(myContract.Element("transactionNumber").Value) == transactionNumber select myContract).FirstOrDefault(); ContractElement.Remove(); contractsRoot.Save(contractsPath); return(true); } catch { return(false); } }
public void DeleteContract(uint contractNumber) { XElement ContractElement; ContractElement = (from item in ContractsFile.Elements() where uint.Parse(item.Element("ContractNumber").Value) == contractNumber select item).FirstOrDefault(); if (ContractElement == null) { throw new IdException { Message = "A contract with this id does not exist in the system." } } ; ContractElement.Remove(); ContractsFile.Save(ContractsPath); }