示例#1
0
        public ActionResult SetState(string ids, short state)
        {
            var sId  = ids.Split(',').Select(o => int.Parse(o));
            var list = MembersService.FindList(o => sId.Contains(o.Id));

            #region 操作日志状态记录
            var _oList = new List <Members>();
            foreach (var item in list)
            {
                var _member = new Members();
                ExtendHelper.CopyProperty <Members>(_member, item);
                _oList.Add(_member);
            }
            #endregion

            list.ForEach(o => { o.Status = state; });
            var re = MembersService.Update(list);
            #region 操作日志
            if (re.Successed)
            {
                for (int i = 0; i < list.Count(); i++)
                {
                    var msg = Sys.LogEngine.CompareModelToLog <Members>(Sys.LogModule.会员管理, list[i], _oList[i]);
                    new Sys.LogEngine().WriteUpdate(msg, Sys.LogModule.会员管理);
                }
            }
            #endregion
            return(new JsonNetResult(re));
        }
        /// <summary>
        /// 更改会员卡状态
        /// </summary>
        /// <param name="state"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public OpResult UpdateMemberCardState(short state, string ids)
        {
            try
            {
                var cards = CurrentRepository.Entities.Where(o => o.CompanyId == CommonService.CompanyId && ("," + ids + ",").Contains("," + o.Id + ","));
                //cards.Each(o => o.State = state);
                var message  = new StringBuilder();
                var stateStr = string.Empty;
                switch (state)
                {
                case 1:    //0:未激活;1:正常;2 已挂失;3:已作废;4 已退卡
                    stateStr = "成功激活会员卡【{0}】!";
                    break;

                case 2:    //
                    stateStr = "会员卡【{0}】已挂失!";
                    break;

                case 3:    //
                    stateStr = "会员卡【{0}】已作废!";
                    break;

                case 4:    //
                    stateStr = "会员卡【{0}】已退卡!";
                    break;
                }
                var _msg = new StringBuilder();
                foreach (var item in cards)
                {
                    var o = new MembershipCard();
                    ExtendHelper.CopyProperty <MembershipCard>(o, item);
                    item.State = state;
                    message.Append(string.Format(stateStr, item.CardSN));
                    _msg.Append(Pharos.Sys.LogEngine.CompareModelToLog <MembershipCard>(Sys.LogModule.会员管理, item, o));
                }
                #region 操作日志
                new Pharos.Sys.LogEngine().WriteUpdate(_msg.ToString(), Sys.LogModule.会员管理);
                #endregion
                CurrentRepository.Update(new MembershipCard());
                return(new OpResult()
                {
                    Successed = true, Message = message.ToString()
                });
            }
            catch (Exception e)
            {
                Log.WriteError(e);

                throw;
            }
        }
        public ActionResult Save(ProductCategory obj)
        {
            var re = new OpResult();

            obj.CompanyId = CommonService.CompanyId;
            if (ProductCategoryService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategoryPSN == obj.CategoryPSN && o.Title == obj.Title && o.Id != obj.Id))
            {
                re.Message = "已存在该名称";
            }
            else if (obj.Id == 0)
            {
                if (obj.CategoryPSN > 0 && ProductService.IsExist(o => o.CompanyId == obj.CompanyId && o.CategorySN == obj.CategoryPSN))
                {
                    re.Message = "该分类存在商品,不允许创建!";
                    return(Content(re.ToJson()));
                }
                var max = ProductCategoryService.MaxSn;
                obj.CategorySN   = max;
                obj.Grade        = GetGrade;
                obj.CategoryCode = ProductCategoryService.MaxCode(obj.CategoryPSN);
                re = ProductCategoryService.Add(obj);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, obj);
                new LogEngine().WriteInsert(msg, LogModule.种类管理);
                #endregion
            }
            else
            {
                var supp = ProductCategoryService.FindById(obj.Id);
                obj.ToCopyProperty(supp);
                //supp.Grade = GetGrade;
                var oProCate = new ProductCategory();
                ExtendHelper.CopyProperty <ProductCategory>(oProCate, supp);
                re = ProductCategoryService.Update(supp);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <ProductCategory>(LogModule.种类管理, supp, oProCate);
                new LogEngine().WriteUpdate(msg, LogModule.种类管理);
                #endregion
            }
            if (re.Successed)
            {
                var stores = string.Join(",", WarehouseService.GetList().Select(o => o.StoreId));
                Pharos.Infrastructure.Data.Redis.RedisManager.Publish("SyncDatabase", new Pharos.ObjectModels.DTOs.DatabaseChanged()
                {
                    CompanyId = CommonService.CompanyId, StoreId = stores, Target = "ProductCategory"
                });
            }
            return(Content(re.ToJson()));
        }
        public ActionResult setState_Editor(string id, short state)
        {
            var obj    = ContractBLL.FindById(id);
            var _oData = new Contract();

            ExtendHelper.CopyProperty <Contract>(_oData, obj);
            obj.State = state;
            var re = ContractBLL.Update(obj);

            #region 操作日志
            if (re.Successed)
            {
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _oData);
                new LogEngine().WriteUpdate(msg, LogModule.合同管理);
            }
            #endregion
            return(new JsonNetResult(re));
        }
示例#5
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);
        }
        public ActionResult AddContract(Logic.Entity.Contract obj)
        {
            var re = new OpResult();

            var relativePath = "";
            var files        = new List <Attachment>();
            var path         = Sys.SysConstPool.SaveAttachPath(ref relativePath);

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                if (file.ContentLength <= 0)
                {
                    continue;
                }
                var    filename = CommonRules.GUID + Path.GetExtension(file.FileName);
                string fullname = path + filename;
                file.SaveAs(fullname);
                files.Add(new Attachment()
                {
                    SourceClassify = 1,
                    Title          = Path.GetFileName(file.FileName),
                    Size           = file.ContentLength / 1024,
                    SaveUrl        = relativePath + filename
                });
            }
            var jia      = new Logic.Entity.ContractBoth();
            var yi       = new Logic.Entity.ContractBoth();
            var compname = Request["CompanyName"];

            if (!compname.IsNullOrEmpty())
            {
                var comps = compname.Split(',');
                jia.CompanyName = comps[0];
                yi.CompanyName  = comps[1];
            }
            var representative = Request["Representative"];

            if (!representative.IsNullOrEmpty())
            {
                var repr = representative.Split(',');
                jia.Representative = repr[0];
                yi.Representative  = repr[1];
            }
            var tel = Request["Tel"];

            if (!tel.IsNullOrEmpty())
            {
                var te = tel.Split(',');
                jia.Tel = te[0];
                yi.Tel  = te[1];
            }
            var fax = Request["Fax"];

            if (!fax.IsNullOrEmpty())
            {
                var fa = fax.Split(',');
                jia.Fax = fa[0];
                yi.Fax  = fa[1];
            }
            var taxnumber = Request["TaxNumber"];//甲方是TaxNumber,乙方是PayNumber,除此之外其余的项甲乙方都相同

            if (!taxnumber.IsNullOrEmpty())
            {
                jia.TaxNumber = taxnumber;
            }
            var paynumber = Request["PayNumber"];//乙方是PayNumber

            if (!paynumber.IsNullOrEmpty())
            {
                yi.PayNumber = paynumber;
            }
            var url = Request["Url"];

            if (!url.IsNullOrEmpty())
            {
                var ur = url.Split(',');
                jia.Url = ur[0];
                yi.Url  = ur[1];
            }
            var address = Request["Address"];

            if (!address.IsNullOrEmpty())
            {
                var addr = address.Split(',');
                jia.Address = addr[0];
                yi.Address  = addr[1];
            }
            var postcode = Request["PostCode"];

            if (!postcode.IsNullOrEmpty())
            {
                var pcode = postcode.Split(',');
                jia.PostCode = pcode[0];
                yi.PostCode  = pcode[1];
            }
            var bankname = Request["BankName"];

            if (!bankname.IsNullOrEmpty())
            {
                var bname = bankname.Split(',');
                jia.BankName = bname[0];
                yi.BankName  = bname[1];
            }

            var bankaccount = Request["BankAccount"];

            if (!bankaccount.IsNullOrEmpty())
            {
                var baccount = bankaccount.Split(',');
                jia.BankAccount = baccount[0];
                yi.BankAccount  = baccount[1];
            }
            obj.CompanyId = CommonService.CompanyId;
            if (string.IsNullOrEmpty(obj.Id))
            {
                obj.ContractBoths = new List <Logic.Entity.ContractBoth>();

                obj.Id         = CommonRules.GUID;
                obj.CreateDT   = DateTime.Now;
                obj.CreateUID  = Sys.CurrentUser.UID;
                obj.ContractSN = ContractBLL.CreateContractSN();

                obj.Attachments = files;
                jia.Signatory   = (int)(ContractSignatory.甲方);
                yi.Signatory    = (int)(ContractSignatory.乙方);
                obj.ContractBoths.Add(jia);
                obj.ContractBoths.Add(yi);

                //var existContractSN = ContractBLL.Find(o => o.ContractSN == obj.ContractSN);
                //if (existContractSN != null)
                //{
                //    re.Message = "该合同编号已存在!";
                //}
                //else
                //{
                //    re = ContractBLL.Add(obj);
                //}
                re = ContractBLL.Add(obj);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj);
                new LogEngine().WriteInsert(msg, LogModule.合同管理);
                #endregion
            }
            else
            {
                var contract = ContractBLL.GetObj(obj.Id);
                //var oldContractSN = contract.ContractSN;
                Contract _contract = new Contract();
                ExtendHelper.CopyProperty <Contract>(_contract, contract);
                obj.Version = contract.Version;
                obj.PId     = contract.PId;

                obj.ToCopyProperty(contract);

                contract.Attachments.AddRange(files);

                var detailId = Request["detailId"];
                if (!detailId.IsNullOrEmpty())
                {
                    var detailIds = detailId.Split(',');
                    var jiaId     = int.Parse(detailIds[0]);
                    var yiId      = int.Parse(detailIds[1]);
                    jia.Id        = jiaId;
                    yi.Id         = yiId;
                    jia.Signatory = 1;
                    yi.Signatory  = 2;
                    var jiares = contract.ContractBoths.FirstOrDefault(o => o.Id == jiaId);
                    var yires  = contract.ContractBoths.FirstOrDefault(o => o.Id == yiId);
                    //jia.ContractId = jiares.ContractId;
                    //yi.ContractId = yires.ContractId;
                    jia.ToCopyProperty(jiares);
                    yi.ToCopyProperty(yires);
                }
                //var existContractSN = ContractBLL.FindList(o => o.ContractSN == contract.ContractSN);
                //if (existContractSN.Count > 0 && oldContractSN != obj.ContractSN)
                //{
                //    re.Message = "该合同编号已存在!";
                //}
                //else
                //{
                //    re = ContractBLL.Update(contract);
                //}
                re = ContractBLL.Update(contract);
                #region 操作日志
                var msg = LogEngine.CompareModelToLog <Contract>(LogModule.合同管理, obj, _contract);
                new LogEngine().WriteUpdate(msg, LogModule.合同管理);
                #endregion
            }
            return(Content(re.ToJson()));
        }