Example #1
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     var sfd = new SaveFileDialog() { Title = "Сохранение анкеты", Filter = "Певец|*.singer" };
     var result = sfd.ShowDialog(this);
     if (result != DialogResult.OK)
         return;
     var sd = new SingerData();
     sd.Name = NameBox.Text;
     sd.Gender = GenderBox.Text;
     sd.Region = RegionBox.Text;
     sd.Hometown = HomeTownBox.Text;
     sd.DateOfBirth = DateOfBirthBox.Value;
     sd.Address = AddressBox.Text;
     sd.Phone = PhoneBox.Text;
     sd.Information = InformationBox.Text;
     if (PhotoBox.Image != null)
     {
         var ms = new MemoryStream();
         PhotoBox.Image.Save(ms, ImageFormat.Png);
         sd.Photo = ms.GetBuffer();
     }
     var xs = new XmlSerializer(typeof(SingerData));
     var file = File.Create(sfd.FileName);
     xs.Serialize(file, sd);
     file.Close();
 }
Example #2
0
 public SingerData GetSingerData()
 {
     var sd = new SingerData();
     sd.Name = NameBox.Text;
     sd.Gender = GenderBox.Text;
     sd.Region = RegionBox.Text;
     sd.Hometown = HomeTownBox.Text;
     sd.DateOfBirth = DateOfBirthBox.Value;
     sd.Address = AddressBox.Text;
     sd.Phone = PhoneBox.Text;
     sd.Information = InformationBox.Text;
     if (PhotoBox.Image != null)
     {
         var ms = new MemoryStream();
         PhotoBox.Image.Save(ms, ImageFormat.Png);
         sd.Photo = ms.GetBuffer();
     }
     return sd;
 }