public ActionResult _SaveAjaxEditing(int id) { if (Employee.CurrentRole.Level == 4) { AjaxViewDeal newData = new AjaxViewDeal(); TryUpdateModel <AjaxViewDeal>(newData); var item = CH.GetDataById <Deal>(id); item.Income = newData.Income; item.ActualPaymentDate = newData.ActualPaymentDate; item.Abandoned = newData.Abandoned; item.AbandonReason = newData.AbandonReason; if (item.Income > 0 && item.ActualPaymentDate != null) { CH.Edit <Deal>(item); } else { ModelState.AddModelError("Income", "实际入账需大于零."); } } else { var item = CH.GetDataById <Deal>(id); item.IsConfirm = true; item.Confirmor = Employee.CurrentUserName; CH.Edit <Deal>(item); } return(View(new GridModel(getData()))); }
public ActionResult Edit(Lead item) { if (EntityUtl.Utl.CheckPropertyAllNull(item, "Name_EN", "Name_CH")) { ModelState.AddModelError("", "名字不完整,中文名和英文名不能同时为空"); } if (EntityUtl.Utl.CheckPropertyAllNull(item, "EMail", "Fax")) { ModelState.AddModelError("", "联系方式不完整,座机和传真号不能同时为空"); } if (ModelState.IsValid) { Image image = ImageController.UploadImg(Request, item.Image); if (image != null) { item.ImageID = image.ID; } CH.Edit <Lead>(item); return(RedirectToAction("Index", "Company")); } ViewBag.CompanyID = item.CompanyID; return(View(item)); }
public ActionResult SetRole(AjaxEmployee model) { if (ModelState.IsValid) { var s = CH.GetDataById <EmployeeRole>(model.ID); s.IsActivated = model.IsActivated; s.RoleID = model.RoleID; s.ExpLevelID = model.ExpLevelID; s.StartDate = model.StartDate; s.IsTrainee = model.IsTrainee; //MembershipUser user = Membership.GetUser(s.AccountName); ProfileBase objProfile = ProfileBase.Create(s.AccountName); objProfile.SetPropertyValue("IsActivated", model.IsActivated); objProfile.Save(); CH.Edit <EmployeeRole>(s); return(Json("")); } else { string error = ""; foreach (var key in ModelState.Keys) { var state = ModelState[key]; if (state.Errors.Any()) { error += state.Errors.First().ErrorMessage + ","; } } return(Json(error.Substring(0, error.Length - 1))); } }
public ActionResult Edit(Project item, IEnumerable <HttpPostedFileBase> attachments) { this.AddErrorIfAllNamesEmpty(item); this.AddErrorStateIfStartDateLaterThanEndDate(item.StartDate, item.EndDate); if (ModelState.IsValid) { if (attachments != null) { if (string.IsNullOrEmpty(item.SalesBriefName)) { item.SalesBriefName = "销售简介"; } foreach (var file in attachments) { var fileName = Path.GetFileName(file.FileName).Replace(" ", "");; string serverpath = "/Uploads/Projects/" + item.ProjectCode + "/Salesbrief"; string path = Server.MapPath(serverpath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var physicalPath = Path.Combine(path, fileName); file.SaveAs(physicalPath); item.SalesBriefUrl = serverpath + "/" + fileName; } } CH.Edit <Project>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult _CompanyIndexEdit(int id) { _CompanyResearchDetail data = new _CompanyResearchDetail(); TryUpdateModel(data); Company updateCompany = CH.GetDataById <Company>(id); if (data.IsValid == "否") { updateCompany.IsValid = false; } else { updateCompany.IsValid = true; } updateCompany.CompanyReviews = data.CompanyReviews; CH.Edit <Company>(updateCompany); var selCompany = from c in CH.DB.Companys select new _CompanyResearchDetail { ID = c.ID, CompanyNameCH = c.Name_CH, CompanyNameEN = c.Name_EN, CompanyContact = c.Contact, CompanyDesicription = c.Description, CompanyReviews = c.CompanyReviews, Creator = c.Creator, CreateDate = c.CreatedDate, IsValid = c.IsValid == false ? "否" : "是" }; return(View(new GridModel(selCompany))); }
public ActionResult _LeadIndexEdit(int id, int?companyid) { _LeadResearchDetail data = new _LeadResearchDetail(); TryUpdateModel(data); Lead updateLead = CH.GetDataById <Lead>(id); if (data.IsValid == "否") { updateLead.IsValid = false; } else { updateLead.IsValid = true; } CH.Edit <Lead>(updateLead); var selLead = from c in CH.DB.Leads where c.CompanyID == companyid select new _LeadResearchDetail { ID = c.ID, LeadNameCH = c.Name_CH, LeadNameEN = c.Name_EN, LeadContact = c.Contact, Email = c.EMail, LeadMobile = c.Mobile, LeadTitle = c.Title, Creator = c.Creator, CreateDate = c.CreatedDate, IsValid = c.IsValid == false ? "否" : "是" }; return(View(new GridModel(selLead))); }
public ActionResult UpdateSalesBrief(int?id, string salesbrief, string salesBriefName, IEnumerable <HttpPostedFileBase> attachments) { var data = CH.GetDataById <Project>(id); data.SaleBrief = salesbrief; data.SalesBriefName = salesBriefName; if (attachments != null) { foreach (var file in attachments) { var fileName = Path.GetFileName(file.FileName).Replace(" ", "");; string serverpath = "/Uploads/Projects/" + data.ProjectCode + "/Salesbrief"; string path = Server.MapPath(serverpath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var physicalPath = Path.Combine(path, fileName); file.SaveAs(physicalPath); data.SalesBriefUrl = serverpath + "/" + fileName; } } CH.Edit <Project>(data); return(RedirectToAction("MyProjectIndex")); }
public ActionResult Edit(TargetOfMonthForMember item) { this.AddErrorStateIfTargetOfMonthNoValid(item); if (ModelState.IsValid) { //this.AddErrorStateIfTargetOfMonthNoValid(item); CH.DB.SaveChanges(); CH.DB.ChangeTracker.DetectChanges(); var list = CH.DB.ChangeTracker.Entries <TargetOfMonthForMember>().ToList(); if (list.Count > 0) { var attacth = list.First().Entity; CH.DB.Detach(attacth); } list = CH.DB.ChangeTracker.Entries <TargetOfMonthForMember>().ToList(); CH.Edit <TargetOfMonthForMember>(item); return(RedirectToAction("MyTargetIndex", new { projectid = item.ProjectID })); } ViewBag.ProjectID = item.ProjectID; return(View(item)); }
public ActionResult Edit(CompanyRelationship item, int[] checkedCategorys, string enname, string chname) { //如何保存多对多关系中 引用变化的例子 if (ModelState.IsValid) { var com = CH.GetDataById <Company>(item.CompanyID); if (com.Name_CH != chname || com.Name_EN != enname) { com.Name_CH = chname; com.Name_EN = enname; CH.Edit <Company>(com); } CH.Edit <CompanyRelationship>(item); if (checkedCategorys != null) { item = CH.GetDataById <CompanyRelationship>(item.ID); item.Categorys.Clear(); var ck = CH.GetAllData <Category>(c => checkedCategorys.Any(cc => cc == c.ID)); ck.ForEach(c => { item.Categorys.Add(c); }); string categorystring = string.Empty; ck.ForEach(l => { if (string.IsNullOrEmpty(categorystring)) { categorystring = l.Name; } else { categorystring += "," + l.Name; } }); item.CategoryString = categorystring; CH.Edit <CompanyRelationship>(item); CH.DB.SaveChanges(); } else { item = CH.GetDataById <CompanyRelationship>(item.ID); item.Categorys.Clear(); CH.DB.SaveChanges(); } if (Employee.EqualToProductInterface()) { return(RedirectToAction("companyrelationshipindex", "productinterface", new { id = item.ProjectID })); } else { return(RedirectToAction("management", "project", new { id = item.ProjectID, tabindex = 3 })); } } ViewBag.ProjectID = item.ProjectID; return(View(item)); }
public ActionResult Confirmed(int id) { var item = CH.GetDataById <TargetOfMonthForMember>(id); item.IsConfirm = true; CH.Edit <TargetOfMonthForMember>(item); return(RedirectToAction("ConfirmList", item.ProjectID)); }
public ActionResult Edit(PhoneSaleSupport item) { if (ModelState.IsValid) { CH.Edit <PhoneSaleSupport>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult _SaveAjaxEditing(int id) { var item = CH.GetDataById <TargetOfMonthForMember>(id); item.IsConfirm = true; CH.Edit <TargetOfMonthForMember>(item); return(View(new GridModel(getData()))); }
public ActionResult Edit(SubCompany item, int?projectid) { if (ModelState.IsValid) { CH.Edit <SubCompany>(item); return(RedirectToAction("Management", "Project", new { id = projectid, tabindex = 3 })); } return(View(item)); }
public ActionResult _AdminSaveAjaxEditing(int id, int?projectid) { var item = CH.GetDataById <TargetOfMonth>(id); item.AdminConfirmor = Employee.GetLoginUserName(); item.IsAdminConfirm = true; CH.Edit <TargetOfMonth>(item); return(View(new GridModel(getData("", projectid)))); }
public ActionResult Edit(Department item) { if (ModelState.IsValid) { CH.Edit <Department>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Edit(DistrictNumber item) { if (ModelState.IsValid) { CH.Edit <DistrictNumber>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult EditMessage(Message item) { if (ModelState.IsValid) { CH.Edit <Message>(item); return(RedirectToAction("MyMessageIndex")); } return(View(item)); }
public ActionResult Edit(OnPhoneBlockType item) { if (ModelState.IsValid) { CH.Edit <OnPhoneBlockType>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Edit(PaymentType item) { if (ModelState.IsValid) { CH.Edit <PaymentType>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Edit(Area item) { if (ModelState.IsValid) { CH.Edit <Area>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult _SaveAjaxEditing(int id) { var item = CH.GetDataById <ProjectType>(id); if (TryUpdateModel(item)) { CH.Edit <ProjectType>(item); } return(View(new GridModel(CH.GetAllData <ProjectType>()))); }
public ActionResult _SaveParticipantAjaxEditing(int participantid) { var item = CH.GetDataById <Participant>(participantid); if (TryUpdateModel(item)) { CH.Edit <Participant>(item); } return(View(new GridModel(GetParticipant(item.ProjectID, item.DealID)))); }
public ActionResult Edit(Template item) { if (ModelState.IsValid) { item.Content = HttpUtility.HtmlDecode(item.Content); CH.Edit <Template>(item); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Edit(Member item) { //this.AddErrorStateIfMemberExist(item.ProjectID, item.Name); if (ModelState.IsValid) { CH.Edit <Member>(item); return(RedirectToAction("Management", "Project", new { id = item.ProjectID, tabindex = 1 })); } return(View(item)); }
public ActionResult Edit(PackageItem item) { if (ModelState.IsValid) { CH.Edit <PackageItem>(item); return(RedirectToAction("Index", "Package")); } ViewBag.PackageID = item.PackageID; return(View(item)); }
public ActionResult _UpdateAjaxEditing(int id) { ProjectReview pr = CH.DB.ProjectReviews.Find(id); if (TryUpdateModel(pr)) { CH.Edit(pr); } return(View(new GridModel(GetData()))); }
public ActionResult _Update(int id) { var item = CH.GetDataById <UserFavorsCrmGroup>(id); if (TryUpdateModel(item)) { CH.Edit <UserFavorsCrmGroup>(item); } return(View(new GridModel(DataQuery()))); }
public ActionResult Edit(Deal item) { if (ModelState.IsValid) { CH.Edit <Deal>(item); var projectid = CH.GetDataById <CompanyRelationship>(item.CompanyRelationshipID).ProjectID; return(RedirectToAction("index", new { id = projectid })); } return(View(item)); }
public ActionResult Edit(Category item) { //this.AddErrorStateIfFieldExist<Category>(item, "Name"); if (ModelState.IsValid) { CH.Edit <Category>(item); return(RedirectToAction("management", "project", new { id = item.ProjectID, tabindex = 0 })); } ViewBag.ProjectID = item.ProjectID; return(View(item)); }
public ActionResult ConfirmTemp(Deal item, int?projectid) { ViewBag.ProjectID = projectid; ViewBag.CompanyRelationshipID = item.CompanyRelationshipID; if (ModelState.IsValid) { CH.Edit <Deal>(item); return(RedirectToAction("ConfirmList", "Deal", new { projectid = projectid })); } return(View(item)); }