예제 #1
0
    protected void btnExportToExcel_Click(object sender, EventArgs e)
    {
        try
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment;filename=(" + Session["SYTerm"].ToString().Replace(" ", string.Empty) + ")" + Session["Filename"] + ".xls");
            Response.ContentType = "application/vnd.xls";
            System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);

            if (GridViewZ.Visible == true)
            {
                GridViewZ.RenderControl(htmlWrite);
            }
            else if (GridViewEE.Visible == true)
            {
                GridViewEE.RenderControl(htmlWrite);
            }
            else if (GridViewFF.Visible == true)
            {
                GridViewFF.RenderControl(htmlWrite);
            }
            else if (GridViewGG.Visible == true)
            {
                GridViewGG.RenderControl(htmlWrite);
            }
            else if (GridViewR.Visible == true)
            {
                GridViewR.RenderControl(htmlWrite);
            }
            else if (GridViewS.Visible == true)
            {
                GridViewS.RenderControl(htmlWrite);
            }
            else if (GridViewX.Visible == true)
            {
                GridViewX.RenderControl(htmlWrite);
            }

            /*
             * else if(GridViewY.Visible == true)
             * {
             *  GridViewY.RenderControl(htmlWrite);
             * }*/

            Response.Write(stringWrite.ToString());
            Response.End();
        }
        catch (Exception ex)
        {
        }
    }
예제 #2
0
    public void reportForZ(string status)//SYTerm Peer Adviser 2 and Peer Adviser 3
    {
        SqlCommand cmd = new SqlCommand("SELECT dbo.Student.StudentName, dbo.Student.StudentNumber, dbo.StudentStatus.Program, (SELECT CASE WHEN dbo.StudentGrades.Grade <> 5.00 THEN 'PASSED' ELSE 'FAILED' END) AS Remarks, dbo.StudentGrades.SYTerm, (SELECT COUNT(*) FROM [PeerAdviserConsultations] WHERE [StudentNumber] = dbo.Student.StudentNumber and [CourseCode] = dbo.PeerAdviserConsultations.CourseCode and Status = 'DONE') AS COUNT, dbo.PeerAdviserConsultations.CourseCode, dbo.StudentGrades.Grade, CONVERT(varchar,dbo.PeerAdviserConsultations.ConsultationDate,101) AS ConsultationDate, dbo.PeerAdviserConsultations.TimeStart, dbo.PeerAdviserConsultations.TimeEnd, (SELECT dbo.Student.StudentName FROM dbo.PeerAdviser INNER JOIN dbo.Student ON dbo.PeerAdviser.StudentNumber = dbo.Student.StudentNumber where dbo.PeerAdviser.PAdviserId = dbo.PeerAdviserConsultations.PAdviserId) AS PAdviserId, dbo.StudentStatus.AcademicStatus FROM dbo.PeerAdviserConsultations INNER JOIN dbo.StudentGrades ON (dbo.PeerAdviserConsultations.StudentNumber = dbo.StudentGrades.StudentNumber and dbo.PeerAdviserConsultations.CourseCode = dbo.StudentGrades.CourseCode) INNER JOIN dbo.Student ON dbo.StudentGrades.StudentNumber = dbo.Student.StudentNumber INNER JOIN dbo.StudentStatus ON dbo.Student.StudentNumber = dbo.StudentStatus.StudentNumber WHERE dbo.PeerAdviserConsultations.Status = 'DONE' and dbo.StudentStatus.CurrentStatus = '" + status + "' ORDER BY StudentName, CourseCode");

        GridViewZ.DataSource = Class2.getDataSet(cmd);
        GridViewZ.DataBind();

        for (int rowIndex = GridViewZ.Rows.Count - 2; rowIndex >= 0; rowIndex--)
        {
            GridViewRow row         = GridViewZ.Rows[rowIndex];
            GridViewRow previousRow = GridViewZ.Rows[rowIndex + 1];

            if (row.Cells[2].Text == previousRow.Cells[2].Text && row.Cells[0].Text == previousRow.Cells[0].Text && row.Cells[7].Text == previousRow.Cells[7].Text)
            {
                row.Cells[2].RowSpan = previousRow.Cells[2].RowSpan < 2 ? 2 :
                                       previousRow.Cells[2].RowSpan + 1;
                previousRow.Cells[2].Visible = false;
            }
        }
    }
예제 #3
0
    protected void btnExportToPDF_Click(object sender, EventArgs e)
    {
        try
        {
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=(" + Session["SYTerm"].ToString().Replace(" ", string.Empty) + ")" + Session["Filename"] + ".pdf");
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            if (GridViewZ.Visible == true)
            {
                GridViewZ.RenderControl(hw);
            }
            else if (GridViewEE.Visible == true)
            {
                /*GridViewEE.AllowPaging = false;
                 * GridViewEE.DataBind();*/
                GridViewEE.RenderControl(hw);
            }
            else if (GridViewFF.Visible == true)
            {
                GridViewFF.RenderControl(hw);
            }
            else if (GridViewGG.Visible == true)
            {
                GridViewGG.RenderControl(hw);
            }
            else if (GridViewR.Visible == true)
            {
                GridViewR.RenderControl(hw);
            }
            else if (GridViewS.Visible == true)
            {
                GridViewS.RenderControl(hw);
            }
            else if (GridViewX.Visible == true)
            {
                GridViewX.RenderControl(hw);
            }

            /*
             * else if(GridViewY.Visible == true)
             * {
             *  GridViewY.RenderControl(htmlWrite);
             * }*/

            StringReader sr         = new StringReader(sw.ToString());
            Document     pdfDoc     = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
            HTMLWorker   htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();
            Response.Write(pdfDoc);
            Response.End();
        }
        catch (Exception ex)
        {
        }
    }