membuat timeline produksi real time menggunakan program vb 2010
hello selamat siang..,
kali ini saya akan sharing yang bertema produktivitas perusahaan,
kita bisa pantau secara realtime hasil produksi dimana pun owner berada, tetap bisa melihat hasil produksi, ada banyak versi aplikasi realtime monitoring produksi yang berkembang saat ini,
mulai dari web base, mobile dan desktop.
kali ini saya akan sharing aplikasi yg berbasis desktop tentunya dengan program vb 2010
kita mulai pembahasannya :
kali ini saya akan sharing yang bertema produktivitas perusahaan,
kita bisa pantau secara realtime hasil produksi dimana pun owner berada, tetap bisa melihat hasil produksi, ada banyak versi aplikasi realtime monitoring produksi yang berkembang saat ini,
mulai dari web base, mobile dan desktop.
kali ini saya akan sharing aplikasi yg berbasis desktop tentunya dengan program vb 2010
kita mulai pembahasannya :
seperti gambar di atas, kita mulai membuat komponen yg ada
1.groupbox
2. label
3. button
4. combobox
5. datetimepicker
rangkailah sperti gambar di atas:
perhatikan gambar,. yg berwarna merah dan hijau adalah panel,. yg nanti dicreate dengan program
selanjutnya inilah source codenya:
######### header
Imports System.IO
Imports MySql.Data.MySqlClient
Imports System.Math
############ class
Public Class live_timeline
Dim combox1 As New ComboBox
Dim dtp1 As New DateTimePicker
Dim dtime, pl, tr, ak, okk, ngg, prosen, perform, quality, eva, oee, ba, ba2 As New Label
Dim status, shift As String
Dim menit, counter, counter2 As Integer
Dim jam As Integer = 0
Dim current As DateTime
########### load tampilan
Private Sub live_timeline_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.GroupBox1.Location = New Point(5, 10)
Me.GroupBox1.Size = New System.Drawing.Size(Me.Width - 10, Me.Height - 50)
load_param()
Dim day As Integer = DateTime.Now.ToString("HHmm")
Dim a1, a2, b1, b2, c1, c2 As String
a1 = sh1_a
a2 = sh1_b
b1 = sh2_a
b2 = sh2_b
c1 = sh3_a
c2 = sh3_b
If Day > a1.Replace(":", "") And Day < a2.Replace(":", "") Then current = "#" & sh1_a & "#"
If Day > b1.Replace(":", "") And Day < 2359 Then current = "#" & sh2_a & "#"
If Day > 0 And Day < b2.Replace(":", "") Then current = "#" & sh2_a & "#"
If Day > c1.Replace(":", "") And Day < c2.Replace(":", "") Then current = "#" & sh3_a & "#"
data_timeline(current)
notif()
End Sub
############# create komponen
Sub notif()
Dim pa As New Panel
pa.Location = New Point(5, 10)
pa.Size = New System.Drawing.Point(10, 50)
pa.BackColor = Color.Green
ba.Location = New Point(20, 30)
ba.Text = "Productive Time: " & vbCrLf & " 0 Menit"
ba.Size = New System.Drawing.Point(100, 30)
Me.gbnotif.Controls.Add(ba)
Me.gbnotif.Controls.Add(pa)
Dim pa2 As New Panel
pa2.Location = New Point(5, 70)
pa2.Size = New System.Drawing.Point(10, 50)
pa2.BackColor = Color.Red
ba2.Location = New Point(20, 90)
ba2.Text = "Break Time: " & vbCrLf & " 0 Menit"
ba2.Size = New System.Drawing.Point(100, 30)
dtime.Location = New Point(1, 140)
dtime.Text = "00:00:00"
dtime.Size = New System.Drawing.Point(140, 40)
dtime.Font = New Font(FontFamily.GenericSansSerif, 23)
pl.Location = New Point(5, 180)
pl.Text = "PLAN: 0000"
pl.Size = New System.Drawing.Point(130, 20)
pl.Font = New Font(FontFamily.GenericSansSerif, 10)
tr.Location = New Point(5, 200)
tr.Text = "TARGET: 0000"
tr.Size = New System.Drawing.Point(130, 20)
tr.Font = New Font(FontFamily.GenericSansSerif, 10)
ak.Location = New Point(5, 220)
ak.Text = "AKTUAL: 0000"
ak.Size = New System.Drawing.Point(130, 20)
ak.Font = New Font(FontFamily.GenericSansSerif, 10)
okk.Location = New Point(5, 240)
okk.Text = "OK: 0000"
okk.Size = New System.Drawing.Point(130, 20)
okk.Font = New Font(FontFamily.GenericSansSerif, 10)
ngg.Location = New Point(5, 260)
ngg.Text = "NG: 0000"
ngg.Size = New System.Drawing.Point(130, 20)
ngg.Font = New Font(FontFamily.GenericSansSerif, 10)
prosen.Location = New Point(5, 300)
prosen.Text = "Last Time:"
prosen.Size = New System.Drawing.Point(130, 80)
prosen.Font = New Font(FontFamily.GenericSansSerif, 10)
perform.Location = New Point(5, 360)
perform.Text = "Performance: 0%"
perform.Size = New System.Drawing.Point(130, 20)
perform.Font = New Font(FontFamily.GenericSansSerif, 10)
quality.Location = New Point(5, 380)
quality.Text = "Quality: 0%"
quality.Size = New System.Drawing.Point(130, 20)
quality.Font = New Font(FontFamily.GenericSansSerif, 10)
eva.Location = New Point(5, 400)
eva.Text = "Availible: 0%"
eva.Size = New System.Drawing.Point(130, 20)
eva.Font = New Font(FontFamily.GenericSansSerif, 10)
oee.Location = New Point(5, 420)
oee.Text = "OEE: 0%"
oee.Size = New System.Drawing.Point(130, 20)
oee.Font = New Font(FontFamily.GenericSansSerif, 10)
Me.gbnotif.Controls.Add(oee)
Me.gbnotif.Controls.Add(eva)
Me.gbnotif.Controls.Add(quality)
Me.gbnotif.Controls.Add(perform)
Me.gbnotif.Controls.Add(prosen)
Me.gbnotif.Controls.Add(ngg)
Me.gbnotif.Controls.Add(okk)
Me.gbnotif.Controls.Add(ak)
Me.gbnotif.Controls.Add(tr)
Me.gbnotif.Controls.Add(pl)
Me.gbnotif.Controls.Add(dtime)
Me.gbnotif.Controls.Add(ba2)
Me.gbnotif.Controls.Add(pa2)
End Sub
################ create komponen
Sub load_param()
Dim b12, b13, b14, b11 As New Button
dtp1.Value = DateTime.Now.ToString("yyyy-MM-dd")
Dim lb1 = New Label
lb1.Name = "lb1"
lb1.Text = "DATE : "
combox1.Name = "combobox1"
combox1.Location = New Point(220, 15)
dtp1.Location = New Point(70, 15)
lb1.Location = New Point(10, 15)
dtp1.Size = New Size(140, 50)
lb1.Size = New Size(140, 50)
combox1.Size = New Size(140, 50)
combox1.Items.Add("FX-1")
combox1.Items.Add("FX-2")
combox1.Items.Add("FX-3")
combox1.Items.Add("FX-4")
combox1.Items.Add("FX-5")
combox1.Items.Add("FX-6")
combox1.Items.Add("FX-7")
combox1.Items.Add("FX-8")
combox1.Items.Add("FX-9")
combox1.Items.Add("FX-10")
combox1.Items.Add("FX-11")
combox1.SelectedItem = "FX-1"
b12.Text = "SHIFT3"
b12.ForeColor = Color.White
b12.BackColor = Color.Blue
b12.Size = New System.Drawing.Size(100, 30)
b12.Location = New Point(570, 10)
AddHandler b12.Click, Sub(sender As Object, e As EventArgs)
gb1.Controls.Clear()
gb2.Controls.Clear()
gb3.Controls.Clear()
gb4.Controls.Clear()
gb5.Controls.Clear()
gb6.Controls.Clear()
gb7.Controls.Clear()
gb8.Controls.Clear()
gb9.Controls.Clear()
gb10.Controls.Clear()
g1.Controls.Clear()
g2.Controls.Clear()
g3.Controls.Clear()
g4.Controls.Clear()
g5.Controls.Clear()
g6.Controls.Clear()
g7.Controls.Clear()
g8.Controls.Clear()
g9.Controls.Clear()
g10.Controls.Clear()
jam = 0
menit = 0
counter = 0
counter2 = 0
shift = 3
current = "#" & sh3_a & "#"
Call data_timeline(current)
End Sub
b13.Text = "SHIFT1"
b13.ForeColor = Color.White
b13.BackColor = Color.Blue
b13.Size = New System.Drawing.Size(100, 30)
b13.Location = New Point(370, 10)
AddHandler b13.Click, Sub(sender As Object, e As EventArgs)
gb1.Controls.Clear()
gb2.Controls.Clear()
gb3.Controls.Clear()
gb4.Controls.Clear()
gb5.Controls.Clear()
gb6.Controls.Clear()
gb7.Controls.Clear()
gb8.Controls.Clear()
gb9.Controls.Clear()
gb10.Controls.Clear()
g1.Controls.Clear()
g2.Controls.Clear()
g3.Controls.Clear()
g4.Controls.Clear()
g5.Controls.Clear()
g6.Controls.Clear()
g7.Controls.Clear()
g8.Controls.Clear()
g9.Controls.Clear()
g10.Controls.Clear()
jam = 0
menit = 0
counter = 0
counter2 = 0
shift = 1
current = "#" & sh1_a & "#"
Call data_timeline(current)
End Sub
b14.Text = "SHIFT2"
b14.ForeColor = Color.White
b14.BackColor = Color.Blue
b14.Size = New System.Drawing.Size(100, 30)
b14.Location = New Point(470, 10)
AddHandler b14.Click, Sub(sender As Object, e As EventArgs)
gb1.Controls.Clear()
gb2.Controls.Clear()
gb3.Controls.Clear()
gb4.Controls.Clear()
gb5.Controls.Clear()
gb6.Controls.Clear()
gb7.Controls.Clear()
gb8.Controls.Clear()
gb9.Controls.Clear()
gb10.Controls.Clear()
g1.Controls.Clear()
g2.Controls.Clear()
g3.Controls.Clear()
g4.Controls.Clear()
g5.Controls.Clear()
g6.Controls.Clear()
g7.Controls.Clear()
g8.Controls.Clear()
g9.Controls.Clear()
g10.Controls.Clear()
jam = 0
menit = 0
counter = 0
counter2 = 0
shift = 2
current = "#" & sh2_a & "#"
Call data_timeline(current)
End Sub
b11.Text = "SHOW LIVE"
b11.ForeColor = Color.White
b11.BackColor = Color.Blue
b11.Size = New System.Drawing.Size(150, 30)
b11.Location = New Point(740, 10)
AddHandler b11.Click, Sub(sender As Object, e As EventArgs)
gb1.Controls.Clear()
gb2.Controls.Clear()
gb3.Controls.Clear()
gb4.Controls.Clear()
gb5.Controls.Clear()
gb6.Controls.Clear()
gb7.Controls.Clear()
gb8.Controls.Clear()
gb9.Controls.Clear()
gb10.Controls.Clear()
g1.Controls.Clear()
g2.Controls.Clear()
g3.Controls.Clear()
g4.Controls.Clear()
g5.Controls.Clear()
g6.Controls.Clear()
g7.Controls.Clear()
g8.Controls.Clear()
g9.Controls.Clear()
g10.Controls.Clear()
jam = 0
menit = 0
counter = 0
counter2 = 0
shift = Nothing
Dim day As Integer = DateTime.Now.ToString("HHmm")
Dim a1, a2, b1, b2, c1, c2 As String
a1 = sh1_a
a2 = sh1_b
b1 = sh2_a
b2 = sh2_b
c1 = sh3_a
c2 = sh3_b
If day > a1.Replace(":", "") And day < a2.Replace(":", "") Then current = "#" & sh1_a & "#"
If day > b1.Replace(":", "") And day < 2359 Then current = "#" & sh2_a & "#"
If day > 0 And day < b2.Replace(":", "") Then current = "#" & sh2_a & "#"
If day > c1.Replace(":", "") And day < c2.Replace(":", "") Then current = "#" & sh3_a & "#"
Call data_timeline(current)
End Sub
Me.GroupBox1.Controls.Add(b11)
Me.GroupBox1.Controls.Add(b12)
Me.GroupBox1.Controls.Add(b13)
Me.GroupBox1.Controls.Add(b14)
Me.GroupBox1.Controls.Add(dtp1)
Me.GroupBox1.Controls.Add(lb1)
Me.GroupBox1.Controls.Add(combox1)
End Sub
#################### looping data
Sub data_timeline(ByVal current As DateTime)
Dim finish As TimeSpan
Call head_timeline(current)
If shift Is Nothing Then
finish = DateTime.Now.TimeOfDay
Else
Dim curr As New DateTime
If shift = 1 Then curr = "#" & sh1_b & "#"
If shift = 2 Then curr = #11:59:00 PM#
If shift = 22 Then curr = "#" & sh2_b & "#"
If shift = 3 Then curr = "#" & sh3_b & "#"
finish = curr.TimeOfDay
End If
Dim start As TimeSpan = current.TimeOfDay
Dim ts, tk As TimeSpan
Dim nilai As Integer
If current.ToString("mm") <> 0 Then
menit = current.ToString("mm")
nilai = menit - 1
End If
For i As Integer = start.TotalMinutes To finish.TotalMinutes - 1
menit = menit + 1
If menit = 60 Then
jam = jam + 1
ts = New TimeSpan(current.Hour + jam, current.Minute - 1, 0)
tk = New TimeSpan(current.Hour + jam, current.Minute, 0)
If i = (finish.TotalMinutes - 1) Then
jam = 0
Exit For
End If
menit = 0
Else
If jam = 0 Then
ts = New TimeSpan(current.Hour, current.Minute + (menit - nilai) - 1, 0)
tk = New TimeSpan(current.Hour, current.Minute + (menit - nilai), 0)
Else
ts = New TimeSpan(current.Hour + jam, current.Minute + (menit - nilai) - 1, 0)
tk = New TimeSpan(current.Hour + jam, current.Minute + (menit - nilai), 0)
End If
End If
If tk.ToString = "1.00:00:00" Then
shift = 22
Dim ddd As DateTime = #12:00:00 AM#
Call data_timeline(ddd)
Exit For
End If
Dim sp As DateTime = Convert.ToDateTime(ts.ToString)
Dim sps As DateTime = Convert.ToDateTime(tk.ToString)
If shift Is Nothing Then
read_data_shift(sp.ToString("HH:mm"), sps.ToString("HH:mm"), combox1.SelectedItem, dtp1.Value.ToString("yyyy-MM-dd"))
End If
If shift = 1 Then
read_data_shift(sp.ToString("HH:mm"), sps.ToString("HH:mm"), combox1.SelectedItem, dtp1.Value.ToString("yyyy-MM-dd"))
End If
If shift = 2 Then
If i = finish.TotalMinutes - 1 Then
shift = 22
Dim ddd As DateTime = #12:00:00 AM#
Call data_timeline(ddd)
End If
read_data_shift(sp.ToString("HH:mm"), sps.ToString("HH:mm"), combox1.SelectedItem, dtp1.Value.ToString("yyyy-MM-dd"))
End If
If shift = 22 Then
Dim dat As Date = "#" & dtp1.Value.ToString("yyyy-MM-dd") & "#"
read_data_shift(sp.ToString("HH:mm"), sps.ToString("HH:mm"), combox1.SelectedItem, dat.AddDays(1).ToString("yyyy-MM-dd"))
End If
If shift = 3 Then
Dim dat As Date = "#" & dtp1.Value.ToString("yyyy-MM-dd") & "#"
read_data_shift(sp.ToString("HH:mm"), sps.ToString("HH:mm"), combox1.SelectedItem, dat.AddDays(1).ToString("yyyy-MM-dd"))
End If
If status = 1 Then
If jam = 9 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb10.Controls.Add(panel2)
End If
If jam = 8 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb9.Controls.Add(panel2)
End If
If jam = 7 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb8.Controls.Add(panel2)
End If
If jam = 6 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb7.Controls.Add(panel2)
End If
If jam = 5 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb6.Controls.Add(panel2)
End If
If jam = 4 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb5.Controls.Add(panel2)
End If
If jam = 3 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb4.Controls.Add(panel2)
End If
If jam = 2 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb3.Controls.Add(panel2)
End If
If jam = 1 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb2.Controls.Add(panel2)
End If
If jam = 0 Then
Dim panel2 As New Panel
If menit <= 15 Then panel2.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel2.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel2.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel2.Location = New Point(15 + (menit * 11), 5)
panel2.Size = New System.Drawing.Point(10, 50)
panel2.BackColor = Color.Green
Me.gb1.Controls.Add(panel2)
End If
counter = counter + 1
perform.Text = "Performance: " & Round((counter / 480) * 100) & "%"
ba.Text = "Productive Time: " & vbCrLf & " " & counter & " Menit"
Else
counter2 = counter2 + 1
ba2.Text = "Break Time: " & vbCrLf & " " & counter2 & " Menit"
If jam = 0 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb1.Controls.Add(panel1)
End If
If jam = 1 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb2.Controls.Add(panel1)
End If
If jam = 2 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb3.Controls.Add(panel1)
End If
If jam = 3 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb4.Controls.Add(panel1)
End If
If jam = 4 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb5.Controls.Add(panel1)
End If
If jam = 5 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb6.Controls.Add(panel1)
End If
If jam = 6 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb7.Controls.Add(panel1)
End If
If jam = 7 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb8.Controls.Add(panel1)
End If
If jam = 8 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb9.Controls.Add(panel1)
End If
If jam = 9 Then
Dim panel1 As New Panel
If menit <= 15 Then panel1.Location = New Point(0 + (menit * 11), 5)
If menit >= 16 Then panel1.Location = New Point(5 + (menit * 11), 5)
If menit >= 31 Then panel1.Location = New Point(10 + (menit * 11), 5)
If menit >= 46 Then panel1.Location = New Point(15 + (menit * 11), 5)
panel1.Size = New System.Drawing.Point(10, 50)
panel1.BackColor = Color.Red
Me.gb10.Controls.Add(panel1)
End If
End If
Next
End Sub
################ create label jam
Sub head_timeline(ByVal curr As DateTime)
Dim lb1 As New Label
lb1.Location = New Point(2, 12)
lb1.Size = New System.Drawing.Point(38, 30)
lb1.ForeColor = Color.White
lb1.Font = New Font(FontFamily.GenericSansSerif, 16)
Me.g1.Controls.Add(lb1)
Dim lb2 As New Label
lb2.Location = New Point(2, 12)
lb2.Size = New System.Drawing.Point(38, 30)
lb2.Font = New Font(FontFamily.GenericSansSerif, 16)
lb2.ForeColor = Color.White
Me.g2.Controls.Add(lb2)
Dim lb3 As New Label
lb3.Location = New Point(2, 12)
lb3.Size = New System.Drawing.Point(38, 30)
lb3.Font = New Font(FontFamily.GenericSansSerif, 16)
lb3.ForeColor = Color.White
Me.g3.Controls.Add(lb3)
Dim lb4 As New Label
lb4.Location = New Point(2, 12)
lb4.Size = New System.Drawing.Point(38, 30)
lb4.Font = New Font(FontFamily.GenericSansSerif, 16)
lb4.ForeColor = Color.White
Me.g4.Controls.Add(lb4)
Dim lb5 As New Label
lb5.Location = New Point(2, 12)
lb5.Size = New System.Drawing.Point(38, 30)
lb5.Font = New Font(FontFamily.GenericSansSerif, 16)
lb5.ForeColor = Color.White
Me.g5.Controls.Add(lb5)
Dim lb6 As New Label
lb6.Location = New Point(2, 12)
lb6.Size = New System.Drawing.Point(38, 30)
lb6.Font = New Font(FontFamily.GenericSansSerif, 16)
lb6.ForeColor = Color.White
Me.g6.Controls.Add(lb6)
Dim lb7 As New Label
lb7.Location = New Point(2, 12)
lb7.Size = New System.Drawing.Point(38, 30)
lb7.Font = New Font(FontFamily.GenericSansSerif, 16)
lb7.ForeColor = Color.White
Me.g7.Controls.Add(lb7)
Dim lb8 As New Label
lb8.Location = New Point(2, 12)
lb8.Size = New System.Drawing.Point(38, 30)
lb8.Font = New Font(FontFamily.GenericSansSerif, 16)
lb8.ForeColor = Color.White
Me.g8.Controls.Add(lb8)
Dim lb9 As New Label
lb9.Location = New Point(2, 12)
lb9.Size = New System.Drawing.Point(38, 30)
lb9.Font = New Font(FontFamily.GenericSansSerif, 16)
lb9.ForeColor = Color.White
Me.g9.Controls.Add(lb9)
Dim lb10 As New Label
lb10.Location = New Point(2, 12)
lb10.Size = New System.Drawing.Point(38, 30)
lb10.Font = New Font(FontFamily.GenericSansSerif, 16)
lb10.ForeColor = Color.White
Me.g10.Controls.Add(lb10)
If (curr.Hour).ToString.Length = 1 Then lb1.Text = "0" & curr.Hour Else lb1.Text = curr.Hour
If (curr.Hour + 1).ToString.Length = 1 Then lb2.Text = "0" & (curr.Hour + 1) Else lb2.Text = curr.Hour + 1
If (curr.Hour + 2).ToString.Length = 1 Then lb3.Text = "0" & (curr.Hour + 2) Else lb3.Text = curr.Hour + 2
If (curr.Hour + 3).ToString.Length = 1 Then lb4.Text = "0" & (curr.Hour + 3) Else lb4.Text = curr.Hour + 3
If (curr.Hour + 4).ToString.Length = 1 Then lb5.Text = "0" & (curr.Hour + 4) Else lb5.Text = curr.Hour + 4
If (curr.Hour + 5).ToString.Length = 1 Then lb6.Text = "0" & (curr.Hour + 5) Else lb6.Text = curr.Hour + 5
If (curr.Hour + 6).ToString.Length = 1 Then lb7.Text = "0" & (curr.Hour + 6) Else lb7.Text = curr.Hour + 6
If (curr.Hour + 7) = 24 Then lb8.Text = "00" Else If (curr.Hour + 7).ToString.Length = 1 Then lb8.Text = "0" & (curr.Hour + 7) Else lb8.Text = curr.Hour + 7
If (curr.Hour + 8) = 25 Then lb9.Text = "01" Else If (curr.Hour + 8).ToString.Length = 1 Then lb9.Text = "0" & (curr.Hour + 8) Else lb9.Text = curr.Hour + 8
If (curr.Hour + 9) = 26 Then lb10.Text = "02" Else If (curr.Hour + 9).ToString.Length = 1 Then lb10.Text = "0" & (curr.Hour + 9) Else lb10.Text = curr.Hour + 9
End Sub
################## timer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
dtime.Text = DateTime.Now.ToString("HH:mm:ss")
If shift Is Nothing Then
If DateTime.Now.ToString("ss") = 0 Then
Application.DoEvents()
gb1.Controls.Clear()
gb2.Controls.Clear()
gb3.Controls.Clear()
gb4.Controls.Clear()
gb5.Controls.Clear()
gb6.Controls.Clear()
gb7.Controls.Clear()
gb8.Controls.Clear()
gb9.Controls.Clear()
gb10.Controls.Clear()
g1.Controls.Clear()
g2.Controls.Clear()
g3.Controls.Clear()
g4.Controls.Clear()
g5.Controls.Clear()
g6.Controls.Clear()
g7.Controls.Clear()
g8.Controls.Clear()
g9.Controls.Clear()
g10.Controls.Clear()
jam = 0
menit = 0
counter = 0
counter2 = 0
Dim day As Integer = DateTime.Now.ToString("HHmm")
Dim a1, a2, b1, b2, c1, c2 As String
a1 = sh1_a
a2 = sh1_b
b1 = sh2_a
b2 = sh2_b
c1 = sh3_a
c2 = sh3_b
If day > a1.Replace(":", "") And day < a2.Replace(":", "") Then current = "#" & sh1_a & "#"
If day > b1.Replace(":", "") And day < 2359 Then current = "#" & sh2_a & "#"
If day > 0 And day < b2.Replace(":", "") Then current = "#" & sh2_a & "#"
If day > c1.Replace(":", "") And day < c2.Replace(":", "") Then current = "#" & sh3_a & "#"
Call data_timeline(current)
End If
End If
End Sub
###############=> database bisa di sesuaikan
Public Sub read_data_shift(ByVal jam As String, ByVal jam1 As String, ByVal line As String, ByVal tgl As String)
Call conecDB()
Dim sqlQuery As String = "SELECT * from production where nama_line='" & line & "' and DATE(tanggal)='" & tgl & "' and time(tanggal) >= '" & jam & "' and time(tanggal) < '" & jam1 & "' order by kode desc limit 1"
Dim dbcomm = New MySqlCommand(sqlQuery, connDB)
Try
Dim i As Integer = dbcomm.ExecuteScalar()
If i <> 0 Then
Dim sqlReader As MySqlDataReader = dbcomm.ExecuteReader()
While sqlReader.Read()
Dim nama_line As String = sqlReader("nama_line").ToString()
Dim tanggal As String = sqlReader("tanggal").ToString()
Dim plan As String = sqlReader("plan").ToString()
Dim target As String = sqlReader("target").ToString()
Dim aktual As String = sqlReader("aktual").ToString()
Dim ok As String = sqlReader("ok").ToString()
Dim ng As String = sqlReader("ng").ToString()
pl.Text = "PLAN: " & plan
tr.Text = "TARGET: " & target
ak.Text = "AKTUAL: " & aktual
okk.Text = "OK: " & ok
ngg.Text = "NG: " & ng
prosen.Text = "Last Time: " & tanggal
quality.Text = "Quality: " & Round((ok / aktual) * 100) & "%"
eva.Text = "Available: " & Round(((480 - 30) / 480) * 100) & "%"
oee.Text = "OEE: " & Round((((ok / aktual) * (450 / 480)) * (counter / 480)) * 100) & "%"
End While
status = 1
Else
status = 0
End If
Catch ex As MySqlException
MsgBox(ex.Message)
End Try
connDB.Close()
End Sub
End Class
sekian dari saya, tinggalkan komentar agan klo masih pengintahu lebih dalam
Komentar
Posting Komentar