コード例 #1
0
        public ActionResult Edit(string CustomerID)
        {
            var model = new CustomerEditViewModel();

            if (!string.IsNullOrWhiteSpace(CustomerID))
            {
                model.CustomerModel = _customerService.GetCustomerById(CustomerID).ToModel <CustomerListModel>();
                model.CustomerModel.AccountPassWord = "";
                model.CustomerStatus = GetCustomerStatusList();
                GetCustomerTypeList()
                .ForEach(
                    p =>
                    model.CustomerTypeList.Add(new SelectListItem()
                {
                    Text     = p.SelectName,
                    Value    = p.SelectValue,
                    Selected = (model.CustomerModel.CustomerTypeID.HasValue && p.SelectValue == model.CustomerModel.CustomerTypeID.Value.ToString())
                }));
                GetPaymentTypeList().ForEach(p => model.PaymentTypeList.Add(new SelectListItem()
                {
                    Text     = p.SelectName,
                    Value    = p.SelectValue,
                    Selected = (model.CustomerModel.PaymentTypeID.HasValue && p.SelectValue == model.CustomerModel.PaymentTypeID.Value.ToString())
                }));

                //业务经理
                GetListCustomerManagerInfo().ForEach(p => model.CustomerManagerList.Add(new SelectListItem
                {
                    Text     = p.SelectName,
                    Value    = p.SelectValue,
                    Selected = (!string.IsNullOrEmpty(model.CustomerModel.CustomerManager) && p.SelectValue == model.CustomerModel.CustomerManager)
                }));



                //显示客户来源平台信息
                var getModel = _customerSourceInfoRepository.First(a => a.CustomerCode == model.CustomerModel.CustomerCode);
                model.SourcePlatform = getModel == null? "普通客户": Customer.GetCustomerSourceTypeDescription(getModel.SourceType);


                model.ReturnUrl = Request.Form["returnUrl"] ?? Url.Action("List", "Customer");
            }
            return(View(model));
        }
コード例 #2
0
        public JsonResult EditCustomer(CustomerEditViewModel model)
        {
            var result = new ResponseResult();

            if (model != null && model.CustomerModel != null)
            {
                try
                {
                    //#region 操作日志
                    ////yungchu
                    ////敏感字-密码,登录帐号

                    //StringBuilder  sb=new StringBuilder();
                    //sb.Append("");
                    //Customer getCustomer=  _customerService.GetCustomerById(model.CustomerModel.CustomerID.ToString());

                    //if (getCustomer.Name!=model.CustomerModel.Name)
                    //{
                    //	sb.AppendFormat(" 名称从{0}更改为{1}", getCustomer.Name, model.CustomerModel.Name);
                    //}
                    //if (getCustomer.AccountID != model.CustomerModel.AccountID)
                    //{
                    //	sb.AppendFormat(" 登陆账号从{0}更改为{1}", getCustomer.AccountID, model.CustomerModel.AccountID);
                    //}


                    //BizLog bizlog = new BizLog()
                    //{
                    //	Summary =sb.ToString()!=""? "[客户编辑]"+sb:"客户编辑",
                    //	KeywordType = KeywordType.CustomerCode,
                    //	Keyword = model.CustomerModel.CustomerCode,
                    //	UserCode = _workContext.User.UserUame,
                    //	UserRealName = _workContext.User.UserUame,
                    //	UserType = UserType.LMS_User,
                    //	SystemCode = SystemType.LMS,
                    //	ModuleName = "客户编辑"
                    //};

                    //_operateLogServices.WriteLog(bizlog, model);
                    //#endregion

                    if (!string.IsNullOrWhiteSpace(model.CustomerModel.AccountID))
                    {
                        model.CustomerModel.AccountID = model.CustomerModel.AccountID.Trim();
                    }
                    if (!string.IsNullOrWhiteSpace(model.CustomerModel.AccountPassWord))
                    {
                        model.CustomerModel.AccountPassWord = model.CustomerModel.AccountPassWord.Trim();
                    }

                    _customerService.UpdateCustomer(model.CustomerModel.ToEntity <Customer>());
                    //更新客户名称到lis客户表 yungchu
                    if (model.CustomerModel.Status != 1)
                    {
                        UpdateCustomerInfoToLis(model.CustomerModel.CustomerCode);
                    }

                    result.Result  = true;
                    result.Message = "Success";
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                    result.Result  = false;
                    result.Message = ex.Message;
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }