예제 #1
0
    protected void btnShow_Click(object sender, EventArgs e)
    {
        AlertWarning.Visible = false;
        AlertRec.Visible     = false;

        if (ddlExamSession.SelectedIndex == 0 || ddlExamYear.SelectedIndex == 0)
        {
            divGrid.Visible      = false;
            AlertWarning.Visible = true;
        }
        else
        {
            AlertWarning.Visible = false;
            plrep.Ind            = 8;
            plrep.Session        = ddlExamSession.SelectedValue;
            plrep.ExamYear       = ddlExamYear.SelectedItem.Text;
            dtgrid = Blrep.MISReport(plrep);

            if (dtgrid.Rows.Count > 1)
            {
                divGrid.Visible     = true;
                lblTotalPage.Text   = " - " + dtgrid.Rows[Convert.ToInt32(dtgrid.Rows.Count - 1)]["TotalPages"].ToString();
                lblPunchedPage.Text = " - " + dtgrid.Rows[Convert.ToInt32(dtgrid.Rows.Count - 1)]["PunchedPages"].ToString();
                lblDiff.Text        = " - " + dtgrid.Rows[Convert.ToInt32(dtgrid.Rows.Count - 1)]["Diff"].ToString();
                lblRegNo.Text       = " - " + dtgrid.Rows[Convert.ToInt32(dtgrid.Rows.Count - 1)]["RegisterNo"].ToString();
                dtgrid.Rows.RemoveAt(Convert.ToInt32(dtgrid.Rows.Count - 1));
                dtgrid.Columns.Remove("FacultyCD");
                dtgrid.Columns.Remove("Ctrl");
                dtgrid.Columns.Remove("TRType");
                GrdMis.DataSource = dtgrid;
                GrdMis.DataBind();
                //GrdMis.Columns[2].ItemStyle.Width = 50;
            }
            else
            {
                divGrid.Visible  = false;
                AlertRec.Visible = true;
            }
            #region
            //DataTable grdDT = new DataTable();
            //grdDT = dt;
            //grdDT.Columns.Add("Diff");
            //int i = 0; Int32 SumTotalPages = 0, SumPunPages = 0 , SumDiff = 0;
            //foreach (DataRow item in dt.Rows)
            //{
            //    SumPunPages = SumPunPages + Convert.ToInt32(item["PunchedPages"]);
            //    SumTotalPages = SumTotalPages + Convert.ToInt32(item["TotalPages"]);
            //    grdDT.Rows[i]["Diff"] = Convert.ToInt32(item["TotalPages"]) - Convert.ToInt32(item["PunchedPages"]);
            //    SumDiff = SumDiff + Convert.ToInt32(grdDT.Rows[i]["Diff"]);
            //    i++;
            //}
            //grdDT.Columns.Remove("FacultyCD");
            //grdDT.Columns.Remove("Ctrl");
            //grdDT.Columns.Remove("TRType");
            //grdDT.Columns.Remove("ImgPath");
            //grdDT.Columns["RecID"].SetOrdinal(0);
            //int relationshipCount = grdDT
            //                        .AsEnumerable()
            //                        .Select(r => r.ItemArray[4])//r.Field<string>("RegisterNo"))
            //                        .Distinct()
            //                        .Count();
            //grdDT.Rows.Add();
            //grdDT.Rows[Convert.ToInt32(dt.Rows.Count - 1)]["TotalPages"] = SumTotalPages;
            //grdDT.Rows[Convert.ToInt32(dt.Rows.Count - 1)]["PunchedPages"] = SumPunPages;
            //grdDT.Rows[Convert.ToInt32(dt.Rows.Count - 1)]["Diff"] = SumDiff;
            //grdDT.Rows[Convert.ToInt32(dt.Rows.Count - 1)]["RegisterNo"] = relationshipCount-1;
            //#region dt column header change
            ////grdDT.Columns["RecID"].ColumnName = "Rec Id";
            ////grdDT.Columns["FacultyName"].ColumnName = "Faculty Name";
            ////grdDT.Columns["ExamName"].ColumnName = "Rec Id";
            ////grdDT.Columns["TRTypeDesc"].ColumnName = "Rec Id";
            ////grdDT.Columns["RegisterNo"].ColumnName = "Rec Id";
            ////grdDT.Columns["TotalPages"].ColumnName = "Rec Id";
            ////grdDT.Columns["PunchedPages"].ColumnName = "Rec Id";
            ////grdDT.Columns["Diff"].ColumnName = "Rec Id";
            ////RemoveDuplicates(grdDT);
            //#endregion
            //GrdMis.DataSource = grdDT;
            //GrdMis.DataBind();
            //GrdMis.HeaderRow.Cells[0].Text = "Rec Id";
            //GrdMis.HeaderRow.Cells[1].Text = "Faculty Name";
            //GrdMis.HeaderRow.Cells[2].Text = "Exam Name";
            //GrdMis.HeaderRow.Cells[3].Text = "TR Type Desc";
            //GrdMis.HeaderRow.Cells[4].Text = "Register No.";
            //GrdMis.HeaderRow.Cells[5].Text = "Total Pages";
            //GrdMis.HeaderRow.Cells[6].Text = "Punched Pages";
            //GrdMis.HeaderRow.Cells[7].Text = "Diff.";
            //GrdMis.Columns[2].ItemStyle.Width = 5;

            //GrdMis.HeaderRow.Cells[0].Width = 50;
            //GrdMis.HeaderRow.Cells[1].Width = 150;
            //GrdMis.HeaderRow.Cells[2].Width = 200;
            //GrdMis.HeaderRow.Cells[3].Width = 121;
            //GrdMis.HeaderRow.Cells[4].Width = 121;
            //GrdMis.HeaderRow.Cells[5].Width = 121;
            //GrdMis.HeaderRow.Cells[6].Width = 121;
            //GrdMis.HeaderRow.Cells[7].Width = 43;
            #endregion
        }
    }
예제 #2
0
    protected void btnprint1_Click(object sender, EventArgs e)
    {
        GrdMis.UseAccessibleHeader    = true;
        GrdMis.HeaderRow.TableSection = TableRowSection.TableHeader;
        GrdMis.FooterRow.TableSection = TableRowSection.TableFooter;

        string footer = "Register No. " + lblRegNo.Text + "   Total Pages" + lblTotalPage.Text + "   Punched Pages" + lblPunchedPage.Text + "   Diff" + lblDiff.Text;

        StringWriter   sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        GrdMis.RenderControl(hw);
        string        gridHTML = sw.ToString().Replace("\"", "'").Replace(System.Environment.NewLine, "");
        StringBuilder sb       = new StringBuilder();

        //////////////////////////////////////////
        string Head = "Data Entry Report For " + ddlExamSession.SelectedItem.Text + "-" + ddlExamYear.SelectedItem.Text;

        sb.Append("<script type = 'text/javascript'>");
        sb.Append("window.onload = new function(){");
        sb.Append("var printWin = window.open('', '', 'left=0");
        sb.Append("left=100,top=200,right=100,bottom=300,width=700,height=500,status=0');");
        sb.Append("printWin.document.write(\"");
        sb.Append("<html>");
        sb.Append("<head>");
        sb.Append("<style type='text/css'>");
        sb.Append("@media print {" +
                  "thead { display: table-header-group,inline; }" +
                  "}" +
                  //"div.chapter, div.appendix {page-break-after: always;}"+
                  "p{ text-align:center;" + "font-size:large; " +
                  "font-family:'Calibri';" +
                  "color:black;" + "margin-left:120px;}" +
                  ".amr{ text-align:center;" + "font-size:x-large; " +
                  "font-family:'Calibri';" +
                  "color:black;" + "margin-left:105px;}"
                  );
        sb.Append("</style>");
        sb.Append("</head>");
        sb.Append("<body>");
        sb.Append("<table>");
        sb.Append("<thead><tr><td>" +
                  "<div>" +
                  "<table>" +
                  "<tr>" +
                  "<td rowspan='3'>" +
                  "<div>" +
                  "<img class='logo' src='bootstrap-3.3.6-dist/images/logo.png' Width='60px' Height='60px'  />" +                       //Width='50px' Height='50px'
                  "</div>" +
                  "</td>" +

                  "</tr>" +
                  "<tr>" +
                  "<td>" +
                  "<p class='amr'>Sant Gadge Baba Amravati University</p>" +
                  "</td>" +
                  "</tr>" +
                  "<tr>" +
                  "<td>" +
                  "<div>" +

                  "<p>" + Head + "</p>" +
                  "</div>" +
                  "</td>" +
                  "</tr>" +
                  "</table>" +
                  "</div>" +
                  "</td></tr></thead>"
                  );
        sb.Append("<tbody><tr><td>");
        sb.Append(gridHTML);
        sb.Append("</td></tr></tbody>");
        sb.Append("<tfoot><tr><td>" + footer + "</td></tr></tfoot>");
        sb.Append("</table>");
        sb.Append("</body>");
        sb.Append("</html>");

        sb.Append("\");");
        sb.Append("printWin.document.close();");
        sb.Append("printWin.focus();");
        sb.Append("printWin.print();");
        sb.Append("printWin.close();");
        sb.Append("};");
        sb.Append("</script>");
        ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
        GrdMis.DataBind();
    }