Imports System.Data.SqlClient 'memasukkan system data sqlclient
Public Class Frm22AhliWaris
Inherits System.Windows.Forms.Form
Dim dat_user As New SqlDataAdapter
Dim a, b As String
Dim i As Integer
'untuk menampilkan jumlah ahli waris
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Call hapus_tabel()
End
End Sub
'untuk menampilkan no laporan
Private Sub tampil_nolaporan() 'untuk menampilkan no_ket ke txtangka(biar angka terurut)
Try
Me.dat_user = New SqlDataAdapter("select max(no_lap) as no_lap from t_laporanwaris", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
Dim i As Integer
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtId.Text = (dtAkses.Rows(i)("no_lap").ToString())
Next i
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Tampil No")
End Try
End Sub
Private Sub jumlah() 'untuk menampilkan jumlah ahli waris ke dalam textbox
Me.dat_user = New SqlDataAdapter("select sum(jumlah) as jumlah from t_ket where no_laporan ='" & Me.TxtId.Text & "'", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtJum.Text = (dtAkses.Rows(i)("jumlah").ToString())
Next i
End Sub
Private Sub bagiannya() 'untuk menampilkan jumlah bagian ke dalam textbox
Me.dat_user = New SqlDataAdapter("select sum(bagian) as jumlah from t_keterangan", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtBagian.Text = (dtAkses.Rows(i)("jumlah").ToString())
Next i
End Sub
'fungsi untuk menampilkan jumlah saudara seibu
Private Sub saudara_seibu() 'untuk menampilkan jumlah saudara seibu ke dalam textbox
Me.dat_user = New SqlDataAdapter("select sum(jumlah) as jumlah from t_ket where id_ket in ('21','7') and no_laporan ='" & Me.TxtId.Text & "' group by jumlah", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtSaudaraSeibu.Text = (dtAkses.Rows(i)("jumlah").ToString())
Next i
End Sub
'fungsi untuk menampilkan jumlah anak laki-laki
Private Sub jumlah_laki() 'untuk menampilkan jumlah anak laki-laki ke dalam textbox
Me.dat_user = New SqlDataAdapter("select sum(jumlah) as jumlah from t_ket where id_ket in ('1') and no_laporan ='" & Me.TxtId.Text & "' group by jumlah", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtLaki.Text = (dtAkses.Rows(i)("jumlah").ToString())
Next i
End Sub
'fungsi untuk menampilkan jumlah anak perempuan
Private Sub jumlah_perempuan() 'untuk menampilkan jumlah anak laki-laki ke dalam textbox
Me.dat_user = New SqlDataAdapter("select sum(jumlah) as jumlah from t_ket where id_ket in ('15') and no_laporan ='" & Me.TxtId.Text & "' group by jumlah", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtPerempuan.Text = (dtAkses.Rows(i)("jumlah").ToString())
Next i
End Sub
'mulai bagian ahli waris
'fungsi untuk bagian anak laki-laki perempuan
Private Sub bagian_anaklakiperempuan()
Try
'apakah ada data anak laki-laki atau anak perempuan
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','15') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak laki-laki atau anak perempuan
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, tidak ada data anak laki-laki atau anak perempuan", MsgBoxStyle.Information, "Informasi")
Exit Sub
Else
'jika ada data anak laki-laki atau anak perempuan
Try
'apakah ada data yang lainnya??
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('2','3','4','5','6','7','8','9','10','11','12','13','14','16','17','18','19','20','21','22') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
If dtt_user.Rows.Count = Nothing Then
'jika tidak ada data yang lain
'MsgBox("ok, hanya ada data anak laki-laki dan anak perempuan", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim laki, perempuan, jumlah As Integer
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
laki = Val(Me.TxtLaki.Text)
perempuan = Val(Me.TxtPerempuan.Text)
jumlah = (laki * 2) + perempuan
bagian = (uang * (laki * 2)) / jumlah
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 8 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 1 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2 untuk anak laki-laki Berhasil Disimpan ", MsgBoxStyle.OkOnly, "Pesan")
uang = Val(Frm21Harta.TxtUang1.Text)
laki = Val(Me.TxtLaki.Text)
perempuan = Val(Me.TxtPerempuan.Text)
jumlah = (laki * 2) + perempuan
bagian = (uang * perempuan) / jumlah
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 9 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 15 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1 untuk anak perempuan Berhasil Disimpan ", MsgBoxStyle.OkOnly, "Pesan")
'ada data yang lainnya
Else
'MsgBox("maaf, ada data yang lainnya", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian anaklakiperempuan")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian anaklakiperempuan")
End Try
End Sub
Private Sub bagian_ayahibusuamiistri()
Try
'apakah ada data ayah,ibu,suami, atau istri?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('14','22','17','3') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data ayah,ibu,suami, atau istri?
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data ayah,ibu,suami, atau istri tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data ayah,ibu,suami, atau istri
Else
'apakah ada data anak laki-laki atau anak perempuan?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','15') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak laki-laki atau anak perempuan
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, tidak ada data anak laki-laki atau anak perempuan", MsgBoxStyle.Information, "Informasi")
Exit Sub
Else
'jika ada data anak laki-laki atau anak perempuan
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim laki, perempuan, jumlah As Integer
Dim coba As String
uang = Val(Me.TxtSisa.Text)
laki = Val(Me.TxtLaki.Text)
perempuan = Val(Me.TxtPerempuan.Text)
jumlah = (laki * 2) + perempuan
bagian = (uang * (laki * 2)) / jumlah
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 8 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 1 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2 untuk anak laki-laki Berhasil Disimpan ", MsgBoxStyle.OkOnly, "Pesan")
uang = Val(Me.TxtSisa.Text)
laki = Val(Me.TxtLaki.Text)
perempuan = Val(Me.TxtPerempuan.Text)
jumlah = (laki * 2) + perempuan
bagian = (uang * perempuan) / jumlah
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 9 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 15 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1 untuk anak perempuan Berhasil Disimpan ", MsgBoxStyle.OkOnly, "Pesan")
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian ayahibusuamiistri")
End Try
End Sub
'fungsi untuk bagian istri
Private Sub bagian_istri()
Try
'apakah ada data istri?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 22 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data istri
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data istri tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data istri
Else
Try
'apakah ada data anak atau cucu
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'tidak ada data anak atau cucu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data anak atau cucu tidak ada", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 4
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 3 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 22 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/4 Berhasil Disimpan untuk istri", MsgBoxStyle.OkOnly, "Pesan")
Exit Sub
'ada data anak atau cucu
Else
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 8
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 5 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 22 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/8 Berhasil Disimpan untuk istri", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Istri")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Istri")
End Try
End Sub
'fungsi untuk bagian suami
Private Sub bagian_suami()
Try
'apakah ada data suami?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 14 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data suami
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data suami tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data suami
Else
Try
'apakah ada data anak atau cucu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak atau cucu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data anak atau cucu tidak ada", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 2
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 1 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 14 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/2 Berhasil Disimpan untuk suami", MsgBoxStyle.OkOnly, "Pesan")
Exit Sub
'jika ada data anak atau cucu
Else
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 4
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 3 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 14 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/4 Berhasil Disimpan untuk suami", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Suami")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Suami")
End Try
End Sub
'fungsi untuk bagian ayah
Private Sub bagian_ayah()
Try
'apakah ada data ayah?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 3 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data ayah
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data ayah tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data ayah
Else
Try
'apakah ada data anak atau cucu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak atau cucu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, ayah tidak ada data anak atau cucu ", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data anak anak atau cucu
Else
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 3 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk ayah", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Ayah")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Ayah")
End Try
End Sub
'fungsi untuk bagian ibu
Private Sub bagian_ibu()
Try
'apakah ada data ibu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 17 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data ibu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data ibu tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika ada data ibu
Else
Try
'apakah ada data anak atau cucu atau saudara laki-laki?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','15','16','5','6','7') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'tidak ada data anak atau cucu atau saudara laki-laki
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, tidak ada data anak atau cucu atau saudara laki-laki untuk ibu ", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 3
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 2 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 17 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/3 Berhasil Disimpan untuk ibu", MsgBoxStyle.OkOnly, "Pesan")
'ada data anak atau cucu atau saudara laki-laki
Else
'MsgBox("maaf, ada data anak atau cucu atau saudara laki-laki untuk ibu ", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 17 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk ibu", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Ibu")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Ibu")
End Try
End Sub
'bagian ashobah hanya seorang
Private Sub ashobah1_laki()
Try
'apakah ada data selain 14 orang laki-laki yang dekat kekerabatnnya dengan si pewaris??
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('14','15','16','17','18','19','20','21','22') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada
If dtt_user.Rows.Count = Nothing Then
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang As String
uang = Frm21Harta.TxtUang1.Text
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 7 & "',"
strsql += " bagian= '" & uang & "'"
strsql += " Where no_ket= '" & 1 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("hanya ada 1 ashobah, dan mendapat semua harta", MsgBoxStyle.OkOnly, "Pesan")
'jika ada data yang lain
Else
'MsgBox("maaf, ada data yang lainnya", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian ashobah1_laki")
End Try
End Sub
'fungsi untuk bagian saudara seibu
Private Sub bagian_saudaraseibu()
'apakah ada data anak, cucu, ayah, atau kakek
Try
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','3','4','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak, cucu, ayah, atau kakek
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, tidak ada data anak, cucu, ayah, atau kakek", MsgBoxStyle.Information, "Informasi")
Try
'apakah ada data saudara seibu???
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('21','7') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data saudara seibu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, tidak ada data saudara seibu", MsgBoxStyle.Information, "Informasi")
Exit Sub
Else
'jika ada data saudara seibu
Try
'apakah data saudara seibu hanya 1 atau lebih???
dat_user = New SqlClient.SqlDataAdapter("select sum(jumlah) as jumlah from t_ket where id_ket in ('21','7') and no_laporan ='" & Me.TxtId.Text & "' group by jumlah having count(*) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika data saudara seibu lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data saudara seibu lebih dari 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian, ibu As Double
Dim coba As String
ibu = Val(Me.TxtSaudaraSeibu.Text)
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang / 3) / ibu
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 2 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 7 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/3 Berhasil Disimpan untuk saudara seibu lebih dari 1(laki-laki)", MsgBoxStyle.OkOnly, "Pesan")
ibu = Val(Me.TxtSaudaraSeibu.Text)
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang / 3) / ibu
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 2 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 21 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/3 Berhasil Disimpan untuk saudara seibu lebih dari 1(perempuan)", MsgBoxStyle.OkOnly, "Pesan")
Else
'jika data saudara seibu hanya 1
'MsgBox("maaf, data saudara seibu hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket='" & 7 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk saudara laki-laki seibu hanya 1", MsgBoxStyle.OkOnly, "Pesan")
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket='" & 21 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk saudara perempuan seibu hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Saudara seibu2")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Saudara seibu1")
End Try
Else
'jika ada data anak, cucu, ayah, atau kakek
'MsgBox("maaf, ada data anak, cucu, ayah, atau kakek", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Saudara seibu3")
End Try
End Sub
'fungsi untuk bagian kakek
Private Sub bagian_kakek()
Try
'apakah ada data kakek
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 4 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data kakek
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data kakek tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'ada data kakek
Else
Try
'apakah ada data ayah?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('3') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data ayah
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data ayah untuk kakek tidak ada", MsgBoxStyle.Information, "Informasi")
Try
'apakah ada data anak atau cucu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak atau cucu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("Maaf, data anak atau cucu untuk kakek tidak ada", MsgBoxStyle.Information, "Informasi")
'jika ada data anak atau cucu
Else
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 4 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk kakek", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Kakek")
End Try
'jika ada data ayah untuk kakek
Else
'MsgBox("Maaf, ada data ayah untuk kakek", MsgBoxStyle.Information, "Information")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Kakek")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Kakek")
End Try
End Sub
'fungsi untuk bagian nenek
Private Sub bagian_nenek()
Try
'apakah ada data nenek?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 18 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data nenek
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data nenek tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'jika tidak ada data nenek
Else
Try
'apakah ada data ibu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('17') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data ibu
If dtt_user.Rows.Count = Nothing Then
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 18 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk nenek", MsgBoxStyle.OkOnly, "Pesan")
''jika ada data ibu
Else
'MsgBox("maaf, ada data ibu untuk nenek ", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Nenek")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Nenek")
End Try
End Sub
'fungsi untuk bagian saudara perempuan seayah
Private Sub bagian_saudaraperempuanseayah()
Try
'apakah ada data saudara perempuan seayah??
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 20 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data saudara perempuan seayah
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data saudara perempuan seayah tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'ada saudara perempuan seayah
Else
Try
'apakah ada data anak, cucu, ayah, kakek, atau saudara laki-laki??
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2','3','4','5','6','7','15','16') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data anak, cucu, ayah, kakek, atau saudara laki-laki
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data anak, cucu, ayah, kakek, atau saudara laki-laki", MsgBoxStyle.Information, "Informasi")
'apakah ada data saudara perempuan seayah seibu??
Try
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('19') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data saudara perempuan seayah seibu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data saudara perempuan seayah seibu", MsgBoxStyle.Information, "Informasi")
Try
'apakah data saudara perempuan seayah hanya 1 atau lebih???
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('20') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika data saudara perempuan seayah lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("data saudara perempuan seayah lebih dari 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang * 2) / 3
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 6 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 20 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2/3 Berhasil Disimpan untuk saudara perempuan seayah lebih dari 1", MsgBoxStyle.OkOnly, "Pesan")
Else
'jika data saudara perempuan seayah hanya 1
'MsgBox("data saudara perempuan seayah hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 2
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 2 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 20 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/2 Berhasil Disimpan untuk saudara perempuan seayah hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah4")
End Try
Else
'jika ada data saudara perempuan seayah seibu
'MsgBox("maaf,ada data saudara perempuan seayah seibu", MsgBoxStyle.Information, "Informasi")
'apakah data saudara perempuan seayah seibu hanya 1 atau lebih????
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('19') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika data saudara perempuan seayah seibu lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf,data saudara perempuan seayah seibu lebih dari 1", MsgBoxStyle.Information, "Informasi")
Exit Sub
Else
'jika data saudara perempuan seayah seibu hanya 1
'MsgBox("maaf,data saudara perempuan seayah seibu hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 20 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk saudara perempuan seayah hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah1")
End Try
'ada data anak, cucu, ayah, kakek, atau saudara laki-laki
Else
'MsgBox("maaf, ada data anak, cucu, ayah, kakek, atau saudara laki-laki ", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah2")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah3")
End Try
End Sub
'fungsi untuk bagian anak perempuan
Private Sub bagian_anakperempuan()
Try
'apakah ada data anak perempuan?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 15 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data anak perempuan tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
Else
Try
'apakah ada data anak laki-laki?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
If dtt_user.Rows.Count = Nothing Then
Try
'apakah data anak perempuan hanya 1?
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('15') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika data anak perempuan lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("Maaf, data anak perempuan lebih dari 1", MsgBoxStyle.Information, "Perhatian")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang * 2) / 3
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 6 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 15 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2/3 Berhasil Disimpan untuk anak perempuan lebih dari 1", MsgBoxStyle.OkOnly, "Pesan")
Exit Sub
'jika data anak perempuan hanya 1
Else
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 2
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 1 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 15 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/2 Berhasil Disimpan untuk 1 anak perempuan", MsgBoxStyle.OkOnly, "Pesan")
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Saudara Perempuan Seayah")
End Try
'ada data anak laki-laki
Else
'MsgBox("maaf, ada data anak laki-laki", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Anak Perempuan")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian Anak Perempuan")
End Try
End Sub
'fungsi untuk bagian cucu perempuan
Private Sub bagian_cucuperempuan()
Try
'untuk mencari apakah ada data cucu perempuan
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 16 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau tidak ada data cucu perempuan
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data cucu perempuan tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'kalau ada data cucu perempuan
Else
Try
'untuk mencari apakah ada data anak laki-laki atau data cucu laki-laki
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','2') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau tidak ada data anak laki-laki atau cucu laki-laki
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data anak laki-laki atau cucu laki-laki", MsgBoxStyle.Information, "Informasi")
'untuk mencari apakah ada data anak perempuan
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('15') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau tidak ada data anak perempuan
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data anak perempuan", MsgBoxStyle.Information, "Informasi")
'untuk mencari apakah data cucu perempuan hanya 1 atau lebih dari 1
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('16') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
If dtt_user.Rows.Count = Nothing Then
'MsgBox("data cucu perempuan lebih dari 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang * 2) / 3
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 6 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 16 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2/3 Berhasil Disimpan untuk cucu perempuan lebih dari 1", MsgBoxStyle.OkOnly, "Pesan")
Else
'MsgBox("data cucu perempuan hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 2
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 1 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 16 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/2 Berhasil Disimpan untuk cucu perempuan hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
'kalau ada data anak perempuan
Else
'untuk mencari apakah data anak perempuan hanya 1 atau lebih dari 1
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('15') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau data anak perempuan lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("Maaf,data anak perempuan lebih dari 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 10 & "',"
strsql += " bagian= '" & 0 & "'"
strsql += " Where id_ket= '" & 16 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 0 Berhasil Disimpan untuk cucu perempuan dimana ada data anak perempuan lebih dari 1", MsgBoxStyle.OkOnly, "Pesan")
Exit Sub
'kalau data anak perempuan hanya 1
Else
'MsgBox("data anak perempuan hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 6
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 4 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 16 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/6 Berhasil Disimpan untuk cucu perempuan dimana ada data anak perempuan hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
End If
Else
'MsgBox("maaf, ada data anak laki-laki atau cucu laki-laki untuk cucu perempuan ", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian cucu perempuan")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian cucu perempuan")
End Try
End Sub
'fungsi untuk bagian saudara perempuan kandung
Private Sub bagian_saudaraperempuankandung()
Try
'apakah ada data saudara perempuan seayah seibu?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 19 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau tidak ada data saudara perempuan seayah seibu
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data saudara perempuan seayah seibu tidak ada", MsgBoxStyle.Information, "Informasi")
Exit Sub
'data saudara perempuan seayah seibu ada
Else
Try
'apakah ada data anak,cucu,saudara laki-laki seayah seibu, ayah, kakek?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('1','15','2','16','5','3','4') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'kalau tidak ada data anak,cucu,saudara laki-laki seayah seibu, ayah, kakek
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data anak,cucu,saudara laki-laki seayah seibu, ayah, atau kakek untuk saudara perempuan seayah seibu", MsgBoxStyle.Information, "Informasi")
'apakah data saudara perempuan seayah seibu hanya 1 atau lebih?
dat_user = New SqlClient.SqlDataAdapter("select id_ket from t_ket where id_ket in('19') and no_laporan ='" & Me.TxtId.Text & "' group by id_ket having count(id_ket) = 1", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'data saudara perempuan seayah seibu lebih dari 1
If dtt_user.Rows.Count = Nothing Then
'MsgBox("data saudara perempuan seayah seibu lebih dari 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = (uang * 2) / 3
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 6 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 19 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 2/3 Berhasil Disimpan untuk saudara perempuan seayah seibu lebih dari 1", MsgBoxStyle.OkOnly, "Pesan")
'data saudara perempuan seayah seibu hanya 1
Else
MsgBox("data saudara perempuan seayah hanya 1", MsgBoxStyle.Information, "Informasi")
Dim strsql As String
Dim cmd As SqlClient.SqlCommand
Dim con = modumum.koneksi
Dim uang, bagian As Double
Dim coba As String
uang = Val(Frm21Harta.TxtUang1.Text)
bagian = uang / 2
coba = Str(Val(bagian))
strsql = " Update t_ket"
strsql += " Set id_bagian= '" & 1 & "',"
strsql += " bagian= '" & coba & "'"
strsql += " Where id_ket= '" & 19 & "'"
strsql += " and no_laporan= '" & Me.TxtId.Text & "'"
cmd = New SqlCommand(strsql)
cmd.Connection = con
con.open()
cmd.ExecuteNonQuery()
con.close()
'MsgBox("Data 1/2 Berhasil Disimpan untuk saudara perempuan seayah seibu hanya 1", MsgBoxStyle.OkOnly, "Pesan")
End If
Else
'MsgBox("maaf, ada data anak,cucu,saudara laki-laki seayah seibu, ayah, atau kakek ", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah seibu")
End Try
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian saudara perempuan seayah seibu")
End Try
End Sub
Private Sub semuanya()
Call jumlah_laki()
jumlah_perempuan()
saudara_seibu()
bagian_anaklakiperempuan()
bagian_istri()
bagian_suami()
bagian_ayah()
bagian_ibu()
sisa_harta()
bagiannya()
sisanya()
bagian_ayahibusuamiistri()
bagian_saudaraperempuankandung()
bagian_cucuperempuan()
bagian_anakperempuan()
bagian_nenek()
bagian_kakek()
bagian_saudaraseibu()
bagian_istri()
bagian_saudaraperempuanseayah()
Me.TxtBagian.Text = ""
Me.TxtSisa.Text = ""
Call hapus_tabel()
sisa_harta()
bagiannya()
sisanya()
Me.Hide()
Frm23Pembagian.Show()
End Sub
Private Sub bersih_data() 'untuk membersihkan yang ada di text2
Me.TxtNama.Text = ""
Me.ComboKet.SelectedItem = ""
Me.TxtAngka1.Text = ""
Me.TxtAngka2.Text = ""
Me.TxtNama.Focus()
End Sub
'untuk membuat awal kata jadi gede
Public Function AwalKataKapital(ByVal strKalimat As String) 'untuk membuat awal kata jadi gede
Dim i As Integer
Dim Temp As String
Dim Lokasi As Integer
Dim huruf As String
Temp$ = ""
For i% = 1 To Len(strKalimat)
huruf = Chr(Asc(Mid(strKalimat, i%, 1)))
If Len(Trim(huruf)) < 1 Then
Lokasi% = i% + 1
End If
If i% = Lokasi% Or i% = 1 Then
Temp$ = Temp$ + UCase(Chr(Asc(Mid(strKalimat, i%, 1))))
Else
Temp$ = Temp$ + LCase(Chr(Asc(Mid(strKalimat, i%, 1))))
End If
Next i
AwalKataKapital = Temp$
End Function
Private Sub tampil_no() 'untuk menampilkan no_ket ke txtangka(biar angka terurut)
Try
Me.dat_user = New SqlDataAdapter("select max(no_ket) as no_ket from t_ket where no_laporan ='" & Me.TxtId.Text & "'", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
Dim i As Integer
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtAngka.Text = (dtAkses.Rows(i)("no_ket").ToString())
Next i
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Tampilkode")
End Try
End Sub
Private Sub tampil_kode() 'untuk menampilkan kode ahli waris sesuai dengan yang ada di combo
Try
Me.dat_user = New SqlDataAdapter("select * from t_ahliwaris where ahliwaris = '" & Me.ComboKet.SelectedItem & "'", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
Dim i As Integer
For i = 0 To (dtAkses.Rows.Count) - 1
Me.TxtAngka2.Text = (dtAkses.Rows(i)("kode_ahliwaris").ToString())
Next i
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Tampilkode")
End Try
End Sub
Private Sub tambah_data() 'untuk menambah data ke dalam database
Dim no As String
no = Str(Val(Me.TxtAngka.Text) + 1)
Me.dat_user = New SqlDataAdapter("insert into t_ket(no_laporan,no_ket,id_ket,ket,nama,jumlah) values('" & Me.TxtId.Text & "','" & no & "','" & Me.TxtAngka2.Text & "', '" & Me.ComboKet.SelectedItem & "','" & Me.TxtNama.Text & "','" & 1 & "')", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
'MsgBox("Data Berhasil Disimpan", MsgBoxStyle.Information, "Informasi")
End Sub
Private Sub sisa_harta() 'untuk menambah data ke dalam database
Me.dat_user = New SqlDataAdapter("SELECT DISTINCT ket, SUM(jumlah) AS jumlah, bagian INTO t_keterangan FROM dbo.t_ket Where dbo.t_ket.no_laporan ='" & Me.TxtId.Text & "' GROUP BY ket, jumlah, bagian", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
'MsgBox("Data Berhasil Disimpan di tabel keterangan", MsgBoxStyle.Information, "Informasi")
End Sub
Private Sub sisanya()
Me.TxtSisa.Text = Frm21Harta.TxtUang1.Text - Me.TxtBagian.Text
End Sub
Private Sub refresh_data()
Try ' script untuk refresh
Me.TxtAngka.Text = ""
Call Me.tampil_no()
Me.ListViewObjek.Items.Clear()
dat_user = New SqlDataAdapter("SELECT * FROM t_ket where no_laporan = '" & Me.TxtId.Text & "' order by no_ket;", modumum.koneksi)
Dim dtahli As New DataTable
dtahli.Clear()
dat_user.Fill(dtahli)
For i = 0 To (dtahli.Rows.Count) - 1
Me.ListViewObjek.Items.Add(dtahli.Rows(i)("no_ket").ToString())
Me.ListViewObjek.Items(Me.ListViewObjek.Items.Count - 1).SubItems.Add(dtahli.Rows(i)("nama").ToString())
Me.ListViewObjek.Items(Me.ListViewObjek.Items.Count - 1).SubItems.Add(dtahli.Rows(i)("ket").ToString())
Next i
Call tampil_no()
Me.TxtNama.Focus()
Catch ex As Exception
End Try
End Sub
Private Sub hapus_data() ' untuk menghapus data di listview
Try
Me.dat_user = New SqlDataAdapter("delete from t_ket where no_ket ='" & Me.TxtAngka1.Text & "' and no_laporan ='" & Me.TxtId.Text & "'", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di hapus data")
End Try
End Sub
Private Sub BtnTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTambah.Click
If Me.TxtNama.Text = "" Or Me.ComboKet.SelectedItem = "" Then 'jika txtnama atau combo tidak diisi
Dim tanya As String
tanya = MsgBox("Silahkan masukan nama atau pilih keterangan terlebih dahulu", MsgBoxStyle.Exclamation, "Kesalahan")
If vbOK Then 'jika tombol OK di klik
Me.TxtNama.Focus() 'cursor akan pindah ke txtnama
End If
Else
Call Me.tambah_data()
Me.ComboKet.Text = ""
Me.refresh_data()
Me.tampil_no()
Me.bersih_data()
End If
End Sub
Private Sub BtnKembali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Hide()
Frm21Harta.Show()
End Sub
Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
Call hapus_tabel()
End
End Sub
Private Sub BtnLanjut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLanjut.Click
Dim nomor As Int16
nomor = 0
If nomor > Me.ListViewObjek.Items.Count - 1 Then 'jika data listview nya masih kosong
MsgBox("maaf,anda belum memasukkan data ahli waris satupun", MsgBoxStyle.Information, "Perhatian")
Else
Dim a As Int16
a = MsgBox("Apakah data ahli waris sudah benar ?", MsgBoxStyle.OkCancel, "Konfirmasi")
Try
Select Case a
Case vbCancel
Exit Sub
Case vbOK
Call jumlah() 'memanggil fungsi jumlah
'jika datanya hanya 1
If Me.TxtJum.Text = 1 Then
Call ashobah1_laki()
semuanya()
Me.Hide()
Frm23Pembagian.Show()
'jika datanya lebih dari 1
Else
Try
'apakah ada data suami?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket in('14') and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
Dim dtt_user As New DataTable
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data suami
If dtt_user.Rows.Count = Nothing Then
'MsgBox("maaf, data suami tidak ada", MsgBoxStyle.Information, "Informasi")
'apakah ada data istri?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 22 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data istri
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data istri", MsgBoxStyle.Information, "Informasi")
Call semuanya()
Else
'jika ada data istri
Call semuanya()
End If
'jika ada data suami
Else
'apakah ada data istri?
dat_user = New SqlClient.SqlDataAdapter("select * from t_ket where id_ket = '" & 22 & "' and no_laporan ='" & Me.TxtId.Text & "'", modumum.koneksi)
dtt_user.Clear()
dat_user.Fill(dtt_user)
'jika tidak ada data istri
If dtt_user.Rows.Count = Nothing Then
'MsgBox("tidak ada data suami dan istri", MsgBoxStyle.Information, "Informasi")
Call semuanya()
'jika ada data suami dan istri
Else
'MsgBox("maaf, ada data suami dan istri, silahkan periksa kembali", MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian ahli waris9")
End Try
End If
End Select
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian ahli waris9")
End Try
End If
End Sub
'saat form di jalankan
Private Sub Frm22AhliWaris_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.TxtNama.Focus()
Call Me.tampil_ket()
'Me.tampil_no()
Me.tampil_nolaporan()
End Sub
'untuk memasukkan keterangan ahli waris ke dalam combo
Private Sub tampil_ket()
Try
Me.dat_user = New SqlDataAdapter("select * from t_ahliwaris", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
Dim i As Integer
For i = 0 To (dtAkses.Rows.Count) - 1
Me.ComboKet.Items.Add(dtAkses.Rows(i)("ahliwaris").ToString())
Next i
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Tampilkode")
End Try
End Sub
'saat item dalam list view di pilih
Private Sub ListViewObjek_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListViewObjek.ItemSelectionChanged
Dim nomor As Int16
nomor = 0
If nomor <= Me.ListViewObjek.SelectedItems.Count - 1 Then
Me.TxtAngka1.Text = Me.ListViewObjek.SelectedItems(Me.ListViewObjek.SelectedItems.Count - 1).Text
End If
End Sub
Private Sub ComboKet_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboKet.SelectedIndexChanged
Call tampil_kode()
End Sub
Private Sub hapus_tabel()
Me.dat_user = New SqlDataAdapter("DROP TABLE t_keterangan", koneksi)
Dim dtAkses As New DataTable
dtAkses.Clear()
Me.dat_user.Fill(dtAkses)
'MsgBox("tabel keterangan berhasil dihapus", MsgBoxStyle.Information, "Informasi")
End Sub
Private Sub BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapus.Click
Dim nomor As Int16
nomor = 0
If Me.TxtAngka1.Text <> "" Then 'jika txtangka ada isi nya
Dim a As Int16
a = MsgBox("Apakah Anda benar-benar ingin menghapus data ?", MsgBoxStyle.OkCancel, "Konfirmasi")
Try
Select Case a
Case vbCancel
Me.TxtAngka1.Text = ""
Exit Sub
Case vbOK
Call hapus_data()
Me.ListViewObjek.Items.Clear()
Call refresh_data()
Me.tampil_no()
Call Me.bersih_data()
MsgBox("Data berhasil dihapus !!", MsgBoxStyle.Information, "Perhatian")
End Select
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, "Error di Bagian ahli waris")
End Try
Else
MsgBox("Maaf, anda belum memilih data yang ingin anda hapus", MsgBoxStyle.Information, "Perhatian")
End If
End Sub
Private Sub TxtNama_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtNama.TextChanged
Dim posisi As Integer
posisi = Me.TxtNama.SelectionStart
Me.TxtNama.Text = AwalKataKapital(Me.TxtNama.Text)
Me.TxtNama.SelectionStart = posisi
End Sub
End Class
Rabu, 23 Maret 2011
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar