0% found this document useful (0 votes)
7 views2 pages

2 Frmbuka

Uploaded by

ilham fiqri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

2 Frmbuka

Uploaded by

ilham fiqri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Option Strict On

Imports VB = Microsoft.VisualBasic
Imports Praktikum.classGlobalVariable
Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class frmBaru

Dim KodeAnalisis As String


Public Tabel As DataTable
Public VarStr, VarStr1, Varstr2, VarStr3 As String

Private Sub BuatKode ()


mdlKoneksi.OpenConnection()
Dim sql = "select * from KodeAnalisis order by Kode desc"
Dim sqlc As OleDbCommand = New OleDbCommand (sql, xConnection)
Dim xDataReader As OleDbDataReader
xDataReader = sqlc.ExecuteReader
xDataReader.Read()
If Not xDataReader.HasRows Then
txtKode.Text = "KD" + "0001"
Else
txtKode.Text =
CSte(Val(Microsoft.VisualBasic_.Mid(xDataReader.Item("Kode") .ToString,4, 3)) + 1)
If Len(txtKode.Text) = 1 Then
txtKode.Text= "KD000" & txtKode.Text & ""
ElseIf Len(txtKode.Text) = 2 Then
txtKode.Text= "KD00" & txtKode.Text & ""
ElseIf Len(txtKode.Text) = 3 Then
txtKode.Text= "KD0" & txtKode.Text & ""
End If
End If
xDataReader.Close()
XConnection.Close()
End Sub

Private Sub frmBaru_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
txtTanggal.Text = CStr(Date.Today0
btnOK.Enabled = False
BuatKode()
End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnOK.Click
mdlKoneksi.OpentConnection()
Dim sql = "insert into KodeAnalisis(Kode,Tanggal,Pengguna)values " & _ " ('" &
txtKode.Text & "','" & txtTanggal.Text &"','" & txtPengguna.Text & "')"

Dim sqlc As OleDbCommand = New OleDbCommand(sql, xConnection)


Dim xDataReader As OleDbDataReader
xDataReader = sqlc.ExecuteReader()
xDataReader.Close()
xConnection.Close()
With FormUtama
.ToolStripStatusKode.Text = txtKode.Text
.ToolStripStatusTanggal.Text = txtTanggal.Text
.ToolStripStatusNama.Text = txtPengguna.Text
.Show()
End Sub
FormUtama.PictureBoxDisplay.Dock = DockStyle.Top
FormUtama.PictureBoxDisplay.Dock = DockStyle.Fill
FormUtama.BaruToolStripMenuItem.Enabled = False
frmModelStruktur.ShowDialog()

End Sub

Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub

Private Sub txtPengguna_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtPengguna.TextChanged
btnOK.Enabled = True
End Sub
End Class

You might also like