/// <summary>
        /// 设置个性签名
        /// </summary>
        /// <param name="loginName">登录名</param>
        /// <param name="signature">手机号</param>
        /// <returns></returns>
        public static OpResult SetSignature(string loginName, string signature)
        {
            var user = Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.LoginName.Equals(loginName, StringComparison.OrdinalIgnoreCase));

            if (user != null)
            {
                user.Signature = signature;
                var result = Update(user);
                if (!result.Successed)
                {
                    throw new MessageException("保存失败!");
                }
                result.Data = user;
                return(result);
            }
            else
            {
                var supp = SupplierService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.MasterAccount == loginName);
                if (supp != null)
                {
                    supp.Signature = signature;
                    var result = SupplierService.Update(supp);
                    if (!result.Successed)
                    {
                        throw new MessageException("保存失败!");
                    }
                    result.Data = supp;
                    return(result);
                }
            }
            throw new MessageException("登录用户不存在!");
        }
        public static void UpdateHandsignOff(string loginName, string password)
        {
            if (loginName.IsNullOrEmpty())
            {
                throw new MessageException("帐号为空!");
            }
            if (password.IsNullOrEmpty())
            {
                throw new MessageException("手势密码为空!");
            }
            var user = Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.LoginName == loginName && o.Handsign == password);

            if (user != null)
            {
                user.Handsign = "";
                Update(user);
            }
            else
            {
                var supp = SupplierService.Find(o => o.CompanyId == Sys.SysCommonRules.CompanyId && o.MasterAccount == loginName && o.Handsign == password);
                if (supp != null)
                {
                    supp.Handsign = "";
                    SupplierService.Update(supp);
                }
                else
                {
                    throw new MessageException("帐号或密码错误!");
                }
            }
        }
        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("帐号或密码错误!");
                }
            }
        }
Exemple #4
0
        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);
        }