|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using CommonFunc;
|
|
|
|
|
|
using MySql.Data.MySqlClient;
|
|
|
|
|
|
namespace XGL.Data
|
|
|
|
|
|
{
|
|
|
|
|
|
//rolepermission
|
|
|
|
|
|
public class rolepermissionDB : IDisposable
|
|
|
|
|
|
{
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
Dispose(true);
|
|
|
|
|
|
GC.SuppressFinalize(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!disposing)
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Exists()
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("select count(1) from rolepermission");
|
|
|
|
|
|
strSql.Append(" where ");
|
|
|
|
|
|
MySqlParameter[] parameters = {
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return DbHelperSQLServer.Exists(strSql.ToString(), parameters);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 增加一条数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Add(XGL.Models.rolepermission model)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("insert into rolepermission(");
|
|
|
|
|
|
strSql.Append("id,roleId,permissionid,isdeleted,createdate,createby,modifydate,modifyby");
|
|
|
|
|
|
strSql.Append(") values (");
|
|
|
|
|
|
strSql.Append("@id,@roleId,@permissionid,@isdeleted,@createdate,@createby,@modifydate,@modifyby");
|
|
|
|
|
|
strSql.Append(") ");
|
|
|
|
|
|
|
|
|
|
|
|
MySqlParameter[] parameters = {
|
|
|
|
|
|
new MySqlParameter("@id", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@roleId", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@permissionid", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@isdeleted", MySqlDbType.Int32,1) ,
|
|
|
|
|
|
new MySqlParameter("@createdate", MySqlDbType.DateTime) ,
|
|
|
|
|
|
new MySqlParameter("@createby", MySqlDbType.VarChar,20) ,
|
|
|
|
|
|
new MySqlParameter("@modifydate", MySqlDbType.DateTime) ,
|
|
|
|
|
|
new MySqlParameter("@modifyby", MySqlDbType.VarChar,20)
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
parameters[0].Value = model.id;
|
|
|
|
|
|
parameters[1].Value = model.roleId;
|
|
|
|
|
|
parameters[2].Value = model.permissionid;
|
|
|
|
|
|
parameters[3].Value = model.isdeleted;
|
|
|
|
|
|
parameters[4].Value = model.createdate;
|
|
|
|
|
|
parameters[5].Value = model.createby;
|
|
|
|
|
|
parameters[6].Value = model.modifydate;
|
|
|
|
|
|
parameters[7].Value = model.modifyby;
|
|
|
|
|
|
DbHelperSQLServer.ExecuteNonQuery(strSql.ToString(), parameters);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新一条数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool Update(XGL.Models.rolepermission model)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("update rolepermission set ");
|
|
|
|
|
|
|
|
|
|
|
|
strSql.Append(" id = @id , ");
|
|
|
|
|
|
strSql.Append(" roleId = @roleId , ");
|
|
|
|
|
|
strSql.Append(" permissionid = @permissionid , ");
|
|
|
|
|
|
strSql.Append(" isdeleted = @isdeleted , ");
|
|
|
|
|
|
strSql.Append(" createdate = @createdate , ");
|
|
|
|
|
|
strSql.Append(" createby = @createby , ");
|
|
|
|
|
|
strSql.Append(" modifydate = @modifydate , ");
|
|
|
|
|
|
strSql.Append(" modifyby = @modifyby ");
|
|
|
|
|
|
strSql.Append(" where ");
|
|
|
|
|
|
|
|
|
|
|
|
MySqlParameter[] parameters = {
|
|
|
|
|
|
new MySqlParameter("@id", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@roleId", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@permissionid", MySqlDbType.Int32,11) ,
|
|
|
|
|
|
new MySqlParameter("@isdeleted", MySqlDbType.Int32,1) ,
|
|
|
|
|
|
new MySqlParameter("@createdate", MySqlDbType.DateTime) ,
|
|
|
|
|
|
new MySqlParameter("@createby", MySqlDbType.VarChar,20) ,
|
|
|
|
|
|
new MySqlParameter("@modifydate", MySqlDbType.DateTime) ,
|
|
|
|
|
|
new MySqlParameter("@modifyby", MySqlDbType.VarChar,20)
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
parameters[0].Value = model.id;
|
|
|
|
|
|
parameters[1].Value = model.roleId;
|
|
|
|
|
|
parameters[2].Value = model.permissionid;
|
|
|
|
|
|
parameters[3].Value = model.isdeleted;
|
|
|
|
|
|
parameters[4].Value = model.createdate;
|
|
|
|
|
|
parameters[5].Value = model.createby;
|
|
|
|
|
|
parameters[6].Value = model.modifydate;
|
|
|
|
|
|
parameters[7].Value = model.modifyby;
|
|
|
|
|
|
int rows = DbHelperSQLServer.ExecuteNonQuery(strSql.ToString(), parameters);
|
|
|
|
|
|
if (rows > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 删除一条数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool Delete()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("delete from rolepermission ");
|
|
|
|
|
|
strSql.Append(" where ");
|
|
|
|
|
|
MySqlParameter[] parameters = {
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int rows = DbHelperSQLServer.ExecuteNonQuery(strSql.ToString(), parameters);
|
|
|
|
|
|
if (rows > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 得到一个对象实体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public XGL.Models.rolepermission GetModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("select id, roleId, permissionid, isdeleted, createdate, createby, modifydate, modifyby ");
|
|
|
|
|
|
strSql.Append(" from rolepermission ");
|
|
|
|
|
|
strSql.Append(" where ");
|
|
|
|
|
|
MySqlParameter[] parameters = {
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XGL.Models.rolepermission model = new XGL.Models.rolepermission();
|
|
|
|
|
|
DataSet ds = DbHelperSQLServer.Query(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());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ds.Tables[0].Rows[0]["roleId"].ToString() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
model.roleId = int.Parse(ds.Tables[0].Rows[0]["roleId"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ds.Tables[0].Rows[0]["permissionid"].ToString() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
model.permissionid = int.Parse(ds.Tables[0].Rows[0]["permissionid"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ds.Tables[0].Rows[0]["isdeleted"].ToString() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
model.isdeleted = int.Parse(ds.Tables[0].Rows[0]["isdeleted"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ds.Tables[0].Rows[0]["createdate"].ToString() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
model.createdate = DateTime.Parse(ds.Tables[0].Rows[0]["createdate"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
model.createby = ds.Tables[0].Rows[0]["createby"].ToString();
|
|
|
|
|
|
if (ds.Tables[0].Rows[0]["modifydate"].ToString() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
model.modifydate = DateTime.Parse(ds.Tables[0].Rows[0]["modifydate"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
model.modifyby = ds.Tables[0].Rows[0]["modifyby"].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获得数据列表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DataSet GetList(string strWhere)
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
|
strSql.Append("select * ");
|
|
|
|
|
|
strSql.Append(" FROM rolepermission ");
|
|
|
|
|
|
if (strWhere.Trim() != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
|
|
|
}
|
|
|
|
|
|
return DbHelperSQLServer.Query(strSql.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|