public CustomerCompany Create(CustomerCompanyViewModel model) { CustomerCompany entity = new CustomerCompany(); entity.Name = model.Name; entity.BrandName = model.BrandName; entity.IndustryID = Utilities.GetCascadingId(model.IndustryValue); entity.IndustryValue = model.IndustryValue; entity.CustomerCateID = model.CustomerCateID; entity.CityID = Utilities.GetCascadingId(model.CityValue); entity.CityValue = model.CityValue; entity.Address = model.Address; entity.AddTime = DateTime.Now; //entity.AddUser = CookieHelper.MemberID; entity.AddUser = 227; entity.Description = model.Description; entity.Fax = model.Fax; entity.LastTime = DateTime.Now; entity.LastUser = 227; entity.Phone = model.Phone; entity.RelationID = model.RelationID; //entity.Finance = model.Finance; //entity.FinancePhone = model.FinancePhone; entity.CoopCateID = model.CoopCateID; entity.SourceCateID = model.SourceCateID; entity.ProxyName = model.ProxyName; entity.ProxyPhone = model.ProxyPhone; entity.ProxyAddress = model.ProxyAddress; entity.RelationID = model.RelationID; db.Add<CustomerCompany>(entity); db.Commit(); return entity; }
public ActionResult Create() { var model = new CustomerCompanyViewModel(); ViewBag.Data_RelationID = Utilities.GetSelectListData( RelationCateService.GetALL(), x => x.ID, x => x.CateName, true, true); ViewBag.Data_CustomerCateID = Utilities.GetSelectListData( CustomerCateService.GetALL(), x => x.ID, x => x.CateName, true); ViewBag.Data_CoopCateID = Utilities.GetSelectListData( CoopCateService.GetALL(), x => x.ID, x => x.CateName, true); ViewBag.Data_SourceCateID = Utilities.GetSelectListData( SourceCateService.GetALL(), x => x.ID, x => x.CateName, true); return PartialView(model); }
public CustomerCompany Update(CustomerCompanyViewModel model) { CustomerCompany entity = Find(model.ID); db.Attach<CustomerCompany>(entity); entity.Name = model.Name; entity.BrandName = model.BrandName; entity.IndustryID = Utilities.GetCascadingId(model.IndustryValue); entity.IndustryValue = model.IndustryValue; entity.CustomerCateID = model.CustomerCateID; entity.CityID = Utilities.GetCascadingId(model.CityValue); entity.CityValue = model.CityValue; entity.Address = model.Address; entity.Description = model.Description; entity.Fax = model.Fax; entity.LastTime = DateTime.Now; entity.LastUser = 227; entity.Phone = model.Phone; entity.RelationID = model.RelationID; entity.CoopCateID = model.CoopCateID; entity.SourceCateID = model.SourceCateID; entity.IsCommon = false; entity.ProxyName = model.ProxyName; entity.ProxyPhone = model.ProxyPhone; entity.ProxyAddress = model.ProxyAddress; //替换从这里开始 if (CookieHelper.MemberID != entity.AddUser) { entity.AddUser = CookieHelper.MemberID; entity.AddTime = DateTime.Now; } db.Commit(); return entity; }
public ActionResult Edit(CustomerCompanyViewModel model) { ServiceResult result = new ServiceResult(); if (ModelState.IsValid) { try { CustomerCompanyService.Update(model); result.Message = "编辑CustomerCompany成功!"; LogHelper.WriteLog("编辑CustomerCompany成功"); } catch (Exception ex) { result.Message = Utilities.GetInnerMostException(ex); result.AddServiceError(result.Message); LogHelper.WriteLog("编辑CustomerCompany错误", ex); } } else { result.Message = "请检查表单是否填写完整!"; result.AddServiceError("请检查表单是否填写完整!"); } return Json(result); }
public ActionResult Edit(int ID) { var entity = CustomerCompanyService.GetALL().Single(x => x.ID == ID); var model = new CustomerCompanyViewModel() { ID = entity.ID, Name = entity.Name, BrandName = entity.BrandName, CityValue = entity.CityValue, IndustryValue = entity.IndustryValue, CustomerCateID = entity.CustomerCateID, CoopCateID = entity.CoopCateID, SourceCateID = entity.SourceCateID, Fax = entity.Fax, Phone = entity.Phone, Address = entity.Address, Description = entity.Description, ProxyName = entity.ProxyName, ProxyAddress = entity.ProxyAddress, ProxyPhone = entity.ProxyPhone, RelationID = entity.RelationID, }; ViewBag.Data_RelationID = Utilities.GetSelectListData( RelationCateService.GetALL(), x => x.ID, x => x.CateName, model.RelationID, true, true); ViewBag.Data_CustomerCateID = Utilities.GetSelectListData( CustomerCateService.GetALL(), x => x.ID, x => x.CateName, model.CustomerCateID, true); ViewBag.Data_CoopCateID = Utilities.GetSelectListData( CoopCateService.GetALL(), x => x.ID, x => x.CateName, model.CoopCateID, true); ViewBag.Data_SourceCateID = Utilities.GetSelectListData( SourceCateService.GetALL(), x => x.ID, x => x.CateName, model.SourceCateID, true); return PartialView(model); }
public ActionResult Details(int ID) { var entity = CustomerCompanyService.Find(ID); var model = new CustomerCompanyViewModel() { Address = entity.Address, BrandName = entity.BrandName, CityValue = entity.CityValue, CustomerCateID = entity.CustomerCateID, Description = entity.Description, Fax = entity.Fax, IndustryValue = entity.IndustryValue, Name = entity.Name, RelationID = entity.RelationID, Phone = entity.Phone, ID = entity.ID, MemberID = entity.AddUser, CoopCateID = entity.CoopCateID, SourceCateID = entity.SourceCateID, ProxyAddress = entity.ProxyAddress, ProxyName = entity.ProxyName, ProxyPhone = entity.ProxyPhone }; ViewBag.Data_CityValue = CityCateService.GetCascadingName(model.CityValue); ViewBag.Data_IndustryValue = IndustryCateService.GetCascadingName(model.IndustryValue); return View(model); }