1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using QM.KJGH.CGGL.IRepository;
- using QM.KJGH.CGGL.Model.Cggl;
- using QM.KJGH.Model.KJGH;
- using QM.OrmSqlSugar;
- using System;
- using System.Threading.Tasks;
- using WS;
- namespace QM.KJGH.CGGL.Repository
- {
-
-
-
- public class CgzjZjbzflRepository : SqlSugarRepository<CgzjZjbzfl>, ICgzjZjbzflRepository
- {
-
-
-
-
- public async Task<bool> Add(CgzjZjbzfl input)
- {
- if (string.IsNullOrWhiteSpace(input.BSM))
- {
- var chk = await GetAsync(t => t.FLMC == input.FLMC && t.ZJFA_BSM == input.ZJFA_BSM && t.FBSM == input.FBSM);
- if(chk != null)
- throw new UseMassageException(input.FLMC + " 已经在,请重新输入");
- input.BSM = DateTime.Now.ToTimeStamp();
- await InsertAsync(input);
- }
- else
- {
- var chk = await GetAsync(t => t.FLMC == input.FLMC && t.ZJFA_BSM == input.ZJFA_BSM && t.FBSM == input.FBSM && t.BSM != input.BSM);
- if (chk != null)
- throw new UseMassageException(input.FLMC + " 已经在,请重新输入");
- await UpdateAsync(input);
- }
- return true;
- }
-
-
-
-
- public async Task<bool> Update(CgglScflDto input)
- {
- var model = await GetAsync(t => t.BSM == input.BSM);
- if (model == null)
- throw new UseArgumentException("参数错误");
- model.FLMC = input.FLMC;
- return await UpdateAsync(model);
- }
-
-
-
-
- public async Task<bool> Delete(CgglScflDto input)
- {
- var db = DbClient();
- try
- {
- db.BeginTran();
-
- await db.Deleteable<CgzjZjbzfl>(t => t.BSM == input.BSM || t.FBSM == input.BSM).ExecuteCommandAsync();
- await db.Deleteable<CgzjZjbz>(t => t.FLBSM == input.BSM).ExecuteCommandAsync();
- db.CommitTran();
- return true;
- }
- catch (Exception ex)
- {
- db.RollbackTran();
- WS.Log.RunLog.Error(ex);
- throw new UseArgumentException("服务器错误");
- }
- }
- }
- }
|