//更新表
        void RefreshData()
        {
            string  sqlStr;
            DataSet ds = new DataSet();

            sqlStr = "select * from tb_Student";
            ds     = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvStudent.DataSource            = ds.Tables[0];
                dgrdvStudent.Columns[0].HeaderText = "学生学号";
                dgrdvStudent.Columns[0].Width      = 168;
                dgrdvStudent.Columns[1].HeaderText = "学生姓名";
                dgrdvStudent.Columns[1].Width      = 159;
                dgrdvStudent.Columns[2].HeaderText = "学生性别";
                dgrdvStudent.Columns[2].Width      = 88;
                dgrdvStudent.Columns[3].HeaderText = "学生年龄";
                dgrdvStudent.Columns[3].Width      = 88;
                dgrdvStudent.Columns[4].HeaderText = "学生班级";
                dgrdvStudent.Columns[4].Width      = 100;
                dgrdvStudent.Columns[5].HeaderText = "所在学院(系别)";
                dgrdvStudent.Columns[5].Width      = 159;
                dgrdvStudent_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvStudent.DataSource = null;
            }
        }
示例#2
0
        void RefreshCourseData()
        {
            string sqlStr;

            sqlStr = "select * from tb_course where csemester='" + cmbSemester.Text.Trim() + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvCourse.DataSource            = ds.Tables[0];
                dgrdvCourse.Columns[0].HeaderText = "课程号";
                dgrdvCourse.Columns[0].Width      = 100;
                dgrdvCourse.Columns[1].HeaderText = "课程名";
                dgrdvCourse.Columns[1].Width      = 130;
                dgrdvCourse.Columns[2].HeaderText = "学分";
                dgrdvCourse.Columns[2].Width      = 50;
                dgrdvCourse.Columns[3].HeaderText = "学时";
                dgrdvCourse.Columns[3].Width      = 50;
                dgrdvCourse.Columns[4].HeaderText = "课程学期";
                dgrdvCourse.Columns[4].Width      = 130;
            }
            else
            {
                dgrdvCourse.DataSource = null;
            }
        }
示例#3
0
        void RefreshData()
        {
            string  sqlStr;
            DataSet ds = new DataSet();

            sqlStr = "select * from tb_Course";
            ds     = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvCourse.DataSource            = ds.Tables[0];
                dgrdvCourse.Columns[0].HeaderText = "课程号";
                dgrdvCourse.Columns[0].Width      = 150;
                dgrdvCourse.Columns[1].HeaderText = "课程名";
                dgrdvCourse.Columns[1].Width      = 200;
                dgrdvCourse.Columns[2].HeaderText = "课程学分";
                dgrdvCourse.Columns[2].Width      = 80;
                dgrdvCourse.Columns[3].HeaderText = "课程学时";
                dgrdvCourse.Columns[3].Width      = 80;
                dgrdvCourse.Columns[4].HeaderText = "开课学期";
                dgrdvCourse.Columns[4].Width      = 150;
                dgrdvCourse_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvCourse.DataSource = null;
            }
        }
示例#4
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgrdvCourse.DataSource == null)
         {
             MessageBox.Show("没有课程可选", "提示");
             return;
         }
         int    n = dgrdvCourse.CurrentCell.RowIndex;
         int    i = dgrdvclass.CurrentCell.RowIndex;
         string selectCno, classno;
         classno   = dgrdvclass[0, i].Value.ToString().Trim();
         selectCno = dgrdvCourse[0, n].Value.ToString().Trim();
         string sqlStr;
         sqlStr = "select * from tb_select where classno='" + classno + "'" + "and Cno='" + selectCno + "'";
         if (CDataBase.GetDataFromDB(sqlStr) != null)
         {
             MessageBox.Show("已选该课程!", "不能重选", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         sqlStr = "insert into tb_select (classNo,Cno) values ('" + classno + "','" + selectCno + "')";
         CDataBase.UpdateDB(sqlStr);
         RefreshSelcetCourseData();
         MessageBox.Show("选课成功", "提示");
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
示例#5
0
        private void btnAll_Click(object sender, EventArgs e)
        {
            cmbCourse.SelectedIndex   = -1;
            cmbSemester.SelectedIndex = -1;
            string sqlStr;

            sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvGrade.DataSource            = ds.Tables[0];
                dgrdvGrade.Columns[0].HeaderText = "学号";
                dgrdvGrade.Columns[0].Width      = 100;
                dgrdvGrade.Columns[1].HeaderText = "姓名";
                dgrdvGrade.Columns[1].Width      = 150;
                dgrdvGrade.Columns[2].HeaderText = "课程号";
                dgrdvGrade.Columns[2].Width      = 100;
                dgrdvGrade.Columns[3].HeaderText = "课程名";
                dgrdvGrade.Columns[3].Width      = 150;
                dgrdvGrade.Columns[4].HeaderText = "学分";
                dgrdvGrade.Columns[4].Width      = 100;
                dgrdvGrade.Columns[5].HeaderText = "开课学期";
                dgrdvGrade.Columns[5].Width      = 150;
                dgrdvGrade.Columns[6].HeaderText = "成绩";
                dgrdvGrade.Columns[6].Width      = 100;
                dgrdvGrade_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvGrade.DataSource = null;
            }
        }
示例#6
0
        void RefreshData()
        {
            string sqlStr;

            sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.csemester='" + cmbSemester.Text.Trim() + "' and tb_grade.sno='" + CPublic.userInfo[0] + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvGrade.DataSource            = ds.Tables[0];
                dgrdvGrade.Columns[0].HeaderText = "学号";
                dgrdvGrade.Columns[0].Width      = 50;
                dgrdvGrade.Columns[1].HeaderText = "姓名";
                dgrdvGrade.Columns[1].Width      = 80;
                dgrdvGrade.Columns[2].HeaderText = "课程号";
                dgrdvGrade.Columns[2].Width      = 70;
                dgrdvGrade.Columns[3].HeaderText = "课程名";
                dgrdvGrade.Columns[3].Width      = 100;
                dgrdvGrade.Columns[4].HeaderText = "学分";
                dgrdvGrade.Columns[4].Width      = 50;
                dgrdvGrade.Columns[5].HeaderText = "开课学期";
                dgrdvGrade.Columns[5].Width      = 100;
                dgrdvGrade.Columns[6].HeaderText = "成绩";
                dgrdvGrade.Columns[6].Width      = 50;
                //dgrdvGrade_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvGrade.DataSource = null;
                MessageBox.Show("暂无该学期成绩", "提示");
            }
        }
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("请输入要查询用户的关键字", "提示");
             txtUserName.Focus();
             return;
         }
         string  sqlStr = "select * from tb_user where userName='******'";
         DataSet ds     = new DataSet();
         ds = CDataBase.GetDataFromDB(sqlStr);
         if (ds != null)
         {
             txtUserName.Text         = "";
             dataGridView1.DataSource = ds.Tables[0];
             SetHeadText();
         }
         else
         {
             dataGridView1.DataSource = null;
             txtUserName.Text         = "";
             MessageBox.Show("没有该用户", "提示");
             RefreshData();
             SetHeadText();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
示例#8
0
        private void cmbSemester_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            cmbCourse.SelectedIndex = -1;
            string  sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.csemester='" + cmbSemester.Text.Trim() + "'";
            DataSet ds     = CDataBase.GetDataFromDB(sqlStr);

            if (ds != null)
            {
                dgrdvGrade.DataSource            = ds.Tables[0];
                dgrdvGrade.Columns[0].HeaderText = "学号";
                dgrdvGrade.Columns[0].Width      = 100;
                dgrdvGrade.Columns[1].HeaderText = "姓名";
                dgrdvGrade.Columns[1].Width      = 150;
                dgrdvGrade.Columns[2].HeaderText = "课程号";
                dgrdvGrade.Columns[2].Width      = 100;
                dgrdvGrade.Columns[3].HeaderText = "课程名";
                dgrdvGrade.Columns[3].Width      = 150;
                dgrdvGrade.Columns[4].HeaderText = "学分";
                dgrdvGrade.Columns[4].Width      = 100;
                dgrdvGrade.Columns[5].HeaderText = "开课学期";
                dgrdvGrade.Columns[5].Width      = 150;
                dgrdvGrade.Columns[6].HeaderText = "成绩";
                dgrdvGrade.Columns[6].Width      = 100;
                dgrdvGrade_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvGrade.DataSource = null;
                //MessageBox.Show("暂无该学期成绩", "提示");
            }
        }
示例#9
0
 //统计
 private void btnItemize_Click(object sender, EventArgs e)
 {
     try
     {
         if (cmbCount.Text.Trim() == "")
         {
             MessageBox.Show("请输入统计条件!", "提示!");
             cmbCount.Focus();
         }
         else if (cmbCount.SelectedIndex == 5)
         {
             if (txtCountValue1.Text.Trim() == "" & txtCountValue2.Text.Trim() == "")
             {
                 MessageBox.Show("请输入统计条件或统计值!", "提示!");
                 cmbCount.Focus();
             }
         }
         string sqlStr;
         sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.cname='" + cmbCourse.Text.Trim() + "' and grade between '" + txtCountValue2.Text.Trim() + "' and '" + txtCountValue1.Text.Trim() + "'";
         DataSet ds = new DataSet();
         ds = CDataBase.GetDataFromDB(sqlStr);
         if (ds != null)
         {
             dgrdvGrade.DataSource            = ds.Tables[0];
             dgrdvGrade.Columns[0].HeaderText = "学号";
             dgrdvGrade.Columns[0].Width      = 100;
             dgrdvGrade.Columns[1].HeaderText = "姓名";
             dgrdvGrade.Columns[1].Width      = 150;
             dgrdvGrade.Columns[2].HeaderText = "课程号";
             dgrdvGrade.Columns[2].Width      = 100;
             dgrdvGrade.Columns[3].HeaderText = "课程名";
             dgrdvGrade.Columns[3].Width      = 150;
             dgrdvGrade.Columns[4].HeaderText = "学分";
             dgrdvGrade.Columns[4].Width      = 100;
             dgrdvGrade.Columns[5].HeaderText = "开课学期";
             dgrdvGrade.Columns[5].Width      = 150;
             dgrdvGrade.Columns[6].HeaderText = "成绩";
             dgrdvGrade.Columns[6].Width      = 100;
             dgrdvGrade_RowHeaderMouseClick(null, null);
         }
         else
         {
             dgrdvGrade.DataSource = null;
             txtCountValue1.Text   = "";
             txtCountValue2.Text   = "";
             MessageBox.Show("无此类信息", "提示");
             cmbCourse.Focus();
             RefreshData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
        //用于显示同步数据
        void RefreshData()
        {
            DataSet myDs   = new DataSet();
            string  sqlStr = "select userName,userPurview from tb_User";

            myDs = CDataBase.GetDataFromDB(sqlStr);
            if (myDs != null)
            {
                dataGridView1.DataSource = myDs.Tables[0];
                SetHeadText();
            }
            else
            {
                dataGridView1.DataSource = null;
            }
        }
示例#11
0
 //进入窗体
 private void FrmGrade_Load(object sender, EventArgs e)
 {
     try
     {
         txtGarde.Enabled        = false;
         txtCountValue1.Enabled  = false;
         txtCountValue2.Enabled  = false;
         cmbCourse.SelectedIndex = 0;
         objClose();
         cmbCourse.SelectedIndex = -1;
         string sqlStr;
         sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno";
         DataSet ds = new DataSet();
         ds = CDataBase.GetDataFromDB(sqlStr);
         if (ds != null)
         {
             dgrdvGrade.DataSource            = ds.Tables[0];
             dgrdvGrade.Columns[0].HeaderText = "学号";
             dgrdvGrade.Columns[0].Width      = 100;
             dgrdvGrade.Columns[1].HeaderText = "姓名";
             dgrdvGrade.Columns[1].Width      = 150;
             dgrdvGrade.Columns[2].HeaderText = "课程号";
             dgrdvGrade.Columns[2].Width      = 100;
             dgrdvGrade.Columns[3].HeaderText = "课程名";
             dgrdvGrade.Columns[3].Width      = 150;
             dgrdvGrade.Columns[4].HeaderText = "学分";
             dgrdvGrade.Columns[4].Width      = 100;
             dgrdvGrade.Columns[5].HeaderText = "开课学期";
             dgrdvGrade.Columns[5].Width      = 150;
             dgrdvGrade.Columns[6].HeaderText = "成绩";
             dgrdvGrade.Columns[6].Width      = 100;
             dgrdvGrade_RowHeaderMouseClick(null, null);
         }
         else
         {
             dgrdvGrade.DataSource = null;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#12
0
        //string selectCondition;

        void RefreshClass()
        {
            string sqlStr;

            sqlStr = "select * from tb_class where classname='" + cmbClass.Text.Trim() + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvclass.DataSource            = ds.Tables[0];
                dgrdvclass.Columns[0].HeaderText = "班级号";
                dgrdvclass.Columns[0].Width      = 70;
                dgrdvclass.Columns[1].HeaderText = "班级名";
                dgrdvclass.Columns[1].Width      = 90;
            }
            else
            {
                dgrdvCourse.DataSource = null;
            }
        }
示例#13
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtNo.Text.Trim() == "")
         {
             MessageBox.Show("木有可删除的记录", "提示");
             return;
         }
         string sqlStr;
         sqlStr = "select * from tb_Select where cno='" + txtNo.Text.Trim() + "'";
         if (CDataBase.GetDataFromDB(sqlStr) != null)
         {
             MessageBox.Show("已有该课程的选课信息,拒绝删除!", "删除出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (MessageBox.Show("确定删除课程“" + txtName.Text.Trim() + "”吗?", "删除课程信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                  MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             sqlStr = "delete from tb_course where cno='" + txtNo.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             int n = dgrdvCourse.CurrentCell.RowIndex;
             dgrdvCourse.Rows.RemoveAt(n);
             if (dgrdvCourse.Rows.Count == 1)
             {
                 ClearAll();
                 dgrdvCourse.DataSource = null;
             }
             else
             {
                 dgrdvCourse_RowHeaderMouseClick(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
示例#14
0
 private void FrmSelectCourse_Load(object sender, EventArgs e)
 {
     try
     {
         cmbSemester.SelectedIndex = 0;
         cmbClass.SelectedIndex    = 0;
         string  sqlStr;
         DataSet ds = new DataSet();
         sqlStr = "select * from tb_course";
         ds     = CDataBase.GetDataFromDB(sqlStr);
         if (ds != null)
         {
             dgrdvCourse.DataSource            = ds.Tables[0];
             dgrdvCourse.Columns[0].HeaderText = "课程号";
             dgrdvCourse.Columns[0].Width      = 100;
             dgrdvCourse.Columns[1].HeaderText = "课程名";
             dgrdvCourse.Columns[1].Width      = 130;
             dgrdvCourse.Columns[2].HeaderText = "学分";
             dgrdvCourse.Columns[2].Width      = 50;
             dgrdvCourse.Columns[3].HeaderText = "学时";
             dgrdvCourse.Columns[3].Width      = 50;
             dgrdvCourse.Columns[4].HeaderText = "课程学期";
             dgrdvCourse.Columns[4].Width      = 130;
         }
         else
         {
             dgrdvCourse.DataSource = null;
         }
         RefreshCourseData();
         RefreshClass();
         RefreshSelcetCourseData();
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
示例#15
0
        void RefreshData()
        {
            string sqlStr;

            //int n = dgrdvGrade.CurrentCell.RowIndex;
            //string gardeName;
            //gardeName = dgrdvGrade[1, n].Value.ToString().Trim();
            //lblShow.Text = "现在正在查看“" + gardeName + "”的成绩";

            sqlStr = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.cname='" + cmbCourse.Text.Trim() + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvGrade.DataSource            = ds.Tables[0];
                dgrdvGrade.Columns[0].HeaderText = "学号";
                dgrdvGrade.Columns[0].Width      = 100;
                dgrdvGrade.Columns[1].HeaderText = "姓名";
                dgrdvGrade.Columns[1].Width      = 150;
                dgrdvGrade.Columns[2].HeaderText = "课程号";
                dgrdvGrade.Columns[2].Width      = 100;
                dgrdvGrade.Columns[3].HeaderText = "课程名";
                dgrdvGrade.Columns[3].Width      = 150;
                dgrdvGrade.Columns[4].HeaderText = "学分";
                dgrdvGrade.Columns[4].Width      = 100;
                dgrdvGrade.Columns[5].HeaderText = "开课学期";
                dgrdvGrade.Columns[5].Width      = 150;
                dgrdvGrade.Columns[6].HeaderText = "成绩";
                dgrdvGrade.Columns[6].Width      = 100;
                dgrdvGrade_RowHeaderMouseClick(null, null);
            }
            else
            {
                dgrdvGrade.DataSource = null;
                //MessageBox.Show("暂无此课程信息", "提示");
            }
        }
示例#16
0
        void RefreshSelcetCourseData()
        {
            string sqlStr, classCno;
            int    i = dgrdvclass.CurrentCell.RowIndex;

            classCno = dgrdvclass[0, i].Value.ToString().Trim();

            //sqlStr = "select tb_select.classNo,tb_class.classname,tb_select.classno,tb_course.Cname,tb_course.csemester"
            //+ "from tb_class inner join(tb_course inner join tb_select on tb_course.cno=tb_select.cno)"
            //+ "on tb_class.classno =tb_select.classno where tb_select.classno='"
            //+ classCno + "'";

            sqlStr = "select tb_select.classNo,tb_class.classname,tb_Course.cno,tb_course.Cname,tb_course.cperiod,tb_course.csemester from tb_class inner join(tb_course inner join tb_select on tb_course.cno=tb_select.cno) on tb_class.classno =tb_select.classno where tb_select.classno='" + classCno + "'";
            DataSet ds = new DataSet();

            ds = CDataBase.GetDataFromDB(sqlStr);
            if (ds != null)
            {
                dgrdvSelectCourse.DataSource            = ds.Tables[0];
                dgrdvSelectCourse.Columns[0].HeaderText = "班级号";
                dgrdvSelectCourse.Columns[0].Width      = 130;
                dgrdvSelectCourse.Columns[1].HeaderText = "班级名";
                dgrdvSelectCourse.Columns[1].Width      = 130;
                dgrdvSelectCourse.Columns[2].HeaderText = "课程号";
                dgrdvSelectCourse.Columns[2].Width      = 130;
                dgrdvSelectCourse.Columns[3].HeaderText = "课程名";
                dgrdvSelectCourse.Columns[3].Width      = 130;
                dgrdvSelectCourse.Columns[4].HeaderText = "课程学时";
                dgrdvSelectCourse.Columns[4].Width      = 130;
                dgrdvSelectCourse.Columns[5].HeaderText = "课程学期";
                dgrdvSelectCourse.Columns[5].Width      = 130;
            }
            else
            {
                dgrdvSelectCourse.DataSource = null;
            }
        }
示例#17
0
 //排序
 private void btnSort_Click(object sender, EventArgs e)
 {
     try
     {
         //if (cmbSort.Text.Trim() == "")
         //{
         //    MessageBox.Show("请选择排序条件", "提示");
         //    cmbSort.Focus();
         //}
         string sqlStr1;
         //, sqlStr2;
         sqlStr1 = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.cname='" + cmbCourse.Text.Trim() + "' ORDER BY grade DESC";
         //sqlStr2 = "select tb_grade.sno,tb_student.sname,tb_grade.cno,tb_course.cname,tb_course.cperiod,tb_course.csemester,tb_grade.grade from tb_student inner join tb_grade on tb_student.sno = tb_grade.sno join tb_course on tb_grade.cno = tb_course.cno where tb_course.cname='" + cmbSemester.Text.Trim() + "' ORDER BY grade DESC";
         DataSet ds = new DataSet();
         //if (cmbSort.SelectedIndex == 0)
         //{
         ds = CDataBase.GetDataFromDB(sqlStr1);
         if (ds != null)
         {
             dgrdvGrade.DataSource            = ds.Tables[0];
             dgrdvGrade.Columns[0].HeaderText = "学号";
             dgrdvGrade.Columns[0].Width      = 100;
             dgrdvGrade.Columns[1].HeaderText = "姓名";
             dgrdvGrade.Columns[1].Width      = 150;
             dgrdvGrade.Columns[2].HeaderText = "课程号";
             dgrdvGrade.Columns[2].Width      = 100;
             dgrdvGrade.Columns[3].HeaderText = "课程名";
             dgrdvGrade.Columns[3].Width      = 150;
             dgrdvGrade.Columns[4].HeaderText = "学分";
             dgrdvGrade.Columns[4].Width      = 100;
             dgrdvGrade.Columns[5].HeaderText = "开课学期";
             dgrdvGrade.Columns[5].Width      = 150;
             dgrdvGrade.Columns[6].HeaderText = "成绩";
             dgrdvGrade.Columns[6].Width      = 100;
             dgrdvGrade_RowHeaderMouseClick(null, null);
         }
     }
     //else if (cmbSort.SelectedIndex == 1)
     //{
     //    ds = CDataBase.GetDataFromDB(sqlStr2);
     //    if (ds != null)
     //    {
     //        dgrdvGrade.DataSource = ds.Tables[0];
     //        dgrdvGrade.Columns[0].HeaderText = "学号";
     //        dgrdvGrade.Columns[0].Width = 100;
     //        dgrdvGrade.Columns[1].HeaderText = "姓名";
     //        dgrdvGrade.Columns[1].Width = 150;
     //        dgrdvGrade.Columns[2].HeaderText = "课程号";
     //        dgrdvGrade.Columns[2].Width = 100;
     //        dgrdvGrade.Columns[3].HeaderText = "课程名";
     //        dgrdvGrade.Columns[3].Width = 150;
     //        dgrdvGrade.Columns[4].HeaderText = "学分";
     //        dgrdvGrade.Columns[4].Width = 100;
     //        dgrdvGrade.Columns[5].HeaderText = "开课学期";
     //        dgrdvGrade.Columns[5].Width = 150;
     //        dgrdvGrade.Columns[6].HeaderText = "成绩";
     //        dgrdvGrade.Columns[6].Width = 100;
     //        dgrdvGrade_RowHeaderMouseClick(null, null);
     //    }
     //}
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
示例#18
0
        //录入
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string  sql = "select sno,cno from tb_grade where sno='" + txtSno.Text.Trim() + "' and cno='" + txtCno.Text.Trim() + "'";
                DataSet ds  = new DataSet();
                ds = CDataBase.GetDataFromDB(sql);
                if (btnAdd.Text == "录入")
                {
                    btnAdd.Text = "确定";
                    cleraAll();
                    txtSno.Text   = "";
                    txtCno.Text   = "";
                    txtGarde.Text = "";
                    objOpen();
                    btnUpdate.Enabled = false;
                    btnDelete.Enabled = false;
                    return;
                }
                else if (txtSno.Text == "")
                {
                    MessageBox.Show("学号不能为空!", "提示");
                    txtSno.Focus();
                    return;
                }
                else if (txtCno.Text == "")
                {
                    MessageBox.Show("课程号不能为空", "提示");
                    txtCno.Focus();
                    return;
                }
                else if (ds != null)
                {
                    MessageBox.Show("该学生此成绩已存在,不能重复录入", "提示");
                    cleraAll();
                    txtSno.Focus();
                }

                btnAdd.Text = "录入";
                string sqlStr;
                sqlStr = "insert into tb_grade (Sno,Cno,grade) values ('" + txtSno.Text.Trim() + "','" + txtCno.Text.Trim()
                         + "','" + txtGarde.Text.Trim() + "')";
                CDataBase.UpdateDB(sqlStr);
                RefreshData();
                if (MessageBox.Show("录入成功,继续录入吗?", "录入成绩", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    cleraAll();
                    objOpen();
                    btnAdd.Text = "确定";
                    btnAll_Click(sender, e);
                }
                else
                {
                    objClose();
                    btnUpdate.Enabled = true;
                    btnDelete.Enabled = true;
                    btnAll_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                CDataBase.conn.Close();
                MessageBox.Show(ex.Message);
                cleraAll();
                objClose();
                btnAdd.Enabled    = true;
                btnUpdate.Enabled = true;
                btnDelete.Enabled = true;
                dgrdvGrade_RowHeaderMouseClick(null, null);
            }
        }
        //查询
        private void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                string sqlStr = "";
                if (txtSelect.Text.Trim() == "")
                {
                    MessageBox.Show("请输入需要查询的" + cmbSelect.SelectedItem.ToString().Trim() + "提示");

                    return;
                }
                else if (cmbSelect.SelectedIndex == 0)
                {
                    sqlStr = "select * from tb_Student where Sno='" + txtSelect.Text.Trim() + "'";
                }
                else if (cmbSelect.SelectedIndex == 1)
                {
                    sqlStr = "select * from tb_Student where Sname like'" + txtSelect.Text.Trim() + "%'";
                }
                else if (cmbSelect.SelectedIndex == 2)
                {
                    sqlStr = "select * from tb_Student where Ssex='" + txtSelect.Text.Trim() + "'";
                }
                else if (cmbSelect.SelectedIndex == 3)
                {
                    sqlStr = "select * from tb_Student where Sage='" + txtSelect.Text.Trim() + "'";
                }
                else if (cmbSelect.SelectedIndex == 4)
                {
                    sqlStr = "select * from tb_Student where Sclass='" + txtSelect.Text.Trim() + "'";
                }
                else if (cmbSelect.SelectedIndex == 5)
                {
                    sqlStr = "select * from tb_Student where Sdept='" + txtSelect.Text.Trim() + "'";
                }
                else if (cmbSelect.SelectedIndex == 6)
                {
                    sqlStr = "select * from tb_student";
                }
                DataSet ds = new DataSet();
                ds = CDataBase.GetDataFromDB(sqlStr);
                if (ds != null)
                {
                    dgrdvStudent.DataSource            = ds.Tables[0];
                    dgrdvStudent.Columns[0].HeaderText = "学生学号";
                    dgrdvStudent.Columns[0].Width      = 168;
                    dgrdvStudent.Columns[1].HeaderText = "学生姓名";
                    dgrdvStudent.Columns[1].Width      = 159;
                    dgrdvStudent.Columns[2].HeaderText = "学生性别";
                    dgrdvStudent.Columns[2].Width      = 88;
                    dgrdvStudent.Columns[3].HeaderText = "学生年龄";
                    dgrdvStudent.Columns[3].Width      = 88;
                    dgrdvStudent.Columns[4].HeaderText = "学生班级";
                    dgrdvStudent.Columns[4].Width      = 100;
                    dgrdvStudent.Columns[5].HeaderText = "所在学院(系别)";
                    dgrdvStudent.Columns[5].Width      = 159;
                    dgrdvStudent_RowHeaderMouseClick(null, null);
                }
                else
                {
                    dgrdvStudent.DataSource = null;
                    ClearAll();
                    MessageBox.Show("没有该条记录,请重新查询。", "提示");
                    RefreshData();
                }
            }
            catch (Exception ex)
            {
                CDataBase.conn.Close();
                MessageBox.Show(ex.Message);
            }
        }