怎么在C#中写注释,让他自动生成代码说明文档?
作者:admin 时间:2023-03-21 05:21:45
只要保证你的注释符合规则,然后单击“工具”中的“生成注释Web页”就可以自动生成代码文档资料了,其存放路径为你的项目所在的目录,名字为“CodeCommentReport”文件夹里面就可以看到所有的代码文档资料了,呵呵
public class baseclass
{
public static sqlconnection dbcon() //下面连接数据库写的代码
{
return new sqlconnection("server=.;database=db_examonline;uid=sa;pwd=");
}
public static void binddg(gridview dg, string id, string strsql, string tname)
{
sqlconnection conn = dbcon(); //创建连接数据库
sqldataadapter sda = new sqldataadapter(strsql, conn);//传入参数
dataset ds = new dataset(); //声明并且初始化dataset
sda.fill(ds, tname); //填充
dg.datasource = ds.tables[tname];//邦定数据源
dg.datakeynames = new string[] { id };//数组法?现在不提倡了 用起来麻烦
dg.databind(); //邦定到gridview 控件
}
public static void operatedata(string strsql) //将strsql传入此方法内
{
sqlconnection conn = dbcon(); //查ungjian连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand(strsql, conn); //执行参数传递过来的命令
cmd.executenonquery(); //返回值
conn.close(); //关闭数据库
}
//================如果是学生登录=========================================
public static bool checkstudent(string studentnum, string studentpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_student where studentnum='" + studentnum + "' and studentpwd='" + studentpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true;//返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close();//关闭数据库
}
//================如果是教师登录=========================================
public static bool checkteacher(string teachernum, string teacherpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_teacher where teachernum='" + teachernum + "' and teacherpwd='" + teacherpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true; //返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close(); //关闭数据库
}
//================如果是管理员登录=========================================
public static bool checkadmin(string adminnum, string adminpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_admin where adminnum='" + adminnum + "' and adminpwd='" + adminpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true; //返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close(); //关闭数据库
}
}
具体不明白的短信我就 ok了~
{
public static sqlconnection dbcon() //下面连接数据库写的代码
{
return new sqlconnection("server=.;database=db_examonline;uid=sa;pwd=");
}
public static void binddg(gridview dg, string id, string strsql, string tname)
{
sqlconnection conn = dbcon(); //创建连接数据库
sqldataadapter sda = new sqldataadapter(strsql, conn);//传入参数
dataset ds = new dataset(); //声明并且初始化dataset
sda.fill(ds, tname); //填充
dg.datasource = ds.tables[tname];//邦定数据源
dg.datakeynames = new string[] { id };//数组法?现在不提倡了 用起来麻烦
dg.databind(); //邦定到gridview 控件
}
public static void operatedata(string strsql) //将strsql传入此方法内
{
sqlconnection conn = dbcon(); //查ungjian连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand(strsql, conn); //执行参数传递过来的命令
cmd.executenonquery(); //返回值
conn.close(); //关闭数据库
}
//================如果是学生登录=========================================
public static bool checkstudent(string studentnum, string studentpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_student where studentnum='" + studentnum + "' and studentpwd='" + studentpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true;//返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close();//关闭数据库
}
//================如果是教师登录=========================================
public static bool checkteacher(string teachernum, string teacherpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_teacher where teachernum='" + teachernum + "' and teacherpwd='" + teacherpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true; //返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close(); //关闭数据库
}
//================如果是管理员登录=========================================
public static bool checkadmin(string adminnum, string adminpwd)
{
sqlconnection conn = dbcon(); //创建连接数据库
conn.open(); //打开数据库
sqlcommand cmd = new sqlcommand("select count(*) from tb_admin where adminnum='" + adminnum + "' and adminpwd='" + adminpwd + "'", conn); //创建command命令
int i = convert.toint32(cmd.executescalar()); //检测返回值
if (i > 0) //如果返回值i大于1则执行
{
return true; //返回正确
}
else //如果返回值i不大于1则执行这个
{
return false; //返回错误
}
conn.close(); //关闭数据库
}
}
具体不明白的短信我就 ok了~
小猪提醒大家:理性玩梗,以免过度。伤害友情,危及自己。
版权声明:此文版权归原作者所有,若有来源错误或者侵犯您的合法权益,您可通过邮箱与我们取得联系,我们将及时进行处理。