public static int i=0;//用于记录学生人数

        //ShowRequireInfo ShowRequireInfoDlg = new ShowRequireInfo();

        //构造函数,完成初始化功能
        //public StudentList()
        //{
        //    student = new Student[50];
        //    i = 0;
        //}
        
        
        /// <summary>
        /// 增加学生信息的方法
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Name"></param>
        /// <param name="Class"></param>
        /// <param name="chinese"></param>
        /// <param name="math"></param>
        /// <param name="english"></param>
        /// <returns></returns>
        public static void AddStudent(Student iStudent)
        {
            //STU[i] = new Student();
            int k;
            if (i >= 0)
            {
                for (k = 0; k < i; k++)
                {
                    if (iStudent.STRID == STU[k].STRID)
                    {
                        MessageBox.Show("This ID Already exists!");
                        break;
                    }
                }
                if (k == i)
                {
                    STU[i] = new Student();
                    STU[i] = iStudent;
                    ++i;
                    MessageBox.Show("Success!");
                }
                else
                    MessageBox.Show("Failing");
                
                
                //MessageBox.Show(Convert.ToString(STU[i-1].ALL));
            }
            else
                MessageBox.Show("Error!");
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {

            Student iStudent = new Student();

            iStudent.STRID = Convert.ToString(textBoxID.Text);
            iStudent.STRNAME = Convert.ToString(textBoxName.Text);
            iStudent.STRCLASS = Convert.ToString(textBoxClass.Text);

            iStudent.CHINESE = Convert.ToSingle(textBoxChinese.Text);
            iStudent.MATH = Convert.ToSingle(textBoxMath.Text);
            iStudent.ENGLISH = Convert.ToSingle(textBoxEnglish.Text);
            iStudent.ALL = iStudent.CHINESE + iStudent.MATH + iStudent.ENGLISH;
            if (StudentList.AddStudent(iStudent) == 1)
            {
                MessageBox.Show("Your total score:" + Convert.ToString(iStudent.ALL));
            }
            
            //labelAllPoint.Text = Convert.ToString(iStudent.ALL);

            //置空textbox
            textBoxID.Text = "";
            textBoxName.Text = "";
            textBoxClass.Text = "";
            textBoxChinese.Text = "";
            textBoxMath.Text = "";
            textBoxEnglish.Text = "";

            

        }
        public static float total = 0;//用于记录全班总成绩的总成绩

        //ShowRequireInfo ShowRequireInfoDlg = new ShowRequireInfo();

        //构造函数,完成初始化功能
        //public StudentList()
        //{
        //    student = new Student[50];
        //    i = 0;
        //}
        
        
        /// <summary>
        /// 增加学生信息的方法
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Name"></param>
        /// <param name="Class"></param>
        /// <param name="chinese"></param>
        /// <param name="math"></param>
        /// <param name="english"></param>
        /// <returns></returns>
        public static int AddStudent(Student iStudent)
        {
            STU[studentNum] = new Student();
            if (studentNum == 0)
            {
                STU[0] = iStudent;
                studentNum++;
                total += STU[0].ALL;
                MessageBox.Show("Success!");
                return 1;
            }
            else
            {
                int k;
                for (k = 0; k < studentNum; k++)
                {
                    STU[k] = new Student();
                    if (iStudent.STRID == STU[k].STRID)
                    {
                        MessageBox.Show("Already exists!");
                        return 0;
                        //break;
                    }
                    else
                    {
                        STU[studentNum] = iStudent;
                        total += STU[studentNum].ALL;

                        ++studentNum;
                        MessageBox.Show("Success!");
                        return 1;
                    }
                }
                if (k >= studentNum)
                {
                    return 0;
                }
                else
                    return 1;
                
            }

            //    //MessageBox.Show(Convert.ToString(STU[i-1].ALL));
            
            //else
            //    MessageBox.Show("Error!");
        }
        private void ShowRequireInfo_Load(object sender, EventArgs e)
        {
            //labelShow.Text="Name    Secore";
            //if (ShowSelect.flag[])
            {
                for (int k = 0; k < StudentList.studentNum; k++)
                {
                    Student STU = new Student();
                    STU = StudentList.ShowAllStudent(k);
                    listBox1.Items.Add(Convert.ToString(STU.STRNAME));
                    listBox2.Items.Add(Convert.ToString(STU.STRID));
                    listBox3.Items.Add(Convert.ToString(STU.STRCLASS));
                    listBox4.Items.Add(Convert.ToString(STU.CHINESE));
                    listBox5.Items.Add(Convert.ToString(STU.MATH));
                    listBox6.Items.Add(Convert.ToString(STU.ENGLISH));
                    listBox7.Items.Add(Convert.ToString(STU.ALL));
                    
                    //labelShow.Text = Convert.ToString(STU.STRNAME + "      " +
                    //    "      " + STU.STRID + "      " + STU.STRCLASS + "      " +
                    //    "      " + STU.CHINESE + "      " + STU.MATH + "      " +
                    //    "      " + STU.ENGLISH + "      " + STU.ALL);
                }
                if (StudentList.Average() != 0)
                    textBoxAvarage.Text = Convert.ToString(StudentList.Average());
              
                   
            }

            //ShowSelect ShowSelectDlg = new ShowSelect();
            //if (ShowSelectDlg.)
            //{
            //}

            //if (Convert.ToBoolean(comboBoxShow.Items.Add("sss")))
            //    labelShow.Text = "ssdfdfadf";
            labelShow.Text = "Hello";
            comboBoxShow.Items.Add("The Top of Three");
            comboBoxShow.Items.Add("Failing");
            comboBoxShow.Items.Add("Analysis Chinese");
            comboBoxShow.Items.Add("Analysis Math");
            comboBoxShow.Items.Add("Analysis English");
        }
        private void ShowRequireInfo_Load(object sender, EventArgs e)
        {
            comboBoxShow.Items.Add("The Top of Three");
            //comboBoxShow.Items.Add("Failing");
            comboBoxShow.Items.Add("Analysis Chinese");
            comboBoxShow.Items.Add("Analysis Math");
            comboBoxShow.Items.Add("Analysis English");


            //listBox中展示所有学生成绩
            for (int k = 0; k < StudentList.i; k++)
            {
                Student STU = new Student();
                STU = StudentList.ShowAllStudent(k);
                listBox1.Items.Add(Convert.ToString(STU.STRNAME));
                listBox2.Items.Add(Convert.ToString(STU.STRID));
                listBox3.Items.Add(Convert.ToString(STU.STRCLASS));
                listBox4.Items.Add(Convert.ToString(STU.CHINESE));
                listBox5.Items.Add(Convert.ToString(STU.MATH));
                listBox6.Items.Add(Convert.ToString(STU.ENGLISH));
                listBox7.Items.Add(Convert.ToString(STU.ALL));

                //labelShow.Text = Convert.ToString(STU.STRNAME + "      " +
                //    "      " + STU.STRID + "      " + STU.STRCLASS + "      " +
                //    "      " + STU.CHINESE + "      " + STU.MATH + "      " +
                //    "      " + STU.ENGLISH + "      " + STU.ALL);
            }
            //求总分平均数模块
            if (StudentList.Average() != 0)
                textBoxAvarage.Text = Convert.ToString(StudentList.Average());

            //labelShow.Text = Convert.ToString(STU.STRNAME + "      " +
            //    "      " + STU.STRID + "      " + STU.STRCLASS + "      " +
            //    "      " + STU.CHINESE + "      " + STU.MATH + "      " +
            //    "      " + STU.ENGLISH + "      " + STU.ALL);

        }
        /// <summary>
        /// 排序,将全班成绩按照从大到小依次排列
        /// </summary>
        public static int SortByScore()
        {
            if (i == 1)
            {
                return 1;
            }
            else
            {
                for (int k = 0; k < i ; k++)
                {
                    //float MaxScore = STU[k].ALL;
                    //STU[k] = new Student();
                    for (int m = 1; m < i; m++)
                    {
                        if (STU[m].ALL > STU[k].ALL)
                        {
                            //STU[k] = new Student();
                            //float temp;
                            //temp = MaxScore;
                            //MaxScore = STU[m].ALL;
                            //STU[m].ALL = temp;
                            Student stutemp = new Student();
                            stutemp = STU[k];
                            STU[k] = STU[m];
                            STU[m] = stutemp;
                        }
                        else
                            continue;
                    }
                }
                return 2;
            }

            
        }
        /// <summary>
        /// 显示所要查询的学生的信息
        /// </summary>
        /// <param name="SubName"></param>
        /// <returns></returns>
        public static int Search(string SubName)
        {
            int k=0;
            if (studentNum == 0)
            {
                MessageBox.Show("There is no students!");
                return -1;
            }
            else
            {
                for (k = 0; k < studentNum; k++)
                {
                    STU[k] = new Student();
                    string name = STU[k].STRNAME;
                    if (name == SubName)
                    {
                        break;
                    }
                    else
                        continue;
                }

                if (k > studentNum)
                {
                    return -1;
                }
                else
                    return k;
            }
        }
 /// <summary>
 /// 排序,将全班成绩按照从大到小依次排列
 /// </summary>
 public static int SortByScore()
 {
     Student stutemp = new Student();
     for (int k = 0; k < studentNum+1; k++)
     {
         STU[k] = new Student();
         //float MaxScore = STU[k].ALL;
         for (int m = 1; m < studentNum+1; m++)
         {
             STU[m] = new Student();
             if (STU[m].ALL > STU[k].ALL)
             {                        
                 stutemp = STU[k];
                 STU[k] = STU[m];
                 STU[m] = stutemp;
             }
             else
                 continue;
         }
     }
     return 1;
 }