Jumat, 15 Maret 2013

Normalisasi (1NF, 2NF, 3NF)
1. Di bawah ini adalah kasus tabel un-normal sebuah peminjaman buku di perpustakaan


2. Tabel diatas kemudian dibuat normalisasi agar setiap tabel memiliki datanya masing-masing dan tidak overlap dengan tabel yang lain, disebut dengan 1NF


3. Tabel yang telah dinormalisasi diatas kemudian dipecah menjadi tiga bagian yaitu 2NF, karena dalam satu tabel di atas mengandung tiga functional dependencies yang perlu dipisah.

4. Tetapi di tabel ketiga terdapat atribut non-key yang masih punya functional dependencies (database peminjaman buku mahasiswa tersebut dan database peminjaman buku itu sendiri), oleh karena itu dibentuklah tabel 3NF yang memecah tabel 3.


 5. BCNF sama seperti bentuk 3NF.


Annisa M. Pamungkas
1106095681
Lab SMBD TSI 2011

Kamis, 03 Januari 2013

Aplikasi Database Undian Berhadiah dan Reportnya

Program aplikasi  berkaitan dengan database  dan penggunaan report  dengan Visual Basic.net

Aplikasi Database Undian Berhadiah dan Reportnya

Program "Hadiah" ini adalah program yang menghubungkan database pelanggan beberapa opertaor yang menjadi member undian berhadiah. setiap penukaran poinnya berarti menukar poin sebanyak nilainya.
Organisasi akan membuat program database dan laporan untuk proyek ini.


1) Buat database Poin berhadiah dan membernya dalam Microsoft Office Access



2) Buat sebuah project VB dalam Visual Studio
3) Kemudian buatlah sebuah form untuk login. Add New Item, Login Form

4) Buat coding pada button OK:


Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim login As New MDIParent1

'masukkan username dan password yg diinginkan'
        If UsernameTextBox.Text = "Annisa" And PasswordTextBox.Text = "987654" Then
            login.Show()
        Else
            MsgBox("Kesalahan saat memasukan Username atau Password")
        End If
        Me.Close()
    End Sub

5) Buat Form MDI Parent. Add New Item, MDI Parent Form

dalam form MDI terdapat: Menu Customer dan Menu Hadiah
dalam report terdapat: Report Customer dan Report Hadiah

6) Form Menu Hadiah
Buat item windows form , masukkan data access , caranya
Add New data source, ikuti petunjuk hingga finish
--> muncul data source drag semua tabel poin
--> drag gridview, masukkan isian data gridview dengan menekan tombol kecil di bagian atas kanan datagridview. ikuti petunjuk dan pilih tampilan yang diinginkan



7) Seperti langkah pada nomor 6, lakukan untuk form Menu Customer



8) Buat windows form baru untuk menampilkan report
--> dalam form tersebut, drag MicrosoftReportViewer dari toolbox
--> buat desain report baru dengan klik tombol kecil di  atas kanan report
--> new design
--> ikkuti petunjuk pembuatan desain
--> setelah selesai klik forward (segitiga kecil) lalu pilih report yg dibuat



berlaku sama pada form menu yang lain



9) tampilkan report masing-masing menu




SOURCE CODE

Login Form:

  Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim login As New MDIParent1

        If UsernameTextBox.Text = "Annisa" And PasswordTextBox.Text = "987654" Then
            login.Show()
        Else
            MsgBox("Kesalahan saat memasukan Username atau Password")
        End If
        Me.Close()
    End Sub

Form 1:


Public Class Form1

    Private Sub THadiahBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles THadiahBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.THadiahBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.HadiahDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'HadiahDataSet.THadiah' table. You can move, or remove it, as needed.
        Me.THadiahTableAdapter.Fill(Me.HadiahDataSet.THadiah)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.THadiahBindingSource.Filter = "KodePoin like '%" & TextBox1.Text & "%'"
    End Sub
End Class

Form 2:


Public Class Form2

    Private Sub TCustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCustomerBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.TCustomerBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.HadiahDataSet)

    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'HadiahDataSet.TCustomer' table. You can move, or remove it, as needed.
        Me.TCustomerTableAdapter.Fill(Me.HadiahDataSet.TCustomer)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.TCustomerBindingSource.Filter = "KodePoin like '%" & TextBox1.Text & "%' "
    End Sub
End Class


MDI Parent:


Imports System.Windows.Forms

Public Class MDIParent1

    Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewWindowToolStripMenuItem.Click
        Dim s As New Form1
        s.MdiParent = Me
        s.Show()
    End Sub

    Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click
        Dim s As New Form2
        s.MdiParent = Me
        s.Show()
    End Sub

    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim SaveFileDialog As New SaveFileDialog
        SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"

        If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
            Dim FileName As String = SaveFileDialog.FileName
            ' TODO: Add code here to save the current contents of the form to a file.
        End If
    End Sub


    Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        'Use My.Computer.Clipboard.GetText() or My.Computer.Clipboard.GetData to retrieve information from the clipboard.
    End Sub

    Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)

    End Sub

    Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)

    End Sub

    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub

    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

    Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
        Me.LayoutMdi(MdiLayout.ArrangeIcons)
    End Sub

    Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
        ' Close all child forms of the parent.
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
    End Sub

    Private m_ChildFormNumber As Integer

    Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
        Dim s As New Form3
        s.MdiParent = Me
        s.Show()
    End Sub

    Private Sub CustomerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim s As New Form4
        s.MdiParent = Me
        s.Show()
    End Sub

    Private Sub CustomerToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerToolStripMenuItem.Click
        Dim s As New Form4
        s.MdiParent = Me
        s.Show()
    End Sub






Kamis, 04 Oktober 2012

automation berkaitan dengan fungsi aritmatika dan penggunaan reference (Word/Excel) di Visual Basic.net



Automation ini menghubungkan data - data yang diinput ketika program .vb dijalankan menuju .docx (Ms. Word) dan .xlsx (Ms. Excel) secara otomatis, sehingga pengguna akan dengan mudah menginput data tanpa perlu membuka aplikasi Ms. Word atau Ms. Excel.

1. Penjelasan

Aplikasi "Menghitung Berat Badan Ideal"
Dengan memasukkan data: Nama, Tinggi Badan dan Berat Badan Anda, aplikasi ini secara otomatis akan menghitung berapa berat badan ideal anda dan berapa berat badan yang harus anda kurangi atau anda tambahkan.
Kemudian dengan meng-klik tombol "Cetak ke Ms. Word" atau "Cetak ke Ms. Excel", aplikasi ini akan membuka file Ms. Word atau Ms. Excel (read-only) sehingga bisa di simpan bahkan di Print.

2. Screenshot
Aplikasi yang dijalankan
output ke Ms. Word
Output ke Ms. Excel



 3. Code

Imports word = Microsoft.Office.Interop.Word
Imports excel = Microsoft.Office.Interop.Excel

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim beratideal As New Integer

        beratideal = 0.9 * (TextBox2.Text - 100)

        Label5.Text = " Berat badan ideal " & TextBox1.Text & " adalah " & beratideal & " kilogram "
        If TextBox3.Text > beratideal Then
            Label6.Text = TextBox1.Text & " harus MENGURANGI berat badan sebesar " & TextBox3.Text - beratideal & " kilogram "
        ElseIf TextBox3.Text < beratideal Then
            Label6.Text = TextBox1.Text & " harus MENAMBAH berat badan sebesar " & beratideal - TextBox3.Text & " kilogram "
        ElseIf TextBox3.Text = beratideal Then
            Label6.Text = TextBox1.Text & " sudah memiliki berat badan yang ideal "
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim myWordApp As New word.Application
        Dim myWordDoc As New word.Document

        myWordDoc = myWordApp.Documents.Open("C:\Users\ACER\Documents\Visual Studio 2010\Projects\AnnisaMufidhaniPamungkas--1106095681\menghitung.docx")
        myWordDoc.Bookmarks("nama").Select()
        myWordApp.Selection.TypeText(TextBox1.Text)
        myWordDoc.Bookmarks("tinggi").Select()
        myWordApp.Selection.TypeText(TextBox2.Text)
        myWordDoc.Bookmarks("berat").Select()
        myWordApp.Selection.TypeText(TextBox3.Text)
        myWordDoc.Bookmarks("ideal").Select()
        myWordApp.Selection.TypeText(Label5.Text)
        myWordDoc.Bookmarks("harus").Select()
        myWordApp.Selection.TypeText(Label6.Text)
        myWordDoc.SaveAs("E:\menghitung_new.docx")
        myWordApp.Visible = True
        myWordDoc.Close()

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim myExcelApp As New excel.Application
        Dim myExcelBook As New excel.Workbook
        Dim beratideal As New Integer

        beratideal = 0.9 * (TextBox2.Text - 100)

        myExcelApp.Visible = True
        myExcelBook = myExcelApp.Workbooks.Open("E:\menghitung.xlsx")
        myExcelApp.Range("B4").Value = TextBox1.Text
        myExcelApp.Range("B5").Value = TextBox2.Text
        myExcelApp.Range("B6").Value = TextBox3.Text
        myExcelApp.Range("B9").Value = beratideal
        myExcelBook.SaveAs("E:\menghitung_new.xlsx")
        myExcelApp.Quit()

    End Sub
End Class