private void ImageToPdf(Document myDocument, out System.IO.MemoryStream stream, out iTextSharp.text.Image gif, int chart)
        {
            stream = new System.IO.MemoryStream();


            switch (chart)
            {
            case 1:
                Chart1.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                break;

            case 2:
                Chart2.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                break;

            case 3:
                Chart3.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                break;

            case 4:
                Chart4.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                break;

            case 5:
                Chart5.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                break;
            }


            Chart1.SaveImage(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
            gif           = iTextSharp.text.Image.GetInstance(stream.ToArray());
            gif.Alignment = Element.ALIGN_CENTER;
            //gif.ScaleAbsolute(10, 10);
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     Chart1.SaveImage(Server.MapPath("../chartImage/") + "BarChart.JPG");
     Chart2.SaveImage(Server.MapPath("../chartImage/") + "PChart.JPG");
 }
예제 #3
0
        private void buildBarChart(string country, string type, DateTime dateStart, DateTime dateEnd)
        {
            String        myConnect = ConfigurationManager.ConnectionStrings["EADPConnectionString2"].ToString();
            SqlConnection myConn    = new SqlConnection(myConnect);

            DataSet ds = new DataSet();

            String strSQL = "SELECT location, avg(cost) as cost FROM [dbo].[Trip] ";

            if (!country.Equals("All"))
            {
                strSQL += "where location = @paraCountry ";
                strSQL += "and status != 'Cancelled' ";
            }

            if (!type.Equals("All") && (!country.Equals("All")))
            {
                strSQL += "and triptype = @paratype ";
                strSQL += "and status != 'Cancelled' ";
            }
            else if (!type.Equals("All") && (country.Equals("All")))
            {
                strSQL += "where triptype = @paratype ";
                strSQL += "and status != 'Cancelled' ";
            }

            if ((!dateStart.Equals("") || (!dateEnd.Equals(""))) && (country.Equals("All")) && (type.Equals("All")))
            {
                strSQL += "where TRIPSTART BETWEEN @paradateStart and @paradateEnd ";
                strSQL += "and status != 'Cancelled' ";
            }
            else if ((!dateStart.Equals("") || (!dateEnd.Equals(""))) && (!country.Equals("All")) && (type.Equals("All")))
            {
                strSQL += "and TRIPSTART BETWEEN @paradateStart and @paradateEnd ";
                strSQL += "and status != 'Cancelled' ";
            }
            else if ((!dateStart.Equals("") || (!dateEnd.Equals(""))) && (country.Equals("All")) && (!type.Equals("All")))
            {
                strSQL += "and TRIPSTART BETWEEN @paradateStart and @paradateEnd ";
                strSQL += "and status != 'Cancelled' ";
            }
            else if ((!dateStart.Equals("") || (!dateEnd.Equals(""))) && (!country.Equals("All")) && (!type.Equals("All")))
            {
                strSQL += "and TRIPSTART BETWEEN @paradateStart and @paradateEnd ";
                strSQL += "and status != 'Cancelled' ";
            }


            strSQL += "group by location";

            SqlDataAdapter da = new SqlDataAdapter(strSQL.ToString(), myConn);

            if (!country.Equals("All"))
            {
                da.SelectCommand.Parameters.AddWithValue("@paraCountry", country);
            }

            if (!type.Equals("All"))
            {
                da.SelectCommand.Parameters.AddWithValue("@paratype", type);
            }

            if (!dateStart.Equals(""))
            {
                da.SelectCommand.Parameters.AddWithValue("@paradateStart", dateStart);
            }

            if (!dateEnd.Equals(""))
            {
                da.SelectCommand.Parameters.AddWithValue("@paradateEnd", dateEnd);
            }

            da.Fill(ds, "tripTable");

            Chart2.DataSource = ds;
            Chart2.DataBind();

            string imgPathing2 = HttpContext.Current.Request.PhysicalApplicationPath + tmpChartName2;

            Chart2.SaveImage(imgPathing2);
        }