protected void Button1_Click(object sender, EventArgs e)
    {
        studentBLL StudentBLL = new studentBLL();
        student Student = new student();
        DataSet Students = new DataSet();
        int select = Convert.ToInt32(DropDownList1.SelectedValue);
        try
        {
            switch (select)
            {
                case 0: Students = StudentBLL.GetList("[stuId] LIKE '%" + Tools.safeUserInput(TextBox1.Text.Trim()) + "%'");
                    GridView3.DataSource = Students;
                    GridView3.DataBind();
                    Panel1.Visible = false;
                    Panel2.Visible = false;
                    Panel3.Visible = true;
                    break;
                    break;
                case 1: Students = StudentBLL.GetList("[name] LIKE '%" + Tools.safeUserInput(TextBox1.Text.Trim()) + "%'");
                    GridView3.DataSource = Students;
                    GridView3.DataBind();
                    Panel1.Visible = false;
                    Panel2.Visible = false;
                    Panel3.Visible = true;
                    break;
                case 2: Student = StudentBLL.GetModelList("[certificateId] ='" +Tools.safeUserInput( TextBox1.Text.Trim() )+ "'")[0];
                    Response.Redirect("studentView.aspx?id=" + Student.id);
                    break;
                case 3: Student = StudentBLL.GetModelList("[phone] ='" + Tools.safeUserInput(TextBox1.Text.Trim()) + "'")[0];
                    Response.Redirect("studentView.aspx?id=" + Student.id);
                    break;

            }
        }
        catch {
            MessageBox.Show(this, "查询失败!");
        }
    }
        /// <summary>
        /// 添加EXCEL信息
        /// </summary>
        public int Add(Page page, FileUpload fu, int classId)
        {
            examrecordDAL ExamRecordDAL = new examrecordDAL();
            try
            {
                int i = 0;
                if (fu.HasFile == false)
                {
                    MessageBox.Show(page, "请选择您要上传的Excel文件!");
                    return 0;//当无文件时,返回
                }
                string IsXls = System.IO.Path.GetExtension(fu.FileName).ToString().ToLower();
                if (IsXls != ".xls")
                {
                    MessageBox.Show(page, "只可以上传Excel文件!");
                    return 0;//当选择的不是Excel文件时,返回
                }
                string path = page.Server.MapPath("storage/scoreInput/");
                string strpath = fu.PostedFile.FileName.ToString();   //获取Execle文件路径
                string filename = "批量成绩信息" + System.DateTime.Now.ToString("yyyyMMddHHmmss").Trim() + ".xls"; //从时间获取文件路径
                fu.PostedFile.SaveAs(path + filename);
                DataSet ds = Tools.ExecleDs(path + filename, filename);
                DataRow[] dr = ds.Tables[0].Select();                        //定义一个DataRow数组
                int rowsnum = ds.Tables[0].Rows.Count;
                if (rowsnum == 0)
                {
                    //Response.Write("<script>alert('Excel表为空表,无数据!')</script>");
                    MessageBox.Show(page, "Excel表为空表,无数据!");//当Excel表为空时,对用户进行提示
                    return 0;
                }
                else
                {
                    for (i = 0; i < dr.Length; i++)
                    {
                        if (isInClass(dr[i]["任课教师"].ToString(), dr[i]["课程名称"].ToString(), classId))
                        {
                            examrecord ExamRecord = new examrecord();
                            string stuId = dr[i]["学生学号"].ToString();
                            if (stuId.Length < 1)
                            {
                                MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生学号不能为空,请检查数据");
                                return i;
                            }
                            else
                            {
                                studentBLL StudentBLL = new studentBLL();
                                student Student = null;
                                try
                                {
                                    Student = StudentBLL.GetModelList("stuId='" + stuId + "'")[0];
                                }
                                catch
                                {
                                    MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生学号不存在,请检查数据");
                                    return i;
                                }
                                if (Student != null)
                                {
                                    if (Student.name.Trim().Equals(dr[i]["学生姓名"].ToString().Trim()))
                                    {
                                        ExamRecord.student = stuId;
                                    }
                                    else
                                    {
                                        MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生学号不存在,请检查数据");
                                        return i;
                                    }
                                }

                            }
                            int score = 0;
                            try
                            {
                                score = Convert.ToInt32(dr[i]["成绩"].ToString());
                            }
                            catch
                            {
                                MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生成绩仅可以为数字且不能为空,请检查数据");
                                return i;
                            }
                            if (score != 0)
                            {
                                ExamRecord.score = score.ToString();
                            }
                            else
                            {
                                MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生成绩仅可以为数字且不能为空,请检查数据");
                                return i;
                            }
                            ExamRecord.classId = classId.ToString();
                            ExamRecordDAL.Add(ExamRecord);
                        }
                        else
                        {
                            MessageBox.Show(page, "导入第" + (i + 1).ToString() + "个成绩信息失败,学生课程名称不存在,请检查数据");
                            return i;
                        }
                    }
                    return i;
                }

            }
            catch { return 0; }
            finally { }
        }