Ejemplo n.º 1
0
        /// <summary>
        /// 类型,1-公告,2-订单新审批,3-供应商新订单
        /// </summary>
        /// <param name="type"></param>
        /// <param name="UID"></param>
        /// <param name="ids">mainIds</param>
        public static void Add(short type, string UID, List <int> ids)
        {
            if (type == 3)
            {
                if (!SupplierService.IsExist(o => o.Id == UID))
                {
                    throw new Pharos.Logic.ApiData.Mobile.Exceptions.MessageException("供应商编号不存在!");
                }
            }
            var list = BaseService <Reader> .FindList(o => o.Type == type && ids.Contains(o.MainId));

            var readers = new List <Reader>();

            ids.ForEach(id =>
            {
                if (!list.Any(i => i.MainId == id && i.ReadCode == UID))
                {
                    readers.Add(new Reader()
                    {
                        MainId = id, ReadCode = UID, Type = type
                    });
                }
            });
            if (readers.Any())
            {
                BaseService <Reader> .AddRange(readers);
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        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);
        }