Example #1
0
        public DayData GetDay()
        {
            var sp = new DayData();
            sp.Name = textBox1.Text;
            sp.Surname = textBox2.Text;

               foreach (EmploymentData ed in listBox1.Items)
            {
            sp.Employments.Add(ed);
            }
              return sp;
        }
Example #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog() { Title = "Сохранение данных", Filter = "файл паспорта|*.passport" };
            var result = sfd.ShowDialog(this);
            if (result != DialogResult.OK)
                return;

            var pd = new DayData();
            pd.Name = textBox1.Text;
            pd.Surname = textBox2.Text;

            if (pictureBox1.Image != null)
            {
                var ms = new MemoryStream();
                pictureBox1.Image.Save(ms, ImageFormat.Png);

                pd.Photo = ms.GetBuffer();
            }

                foreach (EmploymentData ed in listBox1.Items)
                {
                    pd.Employments.Add(ed);
                }

                var xs = new XmlSerializer(typeof(DayData));
                var file = File.Create(sfd.FileName);
                xs.Serialize(file, pd);
                file.Close();
        }