public static List <InterProfile> ReadDate(string path) { List <InterProfile> g = new List <InterProfile>(); string text = ""; using (StreamReader sr = new StreamReader(path)) { text = sr.ReadToEnd(); } string[] Dates = text.Split('/'); foreach (string s in Dates) { string[] MetaDete = s.Split('|'); if (MetaDete.Length == 5) { InterProfile d = new InterProfile { Name = MetaDete[0].Trim(), LastName = MetaDete[1], DateOut = DateTime.ParseExact(MetaDete[2], "dd.MM.yyyy", CultureInfo.InvariantCulture), FilmTime = (float)Convert.ToDouble(MetaDete[3]), Budget = Convert.ToInt32(MetaDete[4]) }; g.Add(d); } } return(g); }
static void Add(List <InterProfile> v) { InterProfile New = new InterProfile(); Console.WriteLine("Enter name"); New.Name = Console.ReadLine(); Console.WriteLine("Enter Last"); New.LastName = Console.ReadLine(); Console.WriteLine("Enter last date"); New.DateOut = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", CultureInfo.InvariantCulture); Console.WriteLine("Enter time at site"); try { New.FilmTime = (float)Convert.ToDouble(Console.ReadLine()); } catch { } Console.WriteLine("Enter Budget"); New.Budget = Convert.ToInt32(Console.ReadLine()); v.Add(New); }
static void ChangeData(List <InterProfile> v) { Console.WriteLine("Enter name to change"); string name = Console.ReadLine(); if ((v.FindIndex(f => f.Name == name) != -1)) { InterProfile Change = v[v.FindIndex(f => f.Name == name)]; Console.WriteLine("1)Name\n2)Produser Name\n3)Date out\n4)Film time\n5)Budget"); var res = Console.ReadKey().KeyChar; Console.WriteLine("Enter new value"); if (res == '1') { Change.Name = Console.ReadLine(); } if (res == '2') { Change.LastName = Console.ReadLine(); } if (res == '3') { Change.DateOut = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", CultureInfo.InvariantCulture); } if (res == '4') { Change.FilmTime = Convert.ToInt16(Console.ReadLine()); } if (res == '5') { Change.Budget = Convert.ToInt16(Console.ReadLine()); } } else { Console.WriteLine("Entered name not found"); Console.ReadKey(); } }
public int CompareTo(InterProfile p) { return(this.DateOut.CompareTo(p.Budget)); }