2025-03-28 09:49:56 +08:00

152 lines
7.2 KiB
C#

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