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.BasicArchives.Storage.Model;
using SuperMap.RealEstate.BasicArchives.Storage.Interface;
namespace SuperMap.RealEstate.BasicArchives.Storage
{
///
/// 服务类 T_PROMOTION 部分
///
partial class Service:IService
{
#region PROMOTION_Insert 插入数据
///
/// 插入数据
///
/// PROMOTION类
/// 日志信息
/// PROMOTION类
public PROMOTION PROMOTION_Insert(PROMOTION pROMOTION, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_PROMOTION)))
{
System.Int32 _PROMOTION_ID=0;
using (DbCommand _DbCommand = DataBaseHelper.CreateCommand(
_SQLStringHelper.GetInsertSQL(pROMOTION, DataBaseHelper.IsOracleClientFactory)))
{
Dictionary _Parameters = _SQLStringHelper.Parameters;
if (DataBaseHelper.IsOracleClientFactory)
{
if (pROMOTION.PROMOTION_ID == null)
_PROMOTION_ID= DataBaseHelper.ExecuteScalar("select "+ TableSchema_PROMOTION.SequenceName +".nextval from dual");
else
_PROMOTION_ID = pROMOTION.PROMOTION_ID.Value;
if (_Parameters.ContainsKey(TableSchema_PROMOTION.PROMOTION_ID.ToLower()))
_Parameters[TableSchema_PROMOTION.PROMOTION_ID.ToLower()]=_PROMOTION_ID;
else
_Parameters.Add(TableSchema_PROMOTION.PROMOTION_ID.ToLower(),_PROMOTION_ID);
}
DataBaseHelper.PrepareCommandParameters(_DbCommand, _Parameters);
_DbCommand.ExecuteNonQuery();
if (DataBaseHelper.IsAccessClientFactory)
{
if (pROMOTION.PROMOTION_ID == null)
_PROMOTION_ID = DataBaseHelper.ExecuteScalar("select @@IDENTITY");
else
_PROMOTION_ID = pROMOTION.PROMOTION_ID.Value;
}
if (DataBaseHelper.IsSqlClientFactory)
{
if (pROMOTION.PROMOTION_ID == null)
_PROMOTION_ID = DataBaseHelper.ExecuteScalar("select IDENT_CURRENT('"+ TableSchema_PROMOTION.TableName +"');");
else
_PROMOTION_ID = pROMOTION.PROMOTION_ID.Value;
}
if (_DbCommand.Transaction == null)
_DbCommand.Connection.Close();
}
pROMOTION.PROMOTION_ID = _PROMOTION_ID;
LoggingDataForInsert(pROMOTION, loggingInfo);
}
return pROMOTION;
}
#endregion
#region PROMOTION_Update 更新数据
///
/// 更新数据
///
/// PROMOTION类
/// 日志信息
/// PROMOTION类
public bool PROMOTION_Update(PROMOTION pROMOTION, ServiceLoggingInfo loggingInfo)
{
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_PROMOTION)))
{
string _SQLStr = _SQLStringHelper.GetUpDateSQL(pROMOTION, DataBaseHelper.IsOracleClientFactory);
if (string.IsNullOrEmpty(_SQLStr)) return true;
if (!LoggingDataForUpdate(pROMOTION, loggingInfo))
return true;
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper.Remove(pROMOTION.PROMOTION_ID.ToString());
Dictionary _Parameters = _SQLStringHelper.Parameters;
return (DataBaseHelper.ExecuteNonQuery(_SQLStr, _Parameters) == 1);
}
}
#endregion
#region PROMOTION_Delete 删除数据
///
/// 删除数据
///
/// 主键字段
/// 日志信息
public void PROMOTION_Delete(System.Int32 pROMOTION_ID, ServiceLoggingInfo loggingInfo)
{
if (ConfigurationSetting.HttpRuntimeCache_Enabled == true)
ServiceCacheHelper.Remove(pROMOTION_ID.ToString());
using (SQLStringHelper _SQLStringHelper =
new SQLStringHelper(typeof(TableSchema_PROMOTION)))
{
string _SQLStr = _SQLStringHelper.GetDeleteSQL(pROMOTION_ID,DataBaseHelper.IsOracleClientFactory);
LoggingDataForDelete(pROMOTION_ID, loggingInfo);
DataBaseHelper.ExecuteNonQuery(_SQLStr, _SQLStringHelper.Parameters);
}
}
#endregion
#region PROMOTION_Search 查询数据
///
/// 查询数据
///
/// 参数集合
/// 日志信息
/// PROMOTION类
public PROMOTION PROMOTION_Search(List parameters, ServiceLoggingInfo loggingInfo)
{
PROMOTION _PROMOTION = null;
if (parameters.Count == 0)
return _PROMOTION;
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (parameters.Count == 1) &&
(parameters[0].Name.Equals(TableSchema_PROMOTION.PROMOTION_ID,System.StringComparison.CurrentCultureIgnoreCase)) &&
ServiceCacheHelper.Read(parameters[0].Value.ToString(),out _PROMOTION))
{
return _PROMOTION;
}
using (SQLStringHelper _SQLStringHelper = new SQLStringHelper(typeof(TableSchema_PROMOTION)))
{
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))
{
_PROMOTION = new PROMOTION();
_SQLStringHelper.DataRowToObject(ref _PROMOTION, _DataSet.Tables[0].Rows[0]);
}
}
if ((ConfigurationSetting.HttpRuntimeCache_Enabled == true) && (_PROMOTION != null))
{
ServiceCacheHelper.Insert( _PROMOTION.PROMOTION_ID.ToString(),_PROMOTION);
}
return _PROMOTION;
}
#endregion
}
}