Files
g.hnyhua.cn/Mtxfw.DAL/Adminjs.cs
2026-02-07 15:48:27 +08:00

135 lines
4.5 KiB
C#

using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Wuqi.Webdiyer;
namespace Mtxfw.DAL
{
/// <summary>
/// 数据访问类:Adminjs
/// </summary>
public partial class Adminjs : Mtxfw.Utility.Myabstract
{
public Adminjs() : base("Adminjs") { }
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Mtxfw.Model.Adminjs model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into Adminjs(");
strSql.Append("jsName,js,ttype,gtype)");
strSql.Append(" values (");
strSql.Append("@jsName,@js,@ttype,@gtype)");
strSql.Append(";select SCOPE_IDENTITY()");
SqlParameter[] parameters = {
new SqlParameter("@jsName", SqlDbType.VarChar,50),
new SqlParameter("@js", SqlDbType.VarChar,8000),
new SqlParameter("@ttype", SqlDbType.Int),
new SqlParameter("@gtype", SqlDbType.Int)};
parameters[0].Value = model.jsName;
parameters[1].Value = model.js;
parameters[2].Value = model.ttype;
parameters[3].Value = model.gtype;
return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(Mtxfw.Model.Adminjs model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update Adminjs set ");
strSql.Append("jsName=@jsName,");
strSql.Append("js=@js");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@jsName", SqlDbType.VarChar,50),
new SqlParameter("@js", SqlDbType.VarChar,8000),
new SqlParameter("@id", SqlDbType.VarChar,50)};
parameters[0].Value = model.jsName;
parameters[1].Value = model.js;
parameters[2].Value = model.id;
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
return rows > 0 ? true : false;
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from Adminjs ");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)};
parameters[0].Value = id;
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Mtxfw.Model.Adminjs GetModel(int id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 id,jsName,js,ttype from Adminjs ");
strSql.Append(" where id=@id");
SqlParameter[] parameters = {
new SqlParameter("@id", SqlDbType.Int,4)};
parameters[0].Value = id;
Mtxfw.Model.Adminjs model = new Mtxfw.Model.Adminjs();
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["id"].ToString() != "")
{
model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
}
model.jsName = ds.Tables[0].Rows[0]["jsName"].ToString();
model.js = ds.Tables[0].Rows[0]["js"].ToString();
model.ttype = int.Parse(ds.Tables[0].Rows[0]["ttype"].ToString());
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select id,jsName,js,ttype ");
strSql.Append(" FROM Adminjs ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
}
}
}