public ActionResult Edit(CustomerCompanyViewModel model)
        {
            ServiceResult result = new ServiceResult();

            TempData["Service_Result"] = result;
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    CustomerCompanyService.Update(model);
                    //标记为已合作客户
                    if (model.CustomerCateID == 5)
                    {
                        var contact = new ContactRequireViewModel()
                        {
                            CompanyID = model.ID,
                            //财务部
                            DepartmentID = 8,
                            Name = model.Name + "财务合同请求",
                            Description = model.Name + "财务合同请求",
                            SenderID = CookieHelper.MemberID,
                            IsRoot = 1
                        };
                        ContactRequireService.Create(contact);
                    }
                    result.Message = "编辑客户成功!";
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = "编辑客户失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "编辑客户失败!", ex);
                }
            }
            ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, model.RelationID, true);
            ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, model.CustomerCateID, true);
            return View(model);
        }
 public ActionResult Edit(int ID)
 {
     var entity = CustomerCompanyService.Find(ID);
     var model = new CustomerCompanyViewModel()
     {
         ID = entity.ID,
         Name = entity.Name,
         Phone = entity.Phone,
         IndustryCode = entity.IndustryValue,
         CustomerCateID = entity.CustomerCateID,
         RelationID = entity.RelationID,
         Fax = entity.Fax,
         Description = entity.Description,
         CityCode = entity.CityValue,
         BrandName = entity.BrandName,
         Address = entity.Address
     };
     ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, model.RelationID, true);
     ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, model.CustomerCateID, true);
     return View(model);
 }
        public ActionResult Create(CustomerCompanyViewModel model)
        {
            ServiceResult result = new ServiceResult();

            TempData["Service_Result"] = result;
            if (!ModelState.IsValid)
            {
                result.Message = "表单输入有误,请仔细填写表单!";
                result.AddServiceError("表单输入有误,请仔细填写表单!");
            }
            else
            {
                try
                {
                    CustomerCompanyService.Create(model);
                    result.Message = "添加客户成功!";
                    return RedirectToAction("index");
                }
                catch (Exception ex)
                {
                    result.Message = "添加客户失败!";
                    result.AddServiceError(Utilities.GetInnerMostException(ex));
                    LogHelper.WriteLog("用户:" + CookieHelper.MemberID + "添加客户失败!", ex);
                }

            }
            ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, true);
            ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, true);
            return View(model);
        }
        public ActionResult Details(int ID)
        {
            var entity = CustomerCompanyService.Find(ID);
            var hasPermission = entity.AddUser == CookieHelper.MemberID
                || CookieHelper.CheckPermission("boss");

            ViewBag.hasPermission = hasPermission;
            var model = new CustomerCompanyViewModel()
            {
                Address = entity.Address,
                BrandName = entity.BrandName,
                CityCode = entity.CityValue,
                CustomerCateID = entity.CustomerCateID,
                Description = entity.Description,
                Fax = entity.Fax,
                IndustryCode = entity.IndustryValue,
                Name = entity.Name,
                RelationID = entity.RelationID,
                Phone = entity.Phone,
                ID = entity.ID,
                MemberID = entity.AddUser
            };
            var cityIds = entity.CityValue.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            var cityValues = CityCateService.GetALL().Where(x => cityIds.Contains(x.ID)).Select(x => x.CateName).ToList();
            ViewBag.Data_CityCode = cityValues;

            var industryIds = entity.IndustryValue.Split(',').Select(x => Convert.ToInt32(x)).ToList();
            var industryValues = IndustryCateService.GetALL().Where(x => industryIds.Contains(x.ID)).Select(x => x.CateName).ToList();
            ViewBag.Data_IndustryCode = industryValues;
            return View(model);
        }
 public ActionResult Create()
 {
     var model = new CustomerCompanyViewModel();
     ViewBag.Data_RelationID = Utilities.GetSelectListData(RelationCateService.GetALL(), x => x.ID, x => x.CateName, true);
     ViewBag.Data_CustomerCateID = Utilities.GetSelectListData(CustomerCateService.GetALL(), x => x.ID, x => x.CateName, true);
     return View(model);
 }