Exemplo n.º 1
0
        private void btnAtualizar_Click(object sender, EventArgs e)
        {
            ClsAlternativa mObjAlternativa = new ClsAlternativa()
            {
                Id_Questao = Convert.ToInt32(gridQuestao.CurrentRow.Cells[0].Value)
            };

            mObjAlternativa.Selecionar();

            DataSet Ds = new DataSet();

            Ds = mObjAlternativa.DSAlternariva;

            frmQuestao frm = new frmQuestao()
            {
                aux = 2
            };

            frm.lblId_Questao.Text = gridQuestao.CurrentRow.Cells[0].Value.ToString();
            frm.txtPergunta.Text   = gridQuestao.CurrentRow.Cells[1].Value.ToString();

            frm.lblId_Alternativa1.Text = Ds.Tables[0].Rows[0][0].ToString();
            frm.txtAlternativa1.Text    = Ds.Tables[0].Rows[0]["Ds_Alternativa"].ToString();
            frm.chk1.Checked            = Convert.ToBoolean(Ds.Tables[0].Rows[0]["St_Verificacao"]);

            frm.lblId_Alternativa2.Text = Ds.Tables[0].Rows[1][0].ToString();
            frm.txtAlternativa2.Text    = Ds.Tables[0].Rows[1]["Ds_Alternativa"].ToString();
            frm.chk2.Checked            = Convert.ToBoolean(Ds.Tables[0].Rows[1]["St_Verificacao"]);

            frm.lblId_Alternativa3.Text = Ds.Tables[0].Rows[2][0].ToString();
            frm.txtAlternativa3.Text    = Ds.Tables[0].Rows[2]["Ds_Alternativa"].ToString();
            frm.chk3.Checked            = Convert.ToBoolean(Ds.Tables[0].Rows[2]["St_Verificacao"]);

            frm.lblId_Alternativa4.Text = Ds.Tables[0].Rows[3][0].ToString();
            frm.txtAlternativa4.Text    = Ds.Tables[0].Rows[3]["Ds_Alternativa"].ToString();
            frm.chk4.Checked            = Convert.ToBoolean(Ds.Tables[0].Rows[3]["St_Verificacao"]);

            frm.lblId_Alternativa5.Text = Ds.Tables[0].Rows[4][0].ToString();
            frm.txtAlternativa5.Text    = Ds.Tables[0].Rows[4]["Ds_Alternativa"].ToString();
            frm.chk5.Checked            = Convert.ToBoolean(Ds.Tables[0].Rows[4]["St_Verificacao"]);

            frm.txtJustificativa.Text = gridQuestao.CurrentRow.Cells[2].Value.ToString();


            frm.ShowDialog();
        }
Exemplo n.º 2
0
        public void ImprimirProva(int IdProva)
        {
            ClsProva mObjProva = new ClsProva
            {
                Id_Prova = IdProva
            };

            mObjProva.Selecionar();

            var Header = "<body style='font-family: sans-serif;'" +
                         "<div id = 'Header' style = 'padding: 5px;'>" +
                         "<h2> Instituto Federal de São Paulo - Campus Capivari - " + DateTime.Now.ToShortDateString() + "</h2>" +
                         "<h3> Professor - " + mObjProva.Id_Prontuario.ToString() + "</h3>" +
                         "<h3> Prova - " + mObjProva.Nm_Prova + "</h3>" +
                         "<p style = 'font-weight: bold;'> Nome:________________________________________________ Prontuario:___________ Nota:______ </p>" +
                         "</div>" +
                         "<div id='Body' style='border: 1px solid black; margin-top: 10px; padding:10px'>";

            mObjProva.ImprimiQuestaoProva();
            DataSet Ds = mObjProva.DSProva;


            ClsQuestao     mObjQuestao     = new ClsQuestao();
            ClsAlternativa mObjAlternativa = new ClsAlternativa();

            var Body     = "";
            int contador = 0;

            foreach (DataRow Questao in Ds.Tables[0].Rows)
            {
                contador++;
                mObjQuestao.Id_Questao = Convert.ToInt32(Questao[1]);
                mObjQuestao.Selecionar();
                mObjAlternativa.Id_Questao = Convert.ToInt32(Questao[1]);
                mObjAlternativa.Selecionar();
                DataSet DsAlternativa = mObjAlternativa.DSAlternariva;


                var QuestaoPDF = "<div id='questao' style=''>" +
                                 "<div id='Enunciado'>" + contador.ToString() + " - " + mObjQuestao.Ds_Pergunta + " </div>" +
                                 "<div id='Respostas' style='margin-top: 5px;'>" +
                                 "A - " + DsAlternativa.Tables[0].Rows[0][1].ToString() + " <br>" +
                                 "B - " + DsAlternativa.Tables[0].Rows[1][1].ToString() + " <br>" +
                                 "C - " + DsAlternativa.Tables[0].Rows[2][1].ToString() + " <br>" +
                                 "D - " + DsAlternativa.Tables[0].Rows[3][1].ToString() + " <br>" +
                                 "E - " + DsAlternativa.Tables[0].Rows[4][1].ToString() + " <br>" +
                                 "</div>" +
                                 "</div>" +
                                 "<div id='Divider' style='width: auto; height: 5px; border-top:1px dashed black; margin:5px 0 5px 0;'></div>";
                Body += QuestaoPDF;
            }

            var Footer = "</div>" +
                         "</body>";

            var Rendere = new IronPdf.HtmlToPdf();

            Rendere.PrintOptions.Title        = "Prova [NOME PROVA]";
            Rendere.PrintOptions.MarginTop    = 10;
            Rendere.PrintOptions.MarginLeft   = 10;
            Rendere.PrintOptions.MarginRight  = 10;
            Rendere.PrintOptions.MarginBottom = 10;

            Rendere.PrintOptions.Footer.DrawDividerLine = true;
            Rendere.PrintOptions.Footer.FontFamily      = "Arial";
            Rendere.PrintOptions.Footer.FontSize        = 10;
            Rendere.PrintOptions.Footer.LeftText        = "{date} {time}";
            Rendere.PrintOptions.Footer.RightText       = "{page} of {total-pages}";

            var PDF        = Rendere.RenderHtmlAsPdf(Header + Body + Footer);
            var OutputPath = "Prova " + mObjProva.Nm_Prova + ".pdf";

            PDF.SaveAs(OutputPath);

            System.Diagnostics.Process.Start(OutputPath);
        }