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

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