339 lines
10 KiB
C#
339 lines
10 KiB
C#
/** 版本信息模板在安装目录下,可自行修改。
|
|
* iot_function_code_config.cs
|
|
*
|
|
* 功 能: N/A
|
|
* 类 名: iot_function_code_config
|
|
*
|
|
* Ver 变更日期 负责人 变更内容
|
|
* ───────────────────────────────────
|
|
* V0.01 2025/6/6 13:58:11 N/A 初版
|
|
*
|
|
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
|
|
*┌──────────────────────────────────┐
|
|
*│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
|
|
*│ 版权所有:动软卓越(北京)科技有限公司 │
|
|
*└──────────────────────────────────┘
|
|
*/
|
|
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
using MySql.Data.MySqlClient;
|
|
using Maticsoft.DBUtility;//Please add references
|
|
namespace Gather.Mysql.DAL
|
|
{
|
|
/// <summary>
|
|
/// 数据访问类:iot_function_code_config
|
|
/// </summary>
|
|
public partial class iot_function_code_config
|
|
{
|
|
public iot_function_code_config()
|
|
{}
|
|
#region BasicMethod
|
|
|
|
/// <summary>
|
|
/// 是否存在该记录
|
|
/// </summary>
|
|
public bool Exists(long id)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select count(1) from iot_function_code_config");
|
|
strSql.Append(" where id=@id");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
|
};
|
|
parameters[0].Value = id;
|
|
|
|
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public bool Add(Gather.Mysql.Model.iot_function_code_config model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("insert into iot_function_code_config(");
|
|
strSql.Append("function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@function_code,@start_address_from_zero,@is_del,@creat_by,@creat_time,@update_by,@update_time)");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@function_code", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@start_address_from_zero", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
|
new MySqlParameter("@update_time", MySqlDbType.DateTime)};
|
|
parameters[0].Value = model.function_code;
|
|
parameters[1].Value = model.start_address_from_zero;
|
|
parameters[2].Value = model.is_del;
|
|
parameters[3].Value = model.creat_by;
|
|
parameters[4].Value = model.creat_time;
|
|
parameters[5].Value = model.update_by;
|
|
parameters[6].Value = model.update_time;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
public bool Update(Gather.Mysql.Model.iot_function_code_config model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("update iot_function_code_config set ");
|
|
strSql.Append("function_code=@function_code,");
|
|
strSql.Append("start_address_from_zero=@start_address_from_zero,");
|
|
strSql.Append("is_del=@is_del,");
|
|
strSql.Append("creat_by=@creat_by,");
|
|
strSql.Append("creat_time=@creat_time,");
|
|
strSql.Append("update_by=@update_by,");
|
|
strSql.Append("update_time=@update_time");
|
|
strSql.Append(" where id=@id");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@function_code", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@start_address_from_zero", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@is_del", MySqlDbType.VarChar,2),
|
|
new MySqlParameter("@creat_by", MySqlDbType.VarChar,64),
|
|
new MySqlParameter("@creat_time", MySqlDbType.DateTime),
|
|
new MySqlParameter("@update_by", MySqlDbType.VarChar,64),
|
|
new MySqlParameter("@update_time", MySqlDbType.DateTime),
|
|
new MySqlParameter("@id", MySqlDbType.Int64)};
|
|
parameters[0].Value = model.function_code;
|
|
parameters[1].Value = model.start_address_from_zero;
|
|
parameters[2].Value = model.is_del;
|
|
parameters[3].Value = model.creat_by;
|
|
parameters[4].Value = model.creat_time;
|
|
parameters[5].Value = model.update_by;
|
|
parameters[6].Value = model.update_time;
|
|
parameters[7].Value = model.id;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public bool Delete(long id)
|
|
{
|
|
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from iot_function_code_config ");
|
|
strSql.Append(" where id=@id");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
|
};
|
|
parameters[0].Value = id;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 批量删除数据
|
|
/// </summary>
|
|
public bool DeleteList(string idlist )
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from iot_function_code_config ");
|
|
strSql.Append(" where id in ("+idlist + ") ");
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public Gather.Mysql.Model.iot_function_code_config GetModel(long id)
|
|
{
|
|
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select id,function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time from iot_function_code_config ");
|
|
strSql.Append(" where id=@id");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@id", MySqlDbType.Int64)
|
|
};
|
|
parameters[0].Value = id;
|
|
|
|
Gather.Mysql.Model.iot_function_code_config model=new Gather.Mysql.Model.iot_function_code_config();
|
|
DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
|
|
if(ds.Tables[0].Rows.Count>0)
|
|
{
|
|
return DataRowToModel(ds.Tables[0].Rows[0]);
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public Gather.Mysql.Model.iot_function_code_config DataRowToModel(DataRow row)
|
|
{
|
|
Gather.Mysql.Model.iot_function_code_config model=new Gather.Mysql.Model.iot_function_code_config();
|
|
if (row != null)
|
|
{
|
|
if(row["id"]!=null && row["id"].ToString()!="")
|
|
{
|
|
model.id=long.Parse(row["id"].ToString());
|
|
}
|
|
if(row["function_code"]!=null)
|
|
{
|
|
model.function_code=row["function_code"].ToString();
|
|
}
|
|
if(row["start_address_from_zero"]!=null)
|
|
{
|
|
model.start_address_from_zero=row["start_address_from_zero"].ToString();
|
|
}
|
|
if(row["is_del"]!=null)
|
|
{
|
|
model.is_del=row["is_del"].ToString();
|
|
}
|
|
if(row["creat_by"]!=null)
|
|
{
|
|
model.creat_by=row["creat_by"].ToString();
|
|
}
|
|
if(row["creat_time"]!=null && row["creat_time"].ToString()!="")
|
|
{
|
|
model.creat_time=DateTime.Parse(row["creat_time"].ToString());
|
|
}
|
|
if(row["update_by"]!=null)
|
|
{
|
|
model.update_by=row["update_by"].ToString();
|
|
}
|
|
if(row["update_time"]!=null && row["update_time"].ToString()!="")
|
|
{
|
|
model.update_time=DateTime.Parse(row["update_time"].ToString());
|
|
}
|
|
}
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select id,function_code,start_address_from_zero,is_del,creat_by,creat_time,update_by,update_time ");
|
|
strSql.Append(" FROM iot_function_code_config ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
return DbHelperMySQL.Query(strSql.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取记录总数
|
|
/// </summary>
|
|
public int GetRecordCount(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select count(1) FROM iot_function_code_config ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
object obj = DbHelperMySQL.GetSingle(strSql.ToString());
|
|
if (obj == null)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(obj);
|
|
}
|
|
}
|
|
/// <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 );
|
|
}
|
|
else
|
|
{
|
|
strSql.Append("order by T.id desc");
|
|
}
|
|
strSql.Append(")AS Row, T.* from iot_function_code_config T ");
|
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
{
|
|
strSql.Append(" WHERE " + strWhere);
|
|
}
|
|
strSql.Append(" ) TT");
|
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
|
return DbHelperMySQL.Query(strSql.ToString());
|
|
}
|
|
|
|
/*
|
|
/// <summary>
|
|
/// 分页获取数据列表
|
|
/// </summary>
|
|
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
|
{
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@tblName", MySqlDbType.VarChar, 255),
|
|
new MySqlParameter("@fldName", MySqlDbType.VarChar, 255),
|
|
new MySqlParameter("@PageSize", MySqlDbType.Int32),
|
|
new MySqlParameter("@PageIndex", MySqlDbType.Int32),
|
|
new MySqlParameter("@IsReCount", MySqlDbType.Bit),
|
|
new MySqlParameter("@OrderType", MySqlDbType.Bit),
|
|
new MySqlParameter("@strWhere", MySqlDbType.VarChar,1000),
|
|
};
|
|
parameters[0].Value = "iot_function_code_config";
|
|
parameters[1].Value = "id";
|
|
parameters[2].Value = PageSize;
|
|
parameters[3].Value = PageIndex;
|
|
parameters[4].Value = 0;
|
|
parameters[5].Value = 0;
|
|
parameters[6].Value = strWhere;
|
|
return DbHelperMySQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
|
}*/
|
|
|
|
#endregion BasicMethod
|
|
#region ExtensionMethod
|
|
|
|
#endregion ExtensionMethod
|
|
}
|
|
}
|
|
|