예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Regex patter = new Regex(@"[1-9]");

            if (patter.IsMatch(textBox2.Text.ToString()))
            {
                textBox2.BackColor = Color.White;
                int   value            = Convert.ToInt32(textBox2.Text);
                var   deserializeUsers = XmlSerializeWrapper.Deserialize <List <Student> >("student.xml");
                Regex parttern         = new Regex($@"[{value}-9]");

                foreach (Student a in deserializeUsers)
                {
                    if (parttern.IsMatch(a.averageMark.ToString()))
                    {
                        textBox1.Text += Environment.NewLine + "ФИО: " + a.FIO + Environment.NewLine + "Оценка: " + a.averageMark;
                    }
                }
            }
            else
            {
                MessageBox.Show("Выход за пределы допустимого диапазона");
                textBox2.BackColor = Color.OrangeRed;
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var deserializeUsers = XmlSerializeWrapper.Deserialize <List <Student> >("student.xml");

            foreach (Student a in deserializeUsers)
            {
                textout.Text += "ФИО: " + a.FIO + Environment.NewLine + "Дата рождения: " + a.DateOFBirthdat.ToLongDateString() + Environment.NewLine + "Курс " + a.course + Environment.NewLine + "Пол " + a.gender + Environment.NewLine + "Специальность " + a.Specialty + Environment.NewLine + "/////////////////" + Environment.NewLine;
            }
        }
예제 #3
0
        private void Looking_Click(object sender, EventArgs e)
        {
            Regex patter = new Regex(@"\D*");

            if (patter.IsMatch(FIO.Text) == true)
            {
                FIO.BackColor = Color.White;
                var deserializeUsers = XmlSerializeWrapper.Deserialize <List <Student> >("student.xml");
                foreach (Student a in deserializeUsers)
                {
                    if (a.FIO.ToUpper() == FIO.Text.ToUpper())
                    {
                        textBox1.Text += "ФИО: " + a.FIO + Environment.NewLine + "Специальность: " + a.Specialty + Environment.NewLine + "Пол: " + a.gender + Environment.NewLine + " Группа" + a.group + Environment.NewLine;
                    }
                    else
                    {
                        int index     = 0;
                        int endOfName = 0;
                        for (int i = 0; i < FIO.Text.Length; i++)
                        {
                            if (endOfName == 1 && FIO.Text[i] == ' ')
                            {
                                endOfName = i - 1;
                                break;
                            }
                            if (FIO.Text[i] == ' ' && endOfName == 0)
                            {
                                index = i + 1;
                                endOfName++;
                            }
                        }
                        int             Length   = endOfName - index;
                        Regex           findWord = new Regex(@"^" + FIO.Text.Substring(0, 2) + @"\D*", RegexOptions.IgnoreCase);
                        MatchCollection match    = findWord.Matches(a.FIO);
                        if (findWord.IsMatch(a.FIO))
                        {
                            textBox1.Text += "Не удалось найти студента, но есть похожие варианты:" + Environment.NewLine;
                            foreach (Match stud in match)
                            {
                                textBox1.Text += stud.Value + Environment.NewLine;
                            }
                            textBox1.Text += "////////////////////////" + Environment.NewLine;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Не соотвествует формату ФИО");
                FIO.BackColor = Color.OrangeRed;
            }
        }
예제 #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex == -1)
     {
         MessageBox.Show("Не выбрано значение");
     }
     else
     {
         textBox1.Clear();
         var deserializeUsers = XmlSerializeWrapper.Deserialize <List <Student> >("student.xml");
         foreach (Student a in deserializeUsers)
         {
             if (a.Specialty.ToUpper() == comboBox1.SelectedItem.ToString().ToUpper())
             {
                 textBox1.Text += Environment.NewLine + "ФИО: " + a.FIO + Environment.NewLine + "Специальность: " + a.Specialty + Environment.NewLine + "Пол: " + a.gender + Environment.NewLine + " Группа" + a.group + Environment.NewLine;
             }
         }
     }
 }