📄 category.cs
字号:
using System;
using System.Data;
using System.Data.SqlClient;
namespace Njnu.DAL
{
/// <summary>
/// Category 的摘要说明。
/// </summary>
public class Category
{
public string GetCateIDByCateName(string name)
{
DataTable dt = new DataTable();
SqlParameter[] parameters = {};
try
{
using(SqlDatabase sqlDB = new SqlDatabase("select ID from Category where name = '" + name + "'", parameters))
{
sqlDB.Run(dt);
}
return dt.Rows[0][0].ToString();
}
catch(Exception e)
{
throw( new Exception(" 类别 ["+ name +"] 在表Category中不存在,请检查!" + e.Message));
}
}
public string GetCateNameByCateID(string ID)
{
DataTable dt = new DataTable();
SqlParameter[] parameters = {};
try
{
using(SqlDatabase sqlDB = new SqlDatabase("select name from Category where ID = '" + ID + "'", parameters))
{
sqlDB.Run(dt);
}
return dt.Rows[0][0].ToString();
}
catch(Exception e)
{
throw( new Exception(" 类别 ["+ ID +"] 在表Category中不存在,请检查!" + e.Message));
}
}
public DataTable GetAllCate()
{
DataTable dt = new DataTable();
SqlParameter[] parameters = {};
using(SqlDatabase sqlDB = new SqlDatabase("select * from Category", parameters))
{
sqlDB.Run(dt);
}
return dt;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -