using Cksoft.Data; using Cksoft.Unity; using DllEapEntity; using System; using System.Collections.Generic; using System.Linq; namespace DllEapDal { public class StaffDal { private IDatabase CurrDb = null; public StaffDal(IDatabase db) { CurrDb = db; } public Staff Login(Staff staff, ref string errorinfo) { try { if (string.IsNullOrEmpty(staff.FCode)) { errorinfo = "用户名为空"; return null; } if (string.IsNullOrEmpty(staff.Password)) { errorinfo = "密码为空"; return null; } List obj = CurrDb.FindListForCondition($" and a.fcode='{staff.FCode}'", ref errorinfo).ToList(); if (obj == null) { errorinfo = $"用户代码={staff.FCode}不存在,异常错误:"+errorinfo; return null; } if(obj.Count<=0) { errorinfo = $"用户代码={staff.FCode}不存在"; return null; } var pass = new Md5Helper().EnCrypt(staff.Password); if (obj[0].Password != pass) { errorinfo = "用户名或密码不正确"; return null; } return obj[0]; } catch (Exception e) { errorinfo = e.Message; return null; } } } }