private void PopulateFollowUps() { var bizM = new bizMessage(); if (Session["USER"] == null) { ucMessanger1.ProcessMessage("Session: " + bizM.GetMessageText("SessionMissing"), Enums.enMsgType.Err, "", null, true); return; } var user = (bizUser.enGageUser)Session["USER"]; var biz = new bizActivity(); bool isRegion, isBranch, isAll; isRegion = isBranch = isAll = false; GridUtilities.SetUserAllowedOpportunities(user, ref isRegion, ref isBranch, ref isAll); var d1 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Recognise", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d2 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Qualify", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d3 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Contact", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d4 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Discover", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d5 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Respond", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d6 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Agree", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); var d7 = biz.GetFollowUps(ddlFilterExcutives.SelectedValue, int.Parse(ddlOAMPSIncome.SelectedValue), int.Parse(ddlBusinessType.SelectedValue), int.Parse(ddlFlagged.SelectedValue), "Process", ddlFilterRegion.SelectedValue, ddlFilterBranch.SelectedValue, isAll); _allIdentify = d1.Where(x => x.OutcomeType != "C" && x.FollowUpDate >= CalenderUtilities.CutOffDate).ToList(); _allQualify = d2.Concat(d1) .Where(x => x.OutcomeType != "C" && x.FollowUpDate >= CalenderUtilities.CutOffDate) .ToList(); _allRespond = d3.Concat(d4) .Concat(d5) .Where(x => x.OutcomeType != "C" && x.FollowUpDate >= CalenderUtilities.CutOffDate) .ToList(); _allComplete = d6.Concat(d7) .Where(x => x.OutcomeType != "C" && x.FollowUpDate >= CalenderUtilities.CutOffDate) .ToList(); // get the summary matrix for opprtunities decimal?estimated = 0, quoted = 0, actual = 0; int? noOfOpportunities = 0; estimated = _allQualify.Sum(x => (x.NetBrokerageEstimated.HasValue) ? x.NetBrokerageEstimated : 0); quoted = _allRespond.Sum(x => (x.NetBrokerageQuoted.HasValue) ? x.NetBrokerageQuoted : 0); actual = _allComplete.Sum(x => (x.NetBrokerageActual.HasValue) ? x.NetBrokerageActual : 0); //biz.FollowUpsMatrix(user.UserName, string.Join(",", new string[] { Enums.ActivityActions.Qualify.ToString(), Enums.ActivityActions.Recognise.ToString() }),false,CalenderUtilities.CutOffDate, ref noOfOpportunities, ref estimated, ref quoted, ref actual); setFollowUpMatrix(lblQualifyMatrix, estimated, actual, _allQualify.Count, Enums.ActivityActions.Qualify.ToString()); //biz.FollowUpsMatrix(user.UserName, string.Join(",", new string[] { Enums.ActivityActions.Contact.ToString(), Enums.ActivityActions.Discover.ToString(), Enums.ActivityActions.Respond.ToString() }),false,CalenderUtilities.CutOffDate, ref noOfOpportunities, ref estimated, ref quoted, ref actual); setFollowUpMatrix(lblRespondMatrix, quoted, actual, _allRespond.Count, Enums.ActivityActions.Contact.ToString()); //biz.FollowUpsMatrix(user.UserName, string.Join(",", new string[] { Enums.ActivityActions.Agree.ToString(), Enums.ActivityActions.Process.ToString() }),false,CalenderUtilities.CutOffDate, ref noOfOpportunities, ref estimated, ref quoted, ref actual); setFollowUpMatrix(lblCompleteMatrix, quoted, actual, _allComplete.Count, Enums.ActivityActions.Agree.ToString()); //this.grvIdentified.DataSource = allIdentify; //this.ucMessanger1.ProcessMessages(biz.MSGS, true); //this.grvIdentified.DataBind(); grvQualifiedIn.DataSource = _allQualify; ucMessanger1.ProcessMessages(biz.MSGS, true); grvQualifiedIn.DataBind(); grvInterested.DataSource = _allRespond; ucMessanger1.ProcessMessages(biz.MSGS, true); grvInterested.DataBind(); grvAccepted.DataSource = _allComplete; ucMessanger1.ProcessMessages(biz.MSGS, true); grvAccepted.DataBind(); // combine all results to have a filtered summery for the week var allFollowups = d1.Concat(d2) .Concat(d3) .Concat(d4) .Concat(d5) .Concat(d6) .Where(x => x.OutcomeType != "C" && x.FollowUpDate >= CalenderUtilities.CutOffDate) .ToList(); ; var weekStartDate = (DateTime.Now.AddDays(-(DateTime.Now.DayOfWeek - DayOfWeek.Monday))); var weekEndDate = weekStartDate.AddDays(6); var weeklyFilteredFollowUps = allFollowups.Where(x => { return(((x.FollowUpDate.HasValue) ? (x.FollowUpDate.Value.Date >= weekStartDate.Date && x.FollowUpDate.Value.Date <= weekEndDate.Date) : false) || ((x.OpportunityDue.HasValue) ? DateTime.Now.Date >= x.OpportunityDue.Value.Date : false ) ); }).ToList(); grvSummary.DataSource = weeklyFilteredFollowUps; ucMessanger1.ProcessMessages(biz.MSGS, true); grvSummary.DataBind(); // change the way the gridview displays the header AlterGridRendering(grvSummary); AlterGridRendering(grvQualifiedIn); AlterGridRendering(grvInterested); AlterGridRendering(grvAccepted); if (weeklyFilteredFollowUps.Count() <= grvSummary.PageSize) { lnkSeeAll0.Enabled = false; } else { lnkSeeAll0.Enabled = true; } lblQualifiedIn.Text = "Qualifying"; // + _allQualify.Count.ToString() + " active)"; lnkSeeAll2.Enabled = true; lblInterested.Text = "Responding"; // + _allRespond.Count.ToString() + " active)"; lnkSeeAll3.Enabled = true; lblAccepted.Text = "Completing"; // + _allComplete.Count.ToString() + " active)"; lnkSeeAll6.Enabled = true; }