示例#1
0
文件: Form1.cs 项目: meishax/Contacts
 void initContracts()
 {
     //如果存在Student.xml查询所有学生信息,如果不存在,则创建后在查询
     if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"/xml/Student.xml"))
     {
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     else
     {
         StudentInfoBLL.CreateStudentXml();
         dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
     }
     //初始化数据表格dataGitlView的列标题
     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 = "专    业";
 }
示例#2
0
文件: Form1.cs 项目: meishax/Contacts
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            StudentInfo studentInfo = new StudentInfo();

            if (treeView1.SelectedNode.Text == "计算机科学与技术")
            {
                studentInfo.Profession   = "计算机科学与技术";
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(studentInfo);
            }
            else if (treeView1.SelectedNode.Text == "电子信息科学与技术")
            {
                studentInfo.Profession   = "电子信息科学与技术";
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(studentInfo);
            }
            else if (treeView1.SelectedNode.Text == "信息安全")
            {
                studentInfo.Profession   = "信息安全";
                dataGridView1.DataSource = StudentInfoBLL.GetStudentInfoList(studentInfo);
            }
            else
            {
                dataGridView1.DataSource = StudentInfoBLL.GetAllStudentInfo();
            }
        }