private void InitPocupatel() { var spName = GetName(); if (spName != null && System.IO.File.Exists(spName)) { var file = System.IO.File.OpenRead(spName); var xs = new XmlSerializer(typeof(Zakaz)); sp = (Zakaz)xs.Deserialize(file); file.Close(); } else { sp = new Zakaz(); } }
private Zakaz GetZakaz() { var cd = new Zakaz(); cd.name = name.Text; cd.surname = surname.Text; cd.place = place.Text; cd.time = time.Value; foreach (ComicData ed in ComicData.Items) { cd.Comic.Add(ed); } return cd; }
private void save_Click(object sender, EventArgs e) { var sfd = new SaveFileDialog() { Title = "Сохранение данных", Filter = "файл заказа|*.zakaz" }; var result = sfd.ShowDialog(this); if (result != DialogResult.OK) return; var cd = new Zakaz(); cd.name = name.Text; cd.surname = surname.Text; cd.place = place.Text; cd.time = time.Value; foreach (ComicData ed in ComicData.Items) { cd.Comic.Add(ed); } var xs = new XmlSerializer(typeof(Zakaz)); var file = File.Create(sfd.FileName); xs.Serialize(file,cd); file.Close(); }