teachersystemdb.cs
来自「教务管理系统 基于.net和sqlserver2000的教务管理系统」· CS 代码 · 共 88 行
CS
88 行
using System;
using System.Data;
using System.Data.SqlClient;
namespace Park.Common
{
/// <summary>
/// TeacherSystemDB 的摘要说明。
/// </summary>
public class TeacherSystemDB
{
public static int AddClass(string teacherid,string courseid,string classname)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("TeacherSystem_Add_Course", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter TeacherID = new SqlParameter("@teacherid", SqlDbType.NVarChar, 20);
TeacherID.Value = teacherid;
myCommand.Parameters.Add(TeacherID);
// Add Parameters to SPROC
SqlParameter CourseID = new SqlParameter("@courseid", SqlDbType.Int);
CourseID.Value = courseid;
myCommand.Parameters.Add(CourseID);
// Add Parameters to SPROC
SqlParameter ClassName = new SqlParameter("@classname", SqlDbType.VarChar, 10);
ClassName.Value = classname;
myCommand.Parameters.Add(ClassName);
// Add Parameters to SPROC
SqlParameter retval = new SqlParameter("@retval", SqlDbType.Int);
retval.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(retval);
// Execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Dispose();
myConnection.Dispose();
return (int)retval.Value;
}
public static void DeleteClass(string teacherid, string classid)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("TeacherSystem_Delete_Class", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter TeacherID = new SqlParameter("@teacherid", SqlDbType.NVarChar, 20);
TeacherID.Value = teacherid;
myCommand.Parameters.Add(TeacherID);
// Add Parameters to SPROC
SqlParameter ClassID = new SqlParameter("@classid", SqlDbType.Int);
ClassID.Value = classid;
myCommand.Parameters.Add(ClassID);
// Execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Dispose();
myConnection.Dispose();
return ;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?