|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using DSWeb.Models;
|
|
|
|
|
using WebSqlHelper;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.EntityDA
|
|
|
|
|
{
|
|
|
|
|
public class AttributeTypeDA
|
|
|
|
|
{
|
|
|
|
|
private const string PARM_ATTR_TYPE_GID = "@gid";
|
|
|
|
|
private const string PARM_ATTR_TYPE_NAME = "@name";
|
|
|
|
|
private const string PARM_ATTR_TYPE_DESCRIPTION = "@description";
|
|
|
|
|
private const string PARM_ATTR_TYPE_CREATE_USER = "@create_user";
|
|
|
|
|
private const string PARM_ATTR_TYPE_CREATE_TIME = "@create_time";
|
|
|
|
|
private const string PARM_ATTR_TYPE_MODIFIED_USER = "@modified_user";
|
|
|
|
|
private const string PARM_ATTR_TYPE_MODIFIED_TIME = "@modified_time";
|
|
|
|
|
private const string PARM_ATTR_TYPE_IS_DELETE = "@is_delete";
|
|
|
|
|
private const string PARM_ATTR_TYPE_DELETE_USER = "@delete_user";
|
|
|
|
|
private const string PARM_ATTR_TYPE_DELETE_TIME = "@delete_time";
|
|
|
|
|
private const string PARM_ATTR_TYPE_SORT = "@sort";
|
|
|
|
|
|
|
|
|
|
private const string SQL_SELECT_ATTR_TYPE_BY_GID = " SELECT GID, NAME, DESCRIPTION, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, ISDELETE, DELETEUSER, DELETETIME,SORT FROM attribute_type WHERE GID = @gid";
|
|
|
|
|
|
|
|
|
|
private const string SQL_SELECT_ATTR_TYPE_ALL = " SELECT GID, NAME, DESCRIPTION, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, ISDELETE, DELETEUSER, DELETETIME,SORT FROM attribute_type WHERE ISDELETE <> 1 ";
|
|
|
|
|
|
|
|
|
|
private const string SQL_INSERT_ATTR_TYPE = " INSERT INTO attribute_type(GID, NAME, DESCRIPTION, CREATEUSER, CREATETIME,SORT) VALUES(@gid,@name,@description,@create_user,GETDATE(),@sort) ";
|
|
|
|
|
|
|
|
|
|
private const string SQL_UPDATE_ATTR_TYPE_BY_GID = " UPDATE attribute_type SET NAME = @name,DESCRIPTION = @description,MODIFIEDUSER = @modified_user,MODIFIEDTIME = GETDATE(),SORT = @sort WHERE GID = @gid ";
|
|
|
|
|
|
|
|
|
|
#region 插入参数类型
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入参数类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempAttributeEntity">参数类型实体类</param>
|
|
|
|
|
/// <returns>值1表示插入完成 值不等于1表示插入失败</returns>
|
|
|
|
|
public int InsertAttributeType(AttributeTypeEntity tempAttributeTypeEntity)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
|
|
{
|
|
|
|
|
SqlParameter[] parms = new SqlParameter[] {
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_GID,SqlDbType.VarChar,36),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_NAME,SqlDbType.VarChar,50),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_DESCRIPTION,SqlDbType.VarChar,50),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_CREATE_USER,SqlDbType.VarChar,36),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_SORT,SqlDbType.Int)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parms[0].Value = tempAttributeTypeEntity.GID;
|
|
|
|
|
parms[1].Value = tempAttributeTypeEntity.Name;
|
|
|
|
|
parms[2].Value = tempAttributeTypeEntity.Description;
|
|
|
|
|
parms[3].Value = tempAttributeTypeEntity.CreateUser;
|
|
|
|
|
parms[4].Value = tempAttributeTypeEntity.Sort;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
iResult = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_INSERT_ATTR_TYPE, parms);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception error)
|
|
|
|
|
{
|
|
|
|
|
iResult = -1;//插入异常
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 更新参数类型
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新参数类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempAttributeEntity">参数类型实体类</param>
|
|
|
|
|
/// <returns>值1表示更新完成 值不等于1表示更新失败</returns>
|
|
|
|
|
public int UpdateAttributeType(AttributeTypeEntity tempAttributeTypeEntity)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
|
|
{
|
|
|
|
|
SqlParameter[] parms = new SqlParameter[] {
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_GID,SqlDbType.VarChar,36),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_NAME,SqlDbType.VarChar,50),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_DESCRIPTION,SqlDbType.VarChar,50),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_MODIFIED_USER,SqlDbType.VarChar,36),
|
|
|
|
|
new SqlParameter(PARM_ATTR_TYPE_SORT,SqlDbType.Int)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parms[0].Value = tempAttributeTypeEntity.GID;
|
|
|
|
|
parms[1].Value = tempAttributeTypeEntity.Name;
|
|
|
|
|
parms[2].Value = tempAttributeTypeEntity.Description;
|
|
|
|
|
parms[3].Value = tempAttributeTypeEntity.ModifiedUser;
|
|
|
|
|
parms[4].Value = tempAttributeTypeEntity.Sort;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
iResult = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, SQL_UPDATE_ATTR_TYPE_BY_GID, parms);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception error)
|
|
|
|
|
{
|
|
|
|
|
iResult = -1;//插入异常
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据参数类型GID获取相关参数类型
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据参数类型GID获取相关参数类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempAttributeTypeID">参数类型GID</param>
|
|
|
|
|
/// <returns>返回实体类</returns>
|
|
|
|
|
public AttributeTypeEntity GetAttributeTypeByID(string tempAttributeTypeID)
|
|
|
|
|
{
|
|
|
|
|
AttributeTypeEntity attributeTypeEntity = null;
|
|
|
|
|
|
|
|
|
|
SqlParameter parm = new SqlParameter(PARM_ATTR_TYPE_GID, SqlDbType.VarChar, 36);
|
|
|
|
|
parm.Value = tempAttributeTypeID;
|
|
|
|
|
|
|
|
|
|
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ATTR_TYPE_BY_GID, parm))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
while (sqlRead.Read())
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity = new AttributeTypeEntity();
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(0))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.GID = sqlRead.GetString(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(1))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Name = sqlRead.GetString(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(2))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Description = sqlRead.GetString(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(3))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.CreateUser = sqlRead.GetString(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(4))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.CreateTime = sqlRead.GetDateTime(4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(5))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.ModifiedUser = sqlRead.GetString(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(6))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.ModifiedTime = sqlRead.GetDateTime(6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(7))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.IsDelete = sqlRead.GetBoolean(7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(8))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.DeleteUser = sqlRead.GetString(8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(9))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.DeleteTime = sqlRead.GetDateTime(9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(10))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Sort = sqlRead.GetInt32(10);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return attributeTypeEntity;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取所有参数类型信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取所有参数类型信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回实体类组</returns>
|
|
|
|
|
public IList<AttributeTypeEntity> GetAttributeTypeAll()
|
|
|
|
|
{
|
|
|
|
|
IList<AttributeTypeEntity> attributeTypeEntities = new List<AttributeTypeEntity>();
|
|
|
|
|
|
|
|
|
|
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_SELECT_ATTR_TYPE_ALL, null))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
while (sqlRead.Read())
|
|
|
|
|
{
|
|
|
|
|
AttributeTypeEntity attributeTypeEntity = new AttributeTypeEntity();
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(0))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.GID = sqlRead.GetString(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(1))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Name = sqlRead.GetString(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(2))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Description = sqlRead.GetString(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(3))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.CreateUser = sqlRead.GetString(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(4))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.CreateTime = sqlRead.GetDateTime(4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(5))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.ModifiedUser = sqlRead.GetString(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(6))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.ModifiedTime = sqlRead.GetDateTime(6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(7))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.IsDelete = sqlRead.GetBoolean(7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(8))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.DeleteUser = sqlRead.GetString(8);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(9))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.DeleteTime = sqlRead.GetDateTime(9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!sqlRead.IsDBNull(10))
|
|
|
|
|
{
|
|
|
|
|
attributeTypeEntity.Sort = sqlRead.GetInt32(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
attributeTypeEntities.Add(attributeTypeEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return attributeTypeEntities;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取SQL语句查询数据集
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取SQL语句查询数据集
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strSql"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataSet GetExcuteSql(string strSql)
|
|
|
|
|
{
|
|
|
|
|
DataSet tempSet = new DataSet();
|
|
|
|
|
|
|
|
|
|
tempSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
|
|
|
|
|
return tempSet;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|