| | |
| | | using Castle.Core.Resource; |
| | | using MES.Service.DB; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Modes; |
| | | using SqlSugar; |
| | |
| | | if (UpdateSupplierStatus(db, entity.Id, "B")) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | if (InsertSupplier(db, entity)) |
| | | return 1; |
| | | break; |
| | | case "3": |
| | | if (DeleteSupplier(entity.Id)) |
| | | return 1; |
| | | break; |
| | | case "2": |
| | | case "4": |
| | | if (InsertOrUpdate(db, entity)) |
| | | return 1; |
| | |
| | | SuppNo = supplier.FNumber, |
| | | SuppSname = supplier.FShortName, |
| | | SuppName = supplier.FName, |
| | | Lxr = supplier.FContact, |
| | | Telf1 = supplier.FTel, |
| | | Lxr = supplier.FTContact, |
| | | Telf1 = supplier.Fmobilephone, |
| | | Fstaffid = supplier.FStaffId, |
| | | Fforbidstatus = supplier.FForbidStatus, |
| | | type = supplier.Type, |
| | | Remarks = supplier.FDescription, |
| | | Type = supplier.Type, |
| | | FSubsidiary = supplier.FUseOrgId, |
| | | Fumbrella = supplier.FCreateOrgId, |
| | | CreateDate = DateTime.Now, |
| | |
| | | List<MesSupplier> supplierList) |
| | | { |
| | | var ids = supplierList.Select(it => it.Id).ToArray(); |
| | | var deleteByIds = db.Deleteable<MesSupplier>().In(ids).ExecuteCommand(); |
| | | var deleteByIds = db.Deleteable<MesSupplier>() |
| | | .Where(s => ids.Contains(s.Id)).ExecuteCommand(); |
| | | if (deleteByIds > 0) |
| | | return true; |
| | | |
| | |
| | | |
| | | private bool InsertOrUpdate(SqlSugarScope db, MesSupplier entity) |
| | | { |
| | | var exists = db.Queryable<MesSupplier>().Any(e => e.Id == entity.Id); |
| | | if (exists) |
| | | { |
| | | var update = db.Updateable(entity).ExecuteCommand(); |
| | | if (update > 0) |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | } |
| | | db.Deleteable<MesSupplier>().Where(s => s.Id == entity.Id) |
| | | .ExecuteCommand(); |
| | | |
| | | var insert = db.Insertable(entity).ExecuteCommand(); |
| | | if (insert > 0) |
| | | return true; |
| | | |
| | | return false; |
| | | } |
| | |
| | | private bool InsertOrUpdateBatch(SqlSugarScope db, |
| | | List<MesSupplier> supplierList) |
| | | { |
| | | foreach (var entity in supplierList) |
| | | if (!InsertOrUpdate(db, entity)) |
| | | return false; |
| | | |
| | | return true; |
| | | return supplierList.All(entity => InsertOrUpdate(db, entity)); |
| | | } |
| | | } |