Ejemplo n.º 1
0
 /// <summary>
 /// opslaan in XML
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 public bool AddProject(Project project)
 {
     List<Project> projects = new List<Project>();
     if(xml.XMLRead(out projects, out error))
     {
         projects.Add(project);
         return xml.XMLWriter(projects, out error);
     }
     return false;
 }
Ejemplo n.º 2
0
 public  bool SetProject(Project pr)
 {
     return xml.SetProject(pr, out error);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// project uit XML bestand halen
        /// </summary>
        /// <param name="project">out project. ophalen</param>
        /// <param name="error">out error</param>
        /// <returns></returns>
        public bool GetProject(out Project project, out string error)
        {
            project = new Project(-1, string.Empty);
            error = string.Empty;
            try
            {
                DataContractSerializer dcs = new DataContractSerializer(typeof(Project), new List<Type> { typeof(Project), typeof(Project) });


                using (FileStream f = new FileStream(@"./Resources/Saves/Project.XML",
                     FileMode.Open, FileAccess.Read))
                {
                    project = dcs.ReadObject(f) as Project;
                }
                return true;
            }
            catch (Exception e)
            {
                error = e.Message;
                return false;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// projecten ophalen
 /// 
 /// </summary>
 /// <param name="projecten">out lijst projecten</param>
 /// <param name="error">out string error</param>
 /// <returns></returns>
 public bool GetProjecten(out List<Project> projecten, out string error)
 {
     projecten = new List<Project>();
     error = string.Empty;
     try
     {
         string query = "SELECT * FROM Project";
         using (OracleConnection conn = new OracleConnection(connectionString))
         {
             OracleCommand command = new OracleCommand(query, conn);
             conn.Open();
             OracleDataReader reader = command.ExecuteReader();
             while (reader.Read())
             {
                 //item = Convert.ToInt32(reader["item"]);
                 int id=Convert.ToInt32(reader["ID"]);
                 string gebied = Convert.ToString(reader["gebied"]);
                 Project proj = new Project(id, gebied);
                 List<Bezoek> bezoeken =new List<Bezoek>();
                 if(!GetBezoeken(out bezoeken, proj.ID, out error)) return false;
                 foreach (Bezoek bez in bezoeken)
                 {
                     proj.Bezoeken.Add(bez);
                 }
                 projecten.Add(proj);
             }
             reader.Close();
         }
         if (projecten.Count < 1)
         {
             error = "Kon geen dieren vinden.";
             return false;
         }
         return true;
     }
     catch (Exception e)
     {
         // set error message and return false
         error = e.Message;
         return false;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="project"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool SetProject(Project project, out string error)
        {
            error = string.Empty;
            try
            {
                DataContractSerializer dcs = new DataContractSerializer(typeof(Project), new List<Type> { typeof(Project), typeof(Project) });

                using (FileStream f = new FileStream(@"./Resources/Saves/Project.XML",
                     FileMode.Create, FileAccess.Write))
                {
                    dcs.WriteObject(f, project);
                }
                return true;
            }
            catch (Exception e)
            {
                error = e.Message;
                return false;
            }
        }