📄 classdb.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using Park.Common;
namespace Park.Common
{
/// <summary>
/// ClassDB 的摘要说明。
/// </summary>
public class ClassDB
{
public static void DeleteClass(string classid)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("ClassSystem_Delete_Class", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter ClassID = new SqlParameter("@id", SqlDbType.NVarChar, 20);
ClassID.Value = classid;
myCommand.Parameters.Add(ClassID);
// Execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Dispose();
myConnection.Dispose();
return ;
}
public static void GetClassStatus(string classid,out string classname,out string coursename,out string teachername, out string capicity, out DateTime endtime)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("ClassSystem_Get_ClassStatus", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter ClassID = new SqlParameter("@id", SqlDbType.Int);
ClassID.Value = classid;
myCommand.Parameters.Add(ClassID);
// Add Parameters to SPROC
SqlParameter ClassName = new SqlParameter("@classname", SqlDbType.Char, 10);
ClassName.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(ClassName);
// Add Parameters to SPROC
SqlParameter CourseName = new SqlParameter("@coursename", SqlDbType.NVarChar, 20);
CourseName.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(CourseName);
// Add Parameters to SPROC
SqlParameter TeacherName = new SqlParameter("@teachername", SqlDbType.Char, 10);
TeacherName.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(TeacherName);
// Add Parameters to SPROC
SqlParameter Capicity = new SqlParameter("@capicity", SqlDbType.Int);
Capicity.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(Capicity);
// Add Parameters to SPROC
SqlParameter EndTime = new SqlParameter("@endtime", SqlDbType.SmallDateTime);
EndTime.Direction = ParameterDirection.Output;
myCommand.Parameters.Add(EndTime);
// Execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
classname = ClassName.Value.ToString();
teachername = TeacherName.Value.ToString();
coursename = CourseName.Value.ToString();
capicity = Capicity.Value.ToString();
try
{
endtime = (DateTime)EndTime.Value;
}
catch(Exception)
{
endtime = DateTime.Now;
}
myCommand.Dispose();
myConnection.Dispose();
}
public static void ChangeClassStatus(string classid,string classname, int capicity, DateTime endtime)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("ClassSystem_Change_ClassStatus", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter ClassID = new SqlParameter("@id", SqlDbType.Int);
ClassID.Value = classid;
myCommand.Parameters.Add(ClassID);
// Add Parameters to SPROC
SqlParameter ClassName = new SqlParameter("@classname", SqlDbType.Char, 10);
ClassName.Value = classname ;
myCommand.Parameters.Add(ClassName);
// Add Parameters to SPROC
SqlParameter Capicity = new SqlParameter("@capicity", SqlDbType.Int);
Capicity.Value = capicity;
myCommand.Parameters.Add(Capicity);
// Add Parameters to SPROC
SqlParameter EndTime = new SqlParameter("@endtime", SqlDbType.SmallDateTime);
EndTime.Value = endtime;
myCommand.Parameters.Add(EndTime);
// Execute the command
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Dispose();
myConnection.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -