You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

253 lines
12 KiB
C#

using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DSWeb.SoftMng.DBUtility;
// ReSharper disable once CheckNamespace
namespace DSWeb.SoftMng.DAL
{
//sys_module
public partial class sys_moduleServerDAL
{
public bool Exists(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) from [sys_module]");
strSql.Append(" where ");
strSql.Append(" GID = @GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperServerSQL.Exists(strSql.ToString(), parameters);
}
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(DSWeb.SoftMng.Model.sys_module model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [sys_module](");
strSql.Append("GID,NAME,DESCRIPTION,MODULEURL,MODULEICON,STATE,SORT,PARENTID,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,SHOWROOTSTATE,TYPE,ENAME,MODTYPE");
strSql.Append(") values (");
strSql.Append("@GID,@NAME,@DESCRIPTION,@MODULEURL,@MODULEICON,@STATE,@SORT,@PARENTID,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@SHOWROOTSTATE,@TYPE,@ENAME,@MODTYPE");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@NAME", SqlDbType.VarChar,150) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,150) ,
new SqlParameter("@MODULEURL", SqlDbType.VarChar,200) ,
new SqlParameter("@MODULEICON", SqlDbType.VarChar,50) ,
new SqlParameter("@STATE", SqlDbType.Int,4) ,
new SqlParameter("@SORT", SqlDbType.Int,4) ,
new SqlParameter("@PARENTID", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@SHOWROOTSTATE", SqlDbType.Int,4) ,
new SqlParameter("@TYPE", SqlDbType.Int,4) ,
new SqlParameter("@ENAME", SqlDbType.VarChar,50) ,
new SqlParameter("@MODTYPE", SqlDbType.Int,4)
};
parameters[0].Value = model.GID ?? (Object)DBNull.Value;
parameters[1].Value = model.NAME ?? (Object)DBNull.Value;
parameters[2].Value = model.DESCRIPTION ?? (Object)DBNull.Value;
parameters[3].Value = model.MODULEURL ?? (Object)DBNull.Value;
parameters[4].Value = model.MODULEICON ?? (Object)DBNull.Value;
parameters[5].Value = model.STATE ?? (Object)DBNull.Value;
parameters[6].Value = model.SORT ?? (Object)DBNull.Value;
parameters[7].Value = model.PARENTID ?? (Object)DBNull.Value;
parameters[8].Value = model.CREATEUSER ?? (Object)DBNull.Value;
parameters[9].Value = model.CREATETIME ?? (Object)DBNull.Value;
parameters[10].Value = model.MODIFIEDUSER ?? (Object)DBNull.Value;
parameters[11].Value = model.MODIFIEDTIME ?? (Object)DBNull.Value;
parameters[12].Value = model.SHOWROOTSTATE ?? (Object)DBNull.Value;
parameters[13].Value = model.TYPE ?? (Object)DBNull.Value;
parameters[14].Value = model.ENAME ?? (Object)DBNull.Value;
parameters[15].Value = model.MODTYPE ?? (Object)DBNull.Value;
return DbHelperServerSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 更新一条数据
/// </summary>
public int Update(DSWeb.SoftMng.Model.sys_module model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update [sys_module] set ");
strSql.Append(" GID = @GID,");
strSql.Append(" NAME = @NAME,");
strSql.Append(" DESCRIPTION = @DESCRIPTION,");
strSql.Append(" MODULEURL = @MODULEURL,");
strSql.Append(" MODULEICON = @MODULEICON,");
strSql.Append(" STATE = @STATE,");
strSql.Append(" SORT = @SORT,");
strSql.Append(" PARENTID = @PARENTID,");
strSql.Append(" CREATEUSER = @CREATEUSER,");
strSql.Append(" CREATETIME = @CREATETIME,");
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER,");
strSql.Append(" MODIFIEDTIME = @MODIFIEDTIME,");
strSql.Append(" SHOWROOTSTATE = @SHOWROOTSTATE,");
strSql.Append(" TYPE = @TYPE,");
strSql.Append(" ENAME = @ENAME,");
strSql.Append(" MODTYPE = @MODTYPE");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
new SqlParameter("@NAME", SqlDbType.VarChar,150) ,
new SqlParameter("@DESCRIPTION", SqlDbType.VarChar,150) ,
new SqlParameter("@MODULEURL", SqlDbType.VarChar,200) ,
new SqlParameter("@MODULEICON", SqlDbType.VarChar,50) ,
new SqlParameter("@STATE", SqlDbType.Int,4) ,
new SqlParameter("@SORT", SqlDbType.Int,4) ,
new SqlParameter("@PARENTID", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@CREATETIME", SqlDbType.DateTime) ,
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
new SqlParameter("@MODIFIEDTIME", SqlDbType.DateTime) ,
new SqlParameter("@SHOWROOTSTATE", SqlDbType.Int,4) ,
new SqlParameter("@TYPE", SqlDbType.Int,4) ,
new SqlParameter("@ENAME", SqlDbType.VarChar,50) ,
new SqlParameter("@MODTYPE", SqlDbType.Int,4)
};
parameters[0].Value = model.GID ?? (Object)DBNull.Value;
parameters[1].Value = model.NAME ?? (Object)DBNull.Value;
parameters[2].Value = model.DESCRIPTION ?? (Object)DBNull.Value;
parameters[3].Value = model.MODULEURL ?? (Object)DBNull.Value;
parameters[4].Value = model.MODULEICON ?? (Object)DBNull.Value;
parameters[5].Value = model.STATE ?? (Object)DBNull.Value;
parameters[6].Value = model.SORT ?? (Object)DBNull.Value;
parameters[7].Value = model.PARENTID ?? (Object)DBNull.Value;
parameters[8].Value = model.CREATEUSER ?? (Object)DBNull.Value;
parameters[9].Value = model.CREATETIME ?? (Object)DBNull.Value;
parameters[10].Value = model.MODIFIEDUSER ?? (Object)DBNull.Value;
parameters[11].Value = model.MODIFIEDTIME ?? (Object)DBNull.Value;
parameters[12].Value = model.SHOWROOTSTATE ?? (Object)DBNull.Value;
parameters[13].Value = model.TYPE ?? (Object)DBNull.Value;
parameters[14].Value = model.ENAME ?? (Object)DBNull.Value;
parameters[15].Value = model.MODTYPE ?? (Object)DBNull.Value;
return DbHelperServerSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 删除一条数据
/// </summary>
public int Delete(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from [sys_module] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
return DbHelperServerSQL.ExecuteSql(strSql.ToString(), parameters);
}
/// <summary>
/// 按条件批量删除
/// </summary>
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from [sys_module] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return DbHelperServerSQL.ExecuteSql(strSql.ToString());
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public DataSet GetModel(string GID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select GID, NAME, DESCRIPTION, MODULEURL, MODULEICON, STATE, SORT, PARENTID, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, SHOWROOTSTATE, TYPE, ENAME, MODTYPE ");
strSql.Append(" from [sys_module] ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,36) };
parameters[0].Value = GID;
DSWeb.SoftMng.Model.sys_module model = new DSWeb.SoftMng.Model.sys_module();
return DbHelperServerSQL.Query(strSql.ToString(), parameters);
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM [sys_module] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by PARENTID,SORT ASC ");
return DbHelperServerSQL.Query(strSql.ToString());
}
/// <summary>
/// 获得前几行数据
/// </summary>
public DataSet GetList(int Top, string strWhere, string filedOrder)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select ");
if (Top > 0)
{
strSql.Append(" top " + Top.ToString());
}
strSql.Append(" * ");
strSql.Append(" FROM [sys_module] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperServerSQL.Query(strSql.ToString());
}
/// <summary>
/// 分页获取数据列表
/// </summary>
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
{
//动软代码
StringBuilder strSql = new StringBuilder();
strSql.Append("SELECT * FROM ( ");
strSql.Append(" SELECT ROW_NUMBER() OVER (");
if (!string.IsNullOrEmpty(orderby.Trim()))
strSql.Append("order by T." + orderby);
strSql.Append(")AS Row, T.* from [sys_module] T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row > {0} and TT.Row <= {1}", startIndex, endIndex);
//公共代码
return DbHelperServerSQL.Query(strSql.ToString());
}
/// <summary>
/// 获取记录总数
/// </summary>
public int GetRecordCount(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(1) FROM [sys_module] ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
return DbHelperServerSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}