Exemplo n.º 1
0
        public List<CUPEQuestionTrendAnalysis> GetCUPEQuestionTrendAnalysis(string cqName, string regName, string counName, string busTypeName, string fromDateStr, string toDateStr)
        {
            List<CUPERESPONSE> crList;
            DateTime toDate;
            DateTime fromDate;
            if (!DateTime.TryParse(fromDateStr, out fromDate))
            {
                fromDate = DateTime.MinValue;
            }
            if (!DateTime.TryParse(toDateStr, out toDate))
            {
                toDate = DateTime.MaxValue;
            }
            if (regName != "All")
            {
                if (busTypeName != "All")
                {
                    crList = GetCUPEResponsesForCUPEQuestionRegionAndBusinessType(cqName, regName, counName, busTypeName, fromDate, toDate);
                }

                else
                {
                    crList = GetCUPEResponsesForCUPEQuestionRegion(cqName, regName, counName, fromDate, toDate);
                }
            }

            else
            {
                if (busTypeName != "All")
                {
                    crList = GetCUPEResponsesForCUPEQuestionBusinessType(cqName, busTypeName, fromDate, toDate);
                }

                else
                {
                    crList = GetCUPEResponsesForCUPEQuestion(cqName, fromDate, toDate);
                }
            }

            List<CUPEQuestionTrendAnalysis> cqtaList = new List<CUPEQuestionTrendAnalysis>();
            CUPEQuestionTrendAnalysis cqta;
            CLIENT client;
            if(crList != null)
            {
                foreach (CUPERESPONSE cr in crList)
                {
                    if (cr.CURRENT != "" && cr.FUTURE != "")
                    {
                        cqta = new CUPEQuestionTrendAnalysis();
                        client = cr.CONTACT.GROUP.CLIENT;
                        cqta.Date = client.STARTDATE;
                        cqta.Region = client.COUNTRY.REGION.NAME.TrimEnd();
                        cqta.Country = client.COUNTRY.NAME.TrimEnd();
                        cqta.BusinessType = client.BUSINESSTYPE.NAME.TrimEnd();
                        cqta.Country = cqta.Region.TrimEnd();
                        cqta.CupeType = cr.CONTACT.GROUP.NAME.TrimEnd();
                        switch (cr.CURRENT)
                        {
                            case "a":
                                cqta.CurrentAnswer = 1;
                                break;
                            case "b":
                                cqta.CurrentAnswer = 2;
                                break;
                            case "c":
                                cqta.CurrentAnswer = 3;
                                break;
                            case "d":
                                cqta.CurrentAnswer = 4;
                                break;
                        }
                        switch (cr.FUTURE)
                        {
                            case "a":
                                cqta.FutureAnswer = 1;
                                break;
                            case "b":
                                cqta.FutureAnswer = 2;
                                break;
                            case "c":
                                cqta.FutureAnswer = 3;
                                break;
                            case "d":
                                cqta.FutureAnswer = 4;
                                break;
                        }
                        cqta.Name = cqName;
                        cqtaList.Add(cqta);
                    }
                }
            }

            return cqtaList;
        }
Exemplo n.º 2
0
        private void CreateCUPEQuestionToTrack(string region, string country, string busi, string from, string to)
        {
            if (currentlyBeingTracked == "" || currentlyBeingTracked == "CUPE")
            {
                List<CUPEQuestionTrendAnalysis> cupes = new List<CUPEQuestionTrendAnalysis>();

                cupes = db.GetCUPEQuestionTrendAnalysis(cupeQuestionsComboBox.Text, region, country, busi, from, to);
                if (cupes.Count > 0)
                {
                    cupes.Sort((x, y) => DateTime.Compare(x.Date, y.Date));
                    float asIsAaverage = cupes.Average(d => d.CurrentAnswer);
                    float futureAnswer = cupes.Average(d => d.FutureAnswer);

                    CUPEQuestionTrendAnalysis track = new CUPEQuestionTrendAnalysis();
                    track.CurrentAnswer = asIsAaverage;
                    track.FutureAnswer = futureAnswer;
                    track.Name = cupeQuestionsComboBox.Text;
                    track.BusinessType = busi;
                    track.CupeType = "---";
                    track.Type1 = TrendAnalysisEntity.Type.Master;
                    cupeToTrack.Add(track);

                    foreach (CUPEQuestionTrendAnalysis c in cupes)
                    {
                        track.Children++;
                        cupeToTrack.Add(c);
                        c.Type1 = TrendAnalysisEntity.Type.Child;
                    }
                    trendGridView.DataSource = null;
                    trendGridView.DataSource = cupeToTrack;
                    trendGridView.Refresh();
                    currentlyBeingTracked = "CUPE";

                    trendGridView.Columns["Collapse"].Visible = true;
                    //Console.WriteLine("children cupe: " + track.Children.ToString());
                }
                else
                    MessageBox.Show("Query returned no results.");

            }
            else
            {
                MessageBox.Show("You can only track one entity type at a time. Please clear grid and try again.");
            }
        }