2025-03-27 15:05:14 +08:00

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