Example #1
0
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          TextReader reader = new StreamReader("profileinf.txt");

          mas = (List <Profileinf>)ser.Deserialize(reader);
          reader.Close();
          Profileinf inf = new Profileinf(Profillabel.Content.ToString(), listBox.Items.ToString());

          mas.Add(inf);
          //string path = "profileinf.txt";
          //if (!File.Exists(path))
          //{

          //    using (StreamWriter sw = File.CreateText(path))
          //    {
          //        ser.Serialize(sw, mas);
          //        sw.Close();

          //    }
          //}
          //else
          //{
          TextWriter writer = new StreamWriter("profileinf.txt");

          ser.Serialize(writer, mas);
          writer.Close();
          // }
      }
Example #2
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            string path = @"D:\checkin1.txt";

            string[] readText = File.ReadAllLines(path);
            for (int i = 3; i < readText.Length; i += 5)
            {
                if (readText[i] == textBoxFio.Text)
                {
                    if (readText[i + 1] == textBox2.Text)
                    {
                        User       user = new User();
                        Profileinf prof = null;
                        user.LastName  = readText[i - 3];
                        user.FirstName = readText[i - 2];
                        user.OtchName  = readText[i - 1];
                        user.Room      = int.Parse(readText[i]);
                        user.Reserv    = int.Parse(readText[i + 1]);

                        NavigationService.Navigate(new Profile(user, prof));

                        //    StreamWriter textFile = new StreamWriter(@"D:\" + user.FirstName.ToString() + user.LastName.ToString() + ".txt");
                        //  //  string patha = (@"C:\Users\Nik\Desktop\" + user.Room.ToString() + ".txt");
                        //   // using //(StreamWriter sw1 = File.CreateText(patha))
                        //    {
                        //        textFile.WriteLine(user.LastName + " " + user.FirstName + " " + user.OtchName);
                        //        textFile.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Неправильный логин или пароль!");
                }
            }
        }
Example #3
0
      public Profile(User id, Profileinf _inf)
      {
          user = id;
          inf  = _inf;
          string user1 = id.Name();

          InitializeComponent();
          Profillabel.Content = user1;
          try
          { listBox.Items.Add(inf.Inf); }
          catch { }
          listBox.ItemsSource = user.listbox;
      }
Example #4
0
        private void enter_Click(object sender, RoutedEventArgs e)
        {
            //  string path = "checkin1.txt";
            TextReader reader = new StreamReader("checkin1.txt");

            mas = (List <User>)ser.Deserialize(reader);
            reader.Close();
            // reader = new StreamReader("profileinf.txt");
            //mas1 = (List<Profileinf>)ser.Deserialize(reader);
            //reader.Close();
            int        t       = 0;
            User       newuser = null;
            Profileinf inf     = null;

            foreach (User p in mas)
            {
                if (int.Parse(textBoxlogin.Text) != p.Room)
                {
                    t++;
                }
                else
                {
                    newuser = p;
                }
            }
            {
                if (int.Parse(textBoxlogin.Text) == newuser.Room && int.Parse(textBoxpassword.Text) == newuser.Reserv)

                {
                    //if (newworker.Profession == "Директор")
                    //{ this.NavigationService.Navigate(new DirectorsPage(newworker.Name)); }

                    try
                    {
                        reader = new StreamReader("profileinf.txt");
                        mas1   = (List <Profileinf>)ser1.Deserialize(reader);
                        reader.Close();
                        string user = newuser.Name();

                        foreach (Profileinf prof in mas1)
                        {
                            if (user == prof.Name)
                            {
                                inf = prof;

                                NavigationService.Navigate(new Profile(newuser, inf));
                            }
                            else
                            {
                                NavigationService.Navigate(new Profile(newuser));
                            }
                        }
                    }
                    catch { NavigationService.Navigate(new Profile(newuser)); }
                }
                else
                {
                    MessageBox.Show("Неверно введен логин или пароль", "Ошибка", MessageBoxButton.OK);
                }
                //User user = new User();
                //string[] readText = File.ReadAllLines(path);
                //for (int i = 3; i < readText.Length; i += 5)
                //{
                //    if (readText[i] == textBoxlogin.Text)
                //    {
                //        if (readText[i + 1] == textBoxpassword.Text)
                //        {

                //            user.LastName = readText[i - 3];
                //            user.FirstName = readText[i - 2];
                //            user.OtchName = readText[i - 1];
                //            user.Room = int.Parse(readText[i]);
                //            user.Reserv = int.Parse(readText[i + 1]);


                //            NavigationService.Navigate(new Profile(user));
                //        }
                //    }


                //Login1 w1 = new Login1();
                //w1.Show();
            }

            //  private void textBox_TextChanged(object sender, TextChangedEventArgs e)
            //{

            //    }
        }