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);
        }
예제 #2
0
        private void buildHorizontalChart(string StudentYear)
        {
            String        myConnect = ConfigurationManager.ConnectionStrings["EADPConnectionString2"].ToString();
            SqlConnection myConn    = new SqlConnection(myConnect);

            DataSet ds = new DataSet();

            String strSQL = "SELECT  Count(i.AdminNo) NoOfStudents, Location FROM [interview] i ";

            strSQL += "INNER JOIN trip t on i.tripid = t.tripid ";
            strSQL += "INNER JOIN register r on i.AdminNo = r.AdminNo ";
            strSQL += "INNER JOIN Student s on r.adminNo = s.adminno ";

            SqlDataAdapter da;

            DateTime now = DateTime.Now;

            if (!StudentYear.Equals("All"))
            {
                if (now.Month > 4)
                {
                    int studentyr = int.Parse(StudentYear);
                    studentyr--;
                    strSQL += "WHERE ((year(getdate()) - 2000) - convert(int, SUBSTRING(i.AdminNo, 1, 2))) = @paraStudentYear Group By [Location] ";
                    //check
                    da = new SqlDataAdapter(strSQL.ToString(), myConn);
                    da.SelectCommand.Parameters.AddWithValue("@paraStudentYear", studentyr);
                }
                else
                {
                    strSQL += "WHERE ((year(getdate()) - 2000) - convert(int, SUBSTRING(i.AdminNo, 1, 2))) = @paraStudentYear Group By [Location] ";
                    //check
                    da = new SqlDataAdapter(strSQL.ToString(), myConn);
                    da.SelectCommand.Parameters.AddWithValue("@paraStudentYear", StudentYear);
                }
            }
            else
            {
                strSQL += "Group By [Location] ";
                da      = new SqlDataAdapter(strSQL.ToString(), myConn);
            }


            da.Fill(ds, "tripTable");

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

            string imgPath4 = HttpContext.Current.Request.PhysicalApplicationPath + tmpChartName4;

            Chart4.SaveImage(imgPath4);
        }