Aplikasi Surat Masuk-Keluar
Aplikasi Surat Masuk-Keluar
Aplikasi Surat Masuk-Keluar
Imports System.Data.Odbc.OdbcConnection
Module Module1
Public ad As Odbc.OdbcConnection
Public Sub kon()
Dim KONEKSI As String = "driver={MySQL ODBC 5.1 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=SURAT;" & _
"UID=root;" & _
"PASSWORD= ;" & _
"OPTION=3;"
ad = New Odbc.OdbcConnection(KONEKSI)
ad.Open()
End Sub
End Module
Login User
Source Code
Imports System.Data.Odbc
Public Class Form1
End Sub
'=====================================================
' PENGATURAN USER DAN PASSWORD FORM 9
' MENAMPILKAN DATA DALAM D.GRID SESUAI AKSES
'=====================================================
Dim a As OdbcDataAdapter
Dim d As DataSet
Dim x As New BindingSource
Public Sub datauser()
kon()
a = New OdbcDataAdapter("select * from user where USERNAME='" & TextBox1.Text
& "'", ad)
d = New DataSet
a.Fill(d)
x.DataSource = d
x.DataMember = d.Tables(0).ToString
Form9.DataGridView1.DataSource = x
Form9.TextBox3.Enabled = False
End Sub
Source Code:
Public Class Form5
Form Cari
Source code :
Imports System.Data.Odbc
Public Class Form4
Sub showt()
Dim tb As OdbcDataAdapter
Dim rd As DataSet
Dim sc As New BindingSource
tb = New OdbcDataAdapter("select * from suratmasuk where " + ComboBox1.Text +
" LIKE '%" + TextBox1.Text + "%'", ad)
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
Sub showK()
Dim tb As OdbcDataAdapter
Dim rd As DataSet
Dim sc As New BindingSource
tb = New OdbcDataAdapter("select * from KELUAR where " + ComboBox1.Text + "
LIKE '%" + TextBox1.Text + "%'", ad)
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
Sub showB()
Dim tb As OdbcDataAdapter
Dim rd As DataSet
Dim sc As New BindingSource
tb = New OdbcDataAdapter("select * from suratmasuk where " & ComboBox1.Text &
" between '" & DateTimePicker1.Value & "' and '" & DateTimePicker2.Value & "'", ad)
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
Sub showBk()
Dim tb As OdbcDataAdapter
Dim rd As DataSet
Dim sc As New BindingSource
tb = New OdbcDataAdapter("select * from kluar where " + ComboBox1.Text + "
between ('" & DateTimePicker1.Value & "' and '" & DateTimePicker2.Value & "')", ad)
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
kon()
If ComboBox1.Text = "TGL" Then
showB()
TextBox1.Visible = False
DateTimePicker1.Visible = True
DateTimePicker2.Visible = True
ElseIf ComboBox1.Text = "TGL_K" Then
showBk()
TextBox1.Visible = False
DateTimePicker1.Visible = True
DateTimePicker2.Visible = True
ElseIf ComboBox2.Text = "MASUK" Then
showt()
TextBox1.Visible = False
DateTimePicker1.Visible = False
DateTimePicker2.Visible = False
Else
showK()
TextBox1.Visible = False
DateTimePicker1.Visible = False
DateTimePicker2.Visible = False
End If
End Sub
Sub showgb()
Dim I As Integer
I = Me.DataGridView1.CurrentRow.Index
With DataGridView1.Rows.Item(I)
Form3.PictureBox1.Image = System.Drawing.Bitmap.FromFile(.Cells(6).Value)
End With
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
showgb()
Form3.Show()
End Sub
Laporan
Source Code :
Imports System.Data.Odbc
Public Class Form6
'========================================================================
' PROSEDUR SHOWT UNTUK MENAMPILKAN DATA SURAT MASUK KE DALAM DATAGRIDVIEW
'========================================================================
Dim tb As OdbcDataAdapter
Sub showt()
Dim rd As DataSet
Dim sc As New BindingSource
If ComboBox2.Text = "=" Then
tb = New OdbcDataAdapter("select no,nomersurat,tgl,dari,perihal from
suratmasuk where " + ComboBox1.Text + " " + ComboBox2.Text + " '" + TextBox1.Text +
"'", ad)
ElseIf ComboBox2.Text = "like" Then
tb = New OdbcDataAdapter("select no,nomersurat,tgl,dari,perihal from
suratmasuk where " + ComboBox1.Text + " " + ComboBox2.Text + " '%" + TextBox1.Text +
"%'", ad)
Else
tb = New OdbcDataAdapter("select no,nomersurat,tgl,dari,perihal from
suratmasuk where " + ComboBox1.Text + " " + ComboBox2.Text + " '" + TextBox1.Text + "'
and '" + TextBox2.Text + "'", ad)
End If
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
'========================================================================
' PROSEDUR SHOWT UNTUK MENAMPILKAN DATA SURAT KLUAR KE DALAM DATAGRIDVIEW
'========================================================================
Sub showK()
Dim rd As DataSet
Dim sc As New BindingSource
If ComboBox2.Text = "=" Then
tb = New OdbcDataAdapter("select no_K,noKLUAR,tgl_KLUAR,TUJUAN,perihal_K
from KELUAR where " + ComboBox1.Text + " " + ComboBox2.Text + " '" + TextBox1.Text +
"'", ad)
ElseIf ComboBox2.Text = "like" Then
tb = New OdbcDataAdapter("select no_K,noKLUAR,tgl_KLUAR,TUJUAN,perihal_K
from KELUAR " + ComboBox1.Text + " " + ComboBox2.Text + " '%" + TextBox1.Text + "%'",
ad)
Else
tb = New OdbcDataAdapter("select no_K,noKLUAR,tgl_KLUAR,TUJUAN,perihal_K
from KELUAR " + ComboBox1.Text + " " + ComboBox2.Text + " '" + TextBox1.Text + "' and
'" + TextBox2.Text + "'", ad)
End If
rd = New DataSet
tb.Fill(rd)
sc.DataSource = rd
sc.DataMember = rd.Tables(0).ToString
DataGridView1.DataSource = sc
ad.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If RadioButton1.Checked Then
showt()
'======================================
' CETAK REPORT SURAT MASUK KE DLM FORM7
'======================================
Dim dtr As New DataTable
With dtr
.Columns.Add("no")
.Columns.Add("nomersurat")
.Columns.Add("TGL")
.Columns.Add("DARI")
.Columns.Add("perihal")
End With
For Each Row As DataGridViewRow In DataGridView1.Rows
dtr.Rows.Add(Row.Cells(0).Value, Row.Cells(1).Value,
Row.Cells(2).FormattedValue, Row.Cells(3).Value, Row.Cells(4).Value)
Next
Form7.ReportViewer1.LocalReport.DataSources.Item(0).Value = dtr
Form7.Show()
Else
showK()
'=======================================
' CETAK REPORT SURAT KELUAR KE DLM FORM7
'=======================================
Dim dtr As New DataTable
With dtr
.Columns.Add("no_K")
.Columns.Add("noKLUAR")
.Columns.Add("tgl_KLUAR")
.Columns.Add("TUJUAN")
.Columns.Add("perihal_K")
End With
For Each Row As DataGridViewRow In DataGridView1.Rows
dtr.Rows.Add(Row.Cells(0).Value, Row.Cells(1).Value,
Row.Cells(2).FormattedValue, Row.Cells(3).Value, Row.Cells(4).Value)
Next
Form8.ReportViewer1.LocalReport.DataSources.Item(0).Value = dtr
Form8.Show()
End If
End Sub
Ganti password
Login Admin
'=============================================================
' MEMBUAT PENOMORAN OTOMATIS BERDASARKAN JUMLAH BARIS TERAKHIR
'=============================================================
Sub autonum()
kon()
Dim da As OdbcCommand
da = New OdbcCommand("SELECT count(no) FROM `suratmasuk` WHERE 1 ", ad)
Dim bc = da.ExecuteReader
bc.Read()
If bc.HasRows Then
TextBox1.Text = "SM." & bc.Item(0) + 1
Else
TextBox1.Text = "SM." & 1
End If
End Sub
Me.PictureBox1.Image =
System.Drawing.Bitmap.FromFile(OpenFileDialog1.FileName)
End Sub
'=====================================================================================
=
' KEBUTUHAN UPDATE, MENAMPILKAN DATA DARI GRID KE DLM TEXTBOX DAN OBJEK INPUTAN YG
LAIN
'=====================================================================================
=
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim I As Integer
I = Me.DataGridView1.CurrentRow.Index
With DataGridView1.Rows.Item(I)
TextBox1.Text = .Cells(0).Value
TextBox2.Text = .Cells(1).Value
TextBox3.Text = .Cells(2).Value
TextBox4.Text = .Cells(3).Value
DateTimePicker1.Value = .Cells(3).Value
TextBox5.Text = .Cells(4).Value
TextBox6.Text = .Cells(5).Value
TextBox7.Text = .Cells(6).Value
Me.PictureBox1.Image = System.Drawing.Bitmap.FromFile(TextBox7.Text)
End With
ad.Close()
End Sub
End Class
Souece Code:
Imports System.Data.Odbc
Public Class Form9
Sub kosong()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
kon()
Dim tbin As OdbcCommand
Dim sql As String
sql = "INSERT INTO user VALUES(?,?,?)"
tbin = New OdbcCommand(sql, Module1.ad)
With tbin.Parameters
.Add("?", OdbcType.VarChar, 10).Value = TextBox1.Text.Trim
.Add("?", OdbcType.VarChar, 10).Value = TextBox2.Text.Trim
.Add("?", OdbcType.VarChar, 30).Value = TextBox3.Text.Trim
End With
tbin.ExecuteNonQuery()
MsgBox("SELESAI")
Form1.showdata()
kosong()
ad.Close()
End Sub
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim I As Integer
I = Me.DataGridView1.CurrentRow.Index
With DataGridView1.Rows.Item(I)
TextBox1.Text = .Cells(0).Value
TextBox2.Text = .Cells(1).Value
TextBox3.Text = .Cells(2).Value
TextBox1.Enabled = False
End With
ad.Close()
End Sub
End Sub
End Class
Data Set :
PDM
user suratmasuk
username varchar(12) <pk> no int <pk>
password varchar(12) username varchar(12) <fk>
akses int nomersurat varchar(20)
... tgl date
dari varchar(20)
perihal varchar(20)
lampran longblob
...
keluar
no_k int <pk>
username varchar(12) <fk>
nokluar varchar(20)
tgl_kluar date
tujuan varchar(20)
perihal_k varchar(20)
lam_k longblob
...