| | |
| | | using SqlSugar; |
| | | |
| | | namespace MES.Service.service.BasicData; |
| | | |
| | | /// <summary> |
| | | /// 部门信息 |
| | | /// </summary> |
| | | public class SysDepartmentManager : Repository<SysDepartment> |
| | | { |
| | | // 当前类已经继承了 Repository 增、删、查、改的方法 |
| | |
| | | { |
| | | var result = db.Updateable<SysDepartment>() |
| | | .SetColumns(s => s.Depextr4 == status) |
| | | .Where(s => s.Id == departmentId).ExecuteCommand(); |
| | | .Where(s => s.Id == departmentId && s.TypeByTable==0).ExecuteCommand(); |
| | | |
| | | if (result > 0) |
| | | return true; |
| | |
| | | private bool DeleteDepartment(SqlSugarScope db, decimal departmentId) |
| | | { |
| | | var deleteById = db.Deleteable<SysDepartment>() |
| | | .Where(s => s.Id == departmentId).ExecuteCommand(); |
| | | .Where(s => s.Id == departmentId && s.TypeByTable==0).ExecuteCommand(); |
| | | if (deleteById > 0) |
| | | return true; |
| | | |
| | |
| | | { |
| | | // 查找是否已存在相同编码的记录。 |
| | | var existingCustomer = Db.Queryable<SysDepartment>() |
| | | .Where(s => s.Departmentcode == department.FNumber) |
| | | .Where(s => s.Departmentcode == department.FNumber && s.TypeByTable==0) |
| | | .First(); |
| | | |
| | | var entity = new SysDepartment |
| | | { |
| | | TypeByTable=0,//用于区分部门表与工作中心信息(0/1) |
| | | // 如果存在,使用现有的ID,后续将删除后重新插入 |
| | | // 如果不存在,设为0,InsertOrUpdate方法将生成新ID |
| | | Id = existingCustomer?.Id ?? 0, |
| | |
| | | Depextr3 = department.FWIPStockID, |
| | | Depextr4 = department.FForbidStatus, |
| | | FParentID = department.FParentID, |
| | | FSubsidiary = department.FUseOrgId, |
| | | Fumbrella = department.FCreateOrgId, |
| | | //FSubsidiary = department.FUseOrgId, |
| | | //Fumbrella = department.FCreateOrgId, |
| | | // 如果存在,使用现有的CreateDate,后续将删除后重新插入 |
| | | // 如果不存在,设为当前时间 |
| | | CreateDate = existingCustomer?.CreateDate ?? DateTime.Now, |
| | |
| | | ? existingCustomer?.Factory |
| | | : department.Factory, |
| | | |
| | | |
| | | FSubsidiary = string.IsNullOrEmpty(department.FUseOrgId) ? "1" : department.FUseOrgId, |
| | | Fumbrella = string.IsNullOrEmpty(department.FCreateOrgId) ? "1" : department.FCreateOrgId, |
| | | }; |
| | | |
| | | // ERP: 0=未禁用, 1=禁用 |