|
@@ -151,10 +151,13 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
{
|
|
|
if (dto.Status == 1)//添加
|
|
|
{
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+
|
|
|
string selectSql = string.Format(@"select * from Res_OfficialActivities where Client='{0}' and Address='{1}' and IsDel='{2}'", dto.Client, dto.Address, 0);
|
|
|
var res_InvitationOfficial = await _sqlSugar.SqlQueryable<Res_OfficialActivities>(selectSql).FirstAsync();//查询是否存在
|
|
|
if (res_InvitationOfficial != null)
|
|
|
{
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
|
|
|
}
|
|
@@ -165,9 +168,39 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
int id = await _sqlSugar.Insertable(_InvitationOfficialActivityData).ExecuteReturnIdentityAsync();
|
|
|
if (id == 0)
|
|
|
{
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+ }
|
|
|
|
|
|
+ //添加到资料库
|
|
|
+ Res_InvitationOfficialActivityData res_InvitationData = new Res_InvitationOfficialActivityData();
|
|
|
+ res_InvitationData.Country = "";
|
|
|
+ res_InvitationData.City = "";
|
|
|
+ res_InvitationData.UnitName = dto.Client;
|
|
|
+ res_InvitationData.Delegation = dto.DiId.ToString();
|
|
|
+ res_InvitationData.Address = dto.Address;
|
|
|
+ res_InvitationData.CreateUserId = dto.CreateUserId;
|
|
|
+ res_InvitationData.Contact = dto.Contact;
|
|
|
+ res_InvitationData.Job = dto.Job;
|
|
|
+ res_InvitationData.Tel = dto.Tel;
|
|
|
+
|
|
|
+ Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
|
|
|
+ (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0 && a.Address == res_InvitationData.Address);
|
|
|
+
|
|
|
+ if (ifNullUp == null)
|
|
|
+ {
|
|
|
+ int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
|
|
|
+ if (DataID != 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!" };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
}
|
|
|
}
|