Public Class Form21Perawatan
'//////////////////////////////////Variabel Buatan
Public LblJudul As New Label
Public GbBelogix As New GroupBox
Public WithEvents GbLantai As New GroupBox
Public WithEvents GbRuang As New GroupBox
Dim WithEvents TxtJumLantai As New TextBox
Dim WithEvents TxtJumRuangan As New TextBox
Dim WithEvents TxtNamaLantai As New TextBox
'//////////////////////////////////Variabel Buatan
'//////////////////////////////////Rumus Buatan Sendiri
'untuk desain form
Private Sub Desain_Form()
'untuk TxtJumLantai
Me.TxtJumLantai.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!)
Me.TxtJumLantai.Size = New System.Drawing.Size(30, 36)
Me.TxtJumLantai.Location = New System.Drawing.Point(0, 0)
Me.TxtJumLantai.Visible = False
'untuk txtid
Me.TxtJumRuangan.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!)
Me.TxtJumRuangan.Size = New System.Drawing.Size(30, 36)
Me.TxtJumRuangan.Location = New System.Drawing.Point(0, 30)
Me.TxtJumRuangan.Visible = False
'untuk TxtNamaLantai
Me.TxtNamaLantai.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!)
Me.TxtNamaLantai.Size = New System.Drawing.Size(150, 36)
Me.TxtNamaLantai.Location = New System.Drawing.Point(35, 0)
Me.TxtNamaLantai.Visible = False
'untuk lbljudul
Me.LblJudul.Text = "PT BELOGIX TRAINING & SOLUTION PROVIDER"
Me.LblJudul.Font = New System.Drawing.Font("Microsoft Sans Serif", 16.0!)
Me.LblJudul.Size = New System.Drawing.Size(520, 30)
Me.LblJudul.Location = New System.Drawing.Point(430, 20)
'untuk GbBelogix
Me.GbBelogix.Text = "PT BELOGIX TRAINING & SOLUTION PROVIDER"
Me.GbBelogix.Location = New System.Drawing.Point(25, 75)
Me.GbBelogix.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!)
Me.GbBelogix.Size = New System.Drawing.Size(1300, 600)
'untuk form11pengguna
Me.Size = New System.Drawing.Size(1065, 640)
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D
Me.BackColor = Color.PapayaWhip
Me.WindowState = FormWindowState.Maximized
Me.Text = "**SIMAS_KETAN**"
Me.Controls.Add(Me.LblJudul)
Me.Controls.Add(Me.GbBelogix)
Me.Controls.Add(Me.TxtJumLantai)
Me.Controls.Add(Me.TxtJumRuangan)
Me.Controls.Add(Me.TxtNamaLantai)
End Sub
Public Sub mouse_hover(ByVal Sender As Object, ByVal e As EventArgs)
Dim grpbx As GroupBox = CType(Sender, GroupBox)
grpbx.BackColor = Color.SandyBrown
Me.TxtNamaLantai.Text = grpbx.Name
End Sub
Public Sub mouse_leave(ByVal Sender As Object, ByVal e As EventArgs)
Dim grpbx As GroupBox = CType(Sender, GroupBox)
grpbx.BackColor = Color.PapayaWhip
Me.TxtNamaLantai.Text = ""
End Sub
'untuk menghitung jumlah lantai di database
Private Sub Jml_Lantai()
Dim comm As New MySql.Data.MySqlClient.MySqlDataAdapter("Select count(kd_lantai) as jumlah from t_lantai ", MdKoneksi.konek)
dt.Clear()
comm.Fill(dt)
For i = 0 To (dt.Rows.Count) - 1
Me.TxtJumLantai.Text = (dt.Rows(i)("jumlah").ToString())
Next i
End Sub
'untuk menghitung jumlah ruangan di database
Private Sub Jml_Ruangan()
Dim comm As New MySql.Data.MySqlClient.MySqlDataAdapter("Select count(kd_ruang) as jumlah from t_ruang ", MdKoneksi.konek)
dt.Clear()
comm.Fill(dt)
For i = 0 To (dt.Rows.Count) - 1
Me.TxtJumRuangan.Text = (dt.Rows(i)("jumlah").ToString())
Next i
End Sub
'untuk menghitung jumlah ruangan di database
Private Sub Tambah_Lantai()
'untuk memasukkan lantai ke dalam groupbox belogix
Dim comm As New MySql.Data.MySqlClient.MySqlDataAdapter("Select kd_lantai , ket_lantai from t_lantai ", MdKoneksi.konek)
dt.Clear()
comm.Fill(dt)
For i = 0 To (dt.Rows.Count) - 1
Dim jml As Integer = Val(Me.TxtJumLantai.Text)
GbLantai = New GroupBox
GbLantai.Size = New System.Drawing.Size((Me.GbBelogix.Size.Width - 50) / jml, (Me.GbBelogix.Size.Height - 50))
GbLantai.Text = (dt.Rows(i)("ket_lantai").ToString())
GbLantai.Name = (dt.Rows(i)("kd_lantai").ToString())
GbLantai.Cursor = Cursors.Hand
GbLantai.Location = New System.Drawing.Point(25 + (GbLantai.Size.Width * i), 30)
Me.GbBelogix.Controls.Add(GbLantai)
'untuk memasukkan ruang ke dalam groupbox lantai
Dim comm2 As New MySql.Data.MySqlClient.MySqlDataAdapter("Select nama_ruang , kd_ruang from t_ruang where kd_lantai='" & dt.Rows(i)("kd_lantai").ToString() & "'", MdKoneksi.konek)
dt2.Clear()
comm2.Fill(dt2)
For i2 = 0 To (dt2.Rows.Count) - 1
'untuk menentukan ukuran groupbox ruang agar sama
Dim comm3 As New MySql.Data.MySqlClient.MySqlDataAdapter("Select count(kd_ruang) as jum from t_ruang where kd_lantai='" & dt.Rows(i)("kd_lantai").ToString() & "'", MdKoneksi.konek)
dt3.Clear()
comm3.Fill(dt3)
For i3 = 0 To (dt3.Rows.Count) - 1
TxtJumRuangan = New TextBox
TxtJumRuangan.Location = New System.Drawing.Point(25, 300 + (50 * i3))
TxtJumRuangan.Text = (dt3.Rows(i3)("jum").ToString())
TxtJumRuangan.Visible = False
Me.GbLantai.Controls.Add(TxtJumRuangan)
Next i3
Dim jum As Integer = Val(Me.TxtJumRuangan.Text)
GbRuang = New GroupBox
GbRuang.Size = New System.Drawing.Size((Me.GbLantai.Size.Width - 50), (Me.GbLantai.Size.Height - 50) / jum)
GbRuang.Name = (dt2.Rows(i2)("kd_ruang").ToString())
GbRuang.Location = New System.Drawing.Point(25, 25 + (GbRuang.Size.Height * i2))
GbRuang.Text = (dt2.Rows(i2)("nama_ruang").ToString())
Me.GbLantai.Controls.Add(GbRuang)
'menambah event secara dinamik
AddHandler GbRuang.MouseHover, AddressOf mouse_hover
AddHandler GbRuang.MouseLeave, AddressOf mouse_leave
Next i2
Next i
End Sub
'//////////////////////////////////Rumus Buatan Sendiri
'//////////////////////////////////Pemakaian Command
'saat form dijalankan
Private Sub Me_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'memanggil rumus
Call Me.Desain_Form()
Call Me.Jml_Lantai()
Call Me.Jml_Ruangan()
Call Me.Tambah_Lantai()
End Sub
'//////////////////////////////////Pemakaian Command
End Class