Пример #1
0
 public void DeleteData(Suoritus suoritus)
 {
     List<Suoritus> tempList = ReadData();
     Suoritus temp = (Suoritus)tempList.SingleOrDefault(x => suoritus.Quals(x));
     tempList.Remove(temp);
     WriteData(tempList);
 }
Пример #2
0
 public void ModifyData(Suoritus suoritus, int index)
 {
     List<Suoritus> lista = new List<Suoritus>();
     lista = ReadData();
     lista[index] = suoritus;
     WriteData(lista);
 }
Пример #3
0
 public bool Quals(Suoritus suoritus)
 {
     if (suoritus.Name.Equals(this.Name) && suoritus.Points == this.Points && suoritus.Semester.Equals(this.Semester))
     {
         return true;
     }
     return false;
 }
Пример #4
0
        public void WriteData(Suoritus suoritus)
        {
            List<Suoritus> listaX = ReadData();
            sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Courses.txt");
            listaX.Add(suoritus);

            foreach (Suoritus temp in listaX)
            {
                String start = String.Format("{0:yyyy-MM-dd}", temp.StartDate);
                String end = String.Format("{0:yyyy-MM-dd}", temp.EndDate);
                sw.WriteLine(temp.Name + ";" + temp.Points + ";" + start + ";" + end + ";" + temp.Semester);
            }
            sw.Close();
        }
Пример #5
0
        private void btnAddCourse_Click(object sender, EventArgs e)
        {
            if (CheckNullnes())
            {
                Suoritus suoritus = new Suoritus(txtCourseName.Text.ToString(), int.Parse(txtStudyPoints.Text.ToString()),
                dateTimeStart.Value, dateTimeEnd.Value, cmbToAddSemester.SelectedItem.ToString());
                controller.addCourse(suoritus);
                ClearComponents();     
            }
            else
            {
                Message("Check values!");
            }

        }
Пример #6
0
 public List<Suoritus> ReadData()
 {
     if(File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Courses.txt"))
     {
         StreamReader sr2 = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "Courses.txt");
         List<Suoritus> lista = new List<Suoritus>();
         while (!sr2.EndOfStream)
         {
             String[] array = sr2.ReadLine().Split(';');
             if (!(array.Length < 5))
             {
                 Suoritus suoritus = new Suoritus(array[0], int.Parse(array[1]), tool.parseFromString(array[2].Split('-')), tool.parseFromString(array[3].Split('-')), array[4]);
                 lista.Add(suoritus);
                 Debug.Write(suoritus.Name + " " + suoritus.Points + " " + suoritus.Semester + " " + suoritus.StartDate);
             }
         }
         sr2.Close();
         return lista;
     }
     return null;
 }
Пример #7
0
 public void Modify(Suoritus suoritus, int index)
 {
     wr.ModifyData(suoritus, index);
     formi.Message("Course modified!");
 }
Пример #8
0
 public void Delete(Suoritus suoritus)
 {
     wr.DeleteData(suoritus);
     formi.setCourses(wr.ReadData());
     formi.Message("Course deleted!");
 }
Пример #9
0
 public void addCourse(Suoritus suoritus)
 {
     wr.WriteData(suoritus);
     formi.setCourses(wr.ReadData());
     formi.Message("Successful!");
 }