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 buildLineChart(string Diploma, string StudentYear)
        {
            String        myConnect = ConfigurationManager.ConnectionStrings["EADPConnectionString2"].ToString();
            SqlConnection myConn    = new SqlConnection(myConnect);

            DataSet ds = new DataSet();

            SqlDataAdapter da;

            DateTime now = DateTime.Now;


            String strSQL = "SELECT COUNT(i.adminno) NoOfStudents, DATENAME(month, TripEnd) AS [Month] 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 ";

            if (!Diploma.Equals("All"))
            {
                strSQL += "WHERE Diploma = @paraDiploma and studentchoice = 'accepted' and (GETDATE() > TripEnd) ";
                da      = new SqlDataAdapter(strSQL.ToString(), myConn);

                if (!StudentYear.Equals("All"))
                {
                    if (now.Month > 4)
                    {
                        int studentyr = int.Parse(StudentYear);
                        studentyr--;
                        strSQL += "AND ((year(getdate()) - 2000) - convert(int, SUBSTRING(i.AdminNo, 1, 2))) = @paraStudentYear Group By [TripEnd] ";
                        //check
                        da = new SqlDataAdapter(strSQL.ToString(), myConn);
                        da.SelectCommand.Parameters.AddWithValue("@paraStudentYear", studentyr);
                    }
                    else
                    {
                        strSQL += "AND ((year(getdate()) - 2000) - convert(int, SUBSTRING(i.AdminNo, 1, 2))) = @paraStudentYear Group By [TripEnd] ";
                        //check
                        da = new SqlDataAdapter(strSQL.ToString(), myConn);
                        da.SelectCommand.Parameters.AddWithValue("@paraStudentYear", StudentYear);
                    }
                }
                else
                {
                    strSQL += "where studentchoice = 'accepted' and (GETDATE() > TripEnd) ";
                    strSQL += "Group By DATENAME(month, TripEnd) ";
                    da      = new SqlDataAdapter(strSQL.ToString(), myConn);
                }
                da.SelectCommand.Parameters.AddWithValue("@paraDiploma", Diploma);
            }

            else 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 [TripEnd] ";
                    //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 [TripEnd] ";
                    //check
                    da = new SqlDataAdapter(strSQL.ToString(), myConn);
                    da.SelectCommand.Parameters.AddWithValue("@paraStudentYear", StudentYear);
                }
            }

            else
            {
                strSQL += "Group By DATENAME(month, TripEnd) ";
                da      = new SqlDataAdapter(strSQL.ToString(), myConn);
            }
            da.Fill(ds, "tripTable");

            Chart3.DataSource = ds;
            Chart3.DataBind();
            string imgPathing2 = HttpContext.Current.Request.PhysicalApplicationPath + tmpChartName3;

            Chart3.SaveImage(imgPathing2);
        }