示例#1
0
        private void button_Copy_Click(object sender, RoutedEventArgs e)
        {
            DataBaseForStudents d1        = new DataBaseForStudents(textBox_FIO.Text, textBox_Age.Text, comboBox_fak.Text, comboBox_direction.Text, Convert.ToInt32(textBox_course.Text), comboBox_expirience.Text);
            XmlSerializer       formatter = new XmlSerializer(typeof(DataBaseForStudents));

            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".xml";
            dlg.Filter     = "Студенты|*.xml";
            dlg.FileName   = "Студент №";
            dlg.ShowDialog();
            Stream myStream = dlg.OpenFile();

            formatter.Serialize(myStream, d1);
            myStream.Close();
        }
示例#2
0
        private void buttonOpen_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openSaveFileDialog = new Microsoft.Win32.OpenFileDialog();
            XmlSerializer formatter = new XmlSerializer(typeof(DataBaseForStudents));
            Stream        myStream  = null;

            openSaveFileDialog.DefaultExt = ".xml";
            openSaveFileDialog.Filter     = "Студенты|*.xml";
            openSaveFileDialog.ShowDialog();
            myStream = openSaveFileDialog.OpenFile();
            DataBaseForStudents d2 = (DataBaseForStudents)formatter.Deserialize(myStream);

            textBox_FIO.Text         = d2.fio;
            textBox_Age.Text         = d2.age;
            comboBox_fak.Text        = d2.fak;
            comboBox_direction.Text  = d2.direction;
            textBox_course.Text      = Convert.ToString(d2.course);
            comboBox_expirience.Text = d2.expirience;
        }