Example #1
0
 private void button13_Click(object sender, EventArgs e)
 {
     if (textBox2.Text != "")
     {
         try
         {
             int     serchkey = Convert.ToInt32(textBox2.Text);
             Student todel    = Serchclass.Liniersearch(students, serchkey);
             if (todel == null)
             {
                 MessageBox.Show("that element not exist");
             }
             students.Remove(todel);
             textBox1.Clear();
             for (int i = 0; i < students.Count; i++)
             {
                 textBox1.AppendText(students[i].printinfo());
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("uncorrect data");
         }
     }
     else
     {
         MessageBox.Show("wrong data");
     }
 }
Example #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox2.Text != "" && textBox3.Text != "")
            {
                Student temp = Serchclass.Liniersearch(students, Convert.ToInt32(textBox2.Text));
                bool    flag = false;
                if (temp != null)
                {
                    for (int i = 0; i < students.Count; i++)
                    {
                        if (temp.Name == students[i].Name || temp.Number == students[i].Number)
                        {
                            MessageBox.Show("this element already exist");
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    try
                    {
                        students.Add(new Student(textBox3.Text, Convert.ToInt32(textBox2.Text)));
                        textBox1.AppendText(students[students.Count - 1].printinfo());
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("uncorrect data");
                    }
                }
            }

            else
            {
                MessageBox.Show("wrong data");
            }
        }
Example #3
0
 private void button8_Click(object sender, EventArgs e)
 {
     if (textBox5.Text != "")
     {
         //bool excep = true;
         int serchkey = 0;
         try
         {
             serchkey = Convert.ToInt32(textBox5.Text);
             int     equal = 0;
             Student flag  = Serchclass.Liniersearch(students, serchkey, ref equal);
             if (flag != null)
             {
                 MessageBox.Show(flag.printinfo() + "number of comparisons: " + equal);
             }
             else
             {
                 MessageBox.Show("elemnt not exist");
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("uncorrect data");
         }
         //int equal = 0;
         //Student flag = Serchclass.Liniersearch(students, serchkey, ref equal);
         //if (flag != null)
         //    MessageBox.Show(flag.printinfo() + "number of comparisons: " + equal);
         //else
         //    MessageBox.Show("elemnt not exist");
     }
     else
     {
         MessageBox.Show("no key inputed");
     }
 }