public static void UpdatePassword(string loginName, string oldpassword, string newpassword) { if (loginName.IsNullOrEmpty()) { throw new MessageException("帐号为空!"); } if (oldpassword.IsNullOrEmpty()) { throw new MessageException("原密码为空!"); } if (newpassword.IsNullOrEmpty()) { throw new MessageException("新密码为空!"); } var old = Security.MD5_Encrypt(oldpassword); var user = Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.LoginName == loginName && o.LoginPwd == old); if (user != null) { user.LoginPwd = Security.MD5_Encrypt(newpassword); Update(user); } else { var supp = SupplierService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.MasterAccount == loginName && o.MasterPwd == old); if (supp != null) { supp.MasterPwd = Security.MD5_Encrypt(newpassword); SupplierService.Update(supp); } else { throw new MessageException("帐号或密码错误!"); } } }
public static object FindPageList(NameValueCollection nvl, out int recordCount) { //var queryUser= CurrentRepository._context.Set<SysUserInfo>(); //var queryData = CurrentRepository._context.Set<SysDataDictionary>(); //var queryRecord = CurrentRepository._context.Set<Receipts>(); var queryUser = BaseService <SysUserInfo> .CurrentRepository.QueryEntity; var queryRecord = CurrentRepository.QueryEntity; var queryData = BaseService <SysDataDictionary> .CurrentRepository.QueryEntity; var query = from x in queryRecord join z in queryData on x.CategoryId equals z.DicSN into tempCate from i in tempCate.DefaultIfEmpty() select new { x.Amount, x.CategoryId, x.Id, x.CreateDT, x.CreateUID, x.Memo, x.Number, x.Pages, x.State, x.Title, CategoryTitle = i.Title, x.Source }; var Category = nvl["CategoryId"]; var CreateId = nvl["CreateId"]; var SupplierId = nvl["SupplierId"]; var State = nvl["State"]; if (!Category.IsNullOrEmpty()) { var cate = int.Parse(Category); query = query.Where(o => o.CategoryId == cate);//这个是要用OperatorUID还是Operator } if (!CreateId.IsNullOrEmpty()) { query = query.Where(o => o.CreateUID == CreateId); } if (!SupplierId.IsNullOrEmpty()) { query = query.Where(o => o.CreateUID == SupplierId); } if (!State.IsNullOrEmpty()) { var sta = short.Parse(State); query = query.Where(o => o.State == sta); } //recordCount = query.Count(); //var sql = query.ToString(); //var list= query.ToPageList(); //return list.Select(x => new recordCount = query.Count(); var list = query.ToPageList(nvl); var userIds = list.Where(o => o.Source == 1).Select(o => o.CreateUID).ToList(); var supplierIds = list.Where(o => o.Source == 2).Select(o => o.CreateUID).ToList(); var users = queryUser.Where(o => userIds.Contains(o.UID)).ToList(); var suppliers = SupplierService.FindList(o => supplierIds.Contains(o.Id)); return(list.Select(x => new { x.Amount, x.CategoryId, x.Id, x.CreateDT, x.CreateUID, x.Memo, x.Number, x.Pages, x.State, x.Title, CreateTitle = CreatorTitle(x.Source, x.CreateUID, suppliers, users), x.CategoryTitle, StateTitle = GetStateTitle(x.State), SourceTitle = x.Source == 1?"本公司":"供应商" })); }
public static OpResult SaveOrUpdate(Supplier obj) { var re = new OpResult(); var classify = SysDataDictService.GetSupplierTypes(); List <SysUserInfo> list = new List <SysUserInfo>(); string desig = GetUser(obj.Designee, list); string stateTitle = obj.MasterState == 1 ? "可用" : "关闭"; obj.CompanyId = CommonService.CompanyId; if (!obj.MasterAccount.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.MasterAccount == obj.MasterAccount && o.BusinessType == 1 && o.CompanyId == obj.CompanyId)) { re.Message = "账号已存在"; } else if (!obj.Title.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.Title == obj.Title && o.BusinessType == 1 && o.CompanyId == obj.CompanyId)) { re.Message = "供应商简称已存在"; } else if (!obj.FullTitle.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.FullTitle == obj.FullTitle && o.BusinessType == 1 && o.CompanyId == obj.CompanyId)) { re.Message = "供应商全称已存在"; } else if (obj.Id.IsNullOrEmpty()) { obj.Id = Logic.CommonRules.GUID; obj.BusinessType = 1; re = SupplierService.Add(obj); #region 写入日志 string msg = "成功新增供应商!"; var module = Pharos.Sys.LogModule.档案管理; if (re.Successed) { string designee = (string.IsNullOrEmpty(obj.Designee) && string.IsNullOrEmpty(desig)) ? "" : ",指派人=" + desig; string phoneNum = string.IsNullOrEmpty(obj.MobilePhone) ? "" : ",手机=" + obj.MobilePhone; string telNum = string.IsNullOrEmpty(obj.Tel) ? "" : ",电话=" + obj.Tel; string email = string.IsNullOrEmpty(obj.Email) ? "" : ",邮箱=" + obj.Email; string address = string.IsNullOrEmpty(obj.Address) ? "" : ",地址=" + obj.Address; msg += "<br />Id=" + obj.Id + ","; msg += "<br />分类=" + GetTitle(classify, obj.ClassifyId) + designee + ",简称=" + obj.Title + ",全称=" + obj.FullTitle + ",联系人=" + obj.Linkman + phoneNum + telNum + email + address + ",账号=" + obj.MasterAccount + ",状态=" + stateTitle + "。"; } else { msg = "新增供应商失败!"; } log.WriteInsert(msg, module); #endregion } else { var supp = SupplierService.FindById(obj.Id); var exc = new List <string>(); if (obj.MasterPwd.IsNullOrEmpty()) { exc.Add("MasterPwd"); } exc.Add("CompanyId"); var isUpdateClassify = obj.ClassifyId != supp.ClassifyId; var isUpdateDesignee = obj.Designee != supp.Designee; var isUpdateLinkman = obj.Linkman != supp.Linkman; var isUpdatePhone = obj.MobilePhone != supp.MobilePhone; var isUpdateTel = obj.Tel != supp.Tel; var isUpdateEmail = obj.Email != supp.Email; var isUpdateAddress = obj.Address != supp.Address; var isUpdateState = obj.MasterState != supp.MasterState; var isUpdatePwd = string.IsNullOrEmpty(obj.MasterPwd) ? false : (obj.MasterPwd != supp.MasterPwd); bool isUpdate = isUpdateClassify || isUpdateDesignee || isUpdateLinkman || isUpdatePhone || isUpdateTel || isUpdateEmail || isUpdateAddress || isUpdatePwd || isUpdateState; obj.ToCopyProperty(supp, exc); re = SupplierService.Update(supp); #region 写入日志 string msg = "成功修改供应商!"; var module = Pharos.Sys.LogModule.档案管理; if (re.Successed) { int n = 0; if (isUpdate) { msg += "<br />Id=" + obj.Id + ",<br />"; if (isUpdateClassify) { var classifyTitle = GetTitle(classify, obj.ClassifyId); msg += "分类=" + classifyTitle; n = n + 1; } if (isUpdateDesignee) { msg += n > 0 ? ",指派人=" + desig : "指派人=" + desig; n = n + 1; } if (isUpdateLinkman) { msg += n > 0 ? ",联系人=" + obj.Linkman : "联系人=" + obj.Linkman; n = n + 1; } if (isUpdatePhone) { msg += n > 0 ? ",手机=" + obj.MobilePhone : "手机=" + obj.MobilePhone; n = n + 1; } if (isUpdateTel) { msg += n > 0 ? ",电话=" + obj.Tel : "电话=" + obj.Tel; n = n + 1; } if (isUpdateEmail) { msg += n > 0 ? ",邮箱=" + obj.Email : "邮箱=" + obj.Email; n = n + 1; } if (isUpdateAddress) { msg += n > 0 ? ",地址=" + obj.Address : "地址=" + obj.Address; n = n + 1; } if (isUpdateState) { msg += n > 0 ? ",状态=" + stateTitle : "状态=" + stateTitle; n = n + 1; } if (isUpdatePwd) { msg += n > 0 ? ",并修改了密码" : "修改了密码"; } msg += "。"; log.WriteUpdate(msg, module); } } else { msg = "修改供应商失败!"; log.WriteUpdate(msg, module); } #endregion } return(re); }
public static OpResult SaveOrUpdate(Supplier obj) { var re = new OpResult(); if (!obj.MasterAccount.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.MasterAccount == obj.MasterAccount && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该账号已存在,请重新填写!"; } else if (!obj.Title.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.Title == obj.Title && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该简称已存在,请重新填写!"; } else if (!obj.FullTitle.IsNullOrEmpty() && SupplierService.IsExist(o => o.Id != obj.Id && o.FullTitle == obj.FullTitle && o.BusinessType == 2 && o.CompanyId == CommonService.CompanyId)) { re.Message = "该全称已存在,请重新填写!"; } else if (obj.Id.IsNullOrEmpty()) { obj.Id = Logic.CommonRules.GUID; obj.BusinessType = 2; obj.CompanyId = CommonService.CompanyId; re = SupplierService.Add(obj); #region 操作日志 try { LogEngine logEngine = new LogEngine(); var logMsg = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj); logEngine.WriteInsert(logMsg, LogModule.批发商); } catch { } #endregion } else { var supp = SupplierService.FindById(obj.Id); Supplier _oInfo = new Supplier(); if (supp != null) { ExtendHelper.CopyProperty <Supplier>(_oInfo, supp); } var exc = new List <string>(); if (obj.MasterPwd.IsNullOrEmpty()) { exc.Add("MasterPwd"); } exc.Add("CompanyId"); obj.BusinessType = supp.BusinessType; obj.ToCopyProperty(supp, exc); re = SupplierService.Update(supp); #region 操作日志 try { LogEngine logEngine = new LogEngine(); var logMsg = LogEngine.CompareModelToLog <Supplier>(LogModule.批发商, obj, _oInfo); logEngine.WriteUpdate(logMsg, LogModule.批发商); } catch { } #endregion } return(re); }