StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_Apoplexy_FollowUp...

71 lines
2.3 KiB
C#

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HL_FristAidPlatform_DataBase
{
public class T_Service_Apoplexy_FollowUpInfoDB : BaseDB, IT_Service_Apoplexy_FollowUpInfo
{
public SqlSugarClient db = GetClient();
public T_Service_Apoplexy_FollowUpInfo Add(T_Service_Apoplexy_FollowUpInfo model)
{
return db.Insertable(model).ExecuteReturnEntity();
}
public T_Service_Apoplexy_FollowUpInfo GetByFGuid(string FGuid)
{
return db.Queryable<T_Service_Apoplexy_FollowUpInfo>().First(it => it.FGUID == FGuid);
}
public int Update(T_Service_Apoplexy_FollowUpInfo model)
{
//不更新ID列
return db.Updateable(model).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
}
public bool UpdateOrInsertFPlan(T_Service_Apoplexy_FollowUpBase model1, T_Service_Apoplexy_FollowUpInfo model2)
{
try
{
db.Ado.BeginTran();
if (SqlFunc.IsNullOrEmpty(model1.GUID))
{
model1.GUID = Guid.NewGuid().ToString();
db.Insertable(model1).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
}
else
{
db.Updateable(model1).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
}
if (SqlFunc.IsNullOrEmpty(model2.GUID))
{
model2.GUID = Guid.NewGuid().ToString();
model2.FGUID = model1.PatientGuid;
db.Insertable(model2).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
}
else
{
db.Updateable(model2).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
}
db.Ado.CommitTran();
return true;
}
catch (Exception)
{
db.Ado.RollbackTran();
return false;
throw;
}
}
}
}