private void button2_Click(object sender, EventArgs e) { OpenFileDialog opf = new OpenFileDialog(); opf.Filter = "XML files(*.xml)|*.xml|All files(*.*)|*.*"; if (opf.ShowDialog() == DialogResult.Cancel) { return; } string filename = opf.FileName; fname = filename; using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate)) { spisok = (All_Visitors)serial.Deserialize(fs); textBox1.Text = spisok.visitors[0].FIO; textBox2.Text = spisok.visitors[0].Phone_Number; textBox4.Text = spisok.visitors[0].Room_Number; comboBox1.Text = spisok.visitors[0].Room_Rang; switch (spisok.visitors[0].Room_Capacity) { case 1: radioButton1.Checked = true; break; case 2: radioButton2.Checked = true; break; case 4: radioButton3.Checked = true; break; } textBox3.Text = Convert.ToString(spisok.visitors[0].Duration); if (spisok.visitors.Count > 1) { button3.Visible = true; } else { button3.Visible = false; } if (spisok.visitors.Count > 1 && first != 0) { button4.Visible = true; } else { button4.Visible = false; } } string filetext = File.ReadAllText(filename); textBox5.Text = filetext; }
private void button4_Click(object sender, EventArgs e) { using (FileStream fs = new FileStream(fname, FileMode.OpenOrCreate)) { All_Visitors newvisitors = (All_Visitors)serial.Deserialize(fs); int n = newvisitors.visitors.Count; if (first > 0) { first--; button4.Visible = true; button3.Visible = true; } textBox1.Text = newvisitors.visitors[first].FIO; textBox2.Text = newvisitors.visitors[first].Phone_Number; textBox4.Text = newvisitors.visitors[first].Room_Number; comboBox1.Text = newvisitors.visitors[first].Room_Rang; switch (newvisitors.visitors[first].Room_Capacity) { case 1: radioButton1.Checked = true; break; case 2: radioButton2.Checked = true; break; case 4: radioButton3.Checked = true; break; } textBox3.Text = Convert.ToString(newvisitors.visitors[first].Duration); if (first > 0 && first < (n - 1)) { button3.Visible = true; button4.Visible = true; } else { button4.Visible = false; } } }