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))); } }
private AjaxEmployee getEmployeeData(int?id) { var selAccount = CH.GetDataById <EmployeeRole>(id); return(new AjaxEmployee() { ID = selAccount.ID, AccountName = selAccount.AccountName, AccountNameCN = selAccount.AccountNameCN, AgentNum = selAccount.AgentNum, BirthDay = selAccount.BirthDay, DepartmentID = selAccount.DepartmentID, DepartmentName = selAccount.Department == null ? string.Empty : selAccount.Department.Name, Email = selAccount.Email, ExpLevelID = selAccount.ExpLevelID, ExpLevelName = selAccount.ExpLevel == null ? string.Empty : selAccount.ExpLevel.Name, IsActivated = selAccount.IsActivated, Gender = selAccount.Gender, IsTrainee = selAccount.IsTrainee, Mobile = selAccount.Mobile, RoleID = selAccount.RoleID, RoleName = selAccount.Role == null ? string.Empty : selAccount.Role.Name, StartDate = selAccount.StartDate, EmailSignatures = selAccount.EmailSignatures, EmailPassword = selAccount.EmailPassword }); }
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 EmailExportCsv(int?projectid, int?dealcondition, int?distinctnumber, string categories = "") { var pjs = CH.GetAllData <Project>(); var pj = CH.GetDataById <Project>(projectid); if (projectid != null) { pj = pjs.Where(p => p.ID == projectid).FirstOrDefault(); } if (pj == null) { return(RedirectToAction("MarketIndex", new { projectid = projectid })); } var ls = pj.ProjectLeadsEmail(dealcondition, distinctnumber, categories); this.AddErrorStateIfCreatorIsTheLoginUserIsNotTheMarketInterface(pj); //if (ModelState.IsValid) //{ MemoryStream output = new MemoryStream(); //StreamWriter writer = new StreamWriter(output, Encoding.UTF8); StreamWriter writer = new StreamWriter(output, System.Text.Encoding.Default); foreach (var lead in ls) { writer.Write(lead); writer.WriteLine(); } writer.Flush(); output.Position = 0; return(File(output, "text/comma-separated-values", "Emails.csv")); //} //else // return RedirectToAction("MarketIndex", new { projectid = projectid }); }
public ActionResult Edit(int id) { var data = CH.GetDataById <News>(id); data.Content = HttpUtility.HtmlDecode(data.Content); return(View(data)); }
public ViewResult Details(int id) { var data = CH.GetDataById <News>(id); data.Content = HttpUtility.HtmlDecode(data.Content); return(View(data)); }
public ActionResult DisplayDeals(int crmid) { CompanyRelationship crm = CH.GetDataById <CompanyRelationship>(crmid); var ds = from d in crm.Deals select new AjaxViewDeal { CompanyNameEN = d.CompanyRelationship.Company.Name_EN, CompanyNameCH = d.CompanyRelationship.Company.Name_CH, DealCode = d.DealCode, Abandoned = d.Abandoned, AbandonReason = d.AbandonReason, ActualPaymentDate = d.ActualPaymentDate, Committer = d.Committer, CommitterContect = d.Committer, CommitterEmail = d.CommitterEmail, ExpectedPaymentDate = d.ExpectedPaymentDate, ID = d.ID, Income = d.Income, IsClosed = d.IsClosed, PackageNameCH = d.Package.Name_CH, PackageNameEN = d.Package.Name_EN, Payment = d.Payment, Currency = d.Currencytype.Name, PaymentDetail = d.PaymentDetail, Sales = d.Sales, ProjectCode = d.Project.ProjectCode, SignDate = d.SignDate, TicketDescription = d.TicketDescription, IsConfirm = (d.IsConfirm == true ? "是" : "否") }; return(PartialView("Deal", ds.ToList())); }
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(int id) { var data = CH.GetDataById <CompanyRelationship>(id); ViewBag.ProjectID = data.ProjectID; return(View(data)); }
public ActionResult AddCompany(Company item, int?projectid, int[] checkedCategorys) { projectid = this.TrySetProjectIDForUser(projectid); ViewBag.ProjectID = projectid; this.AddAddErrorStateIfOneOfNameExist <Company>(item.Name_EN, item.Name_CH); this.AddErrorIfAllNamesEmpty(item); if (ModelState.IsValid) { List <Category> lc = new List <Category>(); if (checkedCategorys != null) { lc = CH.GetAllData <Category>(i => checkedCategorys.Contains(i.ID)); } var p = CH.GetDataById <Project>(projectid); CH.Create <Company>(item); var ms = new List <Member>(); ms.Add(p.GetMemberInProjectByName(Employee.CurrentUserName)); var cr = new CompanyRelationship() { CompanyID = item.ID, ProjectID = projectid, Importancy = 1, Members = ms, Categorys = lc }; CH.Create <CompanyRelationship>(cr); return(RedirectToAction("CompanyRelationshipIndex", "productinterface", new { projectid = projectid })); } else { return(View()); } }
public ActionResult Delete(int id) { var data = CH.GetDataById <Project>(id); data.SaleBrief = HttpUtility.HtmlDecode(data.SaleBrief); return(View(data)); }
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 Delete(int id) { var data = CH.GetDataById <Research>(id); data.Contents = HttpUtility.HtmlDecode(data.Contents); return(View(data)); }
public ActionResult PostID(int?id) { Deal d = CH.GetDataById <Deal>(id); Session["DealID"] = d.ID; Session["ProjectID"] = d.ProjectID; return(PartialView("Confirm", new AjaxViewDeal() { CompanyNameEN = d.CompanyRelationship.Company.Name_EN, CompanyNameCH = d.CompanyRelationship.Company.Name_CH, DealCode = d.DealCode, Abandoned = d.Abandoned, AbandonReason = d.AbandonReason, ActualPaymentDate = d.ActualPaymentDate, Committer = d.Committer, CommitterContect = d.Committer, CommitterEmail = d.CommitterEmail, ExpectedPaymentDate = d.ExpectedPaymentDate, ID = d.ID, Income = d.Income, IsClosed = d.IsClosed, PackageNameCH = d.Package.Name_CH, PackageNameEN = d.Package.Name_EN, Payment = d.Payment, Currency = d.Currencytype.Name, PaymentDetail = d.PaymentDetail, Sales = d.Sales, ProjectCode = d.Project.ProjectCode, SignDate = d.SignDate, TicketDescription = d.TicketDescription, IsConfirm = (d.IsConfirm == true ? "是" : "否"), ModifiedDate = d.ModifiedDate, })); }
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 static IQueryable <_Speaker> GetSpeakers(int?projectid = null) { var data = from c in CH.PDDB.Speakers select new _Speaker { CreatedDate = c.CreatedDate, Creator = c.Creator, Description = c.Description, ID = c.ID, ModifiedDate = c.ModifiedDate, ModifiedUser = c.ModifiedUser, Name = c.Name, Sequence = c.Sequence, Title = c.Title, Company = c.Company, ConferenceID = c.ConferenceID, Content = c.Content, ContentDescription = c.ContentDescription, Profile = c.Profile, ImgPath = c.ImgPath, ClientDurationTypeID = c.ClientDurationTypeID, CategoryID = c.CategoryID, IsVIP = c.IsVIP, ConfirmedAttend = c.ConfirmedAttend, CommunicationRecord = c.CommunicationRecord, DraftCase = c.DraftCase, Email = c.Email, Fax = c.Fax, Importance = c.Importance, InstitutionalNature = c.InstitutionalNature, Mobile = c.Mobile, NewsWebSite = c.NewsWebSite, NoteInformation = c.NoteInformation, Phone = c.Phone, RoyaltiesReference = c.RoyaltiesReference, WebSite = c.WebSite, Address = c.Address, Assistant = c.Assistant }; if (projectid != null) { var projectcode = CH.GetDataById <Project>(projectid).ProjectCode; var conference = CH.PDDB.Conferences.Where(x => x.ProjectCode == projectcode).FirstOrDefault(); if (conference != null) { data = data.Where(w => w.ConferenceID == conference.ID).OrderByDescending(s => s.Sequence); } else { data = data.Where(w => 1 == 2); } } else { data = data.Where(w => 1 == 2); } return(data); }
public ActionResult DeleteConfirmed(int id) { var item = CH.GetDataById <Member>(id); var pid = item.ProjectID; CH.Delete <Member>(id); return(RedirectToAction("Management", "Project", new { id = pid, tabindex = 1 })); }
public ActionResult DeleteConfirmed(int id) { var item = CH.GetDataById <Category>(id); var pid = item.ProjectID; CH.Delete <Category>(id); return(RedirectToAction("myprojectindex", "productinterface", new { id = pid })); }
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 Deleted(int id) { var item = CH.GetDataById <TargetOfMonthForMember>(id); CH.Delete <TargetOfMonthForMember>(id); //return View("MyTargetIndexEx", getData(item.ProjectID)); return(RedirectToAction("MyTargetIndexEx", new { projectid = id })); }
public ActionResult ConfirmTemp(int id) { var item = CH.GetDataById <Deal>(id); ViewBag.ProjectID = item.CompanyRelationship.ProjectID; ViewBag.CompanyRelationshipID = item.CompanyRelationshipID; 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(int id) { var data = CH.GetDataById <TargetOfMonthForMember>(id); var list = CH.DB.ChangeTracker.Entries <TargetOfMonthForMember>().ToList(); //var data = CH.DB.TargetOfMonthForMembers.AsNoTracking().Single(x => x.ID == id); list = CH.DB.ChangeTracker.Entries <TargetOfMonthForMember>().ToList(); return(View(data)); }
public ActionResult AssignCompanies(string selectedCompanies, string selectedMembers) { if (string.IsNullOrWhiteSpace(selectedCompanies)) { return(Content("请选择公司!")); } if (string.IsNullOrWhiteSpace(selectedMembers)) { return(Content("请选择销售人员!")); } //以下的companyid为crmdid 请注意 selectedCRMs = selectedCompanies.Replace("on,", ""); IEnumerable <int> crmIDs = selectedCRMs.Split(',').Select(c => int.Parse(c)); IEnumerable <int> memberIDs = selectedMembers.Split(',').Select(c => int.Parse(c)); //foreach (int companyID in crmIDs) //{ // // var company = CH.GetAllData<CompanyRelationship>(i => i.ID == companyID, "Members").FirstOrDefault(); // var company = CH.GetDataById<CompanyRelationship>(companyID); // if (company != null) // { // foreach (int memberID in memberIDs) // { // if (company.Members.All(m => m.ID != memberID)) // { // var mem = CH.GetDataById<Member>(memberID); // company.Members.Add(mem); // } // } // } // CH.Edit<CompanyRelationship>(company); //} List <DbEntityEntry> copys = new List <DbEntityEntry>(); var crms = CH.DB.CompanyRelationships.Where(w => crmIDs.Contains(w.ID)); foreach (var c in crms) { foreach (int memberID in memberIDs) { if (!c.Members.Any(m => m.ID == memberID)) { var mem = CH.GetDataById <Member>(memberID); c.Members.Add(mem); } } if (memberIDs.Count() > 0) { c.CrmCommentStateID = 2; } var data = CH.DB.Entry(c); data.State = EntityState.Modified; copys.Add(data); } CH.DB.SaveChanges(); return(Content("分配成功!")); }
public ActionResult _SaveAjaxEditing(int id) { var item = CH.GetDataById <TargetOfMonthForMember>(id); item.IsConfirm = true; CH.Edit <TargetOfMonthForMember>(item); return(View(new GridModel(getData()))); }
public ViewResult UpdateSalesBrief(int?id) { ViewBag.ProjectID = id; var data = CH.GetDataById <Project>(id); ViewBag.SalesBriefName = data.SalesBriefName; ViewBag.SalesBriefUrl = data.SalesBriefUrl; return(View("UpdateSalesBrief", "", HttpUtility.HtmlDecode(data.SaleBrief))); }
public ActionResult DeleteConfirmed(int id) { var item = CH.GetDataById <TargetOfMonth>(id); var pid = item.ProjectID; CH.Delete <TargetOfMonth>(id); //return RedirectToAction("TargetOfMonthForProject", "Project"); return(RedirectToAction("Management", "Project", new { id = pid, tabindex = 2 })); }
public ActionResult ExportEmail(string action, int[] checkedRecords, string manager, DateTime?startDate, DateTime?endDate) { if (action == "search") { var selProject = CH.GetAllData <Project>().AsEnumerable(); if (!string.IsNullOrWhiteSpace(manager)) { selProject = selProject.Where(s => s.Manager == manager); } if (startDate != null) { selProject = selProject.Where(s => s.StartDate >= startDate); } if (endDate != null) { selProject = selProject.Where(s => s.StartDate <= endDate); } return(View(selProject.ToList())); } else { IEnumerable <Lead> export; Project selproject = CH.GetDataById <Project>(checkedRecords[0]); export = CH.GetAllData <Lead>().Where(l => selproject.CompanyRelationships.Any(c => c.CompanyID == l.CompanyID)); //export = (from selrelationships in selproject.CompanyRelationships // join sellead in CH.GetAllData<Lead>() on selrelationships.CompanyID equals sellead.CompanyID // select sellead).Distinct(); //if (export.Count() == 0) //{ // //} MemoryStream output = new MemoryStream(); StreamWriter writer = new StreamWriter(output, System.Text.Encoding.UTF8); writer.Write("Lead邮箱,"); writer.WriteLine(); foreach (var item in export) { if (string.IsNullOrWhiteSpace(item.EMail)) { continue; } writer.Write(item.EMail); writer.WriteLine(); } writer.Flush(); output.Position = 0; string fileName = selproject.Name_CH + selproject.ProjectCode + ".csv"; return(File(output, "text/comma-separated-values", fileName)); } }
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)))); }