private void tsmAdd_Click(object sender, EventArgs e) { AddOrChange rec = new AddOrChange(); if (rec.ShowDialog() == DialogResult.OK) { drivers.Add(rec.Own); } dgMain.DataSource = drivers.GetList(); }
public override ListDrivers Load(string path) { using (StreamReader sr = File.OpenText(path)) { ListDrivers ldriver = new ListDrivers(); string s = ""; while ((s = sr.ReadLine()) != null) { CarOwner owner = new CarOwner(); owner.FullName = sr.ReadLine(); s = sr.ReadLine(); switch (s) { case "A": owner.TypeLicense = TypeCar.A; break; case "B": owner.TypeLicense = TypeCar.B; break; case "C": owner.TypeLicense = TypeCar.C; break; case "D": owner.TypeLicense = TypeCar.D; break; default: owner.TypeLicense = TypeCar.none; break; } owner.ModelCar = sr.ReadLine(); s = sr.ReadLine(); switch (s) { case "A": owner.TypeCar = TypeCar.A; break; case "B": owner.TypeCar = TypeCar.B; break; case "C": owner.TypeCar = TypeCar.C; break; case "D": owner.TypeCar = TypeCar.D; break; default: owner.TypeCar = TypeCar.none; break; } owner.CarNumber = Convert.ToInt32(sr.ReadLine()); owner.CarDate = Convert.ToDateTime(sr.ReadLine()); ldriver.Add(owner); } return(ldriver); } }