示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || semestr == 0 || this.label1.Text == "course" || this.comboBox1.Text == "" || this.comboBox1.Text == "")
            {
                MessageBox.Show("Заполните все поля");
            }
            this.dist.NameOfTheDiscipline = this.textBox1.Text;
            this.dist.Semestr             = semestr;
            this.dist.Course          = this.trackBar1.Value;
            this.dist.Specialty       = this.comboBox1.Text;
            this.dist.TypeOfControl   = this.comboBox2.Text;
            this.dist.CountOfLections = Convert.ToInt32(this.numericUpDown1.Value);
            this.dist.CountOfLabs     = Convert.ToInt32(this.numericUpDown2.Value);
            var dists = XmlSerializeWrapper.Deserialize <List <Discipline> >("dists.xml");

            if (dists != null)
            {
                dists.Add(this.dist);
                XmlSerializeWrapper.Serialize(dists, "dists.xml");
            }
            else
            {
                List <Discipline> buffer = new List <Discipline>();
                buffer.Add(this.dist);
                XmlSerializeWrapper.Serialize(buffer, "dists.xml");
            }
            this.Clear();
        }
示例#2
0
        private void button3_Click(object sender, EventArgs e)
        {
            List <Discipline> dists = XmlSerializeWrapper.Deserialize <List <Discipline> >("dists.xml");

            if (dists != null)
            {
                foreach (var i in dists)
                {
                    this.dataGridView1.Rows.Add(i.NameOfTheDiscipline, i.Semestr, i.Course, i.Specialty, i.TypeOfControl, i.CountOfLections, i.CountOfLabs, i.Lector.Name, i.Lector.Surname, i.Lector.Department, i.Lector.Auditorium, i.Lector.Date);
                }
            }
        }