using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using SuperMap.RealEstate.Configuration;
using SuperMap.RealEstate.ServiceModel;
using SuperMap.RealEstate.ServiceModel.Logging;
using SuperMap.RealEstate.HighWay.SellData.Model;
using SuperMap.RealEstate.HighWay.SellData.Interface;
namespace SuperMap.RealEstate.HighWay.SellData
{
///
/// 服务类 T_SELLDATA 部分
///
partial class Service:IService
{
#region SELLDATA_Insert 插入数据
///
/// 插入数据
///
/// SELLDATA类
/// 日志信息
/// SELLDATA类
public SELLDATA SELLDATA_Insert(SELLDATA sELLDATA, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_SELLDATA)))
{
System.Int32 _SELLDATA_ID=0;
using (DbCommand _DbCommand = DataBaseHelper.CreateCommand(
_SQLStringHelper.GetInsertSQL(sELLDATA, DataBaseHelper.IsOracleClientFactory)))
{
Dictionary _Parameters = _SQLStringHelper.Parameters;
if (DataBaseHelper.IsOracleClientFactory)
{
if (sELLDATA.SELLDATA_ID == null)
_SELLDATA_ID= DataBaseHelper.ExecuteScalar("select "+ TableSchema_SELLDATA.SequenceName +".nextval from dual");
else
_SELLDATA_ID = sELLDATA.SELLDATA_ID.Value;
if (_Parameters.ContainsKey(TableSchema_SELLDATA.SELLDATA_ID.ToLower()))
_Parameters[TableSchema_SELLDATA.SELLDATA_ID.ToLower()]=_SELLDATA_ID;
else
_Parameters.Add(TableSchema_SELLDATA.SELLDATA_ID.ToLower(),_SELLDATA_ID);
}
DataBaseHelper.PrepareCommandParameters(_DbCommand, _Parameters);
_DbCommand.ExecuteNonQuery();
if (DataBaseHelper.IsAccessClientFactory)
{
if (sELLDATA.SELLDATA_ID == null)
_SELLDATA_ID = DataBaseHelper.ExecuteScalar("select @@IDENTITY");
else
_SELLDATA_ID = sELLDATA.SELLDATA_ID.Value;
}
if (DataBaseHelper.IsSqlClientFactory)
{
if (sELLDATA.SELLDATA_ID == null)
_SELLDATA_ID = DataBaseHelper.ExecuteScalar("select IDENT_CURRENT('"+ TableSchema_SELLDATA.TableName +"');");
else
_SELLDATA_ID = sELLDATA.SELLDATA_ID.Value;
}
if (_DbCommand.Transaction == null)
_DbCommand.Connection.Close();
}
sELLDATA.SELLDATA_ID = _SELLDATA_ID;
LoggingDataForInsert(sELLDATA, loggingInfo);
}
return sELLDATA;
}
#endregion
#region SELLDATA_Update 更新数据
///
/// 更新数据
///
/// SELLDATA类
/// 日志信息
/// SELLDATA类
public bool SELLDATA_Update(SELLDATA sELLDATA, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_SELLDATA)))
{
string _SQLStr = _SQLStringHelper.GetUpDateSQL(sELLDATA, DataBaseHelper.IsOracleClientFactory);
if (string.IsNullOrEmpty(_SQLStr)) return true;
if (!LoggingDataForUpdate(sELLDATA, loggingInfo))
return true;
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper.Remove(sELLDATA.SELLDATA_ID.ToString());
Dictionary _Parameters = _SQLStringHelper.Parameters;
return (DataBaseHelper.ExecuteNonQuery(_SQLStr, _Parameters) == 1);
}
}
#endregion
#region SELLDATA_Delete 删除数据
///
/// 删除数据
///
/// 主键字段
/// 日志信息
public void SELLDATA_Delete(System.Int32 sELLDATA_ID, ServiceLoggingInfo loggingInfo)
{
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper.Remove(sELLDATA_ID.ToString());
using (SQLStringHelper _SQLStringHelper =
new SQLStringHelper(typeof(TableSchema_SELLDATA)))
{
string _SQLStr = _SQLStringHelper.GetDeleteSQL(sELLDATA_ID,DataBaseHelper.IsOracleClientFactory);
LoggingDataForDelete(sELLDATA_ID, loggingInfo);
DataBaseHelper.ExecuteNonQuery(_SQLStr, _SQLStringHelper.Parameters);
}
}
#endregion
#region SELLDATA_Search 查询数据
///
/// 查询数据
///
/// 参数集合
/// 日志信息
/// SELLDATA类
public SELLDATA SELLDATA_Search(List parameters, ServiceLoggingInfo loggingInfo)
{
SELLDATA _SELLDATA = null;
if (parameters.Count == 0)
return _SELLDATA;
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (parameters.Count == 1) &&
(parameters[0].Name.Equals(TableSchema_SELLDATA.SELLDATA_ID,System.StringComparison.CurrentCultureIgnoreCase)) &&
ServiceCacheHelper.Read(parameters[0].Value.ToString(),out _SELLDATA))
{
return _SELLDATA;
}
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_SELLDATA)))
{
string _SQLStr = _SQLStringHelper.GetSelectSQL(parameters,
DataBaseHelper.IsOracleClientFactory);
DataSet _DataSet = DataBaseHelper.ExecuteDataSet(_SQLStr, _SQLStringHelper.Parameters);
if ((_DataSet.Tables.Count>0) && (_DataSet.Tables[0].Rows.Count > 0))
{
_SELLDATA = new SELLDATA();
_SQLStringHelper.DataRowToObject(ref _SELLDATA, _DataSet.Tables[0].Rows[0]);
}
}
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (_SELLDATA != null))
{
ServiceCacheHelper.Insert( _SELLDATA.SELLDATA_ID.ToString(),_SELLDATA);
}
return _SELLDATA;
}
#endregion
}
}