public override void Save(string filename, ListDrivers ldriver) { using (Stream stream = File.Create(filename)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, ldriver.GetList()); } }
private void tsmNoRight_Click(object sender, EventArgs e) { //главная задача drivers = drivers.ListDriveCar(ModDrive.No); drivers.GetList().Sort(); dgMain.Rows.Clear(); dgMain.DataSource = drivers.GetList(); }
public override void Save(string filename, ListDrivers ldriver) { using (Stream stream = File.Open(filename, FileMode.Create)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CarOwner>)); serializer.Serialize(stream, ldriver.GetList()); stream.Close(); } }
private void tsmOpen_Click(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { FileInfo fi = new FileInfo(openFileDialog.FileName); FileManager fm = GetFileByExtention(fi.Extension); drivers = fm.Load(fi.FullName); dgMain.DataSource = drivers.GetList(); } }
public override ListDrivers Load(string filename) { using (Stream stream = File.Open(filename, FileMode.Open)) { BinaryFormatter formatter = new BinaryFormatter(); List <CarOwner> co = (List <CarOwner>)formatter.Deserialize(stream); ListDrivers ld = new ListDrivers(co); return(ld); } }
public override ListDrivers Load(string filename) { using (Stream stream = File.Open(filename, FileMode.OpenOrCreate)) { XmlSerializer serializer = new XmlSerializer(typeof(List <CarOwner>)); var co = (List <CarOwner>)serializer.Deserialize(stream); ListDrivers ld = new ListDrivers(co); return(ld); } }
public FrmMain() { InitializeComponent(); drivers = new ListDrivers(); canDrivers = new ListDrivers(); notCanDrivers = new ListDrivers(); for (int i = 1; i <= 3; i++)//немного не правильно { cmbSort.Items.Add(HelperEnum.GetEnumDescription((ModDrive)i)); } cmbSort.SelectedIndex = 0; cmbSort.DropDownStyle = ComboBoxStyle.DropDownList; }
public override void Save(string path, ListDrivers ldriver) { using (StreamWriter sw = new StreamWriter(path, false, Encoding.ASCII)) { foreach (CarOwner i in ldriver.GetList()) { sw.WriteLine(); sw.WriteLine(i.FullName); sw.WriteLine(i.TypeLicense); sw.WriteLine(i.ModelCar); sw.WriteLine(i.TypeCar); sw.WriteLine(i.CarNumber); sw.WriteLine(i.CarDate); } sw.Close(); } }
private void cmbSort_SelectedIndexChanged(object sender, EventArgs e) { switch (cmbSort.SelectedItem) //это не красиво { case "Все": drivers = drivers.ListDriveCar(ModDrive.All); drivers.GetList().Sort(); dgMain.DataSource = drivers.GetList(); break; case "Может": canDrivers = drivers.ListDriveCar(ModDrive.Yes); canDrivers.GetList().Sort(); dgMain.DataSource = canDrivers.GetList(); break; case "Не может": notCanDrivers = drivers.ListDriveCar(ModDrive.No); notCanDrivers.GetList().Sort(); dgMain.DataSource = notCanDrivers.GetList(); break; } }
public ListDrivers ListDriveCar(ModDrive a) { ListDrivers ResList = new ListDrivers(); switch (a) { case ModDrive.Yes: foreach (CarOwner co in ListDriver) { if (co.IsCanDrive()) { ResList.ListDriver.Add(co); } } return(ResList); case ModDrive.No: foreach (CarOwner co in ListDriver) { if (!co.IsCanDrive()) { ResList.ListDriver.Add(co); } } return(ResList); case ModDrive.All: foreach (CarOwner co in ListDriver) { ResList.ListDriver.Add(co); } return(ResList); default: return(ResList); } }
private void tsmNew_Click(object sender, EventArgs e) { dgMain.Rows.Clear(); drivers = new ListDrivers(); //создать дата грид }
public abstract void Save(string filename, ListDrivers ldriver);
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); } }