using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Web; using CP.Cache; using CP.Common; using CP.Model; using System.Data; using NIU.Core; namespace CP.Business { public class AdminUserBll { public static AdminUser GetBy(string userName, string pwd) { pwd = Encryption.MD5(pwd); var dc = new DataConnect(); var model = dc.db.SingleOrDefault($"where userName='{userName}' and pwd='{pwd}'"); return model; } public static void PwdEdit(long id, string oldPwd, string pwd, string cfmPwd) { var dc = new DataConnect(); var entity = dc.db.SingleOrDefault(id); if (entity == null) throw new OperationExceptionFacade("操作失败:数据不存在"); if (pwd.Length < 6) throw new OperationExceptionFacade("操作失败:密码至少由6个字符组成"); if (cfmPwd != pwd) throw new OperationExceptionFacade("操作失败:两次输入的密码不相同"); if (entity.Pwd != Encryption.MD5(oldPwd)) throw new OperationExceptionFacade("操作失败:原密码错误"); entity.Pwd = Encryption.MD5(pwd); if (dc.db.Update(entity) <= 0) throw new OperationExceptionFacade("操作失败"); } } }