public ActionResult _index(int?projectid, string companyname, bool?deleted) { var ps = CRM_Logical.GetUserInvolveProject(); ps = ps.Where(w => w.IsActived == true).ToList(); IEnumerable <int> idList = ps.Select(o => o.ID); var crms = from c in CH.DB.CompanyRelationships.Where(w => idList.Contains((int)w.ProjectID)) select c; if (projectid != null) { crms = crms.Where(w => w.ProjectID == projectid); } if (companyname != null) { crms = crms.Where(q => q.Company.Deleted == false && (q.Company.Name_CH.Contains(companyname) || q.Company.Name_EN.Contains(companyname))); } if (deleted != null) { crms = crms.Where(w => w.Deleted == deleted); } var list = from crm in crms select new CompanyInfo { CRMID = crm.ID, CompanyID = crm.CompanyID, CompanyNameCH = crm.Company.Name_CH, CompanyNameEN = crm.Company.Name_EN, Deleted = crm.Deleted, }; list = list.OrderBy(w => w.CompanyNameEN); return(View(new GridModel(list.ToList()))); }
public ActionResult _ProjectResearchIndex(int?month) { var md = MonthDuration.GetMonthInstance(month); //权限控制 var ps = CRM_Logical.GetUserInvolveProject().Select(s => s.ID); var projects = Query.AliveProjects(); var prs = from p in projects.Where(w => ps.Contains(w.ID)) select new _ProjectResearch() { ProjectName = p.Name_CH, MemberCount = p.Members.Count, ProjectCode = p.ProjectCode, ProjectID = p.ID, FirstWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate1 && w.CreatedDate < md.EndDate1), SecondWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2), ThirdWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3), FourthWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4), FivethWeekCompanyCount = p.CompanyRelationships.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5), }; ViewBag.ProjectId = prs.FirstOrDefault().ProjectID; return(View(new GridModel(prs))); }
public ActionResult TargetOfMonthForProject(int?ProjectSelect) { ViewBag.ProjectSelect = ProjectSelect; if (ProjectSelect == null) { return(View(CH.GetAllData <TargetOfMonth>().Where(s => CRM_Logical.GetUserInvolveProject().Any(m => m.ID == s.ProjectID)).OrderByDescending(s => s.EndDate).ToList())); } else { return(View(CH.GetAllData <TargetOfMonth>().Where(s => s.ProjectID == ProjectSelect).OrderByDescending(s => s.EndDate).ToList())); } }
/// <summary> /// 当所属项目未选定时,自动导入存在的项目id /// </summary> /// <param name="item"></param> /// <param name="projectid"></param> /// <returns></returns> public static int?TrySetProjectIDForUser(this Controller item, int?projectid) { if (projectid == null) { var data = CRM_Logical.GetUserInvolveProject().FirstOrDefault(); if (data != null) { projectid = data.ID; } } return(projectid); }
public ViewResult Index(List <int> selectedprojects, bool?isActivated, DateTime?startdate, DateTime?enddate) { startdate = startdate == null ? new DateTime(1, 1, 1) : startdate; enddate = enddate == null ? new DateTime(9999, 1, 1) : startdate; if (selectedprojects != null) { var rs = CH.GetAllData <Research>(r => selectedprojects.Any(sp => sp == r.ProjectID) && r.CreatedDate >= startdate && r.CreatedDate <= enddate); return(View(rs)); } else { var ps = CRM_Logical.GetUserInvolveProject(); var rs = CH.GetAllData <Research>(r => ps.Any(sp => sp.ID == r.ProjectID) && r.CreatedDate >= startdate && r.CreatedDate <= enddate); return(View(rs)); } }
public ViewResult Index(List <int> selectedprojects, bool?isActivated, DateTime?startdate, DateTime?enddate) { startdate = startdate == null ? new DateTime(1, 1, 1) : startdate; enddate = enddate == null ? new DateTime(9999, 1, 1) : startdate; List <string> saleslist = new List <string>(); foreach (var d in CH.GetAllData <EmployeeRole>()) { if (d.RoleID == 12) { saleslist.Add(d.AccountName); } } if (selectedprojects != null) { if (Employee.CurrentRole.Level == ChinaTLRequired.LVL) { var ts = from t in CH.DB.TargetOfMonthForMembers.Where(w => saleslist.Contains(w.Member.Name)) where selectedprojects.Any(sp => sp == t.ProjectID) select t; return(View(ts.OrderByDescending(t => t.CreatedDate).ToList())); } else { var ts = from t in CH.DB.TargetOfMonthForMembers where selectedprojects.Any(sp => sp == t.ProjectID) select t; return(View(ts.OrderByDescending(t => t.CreatedDate).ToList())); } } else { if (Employee.CurrentRole.Level == ChinaTLRequired.LVL) { var ps = CRM_Logical.GetUserInvolveProject(); var rs = CH.GetAllData <TargetOfMonthForMember>(r => ps.Any(sp => sp.ID == r.ProjectID) && r.CreatedDate >= startdate && r.CreatedDate <= enddate && saleslist.Contains(r.Member.Name)); return(View(rs)); } else { var ps = CRM_Logical.GetUserInvolveProject(); var rs = CH.GetAllData <TargetOfMonthForMember>(r => ps.Any(sp => sp.ID == r.ProjectID) && r.CreatedDate >= startdate && r.CreatedDate <= enddate); return(View(rs)); } } }
public static IEnumerable <SelectListItem> SaleRelatedProjects(int?selectVal = null) { List <SelectListItem> selectList = new List <SelectListItem>(); foreach (Project p in CRM_Logical.GetUserInvolveProject()) { SelectListItem selectListItem = new SelectListItem { Text = p.ProjectCode, Value = p.ID.ToString() }; if (selectVal.HasValue && p.ID == selectVal.Value) { selectListItem.Selected = true; } selectList.Add(selectListItem); } return(selectList); }
public static _AvaliableCompanies GetAvaliableCompanies(CRMFilters filters = null) { var data = new _AvaliableCompanies(); if (filters.ProjectId == null) { filters.ProjectId = CRM_Logical.GetUserInvolveProject().FirstOrDefault() == null ? 0 : CRM_Logical.GetUserInvolveProject().FirstOrDefault().ID; } if (filters.ProjectId > 0) { data.MemberCompanies = GetGroupedCRM(true, filters); //data.PublicCompanies = GetPublicCRM(false, filters); } return(data); }
public static List <string> MemberSelectListInOwnProject() { if (Employee.CurrentRole.Level == Role.LVL_Sales) { return(new List <string>() { Employee.CurrentUserName }); } else { var selMember = (from p in CRM_Logical.GetUserInvolveProject() from m in CH.DB.Members where p.IsActived && p.ID == m.ProjectID select m).OrderBy(s => s.Name); return(selMember.Select(s => s.Name).Distinct().ToList()); } }
public ActionResult AssignCompany(int?projectId, string memberFilterForCompany = "", string prefixFilter = "", string fuzzyInput = "") { Project project = null; if (projectId.HasValue) { project = CH.GetDataById <Project>(projectId); } else { project = CRM_Logical.GetUserInvolveProject().FirstOrDefault(); } if (project != null) { ViewBag.ProjectID = project.ID; } ViewBag.MemberFilterForCompany = memberFilterForCompany; ViewBag.selectVal = prefixFilter; ViewBag.fuzzyInput = fuzzyInput; return(View()); }
public static IEnumerable <SelectListItem> ProjectSelectList(string currentUserName, int?selectVal = null) { List <SelectListItem> selectList = new List <SelectListItem>(); var user = Employee.CurrentUserName; var projects = CRM_Logical.GetUserInvolveProject().Where(x => x.IsActived == true); foreach (Project project in projects) { SelectListItem selectListItem = new SelectListItem() { Text = project.ProjectCode, Value = project.ID.ToString() }; if (selectVal.HasValue && project.ID == selectVal.Value) { selectListItem.Selected = true; } selectList.Add(selectListItem); } return(selectList.OrderBy(s => s.Text)); }
public ActionResult _UserResearchIndex(int?month) { var md = MonthDuration.GetMonthInstance(month); var users = Query.AliveMemberNames(); List <string> saleslist = new List <string>(); foreach (var d in CH.GetAllData <EmployeeRole>()) { if (d.RoleID == 12) { saleslist.Add(d.AccountName); } } if (Employee.CurrentRole.Level == ChinaTLRequired.LVL) { List <string> namelist = CRM_Logical.GetUserInvolveProject().SelectMany(w => w.Members).Select(f => f.Name).ToList(); users = users.Where(w => saleslist.Contains(w) && namelist.Contains(w)); } //权限控制 var mems = CRM_Logical.GetUserInvolveProject().Select(s => s.Members.Where(w => w.IsActivated)); var prs = //from c in CH.DB.CompanyRelationships group c by new {c.Creator} into cg //from l in CH.DB.Leads group c by new {c.companyid} into lg from l in CH.DB.Leads group l by new { l.Creator } into lg from u in users where lg.Key.Creator == u select new _UserResearch() { UserName = u, FirstWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2), SecondWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2), ThirdWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3), FourthWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4), FivethWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5) }; //var list = prs.ToList(); //var lg = CH.DB.Leads.Where(w=>w.Creator==Employee.CurrentUserName); //foreach (var v in list) //{ // v.FirstWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate1 && w.CreatedDate < md.EndDate1); // v.SecondWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate2 && w.CreatedDate < md.EndDate2); // v.ThirdWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate3 && w.CreatedDate < md.EndDate3); // v.FourthWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate4 && w.CreatedDate < md.EndDate4); // v.FivethWeekLeadCount = lg.Count(w => w.CreatedDate >= md.StartDate5 && w.CreatedDate < md.EndDate5); //} //var nprs = from l in CH.DB.Leads group l by new { l.Creator } into lg // from p in list // where p.UserName == lg.Key.Creator // select new _UserResearch() // { // UserName = p.UserName, // FirstWeekCompanyCount = p.FirstWeekCompanyCount, // SecondWeekCompanyCount = p.SecondWeekCompanyCount, // ThirdWeekCompanyCount = p.ThirdWeekCompanyCount, // FourthWeekCompanyCount = p.FourthWeekCompanyCount, // FivethWeekCompanyCount = p.FivethWeekCompanyCount, // }; return(View(new GridModel(prs))); }
public ActionResult _CompanyIndex(int?projectid, string sales, int?selType, DateTime?startTime, DateTime?endTime) { //sales只能看到自己的项目Lead if (Employee.CurrentRole.Level == Role.LVL_Sales) { sales = Employee.CurrentUserName; } var selCompany = from data in CH.DB.Companys select data; IQueryable <CompanyRelationship> crms = CH.DB.CompanyRelationships.Where(w => w.ProjectID > 0); if (projectid != null) { // selCompany.Where(c => CH.DB.CompanyRelationships.Where(r => r.ProjectID == projectid).Any(r => r.CompanyID == c.ID)); crms = crms.Where(w => w.ProjectID == projectid); } else { //var relationship = CH.DB.CompanyRelationships.Where(r => CRM_Logical.GetUserInvolveProject().Any(c => c.ID == r.ProjectID)); //selCompany.Where(c => relationship.Any(r => r.CompanyID == c.ID)); var pids = CRM_Logical.GetUserInvolveProject().Select(s => s.ID).ToList(); crms = CH.DB.CompanyRelationships.Where(w => pids.Contains((int)w.ProjectID)); } if (sales != string.Empty && sales != "null") { //var relationship = CH.DB.CompanyRelationships.Where(r => CH.DB.Members.Where(m => m.Name == sales).Any(m => m.ProjectID == r.ProjectID)); //selCompany.Where(c => relationship.Any(r => r.CompanyID == c.ID)); crms = crms.Where(w => w.Members.Any(a => a.Name == sales)); } //selCompany = crms.Select(s => s.Company); switch (selType) { case 1: //selCompany = selCompany.Where(s => s.IsValid == false); crms = crms.Where(w => w.Company.IsValid == false); break; case 2: crms = crms.Where(w => !string.IsNullOrEmpty(w.Company.CompanyReviews)); //selCompany = selCompany.Where(s => !string.IsNullOrEmpty(s.CompanyReviews)); break; default: break; } if (startTime != null) { //selCompany = selCompany.Where(s => s.CreatedDate >= startTime); crms = crms.Where(w => w.Company.CreatedDate >= startTime); } if (endTime != null) { //selCompany = selCompany.Where(s => s.CreatedDate <= endTime); crms = crms.Where(w => w.Company.CreatedDate <= endTime); } var findata = from c in crms select new _CompanyResearchDetail { ID = c.Company.ID, CompanyNameCH = c.Company.Name_CH, CompanyNameEN = c.Company.Name_EN, CompanyContact = c.Company.Contact, CompanyDesicription = c.Company.Description, CompanyReviews = c.Company.CompanyReviews, Creator = c.Company.Creator, CreateDate = c.Company.CreatedDate, IsValid = c.Company.IsValid == false ? "否" : "是", Description = c.Description, }; return(View(new GridModel(findata))); }
public ViewResult Index() { var data = CRM_Logical.GetUserInvolveProject(); return(View(data)); }