Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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("暂无该学期成绩", "提示");
            }
        }
        //更新表
        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;
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 5
0
 //删除
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("确定要删除“" + txtSno.Text.Trim() + "”的资料吗?", "提示", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "delete from tb_grade where sno='" + txtSno.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             int n = dgrdvGrade.CurrentCell.RowIndex;
             dgrdvGrade.Rows.RemoveAt(n);
             if (dgrdvGrade.Rows.Count == 1)
             {
                 cleraAll();
                 dgrdvGrade.DataSource = null;
             }
             else
             {
                 dgrdvGrade_RowHeaderMouseClick(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
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("暂无该学期成绩", "提示");
            }
        }
Ejemplo n.º 8
0
 //修改
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnUpdate.Text == "修改")
         {
             btnUpdate.Text    = "确定";
             btnAdd.Enabled    = false;
             btnDelete.Enabled = false;
             txtSno.Enabled    = false;
             txtCno.Enabled    = false;
             txtGarde.Enabled  = true;
             txtGarde.Text     = "";
             txtGarde.Focus();
         }
         else
         {
             btnUpdate.Text    = "修改";
             btnAdd.Enabled    = true;
             btnDelete.Enabled = true;
             txtSno.Enabled    = false;
             txtCno.Enabled    = false;
             txtGarde.Enabled  = false;
             string sqlStr;
             sqlStr = "update tb_grade set grade='" + txtGarde.Text.Trim() + "'where sno='" + txtSno.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             RefreshData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 9
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;
            }
        }
Ejemplo n.º 10
0
 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);
     }
 }
Ejemplo n.º 11
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgrdvSelectCourse.DataSource == null)
         {
             MessageBox.Show("没有可删除的选课记录!", "提示");
             return;
         }
         int    n = dgrdvSelectCourse.CurrentCell.RowIndex;
         string classNo, selectCno, selectCname;
         classNo     = dgrdvSelectCourse[0, n].Value.ToString().Trim();
         selectCno   = dgrdvSelectCourse[2, n].Value.ToString().Trim();
         selectCname = dgrdvSelectCourse[3, n].Value.ToString().Trim();
         if (MessageBox.Show("确定要删除“" + classNo + "”的所选课程《" + selectCname + "》吗?", "删除选课记录",
                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr;
             sqlStr = "delete from tb_select where classno='" + classNo + "'" + "and Cno='" + selectCno + "'";
             CDataBase.UpdateDB(sqlStr);
             dgrdvSelectCourse.Rows.RemoveAt(n);
             if (dgrdvSelectCourse.Rows.Count == 1)
             {
                 dgrdvSelectCourse.DataSource = null;
             }
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 12
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);
     }
 }
Ejemplo n.º 13
0
 private void btnAlter_Click(object sender, EventArgs e)
 {
     try
     {
         string sqlStr = "update tb_user set userPurview='" + cmbPurivew.Text.Trim() + "'" + "where userName='******'";
         CDataBase.UpdateDB(sqlStr);
         RefreshData();
         SetHeadText();
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 14
0
        //用于显示同步数据
        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;
            }
        }
Ejemplo n.º 15
0
        //窗体载入



        private void btnRegedit_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (btnRegedit.Text == "注册")
                {
                    btnRegedit.Text = "确定";
                    ObjOpen();
                }
                else if (txtUserName.Text.Trim() == "")
                {
                    MessageBox.Show("用户名不能为空!", "提示");
                    txtUserName.Focus();
                }

                else if (txtUserPasswors.Text.Trim() == "")
                {
                    MessageBox.Show("用户名不能为空!", "提示");
                    txtUserPasswors.Focus();
                }
                else if (!UserName(txtUserName.Text.Trim()))
                {
                    MessageBox.Show("该用户已存在,请使用其他账号注册!", "提示");
                    txtUserName.Text = "";
                    ClearAll();
                }
                else
                {
                    btnRegedit.Text = "注册";
                    string sqlStr = "insert into tb_User values('" + txtUserName.Text.Trim() + "','" + txtUserPasswors.Text.Trim() + "','" + cmbPurview1.Text.Trim() + "','是')";
                    if (CDataBase.UpdateDB(sqlStr))
                    {
                        MessageBox.Show(cmbPurview1.Text + " " + txtUserName.Text + "注册成功!", "注册用户");
                    }
                    ClearAll();
                    ObjClose();
                    //btnCancel.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                CDataBase.conn.Close();
                MessageBox.Show(ex.Message);
                ClearAll();
                ObjClose();
            }
        }
 //修改
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnUpdate.Text.Trim() == "修改")
         {
             MessageBox.Show("学号不能修改", "注意");
             btnUpdate.Text     = "确定";
             btnCancel2.Visible = true;
             btnAdd.Enabled     = false;
             btnDelete.Enabled  = false;
             btnClose.Enabled   = false;
             cmbSelect.Enabled  = false;
             btnSelect.Enabled  = false;
             txtSelect.Enabled  = false;
             txtName.Enabled    = true;
             txtAge.Enabled     = true;
             txtClass.Enabled   = true;
             txtDept.Enabled    = true;
             cmbSex.Enabled     = true;
             txtName.Focus();
         }
         else
         {
             btnUpdate.Text     = "修改";
             btnCancel2.Visible = false;
             btnAdd.Enabled     = true;
             btnDelete.Enabled  = true;
             btnClose.Enabled   = true;
             cmbSelect.Enabled  = true;
             btnSelect.Enabled  = true;
             Objclose();
             string sqlStr;
             sqlStr = "update tb_student set Sname='" + txtName.Text.Trim() + "',Ssex='" + cmbSex.Text.Trim() + "',Sage='"
                      + txtAge.Text.Trim() + "',Sclass='" + txtClass.Text.Trim() + "',Sdept='" + txtDept.Text.Trim() + "'where sno='"
                      + txtNo.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             RefreshData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 17
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);
     }
 }
Ejemplo n.º 18
0
 //删除
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         //RefreshData();
         string userName;
         int    n = this.dataGridView1.CurrentCell.RowIndex;
         userName = this.dataGridView1.Rows[n].Cells[0].Value.ToString().Trim();
         if (MessageBox.Show("确认删除 " + userName + " 吗?", "删除用户", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             string sqlStr = "delete from tb_User where userName='******'";
             CDataBase.UpdateDB(sqlStr);
             dataGridView1.Rows.RemoveAt(n);
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 19
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;
            }
        }
Ejemplo n.º 20
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);
     }
 }
Ejemplo n.º 21
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("暂无此课程信息", "提示");
            }
        }
Ejemplo n.º 22
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);
     }
 }
Ejemplo n.º 23
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;
            }
        }
Ejemplo n.º 24
0
 //修改
 private void btnUpdata_Click(object sender, EventArgs e)  //为什么课程号不能修改?——要用课程号作为修改条件
 {
     try
     {
         if (btnUpdata.Text == "修改")
         {
             btnUpdata.Text     = "确定";
             btnCancel2.Visible = true;
             ObjOpen();
             txtNo.Enabled       = false;
             btnAdd.Enabled      = false;
             btnDelete.Enabled   = false;
             dgrdvCourse.Enabled = false;
             txtName.Focus();
         }
         else
         {
             btnUpdata.Text      = "修改";
             btnCancel2.Visible  = false;
             btnAdd.Enabled      = true;
             btnDelete.Enabled   = true;
             dgrdvCourse.Enabled = true;
             ObjClose();
             string sqlStr;
             sqlStr = "update tb_Course set Cname='" + txtName.Text.Trim() + "',Ccredit='" + txtCredit.Text.Trim()
                      + "',Cperiod='" + txtPeriod.Text.Trim() + "',Csemester='" + cmbSemester.Text.Trim() + "'where Cno='" + txtNo.Text.Trim() + "'";
             CDataBase.UpdateDB(sqlStr);
             RefreshData();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 25
0
 private void btnEnter_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtOldPassWord.Text == "")
         {
             MessageBox.Show("请输入原密码!", "提示");
             txtOldPassWord.Focus();
         }
         else if (txtNewPassWord.Text == "")
         {
             MessageBox.Show("请输入新密码", "提示");
             txtNewPassWord.Focus();
         }
         else if (txtMatcPassWord.Text == "")
         {
             MessageBox.Show("请再次输入密码", "提示");
             txtMatcPassWord.Focus();
         }
         else if (txtNewPassWord.Text.Trim() == txtMatcPassWord.Text.Trim())
         {
             string  sql = "select userpassword from tb_User where username='******'";
             DataSet ds  = new DataSet();
             CDataBase.conn.ConnectionString = CDataBase.connStr;
             CDataBase.conn.Open();
             //SqlCommand cmd = new SqlCommand(sql, CDataBase.conn);
             //SqlDataReader sdr = cmd.ExecuteReader();
             SqlDataAdapter adapter = new SqlDataAdapter(sql, CDataBase.conn);
             adapter.Fill(ds);
             if (ds.Tables[0].Rows[0].ItemArray[0].ToString().Trim() == txtOldPassWord.Text.Trim())
             {
                 string sqlStr;
                 CDataBase.conn.Close();
                 sqlStr = "update tb_User set userPassword='******'"
                          + "where userName ='******'";
                 if (CDataBase.UpdateDB(sqlStr))
                 {
                     MessageBox.Show("修改成功!", "提示");
                 }
                 CleaAll();
             }
             else
             {
                 MessageBox.Show("原密码错误", "提示");
                 CleaAll();
                 txtOldPassWord.Focus();
             }
         }
         else
         {
             MessageBox.Show("两次密码输入不一样,重新输入!", "提示");
             txtNewPassWord.Text  = "";
             txtMatcPassWord.Text = "";
             txtNewPassWord.Focus();
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 26
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);
     }
 }
Ejemplo n.º 27
0
 //添加
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnAdd.Text.Trim() == "添加")
         {
             btnAdd.Text        = "确定";
             btnCancel1.Visible = true;
             ObjOpen();
             ClearAll();
             RefreshData();
             btnUpdata.Enabled   = false;
             btnDelete.Enabled   = false;
             dgrdvCourse.Enabled = false;
             return;
         }
         else if (txtNo.Text.Trim() == "")
         {
             MessageBox.Show("课程号不能为空", "提示");
             txtNo.Focus();
             return;
         }
         else if (txtName.Text.Trim() == "")
         {
             MessageBox.Show("课程名不能为空", "提示");
             txtName.Focus();
             return;
         }
         else if (txtCredit.Text.Trim() == "")
         {
             MessageBox.Show("课程学分不能为空", "提示");
             txtCredit.Focus();
             return;
         }
         else if (txtPeriod.Text.Trim() == "")
         {
             MessageBox.Show("课程学时不能为空", "提示");
             txtPeriod.Focus();
             return;
         }
         else if (cmbSemester.SelectedIndex == -1)
         {
             MessageBox.Show("请选择开课学期", "提示");
             cmbSemester.Focus();
             return;
         }
         else if (!No(txtNo.Text.Trim()))
         {
             MessageBox.Show("该课程已有", "提示");
             txtNo.Text = "";
             txtNo.Focus();
             return;
         }
         btnCancel1.Visible = false;
         btnAdd.Text        = "添加";
         string sqlStr;
         sqlStr = "insert into tb_Course values('" + txtNo.Text.Trim() + "','" + txtName.Text.Trim() + "','"
                  + txtCredit.Text.Trim() + "','" + txtPeriod.Text.Trim() + "','" + cmbSemester.Text.Trim() + "')";
         CDataBase.UpdateDB(sqlStr);
         RefreshData();
         if (MessageBox.Show("添加成功,继续添加吗?", "添加课程信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                             MessageBoxDefaultButton.Button1) == DialogResult.Yes)
         {
             btnCancel1.Visible = true;
             ClearAll();
             ObjOpen();
             btnAdd.Text = "确定";
         }
         else
         {
             ObjClose();
             btnUpdata.Enabled   = false;
             btnDelete.Enabled   = false;
             dgrdvCourse.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         CDataBase.conn.Close();
         MessageBox.Show(ex.Message);
         ObjClose();
         btnUpdata.Enabled   = true;
         btnDelete.Enabled   = true;
         dgrdvCourse.Enabled = true;
         dgrdvCourse_RowHeaderMouseClick(null, null);
     }
 }
Ejemplo n.º 28
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);
            }
        }
        //添加
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (btnAdd.Text == "添加")
                {
                    btnCancel.Visible = true;
                    btnAdd.Text       = "确定";

                    ClearAll();      //这句无法工作

                    cmbSex.SelectedIndex = -1;

                    ObjOpen();
                    RefreshData();
                    btnUpdate.Enabled    = false;
                    btnDelete.Enabled    = false;
                    btnSelect.Enabled    = false;
                    cmbSelect.Enabled    = false;
                    txtSelect.Enabled    = false;
                    dgrdvStudent.Enabled = false;
                    return;
                }
                else if (txtNo.Text.Trim() == "")
                {
                    MessageBox.Show("学号不能为空!", "提示");
                    txtNo.Focus();
                    return;
                }
                else if (txtName.Text.Trim() == "")
                {
                    MessageBox.Show("姓名不能为空!", "提示");
                    txtName.Focus();
                    return;
                }
                else if (txtClass.Text.Trim() == "")
                {
                    MessageBox.Show("班级不能为空!", "提示");
                    txtClass.Focus();
                    return;
                }
                else if (cmbSex.SelectedIndex == -1)
                {
                    MessageBox.Show("请选择性别", "提示");
                    cmbSex.Focus();
                    return;
                }
                else if (txtDept.Text == "")
                {
                    MessageBox.Show("所属学院(系别)不能为空!", "提示");
                    txtDept.Focus();
                    return;
                }
                else if (txtAge.Text.Trim() == "")
                {
                    MessageBox.Show("年龄不能为空!", "提示");
                    txtAge.Focus();
                    return;
                }
                else if (!No(txtNo.Text.Trim()))
                {
                    MessageBox.Show("该学号已存在,请重新输入!", "提示");
                    txtNo.Focus();
                    return;
                }

                btnAdd.Text        = "添加";
                btnCancel.Visible  = false;
                btnCancel2.Visible = false;

                string sqlStr;
                sqlStr = "insert into tb_Student values('" + txtNo.Text.Trim() + "','" + txtName.Text.Trim() + "','" + cmbSex.Text.Trim() + "','" + txtAge.Text.Trim() + "','" + txtClass.Text.Trim() + "','" + txtDept.Text.Trim() + "')";
                CDataBase.UpdateDB(sqlStr);
                RefreshData();

                if (MessageBox.Show("添加成功,继续添加吗?", "添加学生信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    btnCancel.Visible = true;
                    ClearAll();
                    ObjOpen();
                    btnAdd.Text = "确定";
                }
                else
                {
                    Objclose();
                    btnUpdate.Enabled    = true;
                    btnDelete.Enabled    = true;
                    btnSelect.Enabled    = true;
                    cmbSelect.Enabled    = true;
                    txtSelect.Enabled    = true;
                    dgrdvStudent.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                CDataBase.conn.Close();
                MessageBox.Show(ex.Message);
                ClearAll();
                Objclose();
                btnUpdate.Enabled    = true;
                btnDelete.Enabled    = true;
                btnSelect.Enabled    = true;
                cmbSelect.Enabled    = true;
                txtSelect.Enabled    = true;
                dgrdvStudent.Enabled = true;
                dgrdvStudent_RowHeaderMouseClick(null, null);
            }
        }