365 lines
12 KiB
C#
365 lines
12 KiB
C#
/** 版本信息模板在安装目录下,可自行修改。
|
|
* meteorological_station.cs
|
|
*
|
|
* 功 能: N/A
|
|
* 类 名: meteorological_station
|
|
*
|
|
* Ver 变更日期 负责人 变更内容
|
|
* ───────────────────────────────────
|
|
* V0.01 2024/2/22 11:05:54 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 DataService.DAL
|
|
{
|
|
/// <summary>
|
|
/// 数据访问类:meteorological_station
|
|
/// </summary>
|
|
public partial class meteorological_station
|
|
{
|
|
public meteorological_station()
|
|
{}
|
|
#region BasicMethod
|
|
|
|
/// <summary>
|
|
/// 是否存在该记录
|
|
/// </summary>
|
|
public bool Exists(string MeteorologicalId)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select count(1) from meteorological_station");
|
|
strSql.Append(" where MeteorologicalId=@MeteorologicalId ");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@MeteorologicalId", MySqlDbType.VarChar,255) };
|
|
parameters[0].Value = MeteorologicalId;
|
|
|
|
return DbHelperMySQL.Exists(strSql.ToString(),parameters);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public bool Add(DataService.Model.meteorological_station model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("insert into meteorological_station(");
|
|
strSql.Append("MeteorologicalId,MeteorologicalNumber,MeteorologicalName,MeteorologicalValue,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@MeteorologicalId,@MeteorologicalNumber,@MeteorologicalName,@MeteorologicalValue,@CreateTime,@EntireTime,@Reserve1,@Reserve2,@Reserve3,@Reserve4,@Reserve5)");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@MeteorologicalId", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalNumber", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalName", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalValue", MySqlDbType.Float,255),
|
|
new MySqlParameter("@CreateTime", MySqlDbType.DateTime),
|
|
new MySqlParameter("@EntireTime", MySqlDbType.DateTime),
|
|
new MySqlParameter("@Reserve1", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve2", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve3", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve4", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve5", MySqlDbType.VarChar,255)};
|
|
parameters[0].Value = model.MeteorologicalId;
|
|
parameters[1].Value = model.MeteorologicalNumber;
|
|
parameters[2].Value = model.MeteorologicalName;
|
|
parameters[3].Value = model.MeteorologicalValue;
|
|
parameters[4].Value = model.CreateTime;
|
|
parameters[5].Value = model.EntireTime;
|
|
parameters[6].Value = model.Reserve1;
|
|
parameters[7].Value = model.Reserve2;
|
|
parameters[8].Value = model.Reserve3;
|
|
parameters[9].Value = model.Reserve4;
|
|
parameters[10].Value = model.Reserve5;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
public bool Update(DataService.Model.meteorological_station model)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("update meteorological_station set ");
|
|
strSql.Append("MeteorologicalNumber=@MeteorologicalNumber,");
|
|
strSql.Append("MeteorologicalName=@MeteorologicalName,");
|
|
strSql.Append("MeteorologicalValue=@MeteorologicalValue,");
|
|
strSql.Append("CreateTime=@CreateTime,");
|
|
strSql.Append("EntireTime=@EntireTime,");
|
|
strSql.Append("Reserve1=@Reserve1,");
|
|
strSql.Append("Reserve2=@Reserve2,");
|
|
strSql.Append("Reserve3=@Reserve3,");
|
|
strSql.Append("Reserve4=@Reserve4,");
|
|
strSql.Append("Reserve5=@Reserve5");
|
|
strSql.Append(" where MeteorologicalId=@MeteorologicalId ");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@MeteorologicalNumber", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalName", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalValue", MySqlDbType.Float,255),
|
|
new MySqlParameter("@CreateTime", MySqlDbType.DateTime),
|
|
new MySqlParameter("@EntireTime", MySqlDbType.DateTime),
|
|
new MySqlParameter("@Reserve1", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve2", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve3", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve4", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@Reserve5", MySqlDbType.VarChar,255),
|
|
new MySqlParameter("@MeteorologicalId", MySqlDbType.VarChar,255)};
|
|
parameters[0].Value = model.MeteorologicalNumber;
|
|
parameters[1].Value = model.MeteorologicalName;
|
|
parameters[2].Value = model.MeteorologicalValue;
|
|
parameters[3].Value = model.CreateTime;
|
|
parameters[4].Value = model.EntireTime;
|
|
parameters[5].Value = model.Reserve1;
|
|
parameters[6].Value = model.Reserve2;
|
|
parameters[7].Value = model.Reserve3;
|
|
parameters[8].Value = model.Reserve4;
|
|
parameters[9].Value = model.Reserve5;
|
|
parameters[10].Value = model.MeteorologicalId;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public bool Delete(string MeteorologicalId)
|
|
{
|
|
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from meteorological_station ");
|
|
strSql.Append(" where MeteorologicalId=@MeteorologicalId ");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@MeteorologicalId", MySqlDbType.VarChar,255) };
|
|
parameters[0].Value = MeteorologicalId;
|
|
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 批量删除数据
|
|
/// </summary>
|
|
public bool DeleteList(string MeteorologicalIdlist )
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("delete from meteorological_station ");
|
|
strSql.Append(" where MeteorologicalId in ("+MeteorologicalIdlist + ") ");
|
|
int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public DataService.Model.meteorological_station GetModel(string MeteorologicalId)
|
|
{
|
|
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select MeteorologicalId,MeteorologicalNumber,MeteorologicalName,MeteorologicalValue,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 from meteorological_station ");
|
|
strSql.Append(" where MeteorologicalId=@MeteorologicalId ");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@MeteorologicalId", MySqlDbType.VarChar,255) };
|
|
parameters[0].Value = MeteorologicalId;
|
|
|
|
DataService.Model.meteorological_station model=new DataService.Model.meteorological_station();
|
|
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 DataService.Model.meteorological_station DataRowToModel(DataRow row)
|
|
{
|
|
DataService.Model.meteorological_station model=new DataService.Model.meteorological_station();
|
|
if (row != null)
|
|
{
|
|
if(row["MeteorologicalId"]!=null)
|
|
{
|
|
model.MeteorologicalId=row["MeteorologicalId"].ToString();
|
|
}
|
|
if(row["MeteorologicalNumber"]!=null)
|
|
{
|
|
model.MeteorologicalNumber=row["MeteorologicalNumber"].ToString();
|
|
}
|
|
if(row["MeteorologicalName"]!=null)
|
|
{
|
|
model.MeteorologicalName=row["MeteorologicalName"].ToString();
|
|
}
|
|
if(row["MeteorologicalValue"]!=null && row["MeteorologicalValue"].ToString()!="")
|
|
{
|
|
model.MeteorologicalValue=decimal.Parse(row["MeteorologicalValue"].ToString());
|
|
}
|
|
if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
|
|
{
|
|
model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
|
|
}
|
|
if(row["EntireTime"]!=null && row["EntireTime"].ToString()!="")
|
|
{
|
|
model.EntireTime=DateTime.Parse(row["EntireTime"].ToString());
|
|
}
|
|
if(row["Reserve1"]!=null)
|
|
{
|
|
model.Reserve1=row["Reserve1"].ToString();
|
|
}
|
|
if(row["Reserve2"]!=null)
|
|
{
|
|
model.Reserve2=row["Reserve2"].ToString();
|
|
}
|
|
if(row["Reserve3"]!=null)
|
|
{
|
|
model.Reserve3=row["Reserve3"].ToString();
|
|
}
|
|
if(row["Reserve4"]!=null)
|
|
{
|
|
model.Reserve4=row["Reserve4"].ToString();
|
|
}
|
|
if(row["Reserve5"]!=null)
|
|
{
|
|
model.Reserve5=row["Reserve5"].ToString();
|
|
}
|
|
}
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql=new StringBuilder();
|
|
strSql.Append("select MeteorologicalId,MeteorologicalNumber,MeteorologicalName,MeteorologicalValue,CreateTime,EntireTime,Reserve1,Reserve2,Reserve3,Reserve4,Reserve5 ");
|
|
strSql.Append(" FROM meteorological_station ");
|
|
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 meteorological_station ");
|
|
if(strWhere.Trim()!="")
|
|
{
|
|
strSql.Append(" where "+strWhere);
|
|
}
|
|
object obj = DbHelperSQL.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.MeteorologicalId desc");
|
|
}
|
|
strSql.Append(")AS Row, T.* from meteorological_station 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 = "meteorological_station";
|
|
parameters[1].Value = "MeteorologicalId";
|
|
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
|
|
}
|
|
}
|
|
|