Example #1
0
        private void btn_TambahPoint_Click(object sender, EventArgs e)
        {
            siswa.setNIS(txt_CARINIS.Text);
            sanksi.setKodeAturan(txtSANKSI);
            siswa.setPoint(Int16.Parse(txtPOINT.Text));

            hasil = siswaDao.UpdatePointSiswa(siswa, sanksi);

            if (hasil == true)
            {
                Sukses y = new Sukses();
                y.Show();
            }
            else
            {
                View.Gagal n = new View.Gagal();
                n.Show();
            }
        }
Example #2
0
        private void btn_HAPUS_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Apakah Anda Yakin Menghapus Data Ini ? ", "Informasi");
            hasil = siswaDao.DeleteSiswa(txt_TAMBAHNIS.Text);

            if (hasil == true)
            {
                Sukses SK = new Sukses();
                SK.Show();
                this.Close();
            }

            else
            {
                MessageBox.Show("Gagal");
            }

            ucsis = new UC_Siswa();
            ucsis.TampilDataSiswa();
        }
Example #3
0
        private void btn_export_Click_1(object sender, EventArgs e)
        {
            if (txt_lokasi.Text == "")
            {
                View.Gagal GGL = new View.Gagal();
                GGL.Show();
            }
            else
            {
                Paragraph prg   = new Paragraph();
                Document  doc   = new Document(iTextSharp.text.PageSize.A4, 40, 40, 40, 10);
                PdfWriter write = PdfWriter.GetInstance(doc, new FileStream(txt_lokasi.Text, FileMode.Create));

                doc.Open();

                // Mempersiapkan font untuk judul dan table
                iTextSharp.text.Font fonttitle = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 14, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                iTextSharp.text.Font fonttable = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

                // Membuat judul

                prg.Alignment    = Element.ALIGN_CENTER;
                prg.SpacingAfter = 5.0F;
                // Menambahkan paragraph ke pdfdocument
                doc.Add(prg);

                // Membuat table
                PdfPTable pdftbl = new PdfPTable(dgv.Columns.Count);
                // Lebar table
                pdftbl.TotalWidth  = 500.0F;
                pdftbl.LockedWidth = true;

                Single[] widths = new Single[dgv.Columns.Count];
                for (int i = 0; i <= dgv.Columns.Count - 1; i++)
                {
                    widths[i] = 1.0F;
                }
                pdftbl.SetWidths(widths);
                // Alignment table 0 = kiri 1 = tengah 2 = kanan
                pdftbl.HorizontalAlignment = 0;
                pdftbl.SpacingBefore       = 5.0F;

                // Mendeklarasikan pdfcell
                PdfPCell pdfcell = new PdfPCell();

                // Membuat header table pdf
                for (int i = 0; i <= dgv.Columns.Count - 1; i++)
                {
                    pdfcell = new PdfPCell(new Phrase(new Chunk(dgv.Columns[i].HeaderText, fonttable)));
                    // Alignment header table
                    pdfcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    // Menambahkan cell ke pdftable
                    pdftbl.AddCell(pdfcell);
                }

                for (int i = 0; i <= dgv.Rows.Count - 2; i++)
                {
                    for (int j = 0; j <= dgv.Columns.Count - 1; j++)
                    {
                        pdfcell = new PdfPCell(new Phrase(dgv[j, i].Value.ToString(), fonttable));
                        // Alignment data pada table
                        pdfcell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                        // Menambah cell ke pdftable
                        pdftbl.AddCell(pdfcell);
                    }
                }

                // Menambahkan pdftable ke pdfdocument
                doc.Add(pdftbl);

                doc.Close();

                Sukses SK = new Sukses();
                SK.Show();
            }
        }