⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projclass.cs

📁 在线考试系统 主要真对考试 开发的个人项目
💻 CS
📖 第 1 页 / 共 5 页
字号:
            {
                myConnection.Close();
            }
        }
        else return 0;


    }
    public int updateScore(string stuId, string courseId, int courseStatus, int score)
    //在分数表里插入相关记录
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_score_statusUpdate", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@stuId", SqlDbType.VarChar, 15).Value = stuId;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;
        myCommand.Parameters.Add("@courseStatus", SqlDbType.Int, 0).Value = courseStatus;
        myCommand.Parameters.Add("@score", SqlDbType.Int, 0).Value = score;
        int ifTest = (new projClass()).ifCourseHasTest(stuId, courseId);

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }



    }
   
    public int updateCourseInfo(string courseId, string courseName, bool isTest)
    //更新课程信息,返回1表示更新成功,返回0则更新失败
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_course_update", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;
        myCommand.Parameters.Add("@courseName", SqlDbType.VarChar, 20).Value = courseName;
        myCommand.Parameters.Add("@isTest", SqlDbType.Bit).Value = isTest;
        
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }


    }
    public int updateTeacherInfoAsCourseId(string teacherName, string courseId)
    //更新教师信息,返回1表示更新成功,返回0则更新失败
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
       
        SqlCommand myCommand = new SqlCommand("sp_teacher_updateAsCourseId", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;
        myCommand.Parameters.Add("@teacherName", SqlDbType.VarChar, 20).Value = teacherName;
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }


    }
    
   
    public int insertCourseInfo(string courseId, string courseName, bool isTest)
    //向course表中添加记录
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_course_insert", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;
        myCommand.Parameters.Add("@courseName", SqlDbType.VarChar, 20).Value = courseName;
        myCommand.Parameters.Add("@isTest", SqlDbType.Bit).Value = isTest;
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int insertAdmin(string adminId, string adminPwd)
    //向管理员表中添加记录
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_admin_insert", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@adminId", SqlDbType.VarChar, 20).Value = adminId;
        myCommand.Parameters.Add("@adminPwd", SqlDbType.VarChar, 20).Value = adminPwd;

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int deleteCourseInfo(string courseId)
    //在course表中删除记录,成功返回1,失败返回0
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_course_delete", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;//删除成功
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;//删除失败

        }
        finally
        {
            myConnection.Close();
        }
    }
    public int deleteScoreInfo(string stuId, string courseId)
    //在course表中删除记录,成功返回1,失败返回0
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_score_delete", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseId;
        myCommand.Parameters.Add("@stuId", SqlDbType.VarChar, 15).Value = stuId;
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;//删除成功
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;//删除失败

        }
        finally
        {
            myConnection.Close();
        }
    }


    public int insertStuinfo(string stuId, string stuName, string stuPwd, int stuSex, int stuStatus, string courseID)
    //向student表中添加记录
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_student_insert", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@stuId", SqlDbType.VarChar, 15).Value = stuId;
        myCommand.Parameters.Add("@stuPwd", SqlDbType.VarChar, 10).Value = stuPwd;
        myCommand.Parameters.Add("@stuName", SqlDbType.Char, 10).Value = stuName;
        myCommand.Parameters.Add("@stuStatus", SqlDbType.Int).Value = stuStatus;
        myCommand.Parameters.Add("@stuSex", SqlDbType.Int).Value = stuSex;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseID;
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int insertTeacherinfo(string teacherId, string teacherPwd, string teacherName, string courseID)
    //向student表中添加记录
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_teacher_insert", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@teacherId", SqlDbType.VarChar, 15).Value = teacherId;
        myCommand.Parameters.Add("@teacherPwd", SqlDbType.VarChar, 10).Value = teacherPwd;
        myCommand.Parameters.Add("@teacherName", SqlDbType.VarChar, 10).Value = teacherName;
        myCommand.Parameters.Add("@courseId", SqlDbType.VarChar, 20).Value = courseID;
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int getStudentCount()
    //取得数据库中学生的人数
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_student_getCount", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myConnection.Open();
        int count = (int)myCommand.ExecuteScalar();
        return count;
    }


    public int deleteStuInfo(string stuId)
    //在student表中删除记录,成功返回1,失败返回0
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_student_delete", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@stuId", SqlDbType.VarChar, 15).Value = stuId;

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;//删除成功
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;//删除失败

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int deleteTeacherInfo(string teacherId)
    //在student表中删除记录,成功返回1,失败返回0
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
        SqlCommand myCommand = new SqlCommand("sp_teacher_delete", myConnection);
        myCommand.CommandType = CommandType.StoredProcedure;
        myCommand.Parameters.Add("@teacherId", SqlDbType.VarChar, 15).Value = teacherId;

        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
            return 1;//删除成功
        }
        catch (SqlException SQLexc)
        {
            Console.WriteLine("SqlException:{0}", SQLexc);
            return 0;//删除失败

        }
        finally
        {
            myConnection.Close();
        }

    }
    public int updateStuStatus(string stuId, string courseId, int status)
    //在学生表里对学生的状态进行修改
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -