LAMPIRAN PROGRAM
Imports System.Data.OleDb
Public Class FormTampilan
Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=tugasakhir.accdb")
Dim user As String = txtUsername.Text Dim pass As String = txtPassword.Text
If user.Length <= 0 Thens
MsgBox("Masukkan username", MsgBoxStyle.Critical, "Perhatian") ElseIf pass.Length <= 0 Then
MsgBox("Masukkan password", MsgBoxStyle.Critical, "Perhatian") Else
Try
cn.Open()
Dim cmd As OleDbCommand = cn.CreateCommand
cmd.CommandText = "SELECT * FROM TblBuatAkun WHERE Nama='" & txtUsername.Text & "' AND Pass='" & txtPassword.Text & "'"
Dim userFound As Boolean = False Dim username As String = ""
Dim dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read
userFound = True
username = dr("Nama").ToString()
End While
If userFound = True Then
FormKabKota.lblNama.Text = username.ToString() FormKabKota.Show()
Me.Hide() Else
MsgBox("Username dan passsword tidak benar!") End If
dr.Close() cmd.Dispose()
Catch ex As Exception MsgBox(ex.Message) Finally
cn.Close() End Try
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program?", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub btndaftar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
FormDaftar.Show() End Sub
Private Sub btnview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
FormView.Show() End Sub
Private Sub txtdaftar_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles
txtdaftar.LinkClicked FormDaftar.Show() End Sub
End Class
Imports System.Data Imports System.Data.OleDb
Public Class FormDaftar
Dim cn As New OleDbConnection Dim cmd As New OleDbCommand Dim dr As OleDbDataReader
Sub Data_Record() Try
Call Koneksi()
Tabel = New Data.OleDb.OleDbDataAdapter("select * from TblBuatAkun", Database)
Data = New DataSet Tabel.Fill(Data)
Record.DataSource = Data
Record.DataMember = Data.Tables(0).ToString() Catch ex As Exception
MsgBox(ex.Message) Finally
Database.Close() End Try
End Sub Sub Atur()
btndaftar.Enabled = True txtnama.Text = ""
Call Koneksi() Call Data_Record() End Sub
Private Sub FormDaftar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub btndaftar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndaftar.Click
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into
TblBuatAkun(Nama,Ttl,No_Hp,Jabatan,Pass,ConPass)" & _
"values('" & txtnama.Text & "','" & txttempat.Text & "','" & txtjabatan.Text & _
"','" & txtnohp.Text & "','" & txtpass.Text & "','" & txtpass2.Text & "')"
i = .ExecuteNonQuery .Dispose()
End With
If txtnama.Text.Length <= 0 Or txttempat.Text.Length <= 0 Or cbday.Text.Length <= 0 Or cbmonth.Text.Length <= 0 Or cbyear.Text.Length <= 0 Or txtjabatan.Text.Length <= 0 Or txtnohp.Text.Length <= 0 Or
txtpass.Text.Length <= 0 Or txtpass2.Text.Length <= 0 Then
MsgBox("Tidak boleh kosong", MsgBoxStyle.Critical, "Perhatian")
Else
FormTampilan.Show() End If
Catch ex As Exception MsgBox(ex.ToString()) Finally
If i > 0 Then
MsgBox("Data berhasi di simpan") End If
Imports System.Data.OleDb Public Class FormKabKota
Dim cn As New OleDbConnection Dim cmd As New OleDbCommand Dim dr As OleDbDataReader
Private Sub btn_next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_next.Click
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into KabKota(KdKabKot,NmKabKot)" & _ "values('" & cbKabKota.Text & "','" & txtKabKot.Text & "')" i = .ExecuteNonQuery
.Dispose() End With
Catch ex As Exception MsgBox(ex.ToString()) Finally
cn.Close() If i > 0 Then
MsgBox("Data berhasi di simpan") FormKecamatan.Show()
End If End Try
Dim kode As String = cbKabKota.Text Dim nama As String = txtKabKot.Text
If kode.Length = 0 Then
MsgBox("Tidak Boleh Kosong", MsgBoxStyle.Critical, "Perhatian") ElseIf nama.Length = 0 Then
MsgBox("Tidak Boleh Kosong", MsgBoxStyle.Critical, "Perhatian") Else
End If End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub txt_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_back.Click
Me.Close()
End Class
Imports System.Data.OleDb Public Class FormKecamatan
Dim cn As New OleDbConnection Dim cmd As New OleDbCommand Dim dr As OleDbDataReader
Private Sub btn_next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_next.Click
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into Kecamatan(NmKec,KdKabKot,NmKabKot)" & _
"values('" & txtKec.Text & "','" & cbKabKot.Text & "','" & txtKab.Text & "')"
i = .ExecuteNonQuery .Dispose()
End With
Catch ex As Exception MsgBox(ex.ToString()) Finally
cn.Close() If i > 0 Then
MsgBox("Data berhasi di simpan") FormPetugas.Show()
End If End Try
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub btn_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_back.Click
Me.Close()
FormKabKota.Show() End Sub
End Class
Dim cn As New OleDbConnection Dim cmd As New OleDbCommand Dim dr As OleDbDataReader
Private Sub nxt_next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nxt_next.Click
If txtnapet.Text.Length <= 0 Or txtnip.Text.Length <= 0 Or txtjabatan.Text.Length <= 0 Or txthp.Text.Length <= 0 Then
MsgBox("Tidak boleh kosong", MsgBoxStyle.Critical, "Perhatian") Else
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into Petugas(Nm_pet,Nip, Jabatan, Telp)" & _
"values('" & txtnapet.Text & "','" & txtnip.Text & "', '" & txtjabatan.Text & "', '" & txthp.Text & "')"
i = .ExecuteNonQuery .Dispose()
End With
Catch ex As Exception MsgBox(ex.ToString()) Finally
cn.Close() If i > 0 Then
MsgBox("Data berhasi di simpan") FormPeserta.Show()
End If End Try End If
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub btn_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_back.Click
Me.Close()
FormKecamatan.Show() End Sub
End Class
Imports System.Data.OleDb Public Class FormPeserta
Dim dr As OleDbDataReader
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtdate.ValueChanged
txtnopkb.Text = Format(txtdate.Value, "MM") End Sub
Private Sub btn_next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_next.Click
If txtnopkb.Text.Length <= 0 Or txtdate.Text.Length <= 0 Or txtnamapeserta.Text.Length <= 0 Or cmbday.Text.Length <= 0 Or cmbmonth.Text.Length <= 0 Or cmbyear.Text.Length < 0 Or
txtpendpes.Text.Length <= 0 Or txtnamasuami.Text.Length <= 0 Or txtpendsuami.Text.Length <= 0 Or txtpekerjasuami.Text.Length <= 0 Or txtpekerjapeserta.Text.Length <= 0 Or txtalamat.Text.Length <= 0 Or txt_crkb.Text.Length <= 0 Or txtnamakec.Text.Length <= 0 Or
cmbkodkab.Text.Length <= 0 Or cmbkodkab.Text.Length <= 0 Then
MsgBox("Tidak boleh kosong", MsgBoxStyle.Critical, "Perhatian") Else
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into Pasien(NoPKB, Tgl_jd_pes, nmpes, Tgl_lhr, Pen_pes, Nm_suami, Pen_suami, Pek_suami, pek_peserta, Almt, Cr_KB, Nmkec, Kd_kabkot, Nm_kabkot, bulan)" & _
"values('" & txtnopkb.Text & "','" & txtdate.Text & "', '" & txtnamapeserta.Text & "', '" & cmbday.Text & "', '" & txtpendpes.Text & "', '" & txtnamasuami.Text & "', '" & txtpendsuami.Text & "', '" &
txtpekerjasuami.Text & "', '" & txtpekerjapeserta.Text & "', '" &
txtalamat.Text & "', '" & txtcarakb.Text & "', '" & txtnamakec.Text & "', '" & cmbkodkab.Text & "', '" & txtnmkabkot.Text & "', '" & Now().Month & "')" i = .ExecuteNonQuery
.Dispose() End With
Catch ex As Exception MsgBox(ex.ToString()) Finally
cn.Close() If i > 0 Then
MsgBox("Data berhasi di simpan") FormPemeriksaan.Show()
End If End Try End If
End Sub
Private Sub btn_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Private Sub btn_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_back.Click
Me.Close()
FormPetugas.Show() End Sub
Private Sub txtnamasuami_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnamasuami.TextChanged
End Sub End Class
Imports System.Data.OleDb Public Class FormPemeriksaan Dim cn As New OleDbConnection Dim cmd As New OleDbCommand Dim dr As OleDbDataReader
Private Sub btn_fnsh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
If txtnoper.Text.Length <= 0 Or txtnapes.Text.Length <= 0 Or txtnamkec.Text.Length <= 0 Or kdkabkot.Text.Length <= 0 Or
nmkabkot.Text.Length <= 0 Or txtnapet.Text.Length <= 0 Then
MsgBox("Tidak boleh kosong", MsgBoxStyle.Critical, "Perhatian") Else
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=TugasAkhir.accdb"
Dim i As Int16 Try
cn.Open() With cmd
.Connection = cn
.CommandText = "insert into Pemeriksaan(No_per,Nm_pes, Nm_kec, Kd_kabkot, Nm_kabkot, Nm_pet)" & _
"values('" & txtnoper.Text & "','" & txtnapes.Text & "', '" & txtnamkec.Text & "', '" & kdkabkot.Text & "', '" & nmkabkot.Text & "', '" & txtnapet.Text & "')"
i = .ExecuteNonQuery .Dispose()
End With
Catch ex As Exception MsgBox(ex.ToString()) Finally
cn.Close() If i > 0 Then
MsgBox("Data berhasi di simpan") FormView.Show()
End If End Try End If
End Sub
System.EventArgs) Handles btn_cancel.Click
MsgBox("Do you want close this program", MsgBoxStyle.Information, "Warning")
Me.Close() End Sub
Private Sub btn_back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_back.Click
Me.Close()
FormPeserta.Show() End Sub
Private Sub btnview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnview.Click
FormView.Show() End Sub
Private Sub FormPemeriksaan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub txtnapes_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnapes.TextChanged
End Sub
Private Sub txtnamkec_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnamkec.TextChanged
End Sub
Private Sub txtnapet_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnapet.TextChanged
End Sub End Class
Imports System.Data.OleDb Public Class FormView
Public da As New OleDbDataAdapter Public dt As New DataTable
Dim cn As New OleDbConnection Dim cmd As New OleDbCommand
Sub ShowData(ByVal bulan As String) If bulan = "" Then
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= TugasAkhir.accdb"
Dim namaTabel As String = ""
Try
cn.Open()
With cmd
.Connection = cn
End With
da.SelectCommand = cmd dt.Clear()
da.Fill(dt)
dgvData.DataSource = dt Catch ex As Exception MsgBox(ex.Message) Finally
cn.Close() End Try
Else
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source= TugasAkhir.accdb"
Dim namaTabel As String = ""
Try
cn.Open()
With cmd
.Connection = cn
.CommandText = "SELECT * FROM pasien WHERE bulan = '" & bulan & "'"
End With
da.SelectCommand = cmd dt.Clear()
da.Fill(dt)
dgvData.DataSource = dt Catch ex As Exception MsgBox(ex.Message) Finally
cn.Close() End Try
End If End Sub
Private Sub FormView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ShowData(cbBulan.Text) End Sub
Private Sub btnTampil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTampil.Click
Dim bulan As String = cbBulan.Text Dim angka As String = ""
If bulan <> "" Then
If bulan = "Januari" Then angka = "1"
ElseIf bulan = "Februari" Then angka = "2"
ElseIf bulan = "Maret" Then angka = "3"
ElseIf bulan = "April" Then angka = "4"
ElseIf bulan = "Mei" Then angka = "5"
ElseIf bulan = "Juni" Then angka = "6"
ElseIf bulan = "Agustus" Then angka = "8"
ElseIf bulan = "September" Then angka = "9"
ElseIf bulan = "Oktober" Then angka = "10"
ElseIf bulan = "November" Then angka = "11"
ElseIf bulan = "Desember" Then End If
End If
ShowData(angka)
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Call cetakData(dgvData, "", "")
AddHandler pdCetak.BeginPrint, AddressOf djie_PrintDocument_BeginPrint
AddHandler pdCetak.PrintPage, AddressOf djie_PrintDocument_PrintPage ppdCetak = New PrintPreviewDialog
With ppdCetak
pdCetak.PrinterSettings.DefaultPageSettings.Landscape = True .Document = pdCetak
.ShowDialog() End With
End Sub End Class
'=========================================================================== ' _____ __ __ _______
'| \ |__| |__| / \
'| | | ____ __ ______ | |__| ____ ____ __ '| || ||_ || | / ____ \ \ | / \ / ___| _| |_ '| || | | || || _____| \ \ | || || |_ |_ _| '| || | | || || | __ __| \ | || || __| | | '| | | | || || \_| || | || || || | | |_ '|_____/ /__/ |__| \______/\_______/ \____/ |__| \____| '
'Editied+Uploaded By djie 2012, http://www.djiesoft.blogspot.com, mailto:djiesoft@gmail.com
'Source Code From : http://social.msdn.microsoft.com/Forums/en-IE/winformsdatacontrols/thread/dc9d3acf-ccf8-457f-ba31-ef09fb357aee 'License :
' - Anda Boleh Menambah Dan Memodifikasi Isi Code Sesuai Kebutuhan ' Dengan Tidak Menghilangkan Nama Asli Pembuat Kode
' - You may Change This Code without removing the original author '=========================================================================== ==
Module Cetak
Private dgview As DataGridView = Nothing
Private oStringFormat As StringFormat
Private oButton As Button Private oCheckbox As CheckBox Private oComboBox As ComboBox
Private nTotalWidth As Int16 Private nRowPos As Int16 Private NewPage As Boolean Private nPageNo As Int16
Private Header As String = "HEADER : http://www.djiesoft.blogspot.com, mailto:djiesoft@gmail.com"
Private sUserName As String = "Printed By djie"
Public Sub cetakData(ByVal p_DataGridView As DataGridView, ByVal pTitleHeader As String, ByVal pUserDisplay As String)
dgview = p_DataGridView Header = pTitleHeader sUserName = pUserDisplay End Sub
Public Sub djie_PrintDocument_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
oStringFormat = New StringFormat
oStringFormat.Alignment = StringAlignment.Near oStringFormat.LineAlignment = StringAlignment.Center oStringFormat.Trimming = StringTrimming.EllipsisCharacter
oStringFormatComboBox = New StringFormat
oStringFormatComboBox.LineAlignment = StringAlignment.Center oStringFormatComboBox.FormatFlags = StringFormatFlags.NoWrap oStringFormatComboBox.Trimming = StringTrimming.EllipsisCharacter
oButton = New Button oCheckbox = New CheckBox oComboBox = New ComboBox
nTotalWidth = 0
For Each oColumn As DataGridViewColumn In dgview.Columns nTotalWidth += oColumn.Width
Next
nPageNo = 1 NewPage = True nRowPos = 0 End Sub
Public Sub djie_PrintDocument_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Static oColumnLefts As New ArrayList Static oColumnWidths As New ArrayList Static oColumnTypes As New ArrayList Static nHeight As Int16
Dim nWidth, i, nRowsPerPage As Int16 Dim nTop As Int16 = e.MarginBounds.Top Dim nLeft As Int16 = e.MarginBounds.Left
If nPageNo = 1 Then
nWidth = CType(Math.Floor(oColumn.Width / nTotalWidth * nTotalWidth * (e.MarginBounds.Width / nTotalWidth)), Int16)
nHeight = e.Graphics.MeasureString(oColumn.HeaderText, oColumn.InheritedStyle.Font, nWidth).Height + 11
oColumnLefts.Add(nLeft) oColumnWidths.Add(nWidth)
oColumnTypes.Add(oColumn.GetType) nLeft += nWidth
Next
End If
Do While nRowPos < dgview.Rows.Count - 1
Dim oRow As DataGridViewRow = dgview.Rows(nRowPos)
If nTop + nHeight >= e.MarginBounds.Height + e.MarginBounds.Top Then
DrawFooter(e, nRowsPerPage)
NewPage = True nPageNo += 1
e.HasMorePages = True Exit Sub
Else
If NewPage Then
' Draw Header
e.Graphics.DrawString(Header, New Font(dgview.Font, FontStyle.Bold), Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top - e.Graphics.MeasureString(Header, New Font(dgview.Font, FontStyle.Bold), e.MarginBounds.Width).Height - 13)
' Draw Columns
nTop = e.MarginBounds.Top i = 0
For Each oColumn As DataGridViewColumn In dgview.Columns
e.Graphics.FillRectangle(New
SolidBrush(Drawing.Color.LightGray), New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)) e.Graphics.DrawString(oColumn.HeaderText, oColumn.InheritedStyle.Font, New
SolidBrush(oColumn.InheritedStyle.ForeColor), New
RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight), oStringFormat) i += 1
Next
NewPage = False
nTop += nHeight i = 0
For Each oCell As DataGridViewCell In oRow.Cells
If oColumnTypes(i) Is GetType(DataGridViewTextBoxColumn) OrElse oColumnTypes(i) Is GetType(DataGridViewLinkColumn) Then
e.Graphics.DrawString(oCell.Value.ToString,
oCell.InheritedStyle.Font, New SolidBrush(oCell.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i), nTop, oColumnWidths(i), nHeight),
oStringFormat)
ElseIf oColumnTypes(i) Is GetType(DataGridViewButtonColumn) Then
oButton.Text = oCell.Value.ToString
oButton.Size = New Size(oColumnWidths(i), nHeight) Dim oBitmap As New Bitmap(oButton.Width,
oButton.Height)
oButton.DrawToBitmap(oBitmap, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
ElseIf oColumnTypes(i) Is GetType(DataGridViewCheckBoxColumn) Then
oCheckbox.Size = New Size(14, 14)
oCheckbox.Checked = CType(oCell.Value, Boolean) Dim oBitmap As New Bitmap(oColumnWidths(i), nHeight) Dim oTempGraphics As Graphics =
Graphics.FromImage(oBitmap)
oTempGraphics.FillRectangle(Brushes.White, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
oCheckbox.DrawToBitmap(oBitmap, New Rectangle(CType((oBitmap.Width - oCheckbox.Width) / 2, Int32),
CType((oBitmap.Height - oCheckbox.Height) / 2, Int32), oCheckbox.Width, oCheckbox.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
ElseIf oColumnTypes(i) Is GetType(DataGridViewComboBoxColumn) Then
oComboBox.Size = New Size(oColumnWidths(i), nHeight) Dim oBitmap As New Bitmap(oComboBox.Width,
oComboBox.Height)
oComboBox.DrawToBitmap(oBitmap, New Rectangle(0, 0, oBitmap.Width, oBitmap.Height))
e.Graphics.DrawImage(oBitmap, New Point(oColumnLefts(i), nTop))
e.Graphics.DrawString(oCell.Value.ToString,
oCell.InheritedStyle.Font, New SolidBrush(oCell.InheritedStyle.ForeColor), New RectangleF(oColumnLefts(i) + 1, nTop, oColumnWidths(i) - 16, nHeight), oStringFormatComboBox)
Dim oCellSize As Rectangle = New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight)
Dim oImageSize As Size = CType(oCell.Value, Image).Size
e.Graphics.DrawImage(oCell.Value, New
Rectangle(oColumnLefts(i) + CType(((oCellSize.Width - oImageSize.Width) / 2), Int32), nTop + CType(((oCellSize.Height - oImageSize.Height) / 2), Int32), CType(oCell.Value, Image).Width, CType(oCell.Value, Image).Height))
End If
e.Graphics.DrawRectangle(Pens.Black, New Rectangle(oColumnLefts(i), nTop, oColumnWidths(i), nHeight))
i += 1
Next
End If
nRowPos += 1 nRowsPerPage += 1
Loop
Call DrawFooter(e, nRowsPerPage)
e.HasMorePages = False
End Sub
Private Sub DrawFooter(ByVal e As
System.Drawing.Printing.PrintPageEventArgs, ByVal RowsPerPage As Int32) Dim sPageNo As String = nPageNo.ToString + " of " +
Math.Ceiling(dgview.Rows.Count / RowsPerPage).ToString
' Right Align - User Name
e.Graphics.DrawString(sUserName, dgview.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
e.Graphics.MeasureString(sPageNo, dgview.Font, e.MarginBounds.Width).Width), e.MarginBounds.Top + e.MarginBounds.Height + 7)
' Left Align - Date/Time
e.Graphics.DrawString(Now.ToLongDateString + " " +
Now.ToShortTimeString, dgview.Font, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top + e.MarginBounds.Height + 7)
' Center - Page No. Info
e.Graphics.DrawString(sPageNo, dgview.Font, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width -
e.Graphics.MeasureString(sPageNo, dgview.Font, e.MarginBounds.Width).Width) / 2, e.MarginBounds.Top + e.MarginBounds.Height + 31)
End Sub End Module
Imports System.Data.OleDb Module ModKoneksi
Public Database As OleDbConnection Public Tabel As OleDbDataAdapter Public Data As DataSet
Public Record, Record_Peminjaman As New BindingSource Public DML As New OleDbCommand
Public Cari As OleDbDataReader
Public Sub Koneksi() Try
Database = New
OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=TugasAkhir.accdb")
Database.Open() Catch ex As Exception MsgBox(ex.ToString()) End Try