public static void Parse(string[] elements, bool save, Shedule[] a, int counter) { for (int i = 0; i < elements.Length; i += 5) { a[counter + i / 5] = new Shedule(int.Parse(elements[i]), DateTime.Parse(elements[i + 1]), elements[i + 2], elements[i + 3], int.Parse(elements[i + 4])); if (save) { Save(a[counter + i / 5]); } } }
public int CompareTo(object obj) { Shedule p = (Shedule)obj; if (this.Number > p.Number) { return(1); } if (this.Number < p.Number) { return(-1); } return(0); }
private static void Save(Shedule m) { StreamWriter save = new StreamWriter("text.txt", true); save.WriteLine(m.Number); save.WriteLine(m.Data); save.WriteLine(m.Subject); save.WriteLine(m.Surname); save.WriteLine(m.Termin); save.Close(); }
int IComparer.Compare(object ob1, object ob2) { Shedule p1 = (Shedule)ob1; Shedule p2 = (Shedule)ob2; if (p1.Termin > p2.Termin) { return(1); } if (p1.Termin < p2.Termin) { return(-1); } return(0); }
int IComparer.Compare(object ob1, object ob2) { Shedule p1 = (Shedule)ob1; Shedule p2 = (Shedule)ob2; if (p1.Data > p2.Data) { return(1); } if (p1.Data < p2.Data) { return(-1); } return(0); }
public static void KKEY() { FileStream file1 = File.OpenRead("text.txt"); byte[] array = new byte[file1.Length]; file1.Read(array, 0, array.Length); string textfromfile = System.Text.Encoding.Default.GetString(array); string[] s = textfromfile.Split("\r\n", StringSplitOptions.RemoveEmptyEntries); file1.Close(); Shedule[] a = new Shedule[s.Length / 5]; int c = 0; while (a[c] != null) { ++c; } for (int i = 0; i < s.Length; i += 5) { a[c + i / 5] = new Shedule(int.Parse(s[i]), DateTime.Parse(s[i + 1]), s[i + 2], s[i + 3], int.Parse(s[i + 4])); } bool[] delete = new bool[100]; Console.WriteLine("Add note: A"); Console.WriteLine("Edit note: E"); Console.WriteLine("Remove note: R"); Console.WriteLine("Show notes: Enter"); Console.WriteLine("Sort by date: N"); Console.WriteLine("Sort by termin: D"); Console.WriteLine("Sort by number: S"); Console.WriteLine("Exit: Esc"); switch (Console.ReadKey().Key) { case ConsoleKey.E: Key.Edit(a); break; case ConsoleKey.N: a[0].One(a); Key.KKEY(); break; case ConsoleKey.D: a[0].Two(a); Key.KKEY(); break; case ConsoleKey.S: a[0].Data1(a); Key.KKEY(); break; case ConsoleKey.Enter: Key.Show(a); break; case ConsoleKey.A: Key.Add(a, c); break; case ConsoleKey.R: Key.Remove(a, delete); break; case ConsoleKey.Escape: break; } }