Exemplo n.º 1
0
        private void BindChart()
        {
            string strSql1 = "select cnvcChanceSpeed,count(*) as cnnChanceCount,sum(cnnForecastIncome) as cnnChanceSum,0 as cnnRate,0 as cnnSumRate ,'' as cnvcComments from tbProject where cnvcDeptID like '" + ddlDept.SelectedValue + "'";

            strSql1 += " and cnvcMgr like '" + ddlMgr.SelectedValue + "'";
            strSql1 += " and cnvcTradeMgr like '" + ddlTradeMgr.SelectedValue + "'";
            if (txtBeginDate.Text != "")
            {
                strSql1 += " and convert(char(10),cndChanceDate,121)>='" + txtBeginDate.Text + "'";
            }
            if (txtEndDate.Text != "")
            {
                strSql1 += " and convert(char(10),cndChanceDate,121)<='" + txtEndDate.Text + "'";
            }
            strSql1 += " group by cnvcChanceSpeed";

            string strSql2 = "select count(*) as cnnCount from tbProject where 1=1 ";

            strSql2 += " and cnvcMgr like '" + ddlMgr.SelectedValue + "'";
            strSql2 += " and cnvcTradeMgr like '" + ddlTradeMgr.SelectedValue + "'";
            if (txtBeginDate.Text != "")
            {
                strSql2 += " and convert(char(10),cndChanceDate,121)>='" + txtBeginDate.Text + "'";
            }
            if (txtEndDate.Text != "")
            {
                strSql2 += " and convert(char(10),cndChanceDate,121)<='" + txtEndDate.Text + "'";
            }

            string strSql3 = "select sum(cnnForecastIncome) as cnnSum from tbProject where 1=1 ";

            strSql3 += " and cnvcMgr like '" + ddlMgr.SelectedValue + "'";
            strSql3 += " and cnvcTradeMgr like '" + ddlTradeMgr.SelectedValue + "'";
            if (txtBeginDate.Text != "")
            {
                strSql3 += " and convert(char(10),cndChanceDate,121)>='" + txtBeginDate.Text + "'";
            }
            if (txtEndDate.Text != "")
            {
                strSql3 += " and convert(char(10),cndChanceDate,121)<='" + txtEndDate.Text + "'";
            }

            DataTable dtChance  = Helper.Query(strSql1);
            DataTable dtChance2 = Helper.Query(strSql2);
            DataTable dtChance3 = Helper.Query(strSql3);

            double dCount = 1;
            double dSum   = 0.00;

            if (dtChance2.Rows.Count > 0)
            {
                string strCount = dtChance2.Rows[0]["cnnCount"].ToString();
                if (strCount != "")
                {
                    dCount = Convert.ToDouble(strCount);
                    if (dCount == 0)
                    {
                        dCount = 1;
                    }
                }
            }
            if (dtChance3.Rows.Count > 0)
            {
                string strSum = dtChance3.Rows[0]["cnnSum"].ToString();
                if (strSum != "")
                {
                    dSum = Convert.ToDouble(strSum);
                    if (dSum == 0)
                    {
                        dSum = 1;
                    }
                }
            }
            foreach (DataRow drChance in dtChance.Rows)
            {
                double dChanceCount = Convert.ToDouble(drChance["cnnChanceCount"]);
                double dRate        = Math.Round(dChanceCount / dCount * 100, 2);
                drChance["cnnRate"] = dRate;

                double dChanceSum = Convert.ToDouble(drChance["cnnChanceSum"]);
                double dSumRate   = Math.Round(dChanceSum / dSum * 100, 2);
                drChance["cnnSumRate"] = dSumRate;
            }
            this.DataTableConvert(dtChance, "cnvcChanceSpeed", ConstApp.A_NAMECODE, "cnvcType='CHANCE_SPEED'");
            //dtChance.Columns.Remove("cnvcChanceSpeed");
            foreach (DataRow dr in dtChance.Rows)
            {
                Dundas.Charting.WebControl.DataPoint dp = new Dundas.Charting.WebControl.DataPoint();
                dp.XValue     = Convert.ToDouble(dr["cnnChanceCount"]);
                dp.YValues[0] = Convert.ToDouble(dr["cnnRate"]);
                dp.Label      = "商机数:" + dr["cnnChanceCount"].ToString() + "\n比例:" + dr["cnnRate"].ToString() + "%";
                dp.LegendText = dr["cnvcChanceSpeedComments"].ToString();
                dp.LegendHref = "javascript:__doPostBack('bindgrid','" + dr["cnvcChanceSpeed"].ToString() + "');";

                Chart1.Series["Series1"].Points.Add(dp);

                Dundas.Charting.WebControl.DataPoint dp2 = new Dundas.Charting.WebControl.DataPoint();
                dp2.XValue     = Convert.ToDouble(dr["cnnChanceSum"]);
                dp2.YValues[0] = Convert.ToDouble(dr["cnnSumRate"]);
                dp2.Label      = "金额:" + dr["cnnChanceSum"].ToString() + "万元\n比例:" + dr["cnnSumRate"].ToString() + "%";
                dp2.LegendText = dr["cnvcChanceSpeedComments"].ToString();
                dp2.LegendHref = "javascript:__doPostBack('bindgrid','" + dr["cnvcChanceSpeed"].ToString() + "');";

                Chart2.Series["Series1"].Points.Add(dp2);
            }


            Chart1.Series[0]["FunnelPointGap"] = "5";
            Chart2.Series[0]["FunnelPointGap"] = "5";

            this.DataGrid1.DataSource = null;
            this.DataGrid1.DataBind();
        }
Exemplo n.º 2
0
        void DrawChart3()
        {
            var investigationId = int.Parse(DropDownList1.SelectedValue);
            var beginDate       = new DateTime(int.Parse(DropY1.SelectedValue), 1, 1);
            var endDate         = new DateTime(int.Parse(DropY2.SelectedValue), 12, 31);
            var ct        = CheckAutoYears.Checked ? new ChartTools(investigationId, Chart2, 0, 0) : new ChartTools(investigationId, beginDate, endDate, Chart2, 0, 0);
            var positions = new List <string>()
            {
                "mentioned in filing"
            };

            Chart2.Visible = CheckChart.Checked;
            Chart2.Width   = int.Parse(DropSize.SelectedValue);
            Chart2.Height  = (int)((Chart2.Width.Value) * 3D / 4D);
            //series are for positions
            Chart2.Series.Clear();
            var s = Chart2.Series.Add(positions[0]);

            s.ChartType  = SeriesChartType.Point.ToString();
            s.XValueType = ChartValueTypes.Date;
            Chart2.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy";
            Chart2.ChartAreas[0].AxisX.IntervalType      = DateTimeIntervalType.Years;
            Chart2.ChartAreas[0].AxisX.Interval          = 1;
            //
            var table = new LinkManager().GetIndividualCompanyLink(investigationId);

            if (CheckExcel.Checked)
            {
                AddExcelAttachment(table);
                return;
            }
            var invManager = new InvestigationManager();
            var tableI     = invManager.GetInvestigatedIndividuals(investigationId);
            var tableC     = invManager.GetInvestigatedCompanies(investigationId);
            var yIndex     = 0;
            var count      = 0;

            foreach (var company in tableC)
            {
                var inds     = 0;
                var indsList = new List <DtstCOI.investigated_individualRow>();
                foreach (var individual in tableI)
                {
                    var sort = table.company_nameColumn.ColumnName + "='"
                               + company.company_name.Replace("'", "''") + "' and "
                               + table.individual_nameColumn.ColumnName + "='"
                               + individual.individual_name.Replace("'", "''") + "'";
                    var useIndividual = false;
                    var links         = new DataView(table, sort, "link_date asc",
                                                     DataViewRowState.CurrentRows);
                    if (links.Count == 0)
                    {
                        continue;
                    }
                    foreach (DataRowView rv in links)
                    {
                        var link = (DtstCOI.individual_company_linkRow)rv.Row;
                        if (!ct.IsPointUsable(link))
                        {
                            continue;
                        }
                        useIndividual = true;
                    }
                    if (useIndividual)
                    {
                        inds++; indsList.Add(individual);
                    }
                }
                if (inds <= 1)
                {
                    continue;
                }
                foreach (var individual in indsList)
                {
                    var sort = table.company_nameColumn.ColumnName + "='"
                               + company.company_name.Replace("'", "''") + "' and "
                               + table.individual_nameColumn.ColumnName + "='"
                               + individual.individual_name.Replace("'", "''") + "'";
                    var links = new DataView(table, sort, "link_date asc", DataViewRowState.CurrentRows);
                    if (links.Count == 0)
                    {
                        continue;
                    }
                    yIndex++;
                    Chart2.ChartAreas[0].AxisY.CustomLabels.Add(yIndex - 0.5, yIndex + 0.5,
                                                                individual.individual_name);
                    foreach (DataRowView rv in links)
                    {
                        var link = (DtstCOI.individual_company_linkRow)rv.Row;
                        if (!ct.IsPointUsable(link))
                        {
                            continue;
                        }
                        string position;
                        int    positionSeriesIndex;
                        if (link.IspositionNull() || link.position.Trim() == string.Empty)
                        {
                            position            = positions[0];
                            positionSeriesIndex = 0;
                        }
                        else
                        {
                            position            = link.position.Trim().ToLower();
                            positionSeriesIndex = positions.IndexOf(position);
                            if (positionSeriesIndex == -1)
                            {
                                s            = Chart2.Series.Add(position);
                                s.ChartType  = SeriesChartType.Point.ToString();
                                s.XValueType = ChartValueTypes.Date;
                                s.MarkerSize = (int)Chart2.Height.Value / 100;
                                positions.Add(position);
                                positionSeriesIndex = positions.Count - 1;
                            }
                        }
                        var point = new Dundas.Charting.WebControl.DataPoint();
                        point.SetValueXY(link.link_date, yIndex);
                        Chart2.Series[positionSeriesIndex].Points.Add(point);
                        count++;
                    }
                }
                yIndex++;
                Chart2.ChartAreas[0].AxisY.CustomLabels.Add(yIndex - 0.5, yIndex + 0.5, company.company_name);
                Chart2.ChartAreas[0].AxisY.StripLines.Add(new StripLine
                {
                    IntervalOffset = yIndex - 0.1,
                    BackColor      = Color.LightGray,
                    StripWidth     = 0.2
                });
            }
            yIndex++;
            Chart2.ChartAreas[0].AxisY.Maximum = yIndex;
            Chart2.Titles[1].Text += " " + count + " matches found";
            if (!CheckData.Checked)
            {
                return;
            }
            GridView1.DataSource = table;
            GridView1.DataBind();
        }