using Yw.DAL.PostgreSql;
|
|
namespace HStation.DAL.PostgreSql
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public partial class AssetsPumpPartMain : BaseDAL_Sorter<Entity.AssetsPumpPartMain>, IAssetsPumpPartMain
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; }
|
}
|
|
//插入拓展
|
public long InsertsEx(Entity.AssetsPumpPartMain part, List<Entity.AssetsPumpPropContent> AssetsPumpPropContents, Entity.AssetsPumpMainAndPartMapping partmap)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Insertable(part).ExecuteReturnSnowflakeId();
|
if (result < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (partmap != null)
|
{
|
partmap.PartID = result;
|
var mainandpartmap = db.Insertable(partmap).ExecuteReturnSnowflakeId();
|
if (mainandpartmap < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsPumpPropContents != null)
|
{
|
foreach (var item in AssetsPumpPropContents)
|
{
|
item.PartID = result;
|
}
|
var content = db.Insertable(AssetsPumpPropContents).ExecuteReturnSnowflakeId();
|
if (content < 0)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
}
|
}
|
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
//编辑拓展
|
public bool UpdateEx(Entity.AssetsPumpPartMain part, List<Entity.AssetsPumpPropContent> AssetsPumpPropContents)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Updateable(part).ExecuteCommandHasChange();
|
if (!result)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsPumpPropContents != null)
|
{
|
var propresult = db.Updateable(AssetsPumpPropContents).ExecuteCommandHasChange();
|
if (!propresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
|
//删除拓展 (删除产品表及属性表)
|
public bool DeleteEx(Entity.AssetsPumpPartMain part, List<Entity.AssetsPumpPropContent> AssetsPumpPropContents)
|
{
|
if (part == null)
|
{
|
return default;
|
}
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
try
|
{
|
db.BeginTran();
|
var result = db.Deleteable(part).ExecuteCommand() > 0;
|
if (!result)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
else
|
{
|
if (AssetsPumpPropContents != null)
|
{
|
var propresult = db.Deleteable(AssetsPumpPropContents).ExecuteCommand() > 0;
|
if (!propresult)
|
{
|
db.RollbackTran();
|
return default;
|
}
|
}
|
}
|
db.CommitTran();
|
return result;
|
}
|
catch (Exception ex)
|
{
|
db.RollbackTran();
|
throw;
|
}
|
}
|
}
|
}
|
}
|