123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.IO;
- using static System.Net.Mime.MediaTypeNames;
- namespace WpfApp1
- {
- /// <summary>
- /// Логика взаимодействия для MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- string pant = "1.txt";
- public MainWindow()
- {
- InitializeComponent();
- }
- struct people
- {
- public string name;
- public string dateB;
- public string pol;
- public string di;
- }
- List<people> peopleList = new List<people>();
- int n = 1;
- bool flag = false;
- int count = 0;
- string zapis()
- {
- string text = "";
- text += tb_name + " ";
- text += dp_date + " ";
-
- if (lb_pol.SelectedItem is per person)
- {
- text += person.pol + " ";
- //MessageBox.Show(person.pol);
- }
- if(cb_1.IsChecked == true)
- {
- text += cb_1.Content;
- }
- if(cb_2.IsChecked == true)
- {
- text += cb_2.Content;
- }
- if(cb_3.IsChecked == true)
- {
- text += cb_3.Content;
- }
- return text;
- }
- void initialDate(int n)
- {
- using (StreamReader sr = new StreamReader(pant))
- {
- try
- {
- if (flag == true)
- {
- for (int i = 0; i < count; i++)
- {
- sr.ReadLine();
- }
- }
- string[] pl = sr.ReadLine().Split(' ');
- people peoples = new people();
- peoples.name = (pl[n]);
- peoples.dateB = pl[n + 1];
- peoples.pol = pl[n + 3];
- peoples.di = pl[n + 4];
- peopleList.Add(peoples);
- }
- catch
- {
- MessageBox.Show("больше данных нет");
- }
- }
-
- }
- void show()
- {
- initialDate(n);
- foreach (people people in peopleList)
- {
- nameV.Content = Convert.ToString(people.name);
- datenV.Content = Convert.ToString(people.dateB);
- polV.Content = Convert.ToString(people.pol);
- diV.Content = Convert.ToString(people.di);
- }
-
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- File.AppendAllText(pant, zapis() + Environment.NewLine);
-
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- show();
- flag = true;
- }
- private void Button_Click_2(object sender, RoutedEventArgs e)
- {
- if (flag==true)
- {
- count++;
- show();
- }
- }
- }
- }
|