Ejemplo n.º 1
0
        //添加成绩信息
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            Model.Class.Class     objClass1   = new Model.Class.Class();
            Model.Student.Student objStudent1 = new Model.Student.Student();
            Model.Course.Course   objCourse1  = new Model.Course.Course();
            objClass1.ClassNo   = cmbClassName.SelectedValue.ToString();
            objStudent1.StuId   = int.Parse(cmbStuNo.SelectedValue.ToString());
            objCourse1.CourseId = int.Parse(cmbCourseName.SelectedValue.ToString());
            string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;

            Manage.Score.Score objSco = new Manage.Score.Score(strConnection);

            int i = objSco.Judge(objStudent1, objCourse1);        // 判断是否存在所选的成绩,如果为0,表示不存在记录,可以增加。为1表示存在记录,不能重复插入成绩。

            if (i == 0)
            {
                Model.Score.Score     objScore   = new Model.Score.Score();
                Model.Student.Student objStudent = new Model.Student.Student();
                Model.Course.Course   objCourse  = new Model.Course.Course();

                objScore.CourseId = int.Parse(cmbCourseName.SelectedValue.ToString());
                objScore.StuId    = int.Parse(cmbStuNo.SelectedValue.ToString());
                objScore.score    = float.Parse(nudScore.Value.ToString());
                objScore.StuName  = txtStuName.Text;
                int iRent = objSco.AddScore(objScore, out strErr);
                if (iRent == 0)
                {
                    MessageBox.Show(strErr);
                    return;
                }
                else
                {
                    MessageBox.Show("添加成功");
                    this.Visible = false;
                    BindClassId();
                    BindStuId();
                    BindCourseId();
                }
            }
            else
            {
                MessageBox.Show("不能重复插入分数");
            }
        }
Ejemplo n.º 2
0
        void BindDataGridViewStu()
        {
            string strErr = "";

            Manage.Score.Score objScore     = new Manage.Score.Score(strConnection);
            DataTable          objDataTable = new DataTable();
            int iRent = objScore.SearchScoreStu(strUserNo, out objDataTable, out strErr);

            if (iRent == 0)
            {
                MessageBox.Show(strErr);
                return;
            }
            else
            {
                dataGridView.DataSource = objDataTable;
            }
        }
Ejemplo n.º 3
0
        //修改成绩信息
        private void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            Model.Student.Student objStudent1 = new Model.Student.Student();
            Model.Course.Course   objCourse1  = new Model.Course.Course();
            objStudent1.StuId   = int.Parse(txtStuNo.ToString());
            objCourse1.CourseId = int.Parse(txtCourseNo.ToString());
            string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;

            Manage.Score.Score objSco = new Manage.Score.Score(strConnection);
            int i = objSco.Judge(objStudent1, objCourse1);     //返回为0,表示不存在该成绩记录,不能修改。返回为1,表示存在记录,可以修改。

            if (i == 1)
            {
                if (DialogResult.Yes == MessageBox.Show("真的要修改该成绩吗?", "确认修改", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    string                strEr      = "";
                    Model.Score.Score     objScore   = new Model.Score.Score();
                    Model.Student.Student objStudent = new Model.Student.Student();
                    Model.Course.Course   objCourse  = new Model.Course.Course();
                    objScore.CourseId = int.Parse(txtCourseNo.ToString());
                    objScore.StuId    = int.Parse(txtStuNo.ToString());
                    objScore.score    = float.Parse(nudScore.Value.ToString());
                    int iRent = objSco.ModifyScore(objScore, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strEr);
                        return;
                    }
                    else
                    {
                        MessageBox.Show("修改成功");
                        //BindDataGridView();
                        this.Visible = false;
                    }
                }
            }
            else if (i == 0)
            {
                MessageBox.Show("当前要修改的成绩不存在,请确定后再修改");
            }
        }
Ejemplo n.º 4
0
        //private void menuDelScore_Click(object sender, EventArgs e)
        //{
        //    btnCancel.Visible = false;
        //    btnSearch.Visible = false;
        //    btnDel.Visible = true;
        //    btnReset.Visible = true;
        //    txtSearchScore.Visible = false;
        //    lblSearchScore.Visible = false;
        //    BindDataGridViewAdmin();
        //}

        //选中一行,删除成绩信息
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选中你要删除的行");
            }
            else
            {
                if (DialogResult.Yes == MessageBox.Show("确定要删除所选行吗?", "确认删除", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    string             strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;
                    Manage.Score.Score objScore      = new Manage.Score.Score(strConnection);
                    string             strErr        = "";
                    for (int i = 0; i < dataGridView.SelectedRows.Count; i++)
                    {
                        string stuNo    = dataGridView.SelectedRows[i].Cells["学号"].Value.ToString();
                        string courseNo = dataGridView.SelectedRows[i].Cells["课程编号"].Value.ToString();
                        stuNo = stuNo.Replace("'", "''");
                        stuNo = stuNo.Trim();

                        //int iCourseId = int.Parse(dataGridView.SelectedRows[i].Cells["课程编号"].Value.ToString());
                        int iRent = objScore.DelScore(stuNo, courseNo, out strErr);

                        if (iRent == 0)
                        {
                            MessageBox.Show(strErr);
                            return;
                        }
                        else
                        {
                            MessageBox.Show("删除成功");
                        }
                    }
                    BindDataGridViewAdmin();
                }
            }
        }
Ejemplo n.º 5
0
        //查询成绩
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string strTeaNo = txtSearchScore.Text.Replace(@"\", @"\\");

            strTeaNo = strTeaNo.Replace("%", @"\%");
            strTeaNo = strTeaNo.Replace("_", @"\_");
            strTeaNo = strTeaNo.Replace("'", @"\''");
            strTeaNo = strTeaNo.Trim();

            string ClassNo = txtSearchScore.Text.Replace(@"\", @"\\");

            ClassNo = ClassNo.Replace("%", @"\%");
            ClassNo = ClassNo.Replace("_", @"\_");
            ClassNo = ClassNo.Replace("'", @"\''");
            ClassNo = ClassNo.Trim();

            string strStuNo = txtSearchScore.Text.Replace(@"\", @"\\");

            strStuNo = strStuNo.Replace("%", @"\%");
            strStuNo = strStuNo.Replace("_", @"\_");
            strStuNo = strStuNo.Replace("'", @"\''");
            strStuNo = strStuNo.Trim();

            string CourseNo = txtSearchScore.Text.Replace(@"\", @"\\");

            CourseNo = CourseNo.Replace("%", @"\%");
            CourseNo = CourseNo.Replace("_", @"\_");
            CourseNo = CourseNo.Replace("'", @"\''");
            CourseNo = CourseNo.Trim();

            string strErr        = "";
            string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings["StudentManager"].ConnectionString;

            Manage.Score.Score objScore = new Manage.Score.Score(strConnection);
            if (txtSearchScore.Text == "")
            {
                MessageBox.Show("请输入你要查询的条件");
            }
            else if (iRight == 1)
            {
                if (lblSearchScore.Text == "请输入教师编号")
                {
                    int iRent = objScore.SearchScoreTeaByAdmin(strTeaNo, out objDataTable, out strErr);

                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入班级编号")
                {
                    int iRent = objScore.SearchScoreClass(ClassNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入学生编号")
                {
                    int iRent = objScore.SearchScoreStudent(strStuNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入课程编号")
                {
                    int iRent = objScore.SearchScoreCourse(CourseNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        //  dataGridView.DataSource = objDataTable;
                        //  dgvScore.DataSource = objDataTable;
                        show();
                    }
                }
            }
            else if (iRight == 2)
            {
                if (lblSearchScore.Text == "请输入课程编号")
                {
                    int iRent = objScore.SearchScoreCourseTea(CourseNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入班级编号")
                {
                    int iRent = objScore.SearchScoreClassTea(ClassNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入学生编号")
                {
                    int iRent = objScore.SearchScoreStuTea(strStuNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
            }
            else
            {
                if (lblSearchScore.Text == "请输入课程编号")
                {
                    int iRent = objScore.SearchScoreCourseStu(CourseNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                else if (lblSearchScore.Text == "请输入学生编号")
                {
                    int iRent = objScore.SearchScoreStuStu(strStuNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
                if (lblSearchScore.Text == "请输入教师编号")
                {
                    int iRent = objScore.SearchScoreTeaStu(strTeaNo, strUserNo, out objDataTable, out strErr);
                    if (iRent == 0)
                    {
                        MessageBox.Show(strErr);
                        return;
                    }
                    else
                    {
                        show();
                    }
                }
            }
        }