/**  版本信息模板在安装目录下，可自行修改。
* energy_data.cs
*
* 功 能： N/A
* 类 名： energy_data
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2023/2/26 19:05:08   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>
	/// 数据访问类:energy_data
	/// </summary>
	public partial class energy_data
	{
		public energy_data()
		{}
		#region  BasicMethod

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string energy_id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from energy_data");
			strSql.Append(" where energy_id=@energy_id ");
			MySqlParameter[] parameters = {
					new MySqlParameter("@energy_id", MySqlDbType.VarChar,50)			};
			parameters[0].Value = energy_id;

			return DbHelperMySQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(DataService.Model.energy_data model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into energy_data(");
			strSql.Append("energy_id,device_id,supply_water_temperature,return_water_temperature,instantaneous_delivery,sampling_value,cumulative_traffic,positive_total_flow,negative_total_flow,instant_heat,revised_version_number,lang,table_address,meter_communication_speed,modified_caliber,flow_unit,flow_integration_unit,zero_sample_value,meter_factor,heat_coefficient,supply_water_temperature_coefficient,return_temperature_coefficient,small_signal_cut_off_point,modify_pulse_unit,allow_cutout_display,ReverseOutputAllows,current_output_type,pulse_output_mode,frequency_output_range,empty_traffic_alarm_allowed,empty_traffic_alarm_threshold,high_limit_alarm_allows,upper_alarm_value,lower_limit_alarm_allowed,lower_limit_alarm_value,excitation_alarm_allows,sensor_coefficient,empty_pipe_sampling_value,alarm_information,current_zero_correction,current_full_scale_correction,meter_range_setting,measure_damping_time,flow_direction_option,cumulative_heat,cumulative_cooling_capacity,input_date,create_time,r1,r2,r3)");
			strSql.Append(" values (");
			strSql.Append("@energy_id,@device_id,@supply_water_temperature,@return_water_temperature,@instantaneous_delivery,@sampling_value,@cumulative_traffic,@positive_total_flow,@negative_total_flow,@instant_heat,@revised_version_number,@lang,@table_address,@meter_communication_speed,@modified_caliber,@flow_unit,@flow_integration_unit,@zero_sample_value,@meter_factor,@heat_coefficient,@supply_water_temperature_coefficient,@return_temperature_coefficient,@small_signal_cut_off_point,@modify_pulse_unit,@allow_cutout_display,@ReverseOutputAllows,@current_output_type,@pulse_output_mode,@frequency_output_range,@empty_traffic_alarm_allowed,@empty_traffic_alarm_threshold,@high_limit_alarm_allows,@upper_alarm_value,@lower_limit_alarm_allowed,@lower_limit_alarm_value,@excitation_alarm_allows,@sensor_coefficient,@empty_pipe_sampling_value,@alarm_information,@current_zero_correction,@current_full_scale_correction,@meter_range_setting,@measure_damping_time,@flow_direction_option,@cumulative_heat,@cumulative_cooling_capacity,@input_date,@create_time,@r1,@r2,@r3)");
			MySqlParameter[] parameters = {
					new MySqlParameter("@energy_id", MySqlDbType.VarChar,50),
					new MySqlParameter("@device_id", MySqlDbType.VarChar,50),
					new MySqlParameter("@supply_water_temperature", MySqlDbType.Decimal,10),
					new MySqlParameter("@return_water_temperature", MySqlDbType.Decimal,10),
					new MySqlParameter("@instantaneous_delivery", MySqlDbType.Decimal,10),
					new MySqlParameter("@sampling_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@cumulative_traffic", MySqlDbType.Decimal,10),
					new MySqlParameter("@positive_total_flow", MySqlDbType.Decimal,10),
					new MySqlParameter("@negative_total_flow", MySqlDbType.Decimal,10),
					new MySqlParameter("@instant_heat", MySqlDbType.Decimal,10),
					new MySqlParameter("@revised_version_number", MySqlDbType.VarChar,255),
					new MySqlParameter("@lang", MySqlDbType.VarChar,255),
					new MySqlParameter("@table_address", MySqlDbType.VarChar,255),
					new MySqlParameter("@meter_communication_speed", MySqlDbType.Int32),
					new MySqlParameter("@modified_caliber", MySqlDbType.Decimal,10),
					new MySqlParameter("@flow_unit", MySqlDbType.VarChar,255),
					new MySqlParameter("@flow_integration_unit", MySqlDbType.VarChar,255),
					new MySqlParameter("@zero_sample_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@meter_factor", MySqlDbType.Decimal,10),
					new MySqlParameter("@heat_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@supply_water_temperature_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@return_temperature_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@small_signal_cut_off_point", MySqlDbType.Decimal,10),
					new MySqlParameter("@modify_pulse_unit", MySqlDbType.Decimal,10),
					new MySqlParameter("@allow_cutout_display", MySqlDbType.VarChar,255),
					new MySqlParameter("@ReverseOutputAllows", MySqlDbType.VarChar,255),
					new MySqlParameter("@current_output_type", MySqlDbType.VarChar,255),
					new MySqlParameter("@pulse_output_mode", MySqlDbType.VarChar,255),
					new MySqlParameter("@frequency_output_range", MySqlDbType.VarChar,255),
					new MySqlParameter("@empty_traffic_alarm_allowed", MySqlDbType.VarChar,255),
					new MySqlParameter("@empty_traffic_alarm_threshold", MySqlDbType.Decimal,10),
					new MySqlParameter("@high_limit_alarm_allows", MySqlDbType.VarChar,255),
					new MySqlParameter("@upper_alarm_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@lower_limit_alarm_allowed", MySqlDbType.VarChar,255),
					new MySqlParameter("@lower_limit_alarm_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@excitation_alarm_allows", MySqlDbType.VarChar,255),
					new MySqlParameter("@sensor_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@empty_pipe_sampling_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@alarm_information", MySqlDbType.VarChar,255),
					new MySqlParameter("@current_zero_correction", MySqlDbType.Decimal,10),
					new MySqlParameter("@current_full_scale_correction", MySqlDbType.Decimal,10),
					new MySqlParameter("@meter_range_setting", MySqlDbType.VarChar,255),
					new MySqlParameter("@measure_damping_time", MySqlDbType.VarChar,255),
					new MySqlParameter("@flow_direction_option", MySqlDbType.VarChar,255),
					new MySqlParameter("@cumulative_heat", MySqlDbType.Decimal,10),
					new MySqlParameter("@cumulative_cooling_capacity", MySqlDbType.Decimal,10),
					new MySqlParameter("@input_date", MySqlDbType.DateTime),
					new MySqlParameter("@create_time", MySqlDbType.DateTime),
					new MySqlParameter("@r1", MySqlDbType.VarChar,255),
					new MySqlParameter("@r2", MySqlDbType.VarChar,255),
					new MySqlParameter("@r3", MySqlDbType.VarChar,255)};
			parameters[0].Value = model.energy_id;
			parameters[1].Value = model.device_id;
			parameters[2].Value = model.supply_water_temperature;
			parameters[3].Value = model.return_water_temperature;
			parameters[4].Value = model.instantaneous_delivery;
			parameters[5].Value = model.sampling_value;
			parameters[6].Value = model.cumulative_traffic;
			parameters[7].Value = model.positive_total_flow;
			parameters[8].Value = model.negative_total_flow;
			parameters[9].Value = model.instant_heat;
			parameters[10].Value = model.revised_version_number;
			parameters[11].Value = model.lang;
			parameters[12].Value = model.table_address;
			parameters[13].Value = model.meter_communication_speed;
			parameters[14].Value = model.modified_caliber;
			parameters[15].Value = model.flow_unit;
			parameters[16].Value = model.flow_integration_unit;
			parameters[17].Value = model.zero_sample_value;
			parameters[18].Value = model.meter_factor;
			parameters[19].Value = model.heat_coefficient;
			parameters[20].Value = model.supply_water_temperature_coefficient;
			parameters[21].Value = model.return_temperature_coefficient;
			parameters[22].Value = model.small_signal_cut_off_point;
			parameters[23].Value = model.modify_pulse_unit;
			parameters[24].Value = model.allow_cutout_display;
			parameters[25].Value = model.ReverseOutputAllows;
			parameters[26].Value = model.current_output_type;
			parameters[27].Value = model.pulse_output_mode;
			parameters[28].Value = model.frequency_output_range;
			parameters[29].Value = model.empty_traffic_alarm_allowed;
			parameters[30].Value = model.empty_traffic_alarm_threshold;
			parameters[31].Value = model.high_limit_alarm_allows;
			parameters[32].Value = model.upper_alarm_value;
			parameters[33].Value = model.lower_limit_alarm_allowed;
			parameters[34].Value = model.lower_limit_alarm_value;
			parameters[35].Value = model.excitation_alarm_allows;
			parameters[36].Value = model.sensor_coefficient;
			parameters[37].Value = model.empty_pipe_sampling_value;
			parameters[38].Value = model.alarm_information;
			parameters[39].Value = model.current_zero_correction;
			parameters[40].Value = model.current_full_scale_correction;
			parameters[41].Value = model.meter_range_setting;
			parameters[42].Value = model.measure_damping_time;
			parameters[43].Value = model.flow_direction_option;
			parameters[44].Value = model.cumulative_heat;
			parameters[45].Value = model.cumulative_cooling_capacity;
			parameters[46].Value = model.input_date;
			parameters[47].Value = model.create_time;
			parameters[48].Value = model.r1;
			parameters[49].Value = model.r2;
			parameters[50].Value = model.r3;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(DataService.Model.energy_data model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update energy_data set ");
			strSql.Append("device_id=@device_id,");
			strSql.Append("supply_water_temperature=@supply_water_temperature,");
			strSql.Append("return_water_temperature=@return_water_temperature,");
			strSql.Append("instantaneous_delivery=@instantaneous_delivery,");
			strSql.Append("sampling_value=@sampling_value,");
			strSql.Append("cumulative_traffic=@cumulative_traffic,");
			strSql.Append("positive_total_flow=@positive_total_flow,");
			strSql.Append("negative_total_flow=@negative_total_flow,");
			strSql.Append("instant_heat=@instant_heat,");
			strSql.Append("revised_version_number=@revised_version_number,");
			strSql.Append("lang=@lang,");
			strSql.Append("table_address=@table_address,");
			strSql.Append("meter_communication_speed=@meter_communication_speed,");
			strSql.Append("modified_caliber=@modified_caliber,");
			strSql.Append("flow_unit=@flow_unit,");
			strSql.Append("flow_integration_unit=@flow_integration_unit,");
			strSql.Append("zero_sample_value=@zero_sample_value,");
			strSql.Append("meter_factor=@meter_factor,");
			strSql.Append("heat_coefficient=@heat_coefficient,");
			strSql.Append("supply_water_temperature_coefficient=@supply_water_temperature_coefficient,");
			strSql.Append("return_temperature_coefficient=@return_temperature_coefficient,");
			strSql.Append("small_signal_cut_off_point=@small_signal_cut_off_point,");
			strSql.Append("modify_pulse_unit=@modify_pulse_unit,");
			strSql.Append("allow_cutout_display=@allow_cutout_display,");
			strSql.Append("ReverseOutputAllows=@ReverseOutputAllows,");
			strSql.Append("current_output_type=@current_output_type,");
			strSql.Append("pulse_output_mode=@pulse_output_mode,");
			strSql.Append("frequency_output_range=@frequency_output_range,");
			strSql.Append("empty_traffic_alarm_allowed=@empty_traffic_alarm_allowed,");
			strSql.Append("empty_traffic_alarm_threshold=@empty_traffic_alarm_threshold,");
			strSql.Append("high_limit_alarm_allows=@high_limit_alarm_allows,");
			strSql.Append("upper_alarm_value=@upper_alarm_value,");
			strSql.Append("lower_limit_alarm_allowed=@lower_limit_alarm_allowed,");
			strSql.Append("lower_limit_alarm_value=@lower_limit_alarm_value,");
			strSql.Append("excitation_alarm_allows=@excitation_alarm_allows,");
			strSql.Append("sensor_coefficient=@sensor_coefficient,");
			strSql.Append("empty_pipe_sampling_value=@empty_pipe_sampling_value,");
			strSql.Append("alarm_information=@alarm_information,");
			strSql.Append("current_zero_correction=@current_zero_correction,");
			strSql.Append("current_full_scale_correction=@current_full_scale_correction,");
			strSql.Append("meter_range_setting=@meter_range_setting,");
			strSql.Append("measure_damping_time=@measure_damping_time,");
			strSql.Append("flow_direction_option=@flow_direction_option,");
			strSql.Append("cumulative_heat=@cumulative_heat,");
			strSql.Append("cumulative_cooling_capacity=@cumulative_cooling_capacity,");
			strSql.Append("input_date=@input_date,");
			strSql.Append("create_time=@create_time,");
			strSql.Append("r1=@r1,");
			strSql.Append("r2=@r2,");
			strSql.Append("r3=@r3");
			strSql.Append(" where energy_id=@energy_id ");
			MySqlParameter[] parameters = {
					new MySqlParameter("@device_id", MySqlDbType.VarChar,50),
					new MySqlParameter("@supply_water_temperature", MySqlDbType.Decimal,10),
					new MySqlParameter("@return_water_temperature", MySqlDbType.Decimal,10),
					new MySqlParameter("@instantaneous_delivery", MySqlDbType.Decimal,10),
					new MySqlParameter("@sampling_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@cumulative_traffic", MySqlDbType.Decimal,10),
					new MySqlParameter("@positive_total_flow", MySqlDbType.Decimal,10),
					new MySqlParameter("@negative_total_flow", MySqlDbType.Decimal,10),
					new MySqlParameter("@instant_heat", MySqlDbType.Decimal,10),
					new MySqlParameter("@revised_version_number", MySqlDbType.VarChar,255),
					new MySqlParameter("@lang", MySqlDbType.VarChar,255),
					new MySqlParameter("@table_address", MySqlDbType.VarChar,255),
					new MySqlParameter("@meter_communication_speed", MySqlDbType.Int32),
					new MySqlParameter("@modified_caliber", MySqlDbType.Decimal,10),
					new MySqlParameter("@flow_unit", MySqlDbType.VarChar,255),
					new MySqlParameter("@flow_integration_unit", MySqlDbType.VarChar,255),
					new MySqlParameter("@zero_sample_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@meter_factor", MySqlDbType.Decimal,10),
					new MySqlParameter("@heat_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@supply_water_temperature_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@return_temperature_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@small_signal_cut_off_point", MySqlDbType.Decimal,10),
					new MySqlParameter("@modify_pulse_unit", MySqlDbType.Decimal,10),
					new MySqlParameter("@allow_cutout_display", MySqlDbType.VarChar,255),
					new MySqlParameter("@ReverseOutputAllows", MySqlDbType.VarChar,255),
					new MySqlParameter("@current_output_type", MySqlDbType.VarChar,255),
					new MySqlParameter("@pulse_output_mode", MySqlDbType.VarChar,255),
					new MySqlParameter("@frequency_output_range", MySqlDbType.VarChar,255),
					new MySqlParameter("@empty_traffic_alarm_allowed", MySqlDbType.VarChar,255),
					new MySqlParameter("@empty_traffic_alarm_threshold", MySqlDbType.Decimal,10),
					new MySqlParameter("@high_limit_alarm_allows", MySqlDbType.VarChar,255),
					new MySqlParameter("@upper_alarm_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@lower_limit_alarm_allowed", MySqlDbType.VarChar,255),
					new MySqlParameter("@lower_limit_alarm_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@excitation_alarm_allows", MySqlDbType.VarChar,255),
					new MySqlParameter("@sensor_coefficient", MySqlDbType.Decimal,10),
					new MySqlParameter("@empty_pipe_sampling_value", MySqlDbType.Decimal,10),
					new MySqlParameter("@alarm_information", MySqlDbType.VarChar,255),
					new MySqlParameter("@current_zero_correction", MySqlDbType.Decimal,10),
					new MySqlParameter("@current_full_scale_correction", MySqlDbType.Decimal,10),
					new MySqlParameter("@meter_range_setting", MySqlDbType.VarChar,255),
					new MySqlParameter("@measure_damping_time", MySqlDbType.VarChar,255),
					new MySqlParameter("@flow_direction_option", MySqlDbType.VarChar,255),
					new MySqlParameter("@cumulative_heat", MySqlDbType.Decimal,10),
					new MySqlParameter("@cumulative_cooling_capacity", MySqlDbType.Decimal,10),
					new MySqlParameter("@input_date", MySqlDbType.DateTime),
					new MySqlParameter("@create_time", MySqlDbType.DateTime),
					new MySqlParameter("@r1", MySqlDbType.VarChar,255),
					new MySqlParameter("@r2", MySqlDbType.VarChar,255),
					new MySqlParameter("@r3", MySqlDbType.VarChar,255),
					new MySqlParameter("@energy_id", MySqlDbType.VarChar,50)};
			parameters[0].Value = model.device_id;
			parameters[1].Value = model.supply_water_temperature;
			parameters[2].Value = model.return_water_temperature;
			parameters[3].Value = model.instantaneous_delivery;
			parameters[4].Value = model.sampling_value;
			parameters[5].Value = model.cumulative_traffic;
			parameters[6].Value = model.positive_total_flow;
			parameters[7].Value = model.negative_total_flow;
			parameters[8].Value = model.instant_heat;
			parameters[9].Value = model.revised_version_number;
			parameters[10].Value = model.lang;
			parameters[11].Value = model.table_address;
			parameters[12].Value = model.meter_communication_speed;
			parameters[13].Value = model.modified_caliber;
			parameters[14].Value = model.flow_unit;
			parameters[15].Value = model.flow_integration_unit;
			parameters[16].Value = model.zero_sample_value;
			parameters[17].Value = model.meter_factor;
			parameters[18].Value = model.heat_coefficient;
			parameters[19].Value = model.supply_water_temperature_coefficient;
			parameters[20].Value = model.return_temperature_coefficient;
			parameters[21].Value = model.small_signal_cut_off_point;
			parameters[22].Value = model.modify_pulse_unit;
			parameters[23].Value = model.allow_cutout_display;
			parameters[24].Value = model.ReverseOutputAllows;
			parameters[25].Value = model.current_output_type;
			parameters[26].Value = model.pulse_output_mode;
			parameters[27].Value = model.frequency_output_range;
			parameters[28].Value = model.empty_traffic_alarm_allowed;
			parameters[29].Value = model.empty_traffic_alarm_threshold;
			parameters[30].Value = model.high_limit_alarm_allows;
			parameters[31].Value = model.upper_alarm_value;
			parameters[32].Value = model.lower_limit_alarm_allowed;
			parameters[33].Value = model.lower_limit_alarm_value;
			parameters[34].Value = model.excitation_alarm_allows;
			parameters[35].Value = model.sensor_coefficient;
			parameters[36].Value = model.empty_pipe_sampling_value;
			parameters[37].Value = model.alarm_information;
			parameters[38].Value = model.current_zero_correction;
			parameters[39].Value = model.current_full_scale_correction;
			parameters[40].Value = model.meter_range_setting;
			parameters[41].Value = model.measure_damping_time;
			parameters[42].Value = model.flow_direction_option;
			parameters[43].Value = model.cumulative_heat;
			parameters[44].Value = model.cumulative_cooling_capacity;
			parameters[45].Value = model.input_date;
			parameters[46].Value = model.create_time;
			parameters[47].Value = model.r1;
			parameters[48].Value = model.r2;
			parameters[49].Value = model.r3;
			parameters[50].Value = model.energy_id;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string energy_id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from energy_data ");
			strSql.Append(" where energy_id=@energy_id ");
			MySqlParameter[] parameters = {
					new MySqlParameter("@energy_id", MySqlDbType.VarChar,50)			};
			parameters[0].Value = energy_id;

			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string energy_idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from energy_data ");
			strSql.Append(" where energy_id in ("+energy_idlist + ")  ");
			int rows=DbHelperMySQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public DataService.Model.energy_data GetModel(string energy_id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select energy_id,device_id,supply_water_temperature,return_water_temperature,instantaneous_delivery,sampling_value,cumulative_traffic,positive_total_flow,negative_total_flow,instant_heat,revised_version_number,lang,table_address,meter_communication_speed,modified_caliber,flow_unit,flow_integration_unit,zero_sample_value,meter_factor,heat_coefficient,supply_water_temperature_coefficient,return_temperature_coefficient,small_signal_cut_off_point,modify_pulse_unit,allow_cutout_display,ReverseOutputAllows,current_output_type,pulse_output_mode,frequency_output_range,empty_traffic_alarm_allowed,empty_traffic_alarm_threshold,high_limit_alarm_allows,upper_alarm_value,lower_limit_alarm_allowed,lower_limit_alarm_value,excitation_alarm_allows,sensor_coefficient,empty_pipe_sampling_value,alarm_information,current_zero_correction,current_full_scale_correction,meter_range_setting,measure_damping_time,flow_direction_option,cumulative_heat,cumulative_cooling_capacity,input_date,create_time,r1,r2,r3 from energy_data ");
			strSql.Append(" where energy_id=@energy_id ");
			MySqlParameter[] parameters = {
					new MySqlParameter("@energy_id", MySqlDbType.VarChar,50)			};
			parameters[0].Value = energy_id;

			DataService.Model.energy_data model=new DataService.Model.energy_data();
			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.energy_data DataRowToModel(DataRow row)
		{
			DataService.Model.energy_data model=new DataService.Model.energy_data();
			if (row != null)
			{
				if(row["energy_id"]!=null)
				{
					model.energy_id=row["energy_id"].ToString();
				}
				if(row["device_id"]!=null)
				{
					model.device_id=row["device_id"].ToString();
				}
				if(row["supply_water_temperature"]!=null && row["supply_water_temperature"].ToString()!="")
				{
					model.supply_water_temperature=decimal.Parse(row["supply_water_temperature"].ToString());
				}
				if(row["return_water_temperature"]!=null && row["return_water_temperature"].ToString()!="")
				{
					model.return_water_temperature=decimal.Parse(row["return_water_temperature"].ToString());
				}
				if(row["instantaneous_delivery"]!=null && row["instantaneous_delivery"].ToString()!="")
				{
					model.instantaneous_delivery=decimal.Parse(row["instantaneous_delivery"].ToString());
				}
				if(row["sampling_value"]!=null && row["sampling_value"].ToString()!="")
				{
					model.sampling_value=decimal.Parse(row["sampling_value"].ToString());
				}
				if(row["cumulative_traffic"]!=null && row["cumulative_traffic"].ToString()!="")
				{
					model.cumulative_traffic=decimal.Parse(row["cumulative_traffic"].ToString());
				}
				if(row["positive_total_flow"]!=null && row["positive_total_flow"].ToString()!="")
				{
					model.positive_total_flow=decimal.Parse(row["positive_total_flow"].ToString());
				}
				if(row["negative_total_flow"]!=null && row["negative_total_flow"].ToString()!="")
				{
					model.negative_total_flow=decimal.Parse(row["negative_total_flow"].ToString());
				}
				if(row["instant_heat"]!=null && row["instant_heat"].ToString()!="")
				{
					model.instant_heat=decimal.Parse(row["instant_heat"].ToString());
				}
				if(row["revised_version_number"]!=null)
				{
					model.revised_version_number=row["revised_version_number"].ToString();
				}
				if(row["lang"]!=null)
				{
					model.lang=row["lang"].ToString();
				}
				if(row["table_address"]!=null)
				{
					model.table_address=row["table_address"].ToString();
				}
				if(row["meter_communication_speed"]!=null && row["meter_communication_speed"].ToString()!="")
				{
					model.meter_communication_speed=int.Parse(row["meter_communication_speed"].ToString());
				}
				if(row["modified_caliber"]!=null && row["modified_caliber"].ToString()!="")
				{
					model.modified_caliber=decimal.Parse(row["modified_caliber"].ToString());
				}
				if(row["flow_unit"]!=null)
				{
					model.flow_unit=row["flow_unit"].ToString();
				}
				if(row["flow_integration_unit"]!=null)
				{
					model.flow_integration_unit=row["flow_integration_unit"].ToString();
				}
				if(row["zero_sample_value"]!=null && row["zero_sample_value"].ToString()!="")
				{
					model.zero_sample_value=decimal.Parse(row["zero_sample_value"].ToString());
				}
				if(row["meter_factor"]!=null && row["meter_factor"].ToString()!="")
				{
					model.meter_factor=decimal.Parse(row["meter_factor"].ToString());
				}
				if(row["heat_coefficient"]!=null && row["heat_coefficient"].ToString()!="")
				{
					model.heat_coefficient=decimal.Parse(row["heat_coefficient"].ToString());
				}
				if(row["supply_water_temperature_coefficient"]!=null && row["supply_water_temperature_coefficient"].ToString()!="")
				{
					model.supply_water_temperature_coefficient=decimal.Parse(row["supply_water_temperature_coefficient"].ToString());
				}
				if(row["return_temperature_coefficient"]!=null && row["return_temperature_coefficient"].ToString()!="")
				{
					model.return_temperature_coefficient=decimal.Parse(row["return_temperature_coefficient"].ToString());
				}
				if(row["small_signal_cut_off_point"]!=null && row["small_signal_cut_off_point"].ToString()!="")
				{
					model.small_signal_cut_off_point=decimal.Parse(row["small_signal_cut_off_point"].ToString());
				}
				if(row["modify_pulse_unit"]!=null && row["modify_pulse_unit"].ToString()!="")
				{
					model.modify_pulse_unit=decimal.Parse(row["modify_pulse_unit"].ToString());
				}
				if(row["allow_cutout_display"]!=null)
				{
					model.allow_cutout_display=row["allow_cutout_display"].ToString();
				}
				if(row["ReverseOutputAllows"]!=null)
				{
					model.ReverseOutputAllows=row["ReverseOutputAllows"].ToString();
				}
				if(row["current_output_type"]!=null)
				{
					model.current_output_type=row["current_output_type"].ToString();
				}
				if(row["pulse_output_mode"]!=null)
				{
					model.pulse_output_mode=row["pulse_output_mode"].ToString();
				}
				if(row["frequency_output_range"]!=null)
				{
					model.frequency_output_range=row["frequency_output_range"].ToString();
				}
				if(row["empty_traffic_alarm_allowed"]!=null)
				{
					model.empty_traffic_alarm_allowed=row["empty_traffic_alarm_allowed"].ToString();
				}
				if(row["empty_traffic_alarm_threshold"]!=null && row["empty_traffic_alarm_threshold"].ToString()!="")
				{
					model.empty_traffic_alarm_threshold=decimal.Parse(row["empty_traffic_alarm_threshold"].ToString());
				}
				if(row["high_limit_alarm_allows"]!=null)
				{
					model.high_limit_alarm_allows=row["high_limit_alarm_allows"].ToString();
				}
				if(row["upper_alarm_value"]!=null && row["upper_alarm_value"].ToString()!="")
				{
					model.upper_alarm_value=decimal.Parse(row["upper_alarm_value"].ToString());
				}
				if(row["lower_limit_alarm_allowed"]!=null)
				{
					model.lower_limit_alarm_allowed=row["lower_limit_alarm_allowed"].ToString();
				}
				if(row["lower_limit_alarm_value"]!=null && row["lower_limit_alarm_value"].ToString()!="")
				{
					model.lower_limit_alarm_value=decimal.Parse(row["lower_limit_alarm_value"].ToString());
				}
				if(row["excitation_alarm_allows"]!=null)
				{
					model.excitation_alarm_allows=row["excitation_alarm_allows"].ToString();
				}
				if(row["sensor_coefficient"]!=null && row["sensor_coefficient"].ToString()!="")
				{
					model.sensor_coefficient=decimal.Parse(row["sensor_coefficient"].ToString());
				}
				if(row["empty_pipe_sampling_value"]!=null && row["empty_pipe_sampling_value"].ToString()!="")
				{
					model.empty_pipe_sampling_value=decimal.Parse(row["empty_pipe_sampling_value"].ToString());
				}
				if(row["alarm_information"]!=null)
				{
					model.alarm_information=row["alarm_information"].ToString();
				}
				if(row["current_zero_correction"]!=null && row["current_zero_correction"].ToString()!="")
				{
					model.current_zero_correction=decimal.Parse(row["current_zero_correction"].ToString());
				}
				if(row["current_full_scale_correction"]!=null && row["current_full_scale_correction"].ToString()!="")
				{
					model.current_full_scale_correction=decimal.Parse(row["current_full_scale_correction"].ToString());
				}
				if(row["meter_range_setting"]!=null)
				{
					model.meter_range_setting=row["meter_range_setting"].ToString();
				}
				if(row["measure_damping_time"]!=null)
				{
					model.measure_damping_time=row["measure_damping_time"].ToString();
				}
				if(row["flow_direction_option"]!=null)
				{
					model.flow_direction_option=row["flow_direction_option"].ToString();
				}
				if(row["cumulative_heat"]!=null && row["cumulative_heat"].ToString()!="")
				{
					model.cumulative_heat=decimal.Parse(row["cumulative_heat"].ToString());
				}
				if(row["cumulative_cooling_capacity"]!=null && row["cumulative_cooling_capacity"].ToString()!="")
				{
					model.cumulative_cooling_capacity=decimal.Parse(row["cumulative_cooling_capacity"].ToString());
				}
				if(row["input_date"]!=null && row["input_date"].ToString()!="")
				{
					model.input_date=DateTime.Parse(row["input_date"].ToString());
				}
				if(row["create_time"]!=null && row["create_time"].ToString()!="")
				{
					model.create_time=DateTime.Parse(row["create_time"].ToString());
				}
				if(row["r1"]!=null)
				{
					model.r1=row["r1"].ToString();
				}
				if(row["r2"]!=null)
				{
					model.r2=row["r2"].ToString();
				}
				if(row["r3"]!=null)
				{
					model.r3=row["r3"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select energy_id,device_id,supply_water_temperature,return_water_temperature,instantaneous_delivery,sampling_value,cumulative_traffic,positive_total_flow,negative_total_flow,instant_heat,revised_version_number,lang,table_address,meter_communication_speed,modified_caliber,flow_unit,flow_integration_unit,zero_sample_value,meter_factor,heat_coefficient,supply_water_temperature_coefficient,return_temperature_coefficient,small_signal_cut_off_point,modify_pulse_unit,allow_cutout_display,ReverseOutputAllows,current_output_type,pulse_output_mode,frequency_output_range,empty_traffic_alarm_allowed,empty_traffic_alarm_threshold,high_limit_alarm_allows,upper_alarm_value,lower_limit_alarm_allowed,lower_limit_alarm_value,excitation_alarm_allows,sensor_coefficient,empty_pipe_sampling_value,alarm_information,current_zero_correction,current_full_scale_correction,meter_range_setting,measure_damping_time,flow_direction_option,cumulative_heat,cumulative_cooling_capacity,input_date,create_time,r1,r2,r3 ");
			strSql.Append(" FROM energy_data ");
			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 energy_data ");
			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.energy_id desc");
			}
			strSql.Append(")AS Row, T.*  from energy_data 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 = "energy_data";
			parameters[1].Value = "energy_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
	}
}

