Anda di halaman 1dari 20

SINTAK PROGRAM

Form Data Konsumen


Private Sub tampilgrid()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "Select ReceivingDateTime,SenderNumber,TextDecoded from
inbox order by ID desc"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
With DataGrid1
.Columns(0).Caption = "TglMasuk"
.Columns(1).Caption = "No Pengirim"
.Columns(2).Caption = "Isi Pesan"
.Columns(0).Width = 2000
.Columns(1).Width = 1500
.Columns(2).Width = 3500
End With
DataGrid1.Refresh
End Sub
Private Sub tampilgrid2()
Call koneksi_database
Adodc2.ConnectionString = "DSN=SMS"
Adodc2.RecordSource = "Select DestinationNumber,TextDecoded from outbox "
Adodc2.Refresh
Set DataGrid2.DataSource = Adodc2
With DataGrid2
.Columns(0).Caption = "No Tujuan"
.Columns(1).Caption = "Isi Pesan"
'.Columns(2).Caption = "Isi Pesan"
.Columns(0).Width = 2000
.Columns(1).Width = 1500
'.Columns(2).Width = 3500
End With
DataGrid2.Refresh
End Sub
Private Sub tampilgrid3()
Call koneksi_database
Adodc3.ConnectionString = "DSN=SMS"
Adodc3.RecordSource = "Select SendingDateTime,DestinationNumber,TextDecoded
from sentitems"
Adodc3.Refresh
Set DataGrid3.DataSource = Adodc3
With DataGrid3
.Columns(0).Caption = "TglTerkirim"
.Columns(1).Caption = "No Tujuan"
.Columns(2).Caption = "Isi Pesan"
.Columns(0).Width = 2000
.Columns(1).Width = 1500
.Columns(2).Width = 3500
End With

DataGrid3.Refresh
End Sub
Private Sub tampilgrid4()
Call koneksi_database2
Adodc4.ConnectionString = "DSN=SMS1"
Adodc4.RecordSource = "Select * from TKonsumen"
Adodc4.Refresh
Set DataGrid4.DataSource = Adodc4
DataGrid4.Refresh
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "Isi Data DenganLengkap !!", vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database
Dim strsql As String
' Kirimpesan
strsql = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text1.Text & "','" & Text2.Text & "')"
db.Execute (strsql)
Call tampilgrid2
Call koneksi_database2
Dim strsql2 As String
strsql2 = "SELECT kdkeluar FROM TPkeluar WHERE Tgl='" & Text17.Text & "'"
Set rs2 = db2.Execute(strsql2)
If rs2.EOF Then
strsql2 = "INSERT INTO TPkeluar (KdKeluar,Tgl,kdKonsumen,kdRumah) VALUEs ('"
& Text17.Text & "','" & Format(DTPicker1, "yyyy/mm/dd") & "','" & Text19.Text & "','" &
Text18.Text & "')"
'Set rs2 = db2.Execute(strsql2)
db2.Execute (strsql2)
Exit Sub
Else
Call koneksi_database2
sql2 = "update TPkeluar set Tgl = '" &Format(DTPicker1, "yyyy/mm/dd") &
"',kdkonsumen='" & Text19.Text & "',kdrumah='" & Text18.Text & "' where kdkeluar= '"
& Text17.Text & "'"
db2.Execute (sql2)
'MsgBox "Data TelahTersimpan", vbExclamation + vbOKOnly, "Informasi"
'Call koneksi_DB
'Call bersih
'Call tampilgrid
End If
End If
End Sub
Private Sub Command11_Click()
Frame4.Visible = True
Call buatkodesms
Command5.Enabled = False
End Sub
Private Sub Command12_Click()

Frame11.Visible = True
End Sub
Private Sub Command13_Click()
DataGrid6.Visible = True
End Sub
Private Sub Command14_Click()
Form9.Show vbModal
End Sub
Private Sub Command2_Click()
Dim posBintang As Integer, posPagar1 As Integer, posPagar2 As Integer, posPagar3 As
Integer, posPagar4 As Integer
Dim temp As String, temp1 As String
'kirim pesan jika format salah
If (Left(Text3.Text, 1)) <> "*" Or (Right(Text3.Text, 1)) <> "#" Then
'MsgBox "Format SMS Salah!! Format SMS : *Nama#Alamat#Type#", vbExclamation +
vbOKOnly, "Informasi"
Call koneksi_database
Dim strsql As String
strsql = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & "Format SMS : *Nama#Alamat#Type#" & " ')"
db.Execute (strsql)
Exit Sub
'Text15.Text = ""
'Text3.Text = ""
'Text4.Text = ""
Else
'Split ataupemisahan format sms
posBintang = InStr(Text3, "*")
posPagar1 = InStr(Text3, "#")
Text5 = Mid(Text3, posBintang + 1, posPagar1 - posBintang - 1)
temp = Right(Text3, Len(Text3) - posPagar1)
posPagar2 = InStr(temp, "#")
Text6 = Mid(temp, 1, posPagar2 - 1)
temp1 = Right(temp, Len(temp) - posPagar2)
posPagar3 = InStr(temp1, "#")
Text7 = Mid(temp1, 1, posPagar3 - 1)
End If
End Sub
Private Sub Command3_Click()
If Text4.Text = "" Or Text5.Text = "" Then
MsgBox "Isi Data DenganLengkap !!", vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
'Dim sql2 As String
sql2 = "SELECT kdkonsumen FROM Tkonsumen WHERE kdkonsumen='" & Text8.Text &
"'"

Set rs2 = db2.Execute(sql2)


If Not rs2.EOF Then
MsgBox "KodeSudah Ada", vbInformation + vbOKOnly, "Information"
Text4.SetFocus
Else
sql2 = "INSERT INTO TKonsumen (KdKonsumen,NoHP,Nama,Alamat,TypeRumah)
VALUES ('" & Text8.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text &
"','" & Text7.Text & "')"
db2.Execute (sql2)
'MsgBox "Data TelahTersimpan", vbExclamation + vbOKOnly, "Informasi"
'Call koneksi_DB
'Call bersih
Call tampilgrid4
Call buatkodeBO
End If
End If
End Sub
Private Sub Command4_Click()
Text2.Text = ""
Text1.Text = ""
Frame4.Visible = False
Command11.Enabled = True
Command5.Enabled = True
End Sub
Private Sub Command5_Click()
Frame4.Visible = True
Call buatkodesms
Command11.Enabled = False
End Sub
Sub buatkodeBO()
'buatkodeotommatiskonsumen
Set rs2 = New ADODB.Recordset
rs2.Open ("select * from TKonsumen Where KdKonsumenIn(Select
Max(KdKonsumen)From TKonsumen)Order By KdKonsumenDesc"), db2
rs2.Requery
Dim UrutanAs String * 14
Dim HitungAs Long
With rs2
If .EOF Then
Urutan = "KSM-" + Format(Date, "ddmmyy") + "0001"
Text8.Text = Urutan
Else
Hitung = Right(!KdKonsumen, 8) + 1
Urutan = "KSM-" + Format(Date, "ddmmyy") + Right("0000" &Hitung, 4)
End If
Text8.Text = Urutan
End With
End Sub
Private Sub Command6_Click()
Unload Me
End Sub
Private Sub Command7_Click()

Frame9.Visible = False
End Sub
Private Sub Command8_Click()
Frame9.Visible = True
End Sub
Private Sub Command9_Click()
Call tampilgrid
DataGrid1_Click
DataGrid1.SetFocus
End Sub
Private Sub DataGrid1_Click()
'Call buatkodeBO
Text4.Text = Adodc1.Recordset.Fields("SenderNumber")
Text3.Text = Adodc1.Recordset.Fields("TextDecoded")
Text15.Text = Adodc1.Recordset.Fields("ReceivingDateTime")
Text1.Text = Adodc1.Recordset.Fields("SenderNumber")
Call koneksi_database2
Dim strsql As String
strsql = "SELECT Tglpesanmasuk FROM TPmasuk WHERE TglPesanmasuk='" &
Text15.Text & "'"
Set rs2 = db2.Execute(strsql)
If rs2.EOF Then
strsql = "INSERT INTO TPmasuk (NoHP, Tglpesanmasuk, IsiPesan) VALUEs ('" &
Text4.Text & "','" & Text15.Text & "','" & Text3.Text & "')"
'Set rs2 = db2.Execute(strsql)
db2.Execute (strsql)
Exit Sub
Else
Call koneksi_database2
sql = "update TPmasuk set TglPesanMasuk = '" & Text15.Text & "',IsiPesan='" & _
Text3.Text & "' where NoHP= '" & Text4.Text & "'"
db2.Execute (sql)
'MsgBox "Data TelahTersimpan", vbExclamation + vbOKOnly, "Informasi"
'Call koneksi_DB
'Call bersih
'Call tampilgrid
End If
'End If
End Sub
Private Sub DataGrid5_Click()
Text1.Text = Adodckon.Recordset.Fields("NoHP")
Text19.Text = Adodckon.Recordset.Fields("kdKonsumen")
Frame11.Visible = False
'Text3.Text = Adodc1.Recordset.Fields("TextDecoded")
End Sub
Private Sub DataGrid6_Click()
'Text2.Text = Adodcrumah.Recordset.Fields(1)
Text2.Text = Adodcrumah.Recordset.Fields(1) & "" &Adodcrumah.Recordset.Fields(2)
Text18.Text = Adodcrumah.Recordset.Fields("kdrumah")
'Text2.Text = Adodcrumah.Recordset.Fields("Lokasi")
DataGrid6.Visible = False

End Sub
Private Sub Form_Activate()
Call buatkodeBO
Call buatkodesms
Frame11.Visible = False
DataGrid6.Visible = False
Call tampilgrid
Command2.Enabled = False
Call tampilgrid
Call tampilgridrumah1
End Sub
Sub buatkodesms()
Set rs2 = New ADODB.Recordset
rs2.Open ("select * from TPkeluar Where KdkeluarIn(Select Max(Kdkeluar)From
Tpkeluar)Order By KdkeluarDesc"), db2
rs2.Requery
Dim UrutanAs String * 14
Dim HitungAs Long
With rs2
If .EOF Then
Urutan = "SMS-" + Format(Date, "ddmmyy") + "0001"
Text17.Text = Urutan
Else
Hitung = Right(!Kdkeluar, 8) + 1
Urutan = "SMS-" + Format(Date, "ddmmyy") + Right("0000" &Hitung, 4)
End If
Text17.Text = Urutan
End With
End Sub
Private Sub tampilgridkonsumen()
Call koneksi_database2
Adodckon.ConnectionString = "DSN=SMS1"
Adodckon.RecordSource = "select kdKonsumen,nama,Nohp from tKonsumen"
Adodckon.Refresh
Set DataGrid5.DataSource = Adodckon
DataGrid5.Refresh
End Sub
Private Sub tampilgridrumah()
Call koneksi_database2
Adodcrumah.ConnectionString = "DSN=SMS1"
Adodcrumah.RecordSource = "select * from trumah"
Adodcrumah.Refresh
Set DataGrid6.DataSource = Adodcrumah
DataGrid6.Refresh
'With DataGrid1
'.Columns(0).Caption = "TglMasuk"
'.Columns(1).Caption = "No Pengirim"
'.Columns(2).Caption = "Isi Pesan"
'.Columns(0).Width = 500
'.Columns(1).Width = 1000
'.Columns(2).Width = 2500
'.Columns(2).Width = 3500
'End With
End Sub
Private Sub tampilgridrumah1()
Call koneksi_database2

Adodc5.ConnectionString = "DSN=SMS1"
Adodc5.RecordSource = "select * from trumah"
Adodc5.Refresh
Set DataGrid7.DataSource = Adodc5
DataGrid7.Refresh
'With DataGrid1
'.Columns(0).Caption = "TglMasuk"
'.Columns(1).Caption = "No Pengirim"
'.Columns(2).Caption = "Isi Pesan"
'.Columns(0).Width = 500
'.Columns(1).Width = 1000
'.Columns(2).Width = 2500
'.Columns(2).Width = 3500
'End With
End Sub
Private Sub Form_Load()
Call tampilgridrumah
Call tampilgridkonsumen
'Call buatkodeBO
Call tampilgrid3
Call tampilgrid4
Frame4.Visible = False
Frame9.Visible = False
End Sub
Private Sub Text13_Change()
'Nampilinpesammasuk
Call koneksi_database
rs.CursorLocation = adUseClient
rs.Open "Select ReceivingDateTime,SenderNumber,TextDecoded from inbox where
SenderNumber like '%" & Text13 & "%'", db
Set DataGrid1.DataSource = rs.DataSource
'With DataGrid1
End Sub
Private Sub Text21_Change()
Call koneksi_database
Dim strsql As String
strsql = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & Text21.Text & " ')"
db.Execute (strsql)
Command3_Click

End Sub
Private Sub Text22_Change()
Call koneksi_database2
rs2.CursorLocation = adUseClient
rs2.Open "Select * from TRumah where typerumah like '%" & Text22 & "%'", db2
Set DataGrid7.DataSource = rs2.DataSource
With DataGrid7
'Text21.Text = Adodc5.Recordset.Fields(2) & "" & Adodc5.Recordset.Fields(1)
End With
End Sub
Private Sub Text3_Change()

Command2.Enabled = True
Command2_Click
End Sub
Private Sub Text4_Change()
'Text9.Text = Text4.Text
End Sub
Private Sub Text6_Change()
'Text11.Text = Text6.Text
End Sub
Private Sub Text7_Change()
'Text12.Text = Text7.Text
'Call koneksi_database2
'rs2.CursorLocation = adUseClient
'rs2.Open "Select * from TRumah where typerumah like '%" & Text7 & "%'", db2
'Set DataGrid7.DataSource = rs2.DataSource
'Call tampilgridrumah1
'If Not rs2.EOF Then
'With DataGrid7
'Text21.Text = Adodc5.Recordset.Fields(2) & "" & Adodc5.Recordset.Fields(1)
'Text21.Text = Adodc5.Recordset.Fields("typerumah")
'Text23.Text = Adodc5.Recordset.Fields("lokasi")
'DataGrid7_Click
'Text21.Text = Adodc5.Recordset.Fields(2) & "" & Adodc5.Recordset.Fields(1)
'DataGrid7_Change
'End With
'Else
' kirimsmsjika format pesansalah
'Call koneksi_database
If Text7.Text = "36" Then
Dim strsql As String
Dim keluar As String
strsql = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & "Type : 36 Lokasi : Perum PBK Stok 2 Unit mulai 200 Jutaan" & " ')"
db.Execute (strsql)
'keluar = "INSERT INTO TPkeluar (KdKeluar,Tgl,kdKonsumen,kdRumah) VALUEs ('" &
Text17.Text & "','" & Format(DTPicker1, "yyyy/mm/dd") & "','" & Text19.Text & "','" &
Text18.Text & "')"
'db2.Execute (keluar)
Exit Sub

ElseIf Text7.Text = "45" Then


Dim keluar1 As String
Dim strsql1 As String
strsql1 = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & "Type : 45 Lokasi : Perum PBK Stok 2 Unit mulai 300 jtaan" & " ')"
db.Execute (strsql1)
'keluar1 = "INSERT INTO TPkeluar (KdKeluar,Tgl,kdKonsumen,kdRumah) VALUEs ('"
& Text17.Text & "','" & Format(DTPicker1, "yyyy/mm/dd") & "','" & Text19.Text & "','" &
Text18.Text & "')"
'db2.Execute (keluar1)
Exit Sub

ElseIf Text7.Text = "70" Then


Dim keluar2 As String
Dim strsql2 As String
strsql2 = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & "Type : 70 Lokasi : Perum PBK Stok 3 Unit mulai 450 jutaan " & " ')"
db.Execute (strsql2)
'keluar2 = "INSERT INTO TPkeluar (KdKeluar,Tgl,kdKonsumen,kdRumah) VALUEs ('"
& Text17.Text & "','" & Format(DTPicker1, "yyyy/mm/dd") & "','" & Text19.Text & "','" &
Text18.Text & "')"
'db2.Execute (keluar2)
Exit Sub
Else
Dim keluar3 As String
Dim strsql3 As String
strsql3 = "INSERT INTO outbox (DestinationNumber,TextDecoded) VALUES ('" &
Text4.Text & "','" & "Type RumahKosong/Tidak Ada, CobaCari Type Lain!!!" & " ')"
db.Execute (strsql3)
'keluar3 = "INSERT INTO TPkeluar (KdKeluar,Tgl,kdKonsumen,kdRumah) VALUEs ('"
& Text17.Text & "','" & Format(DTPicker1, "yyyy/mm/dd") & "','" & Text19.Text & "','" &
Text18.Text & "')"
'db2.Execute (keluar3)
Exit Sub
End If
End Sub
Private Sub Timer2_Timer()
'Call tampilgrid2
End Sub
Private Sub Timer3_Timer()
'Call tampilgrid3
End Sub
Form Tambah User
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "Isi Data DenganLengkap !!", vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
Dim strsql As String
strsql = "SELECT username FROM TUser WHERE Username='" & Text1.Text & "'"
Set rs2 = db2.Execute(strsql)
If Not rs2.EOF Then
MsgBox "KodeSudah Ada", vbInformation + vbOKOnly, "Information"
Text1.SetFocus
Else
strsql = "INSERT INTO TUser (username, password) VALUES ('" & Text1.Text & "','" &
Text2.Text & "')"
db2.Execute (strsql)
MsgBox "Data TelahTersimpan", vbExclamation + vbOKOnly, "Informasi"
'Call koneksi_DB
'Call bersih
Text1.Text = ""

Text2.Text = ""
Call tampilgrid
End If
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Call tampilgrid
End Sub
Private Sub tampilgrid()
Call koneksi_database2
Adodc1.ConnectionString = "DSN=SMS1"
Adodc1.RecordSource = "Select * from TUser"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
Form Utama
Private Sub datakonsumen_Click()
Form1.Show vbModal
End Sub
Private Sub datarumah_Click()
Form3.Show vbModal
End Sub
Private Sub Form_Load()
master.Visible = False
laporan.Visible = False
logout.Enabled = False
End Sub
Private Sub keluar_Click()
Unload Me
End Sub
Private Sub proses_Click()
End Sub
Private Sub lapdatakonsumen_Click()
Form5.Show vbModal
End Sub

Private Sub login_Click()


Form4.Show vbModal
End Sub
Private Sub logout_Click()
master.Visible = False
laporan.Visible = False
logout.Enabled = False
login.Enabled = True
StatusBar1.Panels(2) = ""
End Sub
Private Sub pesankeluar_Click()
Form7.Show vbModal
End Sub
Private Sub pesanmasuk_Click()
Form6.Show vbModal
End Sub
Private Sub tambahuser_Click()
Form10.Show vbModal
End Sub
Private Sub ubahPass_Click()
Form8.Show vbModal
End Sub
Form Data Rumah
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Or Text3.Text = "" Or Text2.Text = "" Then
MsgBox "Cari Data yang Ingin di Edit!!",vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
sql = "update Trumah set lokasi = '" & Text2.Text & "',typerumah='" & _
Text3.Text & "' where kdrumah= '" & Text1.Text & "'"
db2.Execute (sql)
MsgBox "Data Telah di Edit!!",vbExclamation + vbOKOnly, "Informasi"
Call bersih
Call tampilgrid
End If
End Sub
Private Sub Command3_Click()
If Text1.Text = "" Or Text3.Text = "" Or Text2.Text = "" Then
MsgBox "Isi Data DenganLengkap !!", vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
Dim strsql As String
strsql = "SELECT kdrumah FROM Trumah WHERE kdrumah='" & Text1.Text & "'"
Set rs2 = db2.Execute(strsql)
If Not rs2.EOF Then
MsgBox "KodeSudah Ada", vbInformation + vbOKOnly, "Information"

Text1.SetFocus
Else
strsql = "INSERT INTO Trumah (Kdrumah, Lokasi, TypeRumah) VALUES ('" & Text1.Text &
"','" & Text2.Text & "','" & Text3.Text & "')"
db2.Execute (strsql)
MsgBox "Data TelahTersimpan", vbExclamation + vbOKOnly, "Informasi"
'Call koneksi_DB
Call bersih
Call tampilgrid
End If
End If
End Sub
Private Sub Command4_Click()
Call bersih
Call buatkodeBO
End Sub
Private Sub Command5_Click()
If Text1.Text = "" Or Text3.Text = "" Or Text2.Text = "" Then
MsgBox "Cari Data yang Ingin di Hapus!!",vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
Dim pesan As Integer
pesan = MsgBox("ApakahAndayakinakanmenghapus", vbQuestion + vbYesNo,
"Konfirmasi")
If pesan = 6 Then
strsql = "DELETE FROM Trumah WHERE kdrumah='" & Text1.Text & "'"
db2.Executestrsql
MsgBox "Data Telah di Hapus!!",vbExclamation + vbOKOnly, "Informasi"
Call bersih
Call tampilgrid
End If
End If
End Sub
Private Sub DataGrid1_Click()
Text1.Text = Adodc1.Recordset.Fields("kdrumah")
'DTPicker2.Format("yyyy/mm/dd") = Adodc1.Recordset.Fields("TglBerobat")
Text2.Text = Adodc1.Recordset.Fields("lokasi")
Text3.Text = Adodc1.Recordset.Fields("typerumah")
End Sub
Private Sub Form_Activate()
Call tampilgrid
End Sub
Private Sub Form_Load()
Call bersih
End Sub
Sub bersih()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub tampilgrid()
Call koneksi_database2

Adodc1.ConnectionString = "DSN=SMS1"
Adodc1.RecordSource = "Select * from TRumah"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End Sub
Sub buatkodeBO()
Set rs2 = New ADODB.Recordset
rs2.Open ("select * from TRumah Where KdrumahIn(Select Max(Kdrumah)From
Trumah)Order By KdrumahDesc"), db2
rs2.Requery
Dim UrutanAs String * 14
Dim HitungAs Long
With rs2
If .EOF Then
Urutan = "RMH-" + Format(Date, "ddmmyy") + "0001"
Text1.Text = Urutan
Else
Hitung = Right(!Kdrumah, 8) + 1
Urutan = "RMH-" + Format(Date, "ddmmyy") + Right("0000" &Hitung, 4)
End If
Text1.Text = Urutan
End With
End Sub
Private Sub Text4_Change()
Call koneksi_database2
rs2.CursorLocation = adUseClient
rs2.Open "Select * from TRumah where typerumah like '%" & Text4 & "%'", db2
Set DataGrid1.DataSource = rs2.DataSource
End Sub
Form Login
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "Isi Data DenganLengkap !!", vbExclamation + vbOKOnly, "Informasi"
Else
Call koneksi_database2
rs2.Open "Select * from TUser where " & " username='" _
&Trim(Text1.Text) & "' and " _
& " Password='" &Trim(Text2.Text) & "'", db2
If rs2.EOF Then 'jika username/password salah
MsgBox "Username / Password Salah !!", vbExclamation + vbOKOnly, "Informasi"
Text1.SetFocus: SendKeys "{Home}+{End}"
Text1.Text = ""
Text2.Text = ""
Set rs2 = Nothing
Else
Form2.master.Visible = True
Form2.laporan.Visible = True
Form2.logout.Enabled = True
Form2.login.Enabled = False
Form2.StatusBar1.Panels(2) = rs2.Fields("Username")
'Form2.StatusBar1.Panels(4) = rs2.Fields("NmUser")

Unload Me
End If
Set rs2 = Nothing
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Call bersih
End Sub
Sub bersih()
Text1.Text = ""
Text2.Text = ""
End Sub
Laporan Data Konsumen
Private Sub Command1_Click()
'CrystalReport1.SelectionFormula = "({Tkonsumen.NoHP})= '" & Combo2.Text & "'"
CrystalReport1.ReportFileName = App.Path& "/laporanKonsumensemua.rpt"
CrystalReport1.WindowState = crptMaximized
CrystalReport1.RetrieveDataFiles
CrystalReport1.Action = 1
End Sub
Private Sub Command2_Click()
Call koneksi_database2
Adodc1.ConnectionString = "DSN=SMS1"
Adodc1.RecordSource = "select * from tkonsumen where NoHP ='" & Combo2.Text &
"'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "Data tidakditemukan"
Exit Sub
Combo2.SetFocus
End If
CrystalReport2.SelectionFormula = "({Tkonsumen.NoHP})= '" & Combo2.Text & "'"
CrystalReport2.ReportFileName = App.Path& "/laporanKonsumensemua.rpt"
CrystalReport2.WindowState = crptMaximized
CrystalReport2.RetrieveDataFiles
CrystalReport2.Action = 1
End Sub
Private Sub Form_Activate()
Call combo
End Sub
Private Sub Form_Load()
Combo2.Text = "- Pilih -"
End Sub
Private Sub combo()
Call koneksi_database2
Adodc1.ConnectionString = "DSN=SMS1"
Adodc1.RecordSource = "select distinct NoHP from tkonsumen"

Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
Combo2.AddItem Adodc1.Recordset!NoHP
Adodc1.Recordset.MoveNext
Loop
db2.Close
End Sub
LaporanPesanMasuk
Private Sub Command1_Click()
If Combo1 = "- Pilih -" Then
MsgBox "PilihTanggal!!!", , "Informasi"
Combo1.SetFocus
Exit Sub
Else
With CrystalReport1
.SelectionFormula = "{inbox.ReceivingDateTime} in date (" & Combo1.Text & ")"
.ReportFileName = App.Path& "/LapPesanMasukHarian.rpt"
.RetrieveDataFiles
.WindowState = crptMaximized
.Action = 1
End With
End If
End Sub
Private Sub Command2_Click()
If Combo2 = "- Pilih -" Then
MsgBox "Tanggalawalkosong", , "Informasi"
Combo2.SetFocus
Exit Sub
Else
If Combo3 < Combo2 Or Combo2 > Combo3 Then
MsgBox "Tanggalterbalik"
Combo3.SetFocus
Exit Sub
ElseIf Combo3 = Combo2 Then
MsgBox "pilihtanggal yang berbeda", vbInformation, "Informasi"
Combo2.SetFocus
Exit Sub
End If
End If
With CrystalReport2
.SelectionFormula = "{inbox.ReceivingDateTime} in date (" & Combo2 & ") to date (" &
Combo3 & ")"
.ReportFileName = App.Path& "/LapPesanMasukMingguan.rpt"
.RetrieveDataFiles
.WindowState = crptMaximized
.Action = 1
End With
End Sub
Private Sub Command3_Click()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "select * from inbox where SenderNumber='" & Combo4.Text
& "'"
Adodc1.Refresh

If Adodc1.Recordset.EOF Then
MsgBox "Data tidakditemukan"
Exit Sub
Combo4.SetFocus
End If
CrystalReport3.SelectionFormula = "({inbox.SenderNumber})= '" & Combo4.Text & "'"
CrystalReport3.ReportFileName = App.Path& "/LapPesanMasukNo.rpt"
CrystalReport3.WindowState = crptMaximized
CrystalReport3.RetrieveDataFiles
CrystalReport3.Action = 1
End Sub
Private Sub Form_Activate()
Combo1.Text = "- Pilih -"
Combo2.Text = "- Pilih -"
Combo3.Text = "- Pilih -"
Combo4.Text = "- Pilih -"
Call rekamharian
Call rekamharian2
Call comboNo
End Sub
Private Sub comboNo()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "select distinct SenderNumber from inbox"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
Combo4.AddItem Adodc1.Recordset!SenderNumber
Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub
Private Sub rekamharian()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "Select Distinct ReceivingDateTime From inbox order By 1"
'db.Open
Adodc1.Refresh
Adodc1.Recordset.Requery
Do Until Adodc1.Recordset.EOF
'Combo1.AddItem Format(RSPenjualan!Tanggal, "DD-MMM-YYYY")
Combo1.AddItem Format(Adodc1.Recordset!ReceivingDateTime, "YYYY ,MM, DD")
'Combo2.AddItem Format(Adodc1.Recordset!TglTransaksi, "YYYY ,MM, DD")
Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub
Private Sub rekamharian2()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "Select Distinct ReceivingDateTime From inbox order By 1"
'db.Open
Adodc1.Refresh
Adodc1.Recordset.Requery
Do Until Adodc1.Recordset.EOF
'Combo1.AddItem Format(RSPenjualan!Tanggal, "DD-MMM-YYYY")
Combo2.AddItem Format(Adodc1.Recordset!ReceivingDateTime, "YYYY ,MM, DD")

Combo3.AddItem Format(Adodc1.Recordset!ReceivingDateTime, "YYYY ,MM, DD")


Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub
LaporanPesanKeluar
Private Sub Command1_Click()
If Combo1 = "- Pilih -" Then
MsgBox "PilihTanggal!!!", , "Informasi"
Combo1.SetFocus
Exit Sub
Else
With CrystalReport1
.SelectionFormula = "{sentitems.SendingDateTime} in date (" & Combo1.Text & ")"
.ReportFileName = App.Path& "/LapPesanterkirimHarian.rpt"
.RetrieveDataFiles
.WindowState = crptMaximized
.Action = 1
End With
End If
End Sub
Private Sub Command2_Click()
If Combo2 = "- Pilih -" Then
MsgBox "Tanggalawalkosong", , "Informasi"
Combo2.SetFocus
Exit Sub
Else
If Combo3 < Combo2 Or Combo2 > Combo3 Then
MsgBox "Tanggalterbalik"
Combo3.SetFocus
Exit Sub
ElseIf Combo3 = Combo2 Then
MsgBox "pilihtanggal yang berbeda", vbInformation, "Informasi"
Combo2.SetFocus
Exit Sub
End If
End If
With CrystalReport2
.SelectionFormula = "{sentitems.SendingDateTime} in date (" & Combo2 & ") to date
(" & Combo3 & ")"
.ReportFileName = App.Path& "/LapPesanterkirimHarian.rpt"
.RetrieveDataFiles
.WindowState = crptMaximized
.Action = 1
End With
End Sub
Private Sub Command3_Click()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "select * from sentitems where DestinationNumber='" &
Combo4.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then

MsgBox "Data tidakditemukan"


Exit Sub
Combo4.SetFocus
End If
CrystalReport3.SelectionFormula = "({sentitems.DestinationNumber})= '" &
Combo4.Text & "'"
CrystalReport3.ReportFileName = App.Path& "/LapPesanTerkirimNo.rpt"
CrystalReport3.WindowState = crptMaximized
CrystalReport3.RetrieveDataFiles
CrystalReport3.Action = 1
End Sub
Private Sub Form_Activate()
Combo1.Text = "- Pilih -"
Combo2.Text = "- Pilih -"
Combo3.Text = "- Pilih -"
Combo4.Text = "- Pilih -"
Call pesanharian
Call rekamharian2
Call comboNo
End Sub
Private Sub pesanharian()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "Select Distinct SendingDateTime From sentitems order By 1"
'db.Open
Adodc1.Refresh
Adodc1.Recordset.Requery
Do Until Adodc1.Recordset.EOF
'Combo1.AddItem Format(RSPenjualan!Tanggal, "DD-MMM-YYYY")
Combo1.AddItem Format(Adodc1.Recordset!SendingDateTime, "YYYY ,MM, DD")
'Combo2.AddItem Format(Adodc1.Recordset!TglTransaksi, "YYYY ,MM, DD")
Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub
Private Sub rekamharian2()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "Select Distinct SendingDateTime From sentitems order By 1"
'db.Open
Adodc1.Refresh
Adodc1.Recordset.Requery
Do Until Adodc1.Recordset.EOF
'Combo1.AddItem Format(RSPenjualan!Tanggal, "DD-MMM-YYYY")
Combo2.AddItem Format(Adodc1.Recordset!SendingDateTime, "YYYY ,MM, DD")
Combo3.AddItem Format(Adodc1.Recordset!SendingDateTime, "YYYY ,MM, DD")
Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub
Private Sub comboNo()
Call koneksi_database
Adodc1.ConnectionString = "DSN=SMS"
Adodc1.RecordSource = "select distinct DestinationNumber from sentitems"
Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF

Combo4.AddItem Adodc1.Recordset!DestinationNumber
Adodc1.Recordset.MoveNext
Loop
db.Close
End Sub

Tambah User
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
MsgBox "Please Enter !!, Data Ada Kosong!!", vbExclamation + vbOKOnly, "Informasi"
Text1.SetFocus
Else
Call koneksi_database2
rs2.Open "Select * from TUser where " & " username='" _
&Trim(Text1.Text) & "' and " _
& " Password='" &Trim(Text2.Text) & "'", db2
If rs2.EOF Then 'jika username/password salah
MsgBox "Username / Password Salah !!", vbExclamation + vbOKOnly, "Informasi"
Text1.SetFocus: SendKeys "{Home}+{End}"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""

Set rs2 = Nothing


Else
Call koneksi_database2
sql2 = "update TUser set Password = '" & Text4.Text & "' where Username= '" &
Text1.Text & "'"
db2.Execute (sql2)
MsgBox "Data Telah di Edit!!",vbExclamation + vbOKOnly, "Informasi"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call koneksi_database2
rs2.Open "Select * from TUser where Username ='" & Text1 & "'", db2
If rs2.EOF Then
MsgBox "Username Salah, CobaLagi!",vbExclamation + vbOKOnly, "Informasi"
Text1 = ""
Else

Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call koneksi_database2
rs2.Open "Select * from TUser where Password ='" & Text2 & "'", db2
If rs2.EOF Then
MsgBox "Password Salah, CobaLagi!",vbExclamation + vbOKOnly, "Informasi"
Text2 = ""
Else
Text3.SetFocus
End If
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Text4.Text <> Text3.Text Then
MsgBox "HarusSamadengan Password Baru!",vbExclamation + vbOKOnly, "Informasi"
Text4.Text = ""
Text4.SetFocus
Else
Command1.SetFocus
End If
End If
End Sub

Anda mungkin juga menyukai