Ejemplo n.º 1
0
        private void button6_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog() { Title = "Сохранение анкеты", Filter = "Абитуриент|*.enrollee" };
            var result = sfd.ShowDialog(this);
            if (result != DialogResult.OK)
                return;
            var ed = new EnrolleeData();
            ed.Name = EnName.Text;
            ed.LastName = EnLastName.Text;
            ed.Patronymic = EnPatronymic.Text;
            ed.Birth = DateOfBirth.Value;
            ed.Institute = comboBox2.Text;
            ed.Direction = comboBox3.Text;
            if (pictureBox1.Image != null)
            {
                var ms = new MemoryStream();
                pictureBox1.Image.Save(ms, ImageFormat.Png);
                ed.Photo = ms.GetBuffer();
            }
            if (radioButton1.Checked)
            {
                ed.Gender = Gender.Male;
            }
            else
            {
                ed.Gender = Gender.Female;
            }
            foreach (ListViewItem exd in listView1.Items)
            {
                ed.Exams.Add((ExamsData)exd.Tag);
            }

            foreach (Image image in imageList1.Images)
            {

                var ms = new MemoryStream();
                image.Save(ms, ImageFormat.Png);
                ed.Documents.Add(ms.GetBuffer());
            }
               var xs = new XmlSerializer(typeof(EnrolleeData));
            var file = File.Create(sfd.FileName);
            xs.Serialize(file, ed);
            file.Close();
        }
Ejemplo n.º 2
0
        public EnrolleeData GetEnrolleeData()
        {
            var ed = new EnrolleeData();
            ed.Name = EnName.Text;
            ed.LastName = EnLastName.Text;
            ed.Patronymic = EnPatronymic.Text;
            ed.Birth = DateOfBirth.Value;
            ed.Institute = comboBox2.Text;
            ed.Direction = comboBox3.Text;
            if (pictureBox1.Image != null)
            {
                var ms = new MemoryStream();
                pictureBox1.Image.Save(ms, ImageFormat.Png);
                ed.Photo = ms.GetBuffer();
            }
            if (radioButton1.Checked)
            {
                ed.Gender = Gender.Male;
            }
            else
            {
                ed.Gender = Gender.Female;
            }
            foreach (ListViewItem exd in listView1.Items)
            {
                ed.Exams.Add((ExamsData)exd.Tag);
            }

            foreach (Image image in imageList1.Images)
            {

                var ms = new MemoryStream();
                image.Save(ms, ImageFormat.Png);
                ed.Documents.Add(ms.GetBuffer());
            }
            return ed;
        }