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