InvitationOfficialActivitiesRepository.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. using AutoMapper;
  2. using MathNet.Numerics.Statistics.Mcmc;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.Domain;
  5. using OASystem.Domain.Dtos.Groups;
  6. using OASystem.Domain.Entities.Financial;
  7. using OASystem.Domain.Entities.Groups;
  8. using OASystem.Domain.Entities.Resource;
  9. using OASystem.Domain.ViewModels.Groups;
  10. using OASystem.Domain.ViewModels.QiYeWeChat;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Security.Cryptography;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace OASystem.Infrastructure.Repositories.Groups
  18. {
  19. public class InvitationOfficialActivitiesRepository : BaseRepository<Grp_InvitationOfficialActivities, InvitationOfficialActivitiesListDto>
  20. {
  21. private readonly IMapper _mapper;
  22. public InvitationOfficialActivitiesRepository(SqlSugarClient sqlSugar, IMapper mapper) :
  23. base(sqlSugar)
  24. {
  25. this._mapper = mapper;
  26. }
  27. /// <summary>
  28. /// 根据商邀费用Id查询C表和商邀资料及费用表
  29. /// </summary>
  30. /// <param name="dto"></param>
  31. /// <returns></returns>
  32. public async Task<Result> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  33. {
  34. Result result = new Result() { Code = -2, Msg = "程序错误" };
  35. try
  36. {
  37. Grp_InvitationOfficialActivities grp_Invitation = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().First(a => a.Id == dto.Id && a.IsDel == 0);
  38. Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable==81);
  39. Res_InvitationOfficialActivityData res_InvitationOfficialActivityData = new Res_InvitationOfficialActivityData();
  40. if (grp_Invitation!=null)
  41. {
  42. res_InvitationOfficialActivityData = _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().First(a =>a.Country==grp_Invitation.InviterArea && a.UnitName==grp_Invitation.Inviter && a.IsDel == 0);
  43. if (dto.PortType == 1)
  44. {
  45. var data = new
  46. {
  47. _Invitation = grp_Invitation,
  48. _InvitationData = res_InvitationOfficialActivityData,
  49. _CreditCard = grp_CreditCard,
  50. };
  51. result = new Result() { Code = 0, Msg = "查询成功!", Data = data };
  52. }
  53. else
  54. {
  55. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  56. res_InvitationOfficialActivityData ??= new Res_InvitationOfficialActivityData();
  57. invitation.ConsumptionPatterns = grp_CreditCard.ConsumptionPatterns;
  58. invitation.ConsumptionDate = grp_CreditCard.ConsumptionDate;
  59. invitation.PayDId = grp_CreditCard.PayDId;
  60. invitation.OrbitalPrivateTransfer = grp_CreditCard.OrbitalPrivateTransfer;
  61. invitation.Payee = grp_CreditCard.Payee;
  62. invitation.Address = res_InvitationOfficialActivityData.Address;
  63. invitation.Contact = res_InvitationOfficialActivityData.Contact;
  64. invitation.Job = res_InvitationOfficialActivityData.Job;
  65. invitation.Tel = res_InvitationOfficialActivityData.Tel;
  66. invitation.Email = res_InvitationOfficialActivityData.Email;
  67. invitation.Fax = res_InvitationOfficialActivityData.Fax;
  68. invitation.OtherInformation = res_InvitationOfficialActivityData.Remark;
  69. result = new Result() { Code = 0, Msg = "查询成功!", Data = invitation };
  70. }
  71. }
  72. else
  73. {
  74. if (dto.PortType == 1)
  75. {
  76. var data = new
  77. {
  78. _Invitation = grp_Invitation,
  79. _InvitationData = res_InvitationOfficialActivityData,
  80. _CreditCard = grp_CreditCard,
  81. };
  82. result = new Result() { Code = 0, Msg = "暂无数据!", Data = data };
  83. }
  84. else
  85. {
  86. InvitationOfficialActivitiesByIdView invitation = _mapper.Map<InvitationOfficialActivitiesByIdView>(grp_Invitation);
  87. result = new Result() { Code = 0, Msg = "暂无数据!", Data = invitation };
  88. }
  89. }
  90. }
  91. catch (Exception)
  92. {
  93. result = new Result() { Code = -2, Msg = "程序错误" };
  94. throw;
  95. }
  96. return result;
  97. }
  98. /// <summary>
  99. /// 根据团组id查询商邀费用数据
  100. /// </summary>
  101. /// <param name="dto"></param>
  102. /// <returns></returns>
  103. public async Task<Result> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  104. {
  105. Result result = new Result() { Code = -2, Msg = "未知错误" };
  106. try
  107. {
  108. ListViewBase<InvitationOfficialActivitiesView> rst = new ListViewBase<InvitationOfficialActivitiesView>() { ReceiveDt=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") };
  109. string sqlWhere = string.Empty;
  110. if (!string.IsNullOrWhiteSpace(dto.Inviter))
  111. {
  112. sqlWhere += string.Format(@" And Inviter like '%{0}%'", dto.Inviter);
  113. }
  114. if (!string.IsNullOrWhiteSpace(dto.StartInviteTime) && !string.IsNullOrWhiteSpace(dto.EndInviteTime))
  115. {
  116. sqlWhere += string.Format(@" And i.InviteTime between '{0}' and '{1}'", dto.StartInviteTime, dto.EndInviteTime);
  117. }
  118. sqlWhere += string.Format(@" And i.DiId={0} And i.IsDel={1}", dto.DiId, 0);
  119. string UserId = "";
  120. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 81).ToList();
  121. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  122. UserId += gta.UId + ",";
  123. if (!string.IsNullOrWhiteSpace(UserId))
  124. {
  125. UserId = UserId.Substring(0, UserId.Length - 1);
  126. }
  127. else
  128. {
  129. UserId = "0";
  130. }
  131. sqlWhere += string.Format(@" And i.CreateUserId in ({0})", UserId);
  132. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  133. {
  134. Regex r = new Regex("And");
  135. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  136. }
  137. //10011
  138. string sql = string.Format(@"Select Id,DiId,InviterArea,Inviter,InviteTime,
  139. InviteCost,(Select Name From Sys_SetData Where id=i.InviteCurrency And IsDel=0) As InviteCurrency,
  140. SendCost,(Select Name From Sys_SetData Where id=i.SendCurrency And IsDel=0) As SendCurrency,
  141. EventsCost,(Select Name From Sys_SetData Where id=i.EventsCurrency And IsDel=0) As EventsCurrency,
  142. TranslateCost,(Select Name From Sys_SetData Where id=i.TranslateCurrency And IsDel=0) As TranslateCurrency,
  143. IsGoOfficaiaBussiness,
  144. (Select PayMoney From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As PayMoney,
  145. (Select (Select Name From Sys_SetData Where Id =ccp.PaymentCurrency And IsDel=0 ) As PaymentCurrency
  146. From Grp_CreditCardPayment ccp Where CTable=81 And CId=i.Id And IsDel=0) As PaymentCurrency,
  147. (Select IsAuditGM From Grp_CreditCardPayment Where CTable=81 And CId=i.Id And IsDel=0) As IsAudit,
  148. Attachment From Grp_InvitationOfficialActivities i {0} Order By i.id Desc", sqlWhere);
  149. List<InvitationOfficialActivitiesView> _DecreasePayments = await _sqlSugar.SqlQueryable<InvitationOfficialActivitiesView>(sql).ToListAsync();
  150. if (_DecreasePayments.Count != 0)
  151. {
  152. if (dto.PageIndex != 0 && dto.PageSize != 0)
  153. {
  154. int count = _DecreasePayments.Count;
  155. float totalPage = (float)count / dto.PageSize;//总页数
  156. if (totalPage == 0) totalPage = 1;
  157. else totalPage = (int)Math.Ceiling((double)totalPage);
  158. List<InvitationOfficialActivitiesView> invitationOfficialActivities = new List<InvitationOfficialActivitiesView>();
  159. for (int i = 0; i < dto.PageSize; i++)
  160. {
  161. var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
  162. if (RowIndex < _DecreasePayments.Count)
  163. {
  164. invitationOfficialActivities.Add(_DecreasePayments[RowIndex]);
  165. }
  166. else
  167. {
  168. break;
  169. }
  170. }
  171. rst.DataList = invitationOfficialActivities;
  172. rst.DataCount = count;
  173. rst.CurrPageIndex = dto.PageIndex;
  174. rst.CurrPageSize = dto.PageSize;
  175. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  176. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  177. }
  178. else
  179. {
  180. return result = new Result() { Code = 0, Msg = "查询成功!", Data = _DecreasePayments };
  181. }
  182. }
  183. else
  184. {
  185. if (dto.PageIndex != 0 && dto.PageSize != 0)
  186. {
  187. rst.DataList = _DecreasePayments;
  188. rst.DataCount = _DecreasePayments.Count;
  189. rst.CurrPageIndex = dto.PageIndex;
  190. rst.CurrPageSize = dto.PageSize;
  191. rst.ReturnDt = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  192. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = rst };
  193. }
  194. else
  195. {
  196. return result = new Result() { Code = 0, Msg = "暂无数据!", Data = _DecreasePayments };
  197. }
  198. }
  199. }
  200. catch (Exception ex)
  201. {
  202. return result = new Result() { Code = -2, Msg = "未知错误" };
  203. }
  204. }
  205. /// <summary>
  206. /// Info Page Basic Data
  207. /// </summary>
  208. /// <returns></returns>
  209. public async Task<Result> _InitBasicData()
  210. {
  211. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  212. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
  213. //支付方式
  214. var _payTypeDatas = setDatas.Where(it => it.STid == 14).Select(it => new { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  215. ///转账标识
  216. var _costIdentificationDatas = new List<dynamic>()
  217. {
  218. new { Id = 0,Name = "公转" },
  219. new { Id = 1,Name = "私转" }
  220. };
  221. //卡类型
  222. var _cardTypeDatas = setDatas.Where(it => it.STid == 15).Select(it => new SetDataCurrencyInfoView { Id = it.Id, Name = it.Name, Remark = it.Remark }).ToList();
  223. var data = new {
  224. PayTypeData = _payTypeDatas,
  225. CostIdentificationData = _costIdentificationDatas,
  226. CardTypeData = _cardTypeDatas
  227. };
  228. result.Code = 0;
  229. result.Data = data;
  230. return result;
  231. }
  232. /// <summary>
  233. /// 商邀费用操作(Status:1.新增,2.修改)
  234. /// </summary>
  235. /// <param name="dto"></param>
  236. /// <returns></returns>
  237. public async Task<Result> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto, Func<int, int, int, Task<Result>> fn)
  238. {
  239. Result result = new Result() { Code = -2, Msg = "程序错误!" };
  240. BeginTran();
  241. try
  242. {
  243. int id = 0;
  244. Grp_InvitationOfficialActivities grp_Invitation = _mapper.Map<Grp_InvitationOfficialActivities>(dto);
  245. if (dto.Status == 1)//添加
  246. {
  247. string selectSql = string.Format(@"select * from Grp_InvitationOfficialActivities where InviterArea='{0}' and Inviter='{1}' and DiId={2} and IsDel={3}"
  248. , dto.InviterArea, dto.Inviter, dto.DiId, 0);
  249. var _InvitationOfficialActivities = await _sqlSugar.SqlQueryable<Grp_InvitationOfficialActivities>(selectSql).FirstAsync();//查询是否存在
  250. if (_InvitationOfficialActivities != null)
  251. {
  252. return result = new Result() { Code = -1, Msg = "该数据已存在,请勿重复添加!" };
  253. }
  254. else
  255. {
  256. id = await AddAsyncReturnId(grp_Invitation);
  257. if (id != 0)//修改或添加商邀资料
  258. {
  259. Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
  260. res_InvitationData.Country = dto.InviterArea;
  261. res_InvitationData.UnitName = dto.Inviter;
  262. res_InvitationData.Delegation = dto.DiId.ToString();
  263. Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  264. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  265. if (ifNullUp == null)///添加或修改商邀资料
  266. {
  267. res_InvitationData.Remark = dto.OtherInformation;
  268. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  269. if (DataID != 0)
  270. {
  271. result = new Result() { Code = 0, Msg = "添加成功!" };
  272. }
  273. else
  274. {
  275. RollbackTran();
  276. result = new Result() { Code = -1, Msg = "添加失败!" };
  277. }
  278. }
  279. else
  280. {
  281. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>().Where(a => a.Id == ifNullUp.Id).SetColumns(a => new Res_InvitationOfficialActivityData
  282. {
  283. Contact = dto.Contact,
  284. Tel = dto.Tel,
  285. Email = dto.Email,
  286. Fax = dto.Fax,
  287. Address = dto.Address,
  288. Remark = dto.OtherInformation,
  289. }).ExecuteCommandAsync();
  290. }
  291. Grp_CreditCardPayment C = new Grp_CreditCardPayment();
  292. C.PayDId = dto.PayDId;
  293. C.ConsumptionPatterns = dto.ConsumptionPatterns;
  294. C.ConsumptionDate = dto.ConsumptionDate;
  295. C.CTDId = dto.CTDId;
  296. C.BankNo = dto.BankNo;
  297. C.CardholderName = dto.CardholderName;
  298. C.PayMoney = dto.PayMoney;
  299. C.PaymentCurrency = dto.PaymentCurrency;
  300. C.CompanyBankNo = dto.CompanyBankNo;
  301. C.OtherBankName = dto.OtherBankName;
  302. C.OtherSideNo = dto.OtherSideNo;
  303. C.OtherSideName = dto.OtherSideName;
  304. C.Remark = "";
  305. C.CreateUserId = dto.CreateUserId;
  306. C.MFOperator = 0;
  307. C.MFOperatorDate = "";
  308. C.IsAuditDM = 0;
  309. C.AuditDMOperate = 0;
  310. C.AuditDMDate = "";
  311. C.IsAuditMF = 0;
  312. C.AuditMFOperate = 0;
  313. C.AuditMFDate = "";
  314. C.IsAuditGM = 0;
  315. C.AuditGMOperate = 0;
  316. C.AuditGMDate = "";
  317. C.IsPay = 0;
  318. C.DIId = dto.DiId;
  319. C.CId = id;
  320. C.CTable = 81;
  321. C.PayPercentage = 100;
  322. C.PayThenMoney = 0;
  323. C.PayPercentageOld = 0;
  324. C.PayThenMoneyOld = 0;
  325. C.UpdateDate = "";
  326. C.Payee = dto.Payee;
  327. C.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  328. C.ExceedBudget = 0;
  329. //获取新汇率 int diId,int CId, int currencyId
  330. var rate = await fn(dto.DiId, 81, dto.InviteCurrency);
  331. if (rate.Code == 0)
  332. {
  333. var rateInfo = (rate.Data as CurrencyInfo);
  334. if (rateInfo is not null)
  335. {
  336. C.DayRate = rateInfo.Rate;
  337. C.RMBPrice = rateInfo.Rate * C.PayMoney;
  338. }
  339. else
  340. {
  341. C.DayRate = 1;
  342. C.RMBPrice = C.PayMoney;
  343. }
  344. }
  345. int cId = await _sqlSugar.Insertable(C).ExecuteReturnIdentityAsync();
  346. if (cId != 0)
  347. {
  348. result = new Result() { Code = 0, Msg = "添加成功!" };
  349. }
  350. else
  351. {
  352. RollbackTran();
  353. result = new Result() { Code = -1, Msg = "添加失败!" };
  354. }
  355. }
  356. }
  357. }
  358. else//修改
  359. {
  360. var thisTime = new DateTime();
  361. DateTime.TryParse(dto.InviteTime, out thisTime);
  362. bool res = await UpdateAsync(a => a.Id == grp_Invitation.Id, a => new Grp_InvitationOfficialActivities
  363. {
  364. DiId = dto.DiId,
  365. InviterArea = dto.InviterArea,
  366. Inviter = dto.Inviter,
  367. InviteTime = thisTime,
  368. Attachment = dto.Attachment,
  369. InviteCost = dto.InviteCost,
  370. InviteCurrency = dto.InviteCurrency,
  371. SendCost = dto.SendCost,
  372. SendCurrency = dto.SendCurrency,
  373. EventsCost = dto.EventsCost,
  374. EventsCurrency = dto.EventsCurrency,
  375. TranslateCost = dto.TranslateCost,
  376. TranslateCurrency = dto.TranslateCurrency,
  377. IsGoOfficaiaBussiness = dto.IsGoOfficaiaBussiness,
  378. Remark = dto.Remark,
  379. });
  380. if (res)
  381. {
  382. Res_InvitationOfficialActivityData res_InvitationData = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
  383. res_InvitationData.Country = dto.InviterArea;
  384. res_InvitationData.UnitName = dto.Inviter;
  385. Res_InvitationOfficialActivityData ifNullUp = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>().FirstAsync
  386. (a => a.Country == res_InvitationData.Country && a.City == res_InvitationData.City && a.UnitName == res_InvitationData.UnitName && a.IsDel == 0);
  387. if (ifNullUp == null)///添加或修改商邀资料
  388. {
  389. res_InvitationData.Remark = dto.OtherInformation;
  390. res_InvitationData.Delegation = dto.DiId.ToString();
  391. int DataID = await _sqlSugar.Insertable(res_InvitationData).ExecuteReturnIdentityAsync();
  392. if (DataID != 0)
  393. {
  394. result = new Result() { Code = 0, Msg = "添加成功!" };
  395. }
  396. else
  397. {
  398. RollbackTran();
  399. result = new Result() { Code = -1, Msg = "添加失败!" };
  400. }
  401. }
  402. else
  403. {
  404. int CTable = await _sqlSugar.Updateable<Res_InvitationOfficialActivityData>()
  405. .Where(a => a.Id == ifNullUp.Id)
  406. .SetColumns(a => new Res_InvitationOfficialActivityData
  407. {
  408. Contact = dto.Contact,
  409. Tel = dto.Tel,
  410. Email = dto.Email,
  411. Fax = dto.Fax,
  412. Address = dto.Address,
  413. Remark = dto.OtherInformation,
  414. }).ExecuteCommandAsync();
  415. }
  416. Grp_CreditCardPayment grp_CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == grp_Invitation.Id && a.CTable == 81 && a.IsDel == 0);
  417. if (grp_CreditCardPayment != null)
  418. {
  419. grp_CreditCardPayment.PayMoney = dto.PayMoney;
  420. grp_CreditCardPayment.PaymentCurrency = dto.PaymentCurrency;
  421. grp_CreditCardPayment.Payee = dto.Payee;
  422. grp_CreditCardPayment.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  423. //获取新汇率 int diId,int CId, int currencyId
  424. var rate = await fn(dto.DiId, 81, dto.InviteCurrency);
  425. grp_CreditCardPayment.DayRate = 1;
  426. grp_CreditCardPayment.RMBPrice = grp_CreditCardPayment.PayMoney;
  427. if (rate.Code == 0)
  428. {
  429. var rateInfo = (rate.Data as CurrencyInfo);
  430. if (rateInfo is not null)
  431. {
  432. grp_CreditCardPayment.DayRate = rateInfo.Rate;
  433. grp_CreditCardPayment.RMBPrice = rateInfo.Rate * grp_CreditCardPayment.PayMoney;
  434. }
  435. }
  436. int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  437. .Where(a => a.Id == grp_CreditCardPayment.Id)
  438. .SetColumns(a => new Grp_CreditCardPayment
  439. {
  440. ConsumptionPatterns = dto.ConsumptionPatterns,
  441. ConsumptionDate = dto.ConsumptionDate,
  442. CTDId = dto.CTDId,
  443. BankNo = dto.BankNo,
  444. CardholderName = dto.CardholderName,
  445. CompanyBankNo = dto.CompanyBankNo,
  446. OtherBankName = dto.OtherBankName,
  447. OtherSideNo = dto.OtherSideNo,
  448. OtherSideName = dto.OtherSideName,
  449. PayMoney = grp_CreditCardPayment.PayMoney,
  450. PaymentCurrency = grp_CreditCardPayment.PaymentCurrency,
  451. Payee = grp_CreditCardPayment.Payee,
  452. OrbitalPrivateTransfer = grp_CreditCardPayment.OrbitalPrivateTransfer,
  453. DayRate = grp_CreditCardPayment.DayRate,
  454. RMBPrice = grp_CreditCardPayment.RMBPrice,
  455. }).ExecuteCommandAsync();
  456. if (CTable != 0)
  457. {
  458. result = new Result() { Code = 0, Msg = "修改成功!" };
  459. }
  460. else
  461. {
  462. result = new Result() { Code = -1, Msg = "修改失败!" };
  463. RollbackTran();
  464. }
  465. }
  466. else
  467. {
  468. RollbackTran();
  469. result = new Result() { Code = -1, Msg = "修改失败!" };
  470. }
  471. }
  472. else
  473. {
  474. RollbackTran();
  475. result = new Result() { Code = -1, Msg = "修改失败!" };
  476. }
  477. }
  478. CommitTran();
  479. }
  480. catch (Exception ex)
  481. {
  482. result = new Result() { Code = -2, Msg = "程序错误!" };
  483. throw;
  484. }
  485. return result;
  486. }
  487. }
  488. }