using System; using System.Collections.Generic; using System.Linq; using Cksoft.Data; using Cksoft.Data.Repository; using Cksoft.Unity; using DllUfpEntity; using Microsoft.Extensions.Configuration; namespace DllUfpDal { public class StaffManager { public IConfiguration Configuration; private IDatabase EapDb = null; public StaffManager() { } public StaffManager(IDatabase db) { EapDb = db; } public int InsertToEap(Staff staff) { var entity = new DllEapEntity.Staff(); entity.ID = staff.ID.ToString(); entity.FName = staff.FName; entity.FCode = staff.FCode; entity.FStatus = staff.FStatus; entity.modcode = staff.ModCode; entity.modtime = staff.ModTime; entity.Password = staff.Password; entity.reccode = staff.RecCode; entity.rectime = staff.RecTime; entity.Remark = staff.Remark; if (EapDb.InsertFor(entity, string.Empty) < 0) { return -1; } return 1; } public int UpdateToEap(Staff staff) { var entity = new DllEapEntity.Staff(); entity.ID = staff.ID.ToString(); entity.FName = staff.FName; entity.FCode = staff.FCode; entity.FStatus = staff.FStatus; entity.modcode = staff.ModCode; entity.modtime = staff.ModTime; entity.Password = staff.Password; entity.reccode = staff.RecCode; entity.rectime = staff.RecTime; entity.Remark = staff.Remark; if (EapDb.UpdateFor(entity, string.Empty) < 0) { return -1; } return 1; } public int DeleteToEap(string[] ids) { var sql = $"delete from staff where id in ({string.Join(",", ids.Select(c => $"'{c}'"))})"; if (EapDb.ExecuteBySql(sql) < 0) return -1; return 1; } } }