Exemplo n.º 1
0
        private void piechart(string title, string data, ArrayList leg)
        {
            StringBuilder pie    = new StringBuilder();
            StringBuilder legend = new StringBuilder();

            graphTitle.Text = title;

            legend.Append("<table cellSpacing=0 cellPadding=2 border=0 style=\"border:1px solid black\">");
            legend.Append("<tr><td style=\"border-bottom:1px solid black;font-size:1px;\">&nbsp;</td><td style=\"border-bottom:1px solid black\">&nbsp;</td><td class=normal style=\"border-bottom:1px solid black\" width=\"50px\">n</td><td class=normal style=\"border-bottom:1px solid black\" width=\"80px\">%</td></tr>");
            Pie_chart pc = new Pie_chart();

            for (int i = 0; i < leg.Count; i++)
            {
                Legenda l = (Legenda)leg[i];
                legend.AppendFormat("<tr><td width=\"10px\" style=\"border-bottom:1px solid black;border-right:1px solid black\"><table cellpadding=0 cellspacing=0 width=\"10px\"><tr><td bgcolor=\"{0}\" style=\"font-size:9px\">&nbsp;</td></tr></table></td><td class=normal style=\"border-bottom:1px solid black\">{1}</td>", pc.color[i].Name, l.title);
                legend.AppendFormat("<td class=normal style=\"border-bottom:1px solid black\">{0}</td>", l.value.ToString());
                legend.AppendFormat("<td class=normal style=\"border-bottom:1px solid black\">{0}%</td></tr>", l.percent.ToString("###.00"));
            }
            pc.Dispose();
            legend.Append("</table");
            Legend.Text = legend.ToString();
            pie.AppendFormat("<img src=\"/chart/pie.aspx?data={0}\">", data);
            Trace.Warn(pie.ToString());
            Result.Text         = pie.ToString();
            tableData.Visible   = false;
            graphResult.Visible = true;
        }
Exemplo n.º 2
0
        private void DashPortIndustry()
        {
            string companyLead = RadioButtonList1.SelectedValue;

            StringBuilder dashQuery  = new StringBuilder();
            ArrayList     ar         = new ArrayList();
            ArrayList     arlegend   = new ArrayList();
            string        finalQuery = String.Empty;
            DataTable     dt;

            if (companyLead == "0" || companyLead == "2")
            {
                dashQuery.AppendFormat("SELECT * FROM DASH1_COMPANYINDUSTRY_VIEW");
                string opp = getOpportunity();
                if (opp.Length > 0)
                {
                    opp = " AND (" + opp + ")";
                }
                finalQuery = dashQuery.ToString() + opp + " ORDER BY COMPANYTYPEID";
                dt         = DatabaseConnection.CreateDataset(finalQuery).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        IndustryPercent temp = (IndustryPercent)ar[i];
                        if (temp.industryid == Convert.ToInt32(dr["CompanyTypeID"]))
                        {
                            temp.ntimes = temp.ntimes + 1;
                            ar[i]       = temp;
                            exists      = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        IndustryPercent newindustry = new IndustryPercent();
                        newindustry.industryid   = Convert.ToInt32(dr["CompanyTypeID"]);
                        newindustry.industryname = dr["CompanyIndustry"].ToString();
                        newindustry.ntimes       = 1;
                        ar.Add(newindustry);
                    }
                }
            }
            if (companyLead == "0" || companyLead == "1")
            {
                dashQuery.Length = 0;
                dashQuery.AppendFormat("SELECT * FROM DASH1_LEADINDUSTRY_VIEW");
                string opp = getOpportunity();
                if (opp.Length > 0)
                {
                    opp = " AND (" + opp + ")";
                }
                finalQuery = dashQuery.ToString() + opp + " ORDER BY INDUSTRY";
                dt         = DatabaseConnection.CreateDataset(finalQuery).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        IndustryPercent temp = (IndustryPercent)ar[i];
                        if (temp.industryid == Convert.ToInt32(dr["Industry"]))
                        {
                            temp.ntimes = temp.ntimes + 1;
                            ar[i]       = temp;
                            exists      = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        IndustryPercent newindustry = new IndustryPercent();
                        newindustry.industryid   = Convert.ToInt32(dr["Industry"]);
                        newindustry.industryname = dr["LeadIndustry"].ToString();
                        newindustry.ntimes       = 1;
                        ar.Add(newindustry);
                    }
                }
            }

            int    total     = 0;
            double percTotal = 0;
            string res       = String.Empty;

            for (int i = 0; i < ar.Count; i++)
            {
                IndustryPercent temp = (IndustryPercent)ar[i];
                total += temp.ntimes;
            }

            for (int i = 0; i < ar.Count; i++)
            {
                IndustryPercent temp    = (IndustryPercent)ar[i];
                string          indName = (temp.industryid == 0) ?Root.rm.GetString("Das1txt14") : temp.industryname;
                double          percent = Math.Round(Convert.ToDouble(temp.ntimes) * 100 / Convert.ToDouble(total), 0);
                percTotal += percent;
                Legenda leg = new Legenda();
                leg.title   = indName;
                leg.value   = temp.ntimes;
                leg.percent = percent;
                arlegend.Add(leg);
                res += indName + "|" + temp.ntimes + "|";
            }

            try
            {
                piechart(Root.rm.GetString("Das1txt17"), res.Substring(0, res.Length - 1), arlegend);
            }
            catch
            {
                graphTitle.Text = Root.rm.GetString("Das1txt38");
            }
        }
Exemplo n.º 3
0
        private void DashPortIndustry()
        {
            string companyLead = RadioButtonList1.SelectedValue;

            StringBuilder dashQuery  = new StringBuilder();
            ArrayList     ar         = new ArrayList();
            ArrayList     arlegend   = new ArrayList();
            string        finalQuery = String.Empty;
            DataTable     dt;

            if (companyLead == "0" || companyLead == "2")
            {
                dashQuery.AppendFormat("SELECT * FROM DASH1_COMPANYINDUSTRY_VIEW");

                finalQuery = dashQuery.ToString() + " ORDER BY COMPANYTYPEID";
                dt         = DatabaseConnection.CreateDataset(finalQuery).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        IndustryRevenue temp = (IndustryRevenue)ar[i];
                        if (temp.industryId == Convert.ToInt32(dr["CompanyTypeID"]))
                        {
                            switch (Drop2.SelectedValue)
                            {
                            case "0":
                                temp.revenue += Convert.ToDecimal(dr["expectedrevenue"]);
                                break;

                            case "1":
                                temp.revenue += Convert.ToDecimal(dr["incomeprobability"]);
                                break;

                            case "2":
                                temp.revenue += Convert.ToDecimal(dr["amountclosed"]);
                                break;
                            }

                            ar[i]  = temp;
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        IndustryRevenue newindustry = new IndustryRevenue();
                        newindustry.industryId   = Convert.ToInt32(dr["CompanyTypeID"]);
                        newindustry.industryName = dr["CompanyIndustry"].ToString();
                        switch (Drop2.SelectedValue)
                        {
                        case "0":
                            newindustry.revenue += Convert.ToDecimal(dr["expectedrevenue"]);
                            break;

                        case "1":
                            newindustry.revenue += Convert.ToDecimal(dr["incomeprobability"]);
                            break;

                        case "2":
                            newindustry.revenue += Convert.ToDecimal(dr["amountclosed"]);
                            break;
                        }
                        ar.Add(newindustry);
                    }
                }
            }
            if (companyLead == "0" || companyLead == "1")
            {
                dashQuery.Length = 0;
                dashQuery.AppendFormat("SELECT * FROM DASH1_LEADINDUSTRY_VIEW");

                finalQuery = dashQuery.ToString() + " ORDER BY INDUSTRY";
                dt         = DatabaseConnection.CreateDataset(finalQuery).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        IndustryRevenue temp = (IndustryRevenue)ar[i];
                        if (temp.industryId == Convert.ToInt32(dr["Industry"]))
                        {
                            switch (Drop2.SelectedValue)
                            {
                            case "0":
                                temp.revenue += Convert.ToDecimal(dr["expectedrevenue"]);
                                break;

                            case "1":
                                temp.revenue += Convert.ToDecimal(dr["incomeprobability"]);
                                break;

                            case "2":
                                temp.revenue += Convert.ToDecimal(dr["amountclosed"]);
                                break;
                            }

                            ar[i]  = temp;
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        IndustryRevenue newindustry = new IndustryRevenue();
                        newindustry.industryId   = Convert.ToInt32(dr["Industry"]);
                        newindustry.industryName = dr["LeadIndustry"].ToString();
                        switch (Drop2.SelectedValue)
                        {
                        case "0":
                            newindustry.revenue += Convert.ToDecimal(dr["expectedrevenue"]);
                            break;

                        case "1":
                            newindustry.revenue += Convert.ToDecimal(dr["incomeprobability"]);
                            break;

                        case "2":
                            newindustry.revenue += Convert.ToDecimal(dr["amountclosed"]);
                            break;
                        }
                        ar.Add(newindustry);
                    }
                }
            }

            decimal total     = 0;
            double  percTotal = 0;
            string  res       = String.Empty;

            for (int i = 0; i < ar.Count; i++)
            {
                IndustryRevenue temp = (IndustryRevenue)ar[i];
                total += temp.revenue;
            }

            for (int i = 0; i < ar.Count; i++)
            {
                IndustryRevenue temp    = (IndustryRevenue)ar[i];
                string          indName = temp.revenue.ToString("c");
                double          percent = Math.Round(Convert.ToDouble(temp.revenue) * 100 / Convert.ToDouble(total), 0);
                percTotal += percent;
                Legenda leg = new Legenda();
                leg.title   = (temp.industryId == 0) ?Root.rm.GetString("Das1txt14") : temp.industryName;
                leg.value   = temp.revenue;
                leg.percent = percent;
                arlegend.Add(leg);
                res += indName + "|" + Math.Round(temp.revenue, 0) + "|";
            }

            try
            {
                switch (Drop2.SelectedValue)
                {
                case "0":
                    piechart(Root.rm.GetString("Das1txt23"), res.Substring(0, res.Length - 1), arlegend);
                    break;

                case "1":
                    piechart(Root.rm.GetString("Das1txt24"), res.Substring(0, res.Length - 1), arlegend);
                    break;

                case "2":
                    piechart(Root.rm.GetString("Das1txt25"), res.Substring(0, res.Length - 1), arlegend);
                    break;
                }
            }
            catch
            {
                graphTitle.Text = Root.rm.GetString("Das1txt38");
            }
        }
Exemplo n.º 4
0
        private void DashPortAddress(string type)
        {
            string companyLead = RadioButtonList1.SelectedValue;

            Trace.Warn("companylead", companyLead);
            StringBuilder dashQuery = new StringBuilder();
            ArrayList     ar        = new ArrayList();
            ArrayList     arlegend  = new ArrayList();

            DataTable dt;

            if (companyLead == "0" || companyLead == "2")
            {
                string opp = getOpportunity();
                if (opp.Length > 0)
                {
                    opp = " AND (" + opp + ")";
                }
                dashQuery.AppendFormat("SELECT DISTINCT {0},COUNT({0}) AS NTIMES FROM DASH1_COMPANYINDUSTRY_VIEW WHERE {1} GROUP BY {0}", type, opp);

                dt = DatabaseConnection.CreateDataset(dashQuery.ToString()).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    Trace.Warn("C " + dr[type].ToString().ToUpper(), dr["ntimes"].ToString());
                    AddressPercent newsales = new AddressPercent();
                    newsales.address = dr[type].ToString().ToUpper();
                    newsales.ntimes  = Convert.ToInt32(dr["ntimes"]);
                    ar.Add(newsales);
                }
            }
            if (companyLead == "0" || companyLead == "1")
            {
                dashQuery.Length = 0;
                string opp = getOpportunity();
                if (opp.Length > 0)
                {
                    opp = " AND (" + opp + ")";
                }
                dashQuery.AppendFormat("SELECT DISTINCT {0},COUNT({0}) AS NTIMES FROM DASH1_LEADINDUSTRY_VIEW WHERE {1} GROUP BY {0}", type, opp);

                dt = DatabaseConnection.CreateDataset(dashQuery.ToString()).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    Trace.Warn("L " + dr[type].ToString().ToUpper(), dr["ntimes"].ToString());
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        AddressPercent temp = (AddressPercent)ar[i];
                        if (temp.address == dr[type].ToString().ToUpper())
                        {
                            temp.ntimes += Convert.ToInt32(dr["ntimes"]);
                            ar[i]        = temp;
                            exists       = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        AddressPercent newsales = new AddressPercent();
                        newsales.address = dr[type].ToString().ToUpper();
                        newsales.ntimes  = Convert.ToInt32(dr["ntimes"]);
                        ar.Add(newsales);
                    }
                }
            }

            int    total     = 0;
            double percTotal = 0;
            string res       = String.Empty;

            for (int i = 0; i < ar.Count; i++)
            {
                AddressPercent temp = (AddressPercent)ar[i];
                total += temp.ntimes;
            }

            for (int i = 0; i < ar.Count; i++)
            {
                AddressPercent temp       = (AddressPercent)ar[i];
                string         nationName = (temp.address.Length == 0) ?Root.rm.GetString("Das1txt14") : temp.address;
                double         percent    = Math.Round(Convert.ToDouble(temp.ntimes) * 100 / Convert.ToDouble(total), 3);
                percTotal += percent;
                Legenda leg = new Legenda();
                leg.title   = nationName;
                leg.value   = temp.ntimes;
                leg.percent = percent;
                arlegend.Add(leg);
                res += nationName + "|" + temp.ntimes + "|";
            }

            string title = String.Empty;

            switch (type)
            {
            case "Nation":
                title = Root.rm.GetString("Das1txt19");
                break;

            case "Province":
                title = Root.rm.GetString("Das1txt20");
                break;

            case "City":
                title = Root.rm.GetString("Das1txt21");
                break;
            }

            try
            {
                piechart(title, res.Substring(0, res.Length - 1), arlegend);
            }
            catch
            {
                graphTitle.Text = Root.rm.GetString("Das1txt38");
            }
        }
Exemplo n.º 5
0
        private void DashPortAddress(string type)
        {
            string companyLead = RadioButtonList1.SelectedValue;

            Trace.Warn("companylead", companyLead);
            StringBuilder dashQuery = new StringBuilder();
            ArrayList     ar        = new ArrayList();
            ArrayList     arlegend  = new ArrayList();

            DataTable dt;

            if (companyLead == "0" || companyLead == "2")
            {
                switch (Drop2.SelectedValue)
                {
                case "0":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(EXPECTEDREVENUE) AS NTIMES FROM DASH1_COMPANYINDUSTRY_VIEW  GROUP BY {0}", type);
                    break;

                case "1":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(INCOMEPROBABILITY) AS NTIMES FROM DASH1_COMPANYINDUSTRY_VIEW GROUP BY {0}", type);
                    break;

                case "2":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(AMOUNTCLOSED) AS NTIMES FROM DASH1_COMPANYINDUSTRY_VIEW GROUP BY {0}", type);
                    break;
                }


                dt = DatabaseConnection.CreateDataset(dashQuery.ToString()).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    Trace.Warn("C " + dr[type].ToString().ToUpper(), dr["ntimes"].ToString());
                    AddressRevenue newsales = new AddressRevenue();
                    newsales.address = dr[type].ToString().ToUpper();
                    newsales.revenue = Convert.ToInt32(dr["ntimes"]);
                    ar.Add(newsales);
                }
            }
            if (companyLead == "0" || companyLead == "1")
            {
                dashQuery.Length = 0;

                switch (Drop2.SelectedValue)
                {
                case "0":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(EXPECTEDREVENUE) AS NTIMES FROM DASH1_LEADINDUSTRY_VIEW GROUP BY {0}", type);
                    break;

                case "1":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(INCOMEPROBABILITY) AS NTIMES FROM DASH1_LEADINDUSTRY_VIEW GROUP BY {0}", type);
                    break;

                case "2":
                    dashQuery.AppendFormat("SELECT DISTINCT {0},SUM(AMOUNTCLOSED) AS NTIMES FROM DASH1_LEADINDUSTRY_VIEW GROUP BY {0}", type);
                    break;
                }

                dt = DatabaseConnection.CreateDataset(dashQuery.ToString()).Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    Trace.Warn("L " + dr[type].ToString().ToUpper(), dr["ntimes"].ToString());
                    bool exists = false;
                    for (int i = 0; i < ar.Count; i++)
                    {
                        AddressRevenue temp = (AddressRevenue)ar[i];
                        if (temp.address == dr[type].ToString().ToUpper())
                        {
                            temp.revenue += Convert.ToDecimal(dr["ntimes"]);
                            ar[i]         = temp;
                            exists        = true;
                            break;
                        }
                    }
                    if (!exists)
                    {
                        AddressRevenue newsales = new AddressRevenue();
                        newsales.address = dr[type].ToString().ToUpper();
                        newsales.revenue = Convert.ToDecimal(dr["ntimes"]);
                        ar.Add(newsales);
                    }
                }
            }

            decimal total     = 0;
            double  percTotal = 0;
            string  res       = String.Empty;

            for (int i = 0; i < ar.Count; i++)
            {
                AddressRevenue temp = (AddressRevenue)ar[i];
                total += temp.revenue;
            }

            for (int i = 0; i < ar.Count; i++)
            {
                AddressRevenue temp    = (AddressRevenue)ar[i];
                string         indName = temp.revenue.ToString("c");
                double         percent = Math.Round(Convert.ToDouble(temp.revenue) * 100 / Convert.ToDouble(total), 0);
                percTotal += percent;
                Legenda leg = new Legenda();
                leg.title   = (temp.address.Length == 0) ?Root.rm.GetString("Das1txt14") : temp.address;
                leg.value   = temp.revenue;
                leg.percent = percent;
                arlegend.Add(leg);
                res += indName + "|" + Math.Round(temp.revenue, 0) + "|";
            }

            string title = String.Empty;

            switch (type)
            {
            case "Nation":
                switch (Drop2.SelectedValue)
                {
                case "0":
                    title = Root.rm.GetString("Das1txt29");
                    break;

                case "1":
                    title = Root.rm.GetString("Das1txt30");
                    break;

                case "2":
                    title = Root.rm.GetString("Das1txt31");
                    break;
                }
                break;

            case "Province":
                switch (Drop2.SelectedValue)
                {
                case "0":
                    title = Root.rm.GetString("Das1txt32");
                    break;

                case "1":
                    title = Root.rm.GetString("Das1txt33");
                    break;

                case "2":
                    title = Root.rm.GetString("Das1txt34");
                    break;
                }
                break;

            case "City":
                switch (Drop2.SelectedValue)
                {
                case "0":
                    title = Root.rm.GetString("Das1txt35");
                    break;

                case "1":
                    title = Root.rm.GetString("Das1txt36");
                    break;

                case "2":
                    title = Root.rm.GetString("Das1txt37");
                    break;
                }
                break;
            }

            try
            {
                piechart(title, res.Substring(0, res.Length - 1), arlegend);
            }
            catch
            {
                graphTitle.Text = Root.rm.GetString("Das1txt38");
            }
        }