コード例 #1
0
 private void toolStrip_delete_Click_1(object sender, EventArgs e)
 {
     //选中某一个学生之后,删除该学生的信息
     if (dataGridView1.SelectedRows.Count == 1)
     {
         if (MessageBox.Show("确定删除此学生信息?", "确认信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                             MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             int selectrow = Int32.Parse(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString());
             if (StudentInfoBLL.DeleteStudentInfo(selectrow))
             {
                 MessageBox.Show("删除学生信息成功");
             }
             else
             {
                 MessageBox.Show("删除学生信息失败,请检查是否选中学生信息!");
             }
             initContracts();
         }
     }
     else
     {
         MessageBox.Show("请选中一行再点击删除按钮");
     }
 }
コード例 #2
0
ファイル: Form_Main.cs プロジェクト: JkleLin/Code_Wearhouse
        private void updateProfessionTreeView()
        {
            StudentInfoBLL studentadd = new StudentInfoBLL();

            professionTreeView.Nodes.Clear();
            professionTreeView.Nodes.Add(studentadd.GetProfessionNode());
        }
コード例 #3
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
        private void toolStrip_edit_Click(object sender, EventArgs e)
        {
            //打开编辑
            if (dataGridView1.SelectedRows.Count == 1)
            {
                string    selectrow = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
                Form_Edit formedit  = new Form_Edit();
                formedit.studentid_edit = selectrow;
                formedit.ShowDialog();
                if (treeView1.SelectedNode != null)
                {
                    StudentInfo Rchose = new StudentInfo();

                    switch (treeView1.SelectedNode.Tag.ToString())
                    {
                    //通过调用search中现有的方法完成
                    case "0": dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo(); break;

                    case "1":
                        Rchose.Profession        = treeView1.SelectedNode.Text;
                        dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(Rchose);
                        break;
                        //使用Tag标志区别选中的标签类别,可以再次扩展,这里不做了,用Tag意义不大
                    }
                }
                else
                {
                    initContracts();
                }
            }
            else
            {
                MessageBox.Show("请选中一行后再点击编辑按钮");
            }
        }
コード例 #4
0
ファイル: Form_Search.cs プロジェクト: rfvscj/myContracts
        private void btn_search_Click(object sender, EventArgs e)
        {
            //查询
            if (cb_searchitem.Text == string.Empty)
            {
                dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
                InitHeadTitle();
            }
            else
            {
                if (txt_searchtext.Text != string.Empty)
                {
                    StudentInfo studentsearch = new StudentInfo();
                    switch (cb_searchitem.SelectedIndex)
                    {
                    case 0: studentsearch.StudentId = txt_searchtext.Text; break;

                    case 1: studentsearch.Name = txt_searchtext.Text; break;
                    }
                    dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(studentsearch);
                    InitHeadTitle();
                }
                else
                {
                    MessageBox.Show("请输入要查询的" + cb_searchitem.Text);
                }
            }
        }
コード例 #5
0
ファイル: Form_Edit.cs プロジェクト: cocos56/CS
        private void btn_update_Click(object sender, EventArgs e)
        {
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            studentinfo.StudentId = txt_studengid.Text;
            studentinfo.Name      = txt_name.Text;
            if (rb_man.Checked)
            {
                studentinfo.Sex = "男";
            }
            else if (rb_woman.Checked)
            {
                studentinfo.Sex = "女";
            }
            studentinfo.Age         = Int32.Parse(txt_age.Text);
            studentinfo.BirthDate   = DateTime.Parse(dt_birthdate.Text);
            studentinfo.Phone       = txt_phone.Text;
            studentinfo.Email       = txt_email.Text;
            studentinfo.HomeAddress = txt_homeaddress.Text;
            studentinfo.Profession  = txt_profession.Text;
            if (StudentInfoBLL.UpdateStudentInfo(studentinfo))
            {
                MessageBox.Show("修改学生信息成功!");
            }
        }
コード例 #6
0
ファイル: Form_Main.cs プロジェクト: JkleLin/Code_Wearhouse
        private void toolStrip_recover_Click(object sender, EventArgs e)
        {
            StudentInfoBLL studentsave = new StudentInfoBLL();

            studentsave.RecoverStudentInfo();
            initContracts();
        }
コード例 #7
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
        private void toolStrip_add_Click(object sender, EventArgs e)
        {
            //打开添加窗体
            Form_Add formadd = new Form_Add();

            formadd.ShowDialog();
            //添加删除或编辑后仍是当前选中节点的数据
            if (treeView1.SelectedNode != null)
            {
                StudentInfo Rchose = new StudentInfo();

                switch (treeView1.SelectedNode.Tag.ToString())
                {
                //通过调用search中现有的方法完成
                case "0": dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo(); break;

                case "1":
                    Rchose.Profession        = treeView1.SelectedNode.Text;
                    dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(Rchose);
                    break;
                    //使用Tag标志区别选中的标签类别,可以再次扩展,这里不做了,用Tag意义不大
                }
            }
            else
            {
                initContracts();
            }
        }
コード例 #8
0
ファイル: Form_Edit.cs プロジェクト: rfvscj/myContracts
        public void initControl()
        {
            //查询信息并显示编辑前信息
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            if (studentinfo != null)
            {
                txt_studentid.Text = studentinfo.StudentId;
                txt_name.Text      = studentinfo.Name;
                if (studentinfo.Sex == "男")
                {
                    rb_man.Checked   = true;
                    rb_woman.Checked = false;
                }
                else
                {
                    rb_man.Checked   = false;
                    rb_woman.Checked = true;
                }
                txt_age.Text         = studentinfo.Age.ToString();
                dt_birthdate.Text    = studentinfo.BirthDate.ToString();
                txt_phone.Text       = studentinfo.Phone;
                txt_email.Text       = studentinfo.Email;
                txt_homeaddress.Text = studentinfo.HomeAddress;
                txt_profession.Text  = studentinfo.Profession;
            }
        }
コード例 #9
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     try {
         StudentInfo studentinfo = new StudentInfo();
         studentinfo.StudentId = txt_studengid.Text;
         studentinfo.Name      = txt_name.Text;
         if (rb_man.Checked)
         {
             studentinfo.Sex = "男";
         }
         else if (rb_woman.Checked)
         {
             studentinfo.Sex = "女";
         }
         studentinfo.Age         = Int32.Parse(txt_age.Text);
         studentinfo.BirthDate   = DateTime.Parse(dt_birthdate.Text);
         studentinfo.Phone       = txt_phone.Text;
         studentinfo.Email       = txt_email.Text;
         studentinfo.HomeAddress = txt_homeaddress.Text;
         studentinfo.Profession  = txt_profession.Text;
         if (StudentInfoBLL.AddStudentInfo(studentinfo))
         {
             MessageBox.Show("添加学生信息成功!");
         }
     }catch (Exception)
     {
         MessageBox.Show("有数据输入错误!", "错误", MessageBoxButtons.OK);
     }
 }
コード例 #10
0
ファイル: Form_Edit.cs プロジェクト: cocos56/CS
        private void button1_Click(object sender, EventArgs e)
        {
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            if (studentinfo != null)
            {
                txt_studengid.Text = studentinfo.StudentId.ToString();
                txt_name.Text      = studentinfo.Name;
                if (studentinfo.Sex == "男")
                {
                    rb_man.Checked   = true;
                    rb_woman.Checked = false;
                }
                else
                {
                    rb_man.Checked   = false;
                    rb_woman.Checked = true;
                }
                txt_age.Text         = studentinfo.Age.ToString();
                dt_birthdate.Text    = studentinfo.BirthDate.ToString();
                txt_phone.Text       = studentinfo.Phone;
                txt_email.Text       = studentinfo.Email;
                txt_homeaddress.Text = studentinfo.HomeAddress;
                txt_profession.Text  = studentinfo.Profession;
            }
        }
コード例 #11
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_studengid.Text == "" ||
                txt_age.Text == "" ||
                txt_email.Text == "" ||
                txt_homeaddress.Text == "" ||
                txt_name.Text == "" ||
                txt_phone.Text == "" ||
                txt_profession.Text == "" ||
                (rb_man.Checked == false &&
                 rb_woman.Checked == false))
            {
                MessageBox.Show("添加学生信息失败,请检查信息是否填写完整。");
                return;
            }

            StudentInfo studentinfo = new StudentInfo();

            studentinfo.StudentId = Int32.Parse(txt_studengid.Text);
            studentinfo.Name      = txt_name.Text;
            if (rb_man.Checked)
            {
                studentinfo.Sex = "男";
            }
            else if (rb_woman.Checked)
            {
                studentinfo.Sex = "女";
            }
            studentinfo.Age         = Int32.Parse(txt_age.Text);
            studentinfo.BirthDate   = DateTime.Parse(dt_birthday.Text);
            studentinfo.Phone       = txt_phone.Text;
            studentinfo.Email       = txt_email.Text;
            studentinfo.HomeAddress = txt_homeaddress.Text;
            studentinfo.Profession  = txt_profession.Text;

            if (StudentInfoBLL.AddStudentInfo(studentinfo))
            {
                MessageBox.Show("添加学生信息成功!");
                txt_studengid.Text   = "";
                txt_age.Text         = "";
                txt_email.Text       = "";
                txt_homeaddress.Text = "";
                txt_name.Text        = "";
                txt_phone.Text       = "";
                txt_profession.Text  = "";
                dt_birthday.Value    = DateTime.Now;
                rb_man.Checked       = false;
                rb_woman.Checked     = false;
            }
            else
            {
                MessageBox.Show("添加学生信息失败,学生编号重复。");
            }
        }
コード例 #12
0
ファイル: Form_Main.cs プロジェクト: JkleLin/Code_Wearhouse
        private void professionTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode pnode = professionTreeView.SelectedNode;

            if (pnode.Text != "专业")
            {
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoListByProfession(pnode.Text);
            }
            else
            {
                dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
            }
        }
コード例 #13
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            StudentInfo student = new StudentInfo();

            student.Profession = treeView1.SelectedNode.Text;
            if (treeView1.SelectedNode.Text == "全部")
            {
                dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
            }
            else
            {
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(student);
            }
        }
コード例 #14
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            StudentInfo Rchose = new StudentInfo();

            switch (e.Node.Tag.ToString())
            {
            //通过调用search中现有的方法完成
            case "0": dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo(); break;

            case "1": Rchose.Profession  = treeView1.SelectedNode.Text;
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(Rchose);
                break;

                //使用Tag标志区别选中的标签类别,可以再次扩展,这里不做了,用Tag意义不大
            }
        }
コード例 #15
0
ファイル: Form_Edit.cs プロジェクト: NNroc/ProgrammingStudio
        private void btn_edit_Click(object sender, EventArgs e)
        {
            StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);

            Regex r = new Regex("^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$");

            if (!r.IsMatch(txt_email.Text.ToString()))
            {
                MessageBox.Show(txt_email.Text.ToString() + " 不是个正确的邮箱");
                return;
            }

            Regex id = new Regex("^\\+?[1-9][0-9]*$");

            if (!id.IsMatch(txt_studengid.Text))
            {
                MessageBox.Show("编号" + txt_studengid.Text + "不是个正整数");
                return;
            }

            studentinfo.StudentId = Int32.Parse(txt_studengid.Text);
            studentinfo.Name      = txt_name.Text;
            if (rb_man.Checked)
            {
                studentinfo.Sex = "男";
            }
            else if (rb_woman.Checked)
            {
                studentinfo.Sex = "女";
            }
            studentinfo.Age         = Int32.Parse(txt_age.Text);
            studentinfo.BirthDate   = DateTime.Parse(dt_birthday.Text);
            studentinfo.Phone       = txt_phone.Text;
            studentinfo.Email       = txt_email.Text;
            studentinfo.HomeAddress = txt_homeaddress.Text;
            studentinfo.Profession  = txt_profession.Text;

            if (StudentInfoBLL.UpdateStudentInfo(studentinfo))
            {
                MessageBox.Show("修改学生信息成功!");
            }
        }
コード例 #16
0
 void initContracts()
 {
     //不存在students.xml,则先行创建
     if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/Students.xml"))
     {
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     else
     {
         StudentInfoBLL.CreateStudentXml();
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     dataGridView1.Columns[0].HeaderText = "学生编号";
     dataGridView1.Columns[1].HeaderText = "学生姓名";
     dataGridView1.Columns[2].HeaderText = "学生性别";
     dataGridView1.Columns[3].HeaderText = "学生年龄";
     dataGridView1.Columns[4].HeaderText = "出生日期";
     dataGridView1.Columns[5].HeaderText = "手机号码";
     dataGridView1.Columns[6].HeaderText = "家庭地址";
     dataGridView1.Columns[7].HeaderText = "电子邮箱";
     dataGridView1.Columns[8].HeaderText = "专    业";
 }
コード例 #17
0
ファイル: Form_Main.cs プロジェクト: JkleLin/Code_Wearhouse
 void initContracts()
 {
     //if "Students.xml" is esixt,Check all student's information.else create a document and check
     if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/xml/Students.xml"))
     {
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     else
     {
         StudentInfoBLL.CreateStudentXml();
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     dataGridView1.Columns[0].HeaderText = "学生编号";
     dataGridView1.Columns[1].HeaderText = "学生姓名";
     dataGridView1.Columns[2].HeaderText = "学生性别";
     dataGridView1.Columns[3].HeaderText = "学生年龄";
     dataGridView1.Columns[4].HeaderText = "出生日期";
     dataGridView1.Columns[5].HeaderText = "手机号码";
     dataGridView1.Columns[6].HeaderText = "家庭地址";
     dataGridView1.Columns[7].HeaderText = "电子邮箱";
     dataGridView1.Columns[8].HeaderText = "专业学科";
     updateProfessionTreeView();
 }
コード例 #18
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
 void initContracts()
 {
     //如果存在Students.xml,查询所有学生信息,如果不存在,则创建该文件后再查询
     if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/xml/Students.xml"))
     {
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     else
     {
         StudentInfoBLL.CreateStudentXml();
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     //初始化数据表格dataGridView1的列标题
     dataGridView1.Columns[0].HeaderText = "学生编号";
     dataGridView1.Columns[1].HeaderText = "学生姓名";
     dataGridView1.Columns[2].HeaderText = "学生性别";
     dataGridView1.Columns[3].HeaderText = "学生年龄";
     dataGridView1.Columns[4].HeaderText = "出生日期";
     dataGridView1.Columns[5].HeaderText = "手机号码";
     dataGridView1.Columns[6].HeaderText = "家庭住址";
     dataGridView1.Columns[7].HeaderText = "电子邮箱";
     dataGridView1.Columns[8].HeaderText = "专  业";
 }
コード例 #19
0
ファイル: Form_Edit.cs プロジェクト: rfvscj/myContracts
 private void btn_update_Click(object sender, EventArgs e)
 {
     try {
         //更新学生编辑信息
         StudentInfo studentinfo = StudentInfoBLL.GetStudentInfo(studentid_edit);
         //studentinfo.StudentId = Int32.Parse(txt_studengid.Text);
         studentinfo.Name = txt_name.Text;
         if (rb_man.Checked)
         {
             studentinfo.Sex = "男";
         }
         else if (rb_woman.Checked)
         {
             studentinfo.Sex = "女";
         }
         studentinfo.Age         = Int32.Parse(txt_age.Text);
         studentinfo.BirthDate   = DateTime.Parse(dt_birthdate.Text);
         studentinfo.Phone       = txt_phone.Text;
         studentinfo.Email       = txt_email.Text;
         studentinfo.HomeAddress = txt_homeaddress.Text;
         studentinfo.Profession  = txt_profession.Text;
         if (StudentInfoBLL.UpdateStudentInfo(studentinfo))
         {
             MessageBox.Show("修改学生信息成功!");
         }
     }catch (Exception)
     {
         if (String.IsNullOrEmpty(txt_age.Text))
         {
             MessageBox.Show("年龄输入不能为空!");
         }
         else
         {
             MessageBox.Show("请不要修改学生编号!", "错误", MessageBoxButtons.OK);
         }
     }
 }
コード例 #20
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openfile = new OpenFileDialog();

            openfile.InitialDirectory = @"C:\Documents and Settings\Administrator\桌面";//打开文件的初始目录
            openfile.Filter           = "xmlbak文件(*.xmlbak)|";
            openfile.DefaultExt       = ".xmlbak";
            DialogResult dr1 = openfile.ShowDialog();

            if (dr1 == DialogResult.OK)
            {
                String filePath = openfile.FileName.ToString();
                try
                {
                    //获取用户选择文件的后缀名
                    string extension = Path.GetExtension(openfile.FileName);
                    if (extension != ".xmlbak")
                    {
                        MessageBox.Show("请选择.xmlbak后缀的文件");
                    }
                    else
                    {
                        if (!(File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/xml/Students.xml")))
                        {
                            StudentInfoBLL.CreateStudentXml();
                        }
                        string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/xml/Students.xml";
                        File.Copy(filePath, path, true);
                        MessageBox.Show("恢复成功!", "成功", MessageBoxButtons.OK);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("未知异常!", "异常", MessageBoxButtons.OK);
                }
            }
        }
コード例 #21
0
ファイル: Form_Add.cs プロジェクト: NNroc/ProgrammingStudio
        private void btn_add_Click(object sender, EventArgs e)
        {
            if (txt_studengid.Text == "" ||
                txt_age.Text == "" ||
                txt_email.Text == "" ||
                txt_homeaddress.Text == "" ||
                txt_name.Text == "" ||
                txt_phone.Text == "" ||
                txt_profession.Text == "" ||
                (rb_man.Checked == false &&
                 rb_woman.Checked == false))
            {
                MessageBox.Show("添加学生信息失败,请检查信息是否填写完整。");
                return;
            }
            StudentInfo studentinfo = new StudentInfo();

            Regex r = new Regex("^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$");

            if (!r.IsMatch(txt_email.Text.ToString()))
            {
                MessageBox.Show(txt_email.Text.ToString() + " 不是个正确的邮箱");
                return;
            }

            Regex id = new Regex("^\\+?[1-9][0-9]*$");

            if (!id.IsMatch(txt_studengid.Text))
            {
                MessageBox.Show("编号" + txt_studengid.Text + "不是个正整数");
                return;
            }

            studentinfo.StudentId = Int32.Parse(txt_studengid.Text);
            studentinfo.Name      = txt_name.Text;
            if (rb_man.Checked)
            {
                studentinfo.Sex = "男";
            }
            else if (rb_woman.Checked)
            {
                studentinfo.Sex = "女";
            }
            studentinfo.Age         = Int32.Parse(txt_age.Text);
            studentinfo.BirthDate   = DateTime.Parse(dt_birthday.Text);
            studentinfo.Phone       = txt_phone.Text;
            studentinfo.Email       = txt_email.Text;
            studentinfo.HomeAddress = txt_homeaddress.Text;
            studentinfo.Profession  = txt_profession.Text;

            if (StudentInfoBLL.AddStudentInfo(studentinfo))
            {
                MessageBox.Show("添加学生信息成功!");
                txt_studengid.Text   = "";
                txt_age.Text         = "";
                txt_email.Text       = "";
                txt_homeaddress.Text = "";
                txt_name.Text        = "";
                txt_phone.Text       = "";
                txt_profession.Text  = "";
                dt_birthday.Value    = DateTime.Now;
                rb_man.Checked       = false;
                rb_woman.Checked     = false;
            }
            else
            {
                MessageBox.Show("添加学生信息失败,学生编号重复。");
            }
        }
コード例 #22
0
ファイル: Form_Main.cs プロジェクト: JkleLin/Code_Wearhouse
        private void toolStrip_backup_Click(object sender, EventArgs e)
        {
            StudentInfoBLL studentsave = new StudentInfoBLL();

            studentsave.SaveStudentInfoList();
        }
コード例 #23
0
ファイル: Form_Main.cs プロジェクト: rfvscj/myContracts
        private void toolStrip_delete_Click(object sender, EventArgs e)
        {
            //删除信息
            if (dataGridView1.SelectedRows.Count == 1)
            {
                if (MessageBox.Show("确定要删除此学生信息?", "确认信息", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    string selectrow = dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString();
                    if (StudentInfoBLL.DeleteStudentInfo(selectrow))
                    {
                        MessageBox.Show("删除学生信息成功!");
                        if (treeView1.SelectedNode != null)
                        {
                            StudentInfo Rchose = new StudentInfo();

                            switch (treeView1.SelectedNode.Tag.ToString())
                            {
                            //通过调用search中现有的方法完成
                            case "0": dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo(); break;

                            case "1":
                                Rchose.Profession        = treeView1.SelectedNode.Text;
                                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(Rchose);
                                break;
                                //使用Tag标志区别选中的标签类别,可以再次扩展,这里不做了,用Tag意义不大
                            }
                        }
                        else
                        {
                            initContracts();
                        }
                    }

                    else
                    {
                        MessageBox.Show("删除学生信息失败,请检查是否选中学生信息!");
                        if (treeView1.SelectedNode != null)
                        {
                            StudentInfo Rchose = new StudentInfo();

                            switch (treeView1.SelectedNode.Tag.ToString())
                            {
                            //通过调用search中现有的方法完成
                            case "0": dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo(); break;

                            case "1":
                                Rchose.Profession        = treeView1.SelectedNode.Text;
                                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(Rchose);
                                break;
                                //使用Tag标志区别选中的标签类别,可以再次扩展,这里不做了,用Tag意义不大
                            }
                        }
                        else
                        {
                            initContracts();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("请选中一行后再点击删除按钮!");
                }
            }
        }