Ejemplo n.º 1
0
        public Stud(string name, int age, string spec, string birthday,
                    string k, string group, string gender, string sr,
                    AddressWithCity add)
        {
            Name        = name;
            Age         = age;
            Spec        = spec;
            BirthDay    = birthday;
            this.k      = k;
            this.group  = group;
            this.gender = gender;
            this.sr     = sr;
            AddressWithCity address = add;

            City       = add.city.city;
            street     = add.address.street;
            house      = add.address.house;
            apartament = add.address.apartament;
        }
Ejemplo n.º 2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            City    city = new City();
            Address add  = new Address();

            if (!Proverka())
            {
                MessageBox.Show("Невалидные данные");
            }
            else
            {
                city.city = textBox4.Text;

                add.street     = textBox5.Text;
                add.house      = textBox6.Text;
                add.apartament = textBox7.Text;

                AddressWithCity a = new AddressWithCity(city, add);
                Stud            s = new Stud(richTextBox2.Text, Convert.ToInt32(textBox2.Text), comboBox6.SelectedItem.ToString(),
                                             comboBox1.SelectedItem.ToString() + "/"
                                             + comboBox2.SelectedItem.ToString() + "/" +
                                             comboBox3.SelectedItem.ToString(),
                                             comboBox4.SelectedItem.ToString(), comboBox5.SelectedItem.ToString(),
                                             radioButton1.Checked ? "М" : "Ж", textBox3.Text, a);
                try
                {
                    XmlSerializer formatter = new XmlSerializer(typeof(Stud));

                    using (FileStream fs = new FileStream("student.xml", FileMode.OpenOrCreate))
                    {
                        formatter.Serialize(fs, s);

                        MessageBox.Show("Объект стериализован");
                    }
                    richTextBox1.Text = File.ReadAllText("student.xml");
                }
                catch (Exception p)
                {
                    MessageBox.Show(p.ToString());
                }
            }
        }