Exemplo n.º 1
0
        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("请选中一行后再点击编辑按钮");
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        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意义不大
            }
        }
Exemplo n.º 7
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 = "专    业";
 }
Exemplo n.º 8
0
 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 = "专  业";
 }
Exemplo n.º 9
0
 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();
 }
Exemplo n.º 10
0
        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("请选中一行后再点击删除按钮!");
                }
            }
        }