Rabu, 29 Februari 2012

BIKIN POP UP VB.NET

PREVIEW


CODE :


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        textBoxContent.Text = "This is a sample content, it can spread on multiple lines"
        textBoxTitle.Text = "Title"
        textBoxDelayShowing.Text = "500"
        textBoxDelayStaying.Text = "3000"
        textBoxDelayHiding.Text = "500"
        checkBoxSelectionRectangle.Checked = True
        checkBoxTitleClickable.Checked = False
        checkBoxContentClickable.Checked = True
        checkBoxCloseClickable.Checked = True
        checkBoxKeepVisibleOnMouseOver.Checked = True
        checkBoxReShowOnMouseOver.Checked = False

        taskbarNotifier1 = New TaskBarNotifier()
        taskbarNotifier1.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier1.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), New Point(127, 8))
        taskbarNotifier1.TitleRectangle = New Rectangle(40, 9, 70, 25)
        taskbarNotifier1.TextRectangle = New Rectangle(8, 41, 133, 68)

        taskbarNotifier2 = New TaskBarNotifier()
        taskbarNotifier2.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin2.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier2.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close2.bmp"), Color.FromArgb(255, 0, 255), New Point(300, 74))
        taskbarNotifier2.TitleRectangle = New Rectangle(123, 80, 176, 16)
        taskbarNotifier2.TextRectangle = New Rectangle(116, 97, 197, 22)

        taskbarNotifier3 = New TaskBarNotifier()
        taskbarNotifier3.SetBackgroundBitmap(New Bitmap(MyClass.GetType(), "skin3.bmp"), Color.FromArgb(255, 0, 255))
        taskbarNotifier3.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"), Color.FromArgb(255, 0, 255), New Point(280, 57))
        taskbarNotifier3.TitleRectangle = New Rectangle(150, 57, 125, 28)
        taskbarNotifier3.TextRectangle = New Rectangle(75, 92, 215, 55)

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    Friend WithEvents groupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents label2 As System.Windows.Forms.Label
    Friend WithEvents label1 As System.Windows.Forms.Label
    Friend WithEvents textBoxContent As System.Windows.Forms.TextBox
    Friend WithEvents textBoxTitle As System.Windows.Forms.TextBox
    Friend WithEvents groupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents label5 As System.Windows.Forms.Label
    Friend WithEvents label4 As System.Windows.Forms.Label
    Friend WithEvents label3 As System.Windows.Forms.Label
    Friend WithEvents textBoxDelayShowing As System.Windows.Forms.TextBox
    Friend WithEvents textBoxDelayStaying As System.Windows.Forms.TextBox
    Friend WithEvents textBoxDelayHiding As System.Windows.Forms.TextBox
    Friend WithEvents groupBox3 As System.Windows.Forms.GroupBox
    Friend WithEvents checkBoxCloseClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxContentClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxTitleClickable As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxSelectionRectangle As System.Windows.Forms.CheckBox
    Friend WithEvents ButtonShowPopup2 As System.Windows.Forms.Button
    Friend WithEvents ButtonShowPopup1 As System.Windows.Forms.Button
    Friend WithEvents ButtonShowPopup3 As System.Windows.Forms.Button
    Friend WithEvents checkBoxKeepVisibleOnMouseOver As System.Windows.Forms.CheckBox
    Friend WithEvents checkBoxReShowOnMouseOver As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.groupBox1 = New System.Windows.Forms.GroupBox()
        Me.label2 = New System.Windows.Forms.Label()
        Me.label1 = New System.Windows.Forms.Label()
        Me.textBoxContent = New System.Windows.Forms.TextBox()
        Me.textBoxTitle = New System.Windows.Forms.TextBox()
        Me.groupBox2 = New System.Windows.Forms.GroupBox()
        Me.label5 = New System.Windows.Forms.Label()
        Me.label4 = New System.Windows.Forms.Label()
        Me.label3 = New System.Windows.Forms.Label()
        Me.textBoxDelayShowing = New System.Windows.Forms.TextBox()
        Me.textBoxDelayStaying = New System.Windows.Forms.TextBox()
        Me.textBoxDelayHiding = New System.Windows.Forms.TextBox()
        Me.groupBox3 = New System.Windows.Forms.GroupBox()
        Me.checkBoxCloseClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxContentClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxTitleClickable = New System.Windows.Forms.CheckBox()
        Me.checkBoxSelectionRectangle = New System.Windows.Forms.CheckBox()
        Me.ButtonShowPopup2 = New System.Windows.Forms.Button()
        Me.ButtonShowPopup1 = New System.Windows.Forms.Button()
        Me.ButtonShowPopup3 = New System.Windows.Forms.Button()
        Me.checkBoxKeepVisibleOnMouseOver = New System.Windows.Forms.CheckBox()
        Me.checkBoxReShowOnMouseOver = New System.Windows.Forms.CheckBox()
        Me.groupBox1.SuspendLayout()
        Me.groupBox2.SuspendLayout()
        Me.groupBox3.SuspendLayout()
        Me.SuspendLayout()
        '
        'groupBox1
        '
        Me.groupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.label2, Me.label1, Me.textBoxContent, Me.textBoxTitle})
        Me.groupBox1.Location = New System.Drawing.Point(4, 4)
        Me.groupBox1.Name = "groupBox1"
        Me.groupBox1.Size = New System.Drawing.Size(296, 88)
        Me.groupBox1.TabIndex = 8
        Me.groupBox1.TabStop = False
        Me.groupBox1.Text = "Text"
        '
        'label2
        '
        Me.label2.Location = New System.Drawing.Point(12, 52)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(48, 16)
        Me.label2.TabIndex = 10
        Me.label2.Text = "Content"
        '
        'label1
        '
        Me.label1.Location = New System.Drawing.Point(12, 20)
        Me.label1.Name = "label1"
        Me.label1.Size = New System.Drawing.Size(40, 16)
        Me.label1.TabIndex = 9
        Me.label1.Text = "Title"
        '
        'textBoxContent
        '
        Me.textBoxContent.Location = New System.Drawing.Point(60, 52)
        Me.textBoxContent.Name = "textBoxContent"
        Me.textBoxContent.Size = New System.Drawing.Size(224, 20)
        Me.textBoxContent.TabIndex = 8
        Me.textBoxContent.Text = "textBoxContent"
        '
        'textBoxTitle
        '
        Me.textBoxTitle.Location = New System.Drawing.Point(60, 20)
        Me.textBoxTitle.Name = "textBoxTitle"
        Me.textBoxTitle.Size = New System.Drawing.Size(224, 20)
        Me.textBoxTitle.TabIndex = 7
        Me.textBoxTitle.Text = "textBoxTitle"
        '
        'groupBox2
        '
        Me.groupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.label5, Me.label4, Me.label3, Me.textBoxDelayShowing, Me.textBoxDelayStaying, Me.textBoxDelayHiding})
        Me.groupBox2.Location = New System.Drawing.Point(4, 100)
        Me.groupBox2.Name = "groupBox2"
        Me.groupBox2.Size = New System.Drawing.Size(296, 88)
        Me.groupBox2.TabIndex = 15
        Me.groupBox2.TabStop = False
        Me.groupBox2.Text = "Animation Delays (ms)"
        '
        'label5
        '
        Me.label5.Location = New System.Drawing.Point(200, 28)
        Me.label5.Name = "label5"
        Me.label5.Size = New System.Drawing.Size(80, 16)
        Me.label5.TabIndex = 19
        Me.label5.Text = "Delay Hiding"
        '
        'label4
        '
        Me.label4.Location = New System.Drawing.Point(112, 28)
        Me.label4.Name = "label4"
        Me.label4.Size = New System.Drawing.Size(80, 16)
        Me.label4.TabIndex = 18
        Me.label4.Text = "Delay Staying"
        '
        'label3
        '
        Me.label3.Location = New System.Drawing.Point(16, 28)
        Me.label3.Name = "label3"
        Me.label3.Size = New System.Drawing.Size(80, 16)
        Me.label3.TabIndex = 17
        Me.label3.Text = "Delay Showing"
        '
        'textBoxDelayShowing
        '
        Me.textBoxDelayShowing.Location = New System.Drawing.Point(24, 52)
        Me.textBoxDelayShowing.Name = "textBoxDelayShowing"
        Me.textBoxDelayShowing.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayShowing.TabIndex = 16
        Me.textBoxDelayShowing.Text = "textBoxDelayShowing"
        '
        'textBoxDelayStaying
        '
        Me.textBoxDelayStaying.Location = New System.Drawing.Point(120, 52)
        Me.textBoxDelayStaying.Name = "textBoxDelayStaying"
        Me.textBoxDelayStaying.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayStaying.TabIndex = 15
        Me.textBoxDelayStaying.Text = "textBoxDelayStaying"
        '
        'textBoxDelayHiding
        '
        Me.textBoxDelayHiding.Location = New System.Drawing.Point(208, 52)
        Me.textBoxDelayHiding.Name = "textBoxDelayHiding"
        Me.textBoxDelayHiding.Size = New System.Drawing.Size(56, 20)
        Me.textBoxDelayHiding.TabIndex = 14
        Me.textBoxDelayHiding.Text = "textBoxDelayHiding"
        '
        'groupBox3
        '
        Me.groupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.checkBoxReShowOnMouseOver, Me.checkBoxKeepVisibleOnMouseOver, Me.checkBoxCloseClickable, Me.checkBoxContentClickable, Me.checkBoxTitleClickable, Me.checkBoxSelectionRectangle})
        Me.groupBox3.Location = New System.Drawing.Point(4, 192)
        Me.groupBox3.Name = "groupBox3"
        Me.groupBox3.Size = New System.Drawing.Size(296, 116)
        Me.groupBox3.TabIndex = 16
        Me.groupBox3.TabStop = False
        Me.groupBox3.Text = "Options"
        '
        'checkBoxCloseClickable
        '
        Me.checkBoxCloseClickable.Location = New System.Drawing.Point(16, 48)
        Me.checkBoxCloseClickable.Name = "checkBoxCloseClickable"
        Me.checkBoxCloseClickable.Size = New System.Drawing.Size(104, 16)
        Me.checkBoxCloseClickable.TabIndex = 3
        Me.checkBoxCloseClickable.Text = "Close Clickable"
        '
        'checkBoxContentClickable
        '
        Me.checkBoxContentClickable.Location = New System.Drawing.Point(128, 24)
        Me.checkBoxContentClickable.Name = "checkBoxContentClickable"
        Me.checkBoxContentClickable.Size = New System.Drawing.Size(112, 16)
        Me.checkBoxContentClickable.TabIndex = 1
        Me.checkBoxContentClickable.Text = "Content Clickable"
        '
        'checkBoxTitleClickable
        '
        Me.checkBoxTitleClickable.Location = New System.Drawing.Point(16, 24)
        Me.checkBoxTitleClickable.Name = "checkBoxTitleClickable"
        Me.checkBoxTitleClickable.Size = New System.Drawing.Size(96, 16)
        Me.checkBoxTitleClickable.TabIndex = 0
        Me.checkBoxTitleClickable.Text = "Title Clickable"
        '
        'checkBoxSelectionRectangle
        '
        Me.checkBoxSelectionRectangle.Location = New System.Drawing.Point(128, 48)
        Me.checkBoxSelectionRectangle.Name = "checkBoxSelectionRectangle"
        Me.checkBoxSelectionRectangle.Size = New System.Drawing.Size(160, 16)
        Me.checkBoxSelectionRectangle.TabIndex = 2
        Me.checkBoxSelectionRectangle.Text = "Show Selection Rectangle"
        '
        'ButtonShowPopup2
        '
        Me.ButtonShowPopup2.Location = New System.Drawing.Point(108, 316)
        Me.ButtonShowPopup2.Name = "ButtonShowPopup2"
        Me.ButtonShowPopup2.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup2.TabIndex = 18
        Me.ButtonShowPopup2.Text = "Show popup 2"
        '
        'ButtonShowPopup1
        '
        Me.ButtonShowPopup1.Location = New System.Drawing.Point(8, 316)
        Me.ButtonShowPopup1.Name = "ButtonShowPopup1"
        Me.ButtonShowPopup1.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup1.TabIndex = 17
        Me.ButtonShowPopup1.Text = "Show popup 1"
        '
        'ButtonShowPopup3
        '
        Me.ButtonShowPopup3.Location = New System.Drawing.Point(208, 316)
        Me.ButtonShowPopup3.Name = "ButtonShowPopup3"
        Me.ButtonShowPopup3.Size = New System.Drawing.Size(88, 23)
        Me.ButtonShowPopup3.TabIndex = 19
        Me.ButtonShowPopup3.Text = "Show popup 3"
        '
        'checkBoxKeepVisibleOnMouseOver
        '
        Me.checkBoxKeepVisibleOnMouseOver.Location = New System.Drawing.Point(16, 72)
        Me.checkBoxKeepVisibleOnMouseOver.Name = "checkBoxKeepVisibleOnMouseOver"
        Me.checkBoxKeepVisibleOnMouseOver.Size = New System.Drawing.Size(272, 16)
        Me.checkBoxKeepVisibleOnMouseOver.TabIndex = 4
        Me.checkBoxKeepVisibleOnMouseOver.Text = "Keep Visible when Mouse over window"
        '
        'checkBoxReShowOnMouseOver
        '
        Me.checkBoxReShowOnMouseOver.Location = New System.Drawing.Point(16, 92)
        Me.checkBoxReShowOnMouseOver.Name = "checkBoxReShowOnMouseOver"
        Me.checkBoxReShowOnMouseOver.Size = New System.Drawing.Size(272, 16)
        Me.checkBoxReShowOnMouseOver.TabIndex = 5
        Me.checkBoxReShowOnMouseOver.Text = "Re-show when Mouse over window when hiding"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(304, 349)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ButtonShowPopup3, Me.ButtonShowPopup2, Me.ButtonShowPopup1, Me.groupBox3, Me.groupBox2, Me.groupBox1})
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "VB.NET TaskBarNotifier Demo"
        Me.groupBox1.ResumeLayout(False)
        Me.groupBox2.ResumeLayout(False)
        Me.groupBox3.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private WithEvents taskbarNotifier1 As TaskBarNotifier
    Private WithEvents taskbarNotifier2 As TaskBarNotifier
    Private WithEvents taskbarNotifier3 As TaskBarNotifier


    Private Sub Notifier_CloseButtonClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.CloseButtonClick, _
                                                                    taskbarNotifier2.CloseButtonClick, _
                                                                    taskbarNotifier3.CloseButtonClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: CloseButton was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: CloseButton was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: CloseButton was clicked")
        End If

    End Sub

    Private Sub Notifier_TitleClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.TitleClick, _
                                                                    taskbarNotifier2.TitleClick, _
                                                                    taskbarNotifier3.TitleClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: Title was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: Title was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: Title was clicked")
        End If

    End Sub

    Private Sub Notifier_TextClick(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                            Handles taskbarNotifier1.TextClick, _
                                                                    taskbarNotifier2.TextClick, _
                                                                    taskbarNotifier3.TextClick

        Dim taskbarSender As TaskBarNotifier = DirectCast(sender, TaskBarNotifier)

        If taskbarSender.Equals(taskbarNotifier1) Then
            MsgBox("TaskBarNotifier 1: TextZone was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier2) Then
            MsgBox("TaskBarNotifier 2: TextZone was clicked")
        End If

        If taskbarSender.Equals(taskbarNotifier3) Then
            MsgBox("TaskBarNotifier 3: TextZone was clicked")
        End If

    End Sub

    Private Sub ButtonShowPopup1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup1.Click

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier1
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With

    End Sub

    Private Sub ButtonShowPopup2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup2.Click

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier2
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With
    End Sub

    Private Sub ButtonShowPopup3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonShowPopup3.Click

        'This is an addition TaskbarNotifier window.
        'Made this in order to see how 'easy' it is to create my own custom skin.

        ' Believe me... If you know your way around in a bitmap editor...It's EASY !!! :-)

        If (textBoxTitle.Text.Length = 0 OrElse textBoxContent.Text.Length = 0) Then
            MsgBox("Enter a title and a content Text")
            Exit Sub
        End If

        If Not IsNumeric(textBoxDelayShowing.Text) OrElse _
           Not IsNumeric(textBoxDelayStaying.Text) OrElse _
           Not IsNumeric(textBoxDelayHiding.Text) Then
            MsgBox("Enter valid Delays (integers)")
            Exit Sub
        End If

        With taskbarNotifier3
            .NormalTitleColor = Color.Black
            .HoverTitleColor = Color.Black
            .NormalContentColor = Color.Yellow
            .HoverContentColor = Color.White
            .CloseButtonClickEnabled = checkBoxCloseClickable.Checked
            .TitleClickEnabled = checkBoxTitleClickable.Checked
            .TextClickEnabled = checkBoxContentClickable.Checked
            .DrawTextFocusRect = checkBoxSelectionRectangle.Checked
            .KeepVisibleOnMouseOver = checkBoxKeepVisibleOnMouseOver.Checked
            .ReShowOnMouseOver = checkBoxReShowOnMouseOver.Checked
            .Show(textBoxTitle.Text, _
                  textBoxContent.Text, _
                  Integer.Parse(textBoxDelayShowing.Text), _
                  Integer.Parse(textBoxDelayStaying.Text), _
                  Integer.Parse(textBoxDelayHiding.Text))
        End With

    End Sub

End Class
 


Trik SQl server (menghitung total detail dalam header)

Bingung juga mau ngasih judul tuk postingan yang satu ni, benernya sie ini trik lama, yaa itung itung buat nambah postingan, barang kali bisa bermanfaat. ok dah, mending langsung ke TKP aja..!!!

Temen temen yang biasa buat program pasti dah ga asing dengan istilah "Header n Dettail", ya jelaslah klo misal mau bikin program transaksi pasti harus punya header untuk mencatat isi pokok transaksi spt( kode,tanggal transaksi, subject yg melakukan transaksi dll), nah sedangkan untuk detail transaksinya dibuat untuk mencatat detail transaksi,dengan mengacu primary key yg ada di header sebagai foreign key  di detail..

KASUS

Kita ambil contoh kasus dalam transaksi Pinjam di Koperasi,,
contoh table Pinjam_hdr (header)


 contoh table Pinjam_dtl (detail)


Sekarang kita mau menampilkan jumlah pinjam (jmlpinjam) di table pinjam_hdr dan menampilkan total dari jumlah pokok (jmlpokok) di table pinjam detail  dengan filter yg sudah dibayar (dibayar=1),

 QUERY :

SELECT     (SELECT     SUM(JMLPOKOK)
                       FROM          PINJAM_DTL
                       WHERE      DIBAYAR = 1 AND PINJAM_DTL.NOPINJAM = PINJAM_HDR.NOPINJAM) AS JMLPOKOK, JMLPINJAM, NOPINJAM, NAMA_NASABAH,
                      TGLPINJAM
FROM         dbo.PINJAM_HDR
WHERE     (NOPINJAM = 'KT-1109-0037')


HASIL :


HASIL TANPA FILTER NOPINJAM


QUERY :

SELECT     (SELECT     SUM(JMLPOKOK)
                       FROM          PINJAM_DTL
                       WHERE      DIBAYAR = 1 AND PINJAM_DTL.NOPINJAM = PINJAM_HDR.NOPINJAM) AS JMLPOKOK, JMLPINJAM, NOPINJAM, NAMA_NASABAH,
                      TGLPINJAM
FROM         dbo.PINJAM_HDR

Jumat, 17 Februari 2012

Property

Sebuah  field dalam class memiliki access modifier  tertentu, bisa private, public, atau protected.
Kita  harus  bijaksana  dalam menggunakan  access modifier  field  ini,  jika  tidak  berhati-hati  bisa
menyebakan desain class kita rentan terhadap perubahan dikemudian hari.   Salah satu point yang
hendak dicapai dalam Object Oriented Desain adalah meminimalkan terjadinya ripple effect. Efek
ini bisa terjadi jika perubahan class yang satu mengakibatkan perubahan di class  lainnya,  istilah
lainnya  adalah  "tighty-coupled".  Demi  Encapsulation,  variabel/data  tidak  boleh  diekspose
langsung,  karena  itu  access modifier  nya  harus  private.  Lalu  bagaimana  cara  saya mengakses
variabel  tersebut  dari  class  lain.  Bukankah  kalau  access  modifier  nya  private  hanya  dikenal
diclass  tersebut? Variabel hanya boleh diakses  lewat method  accessor dan mutator nya. What
the #$%@#  istilah apa  lagi itu accessor dan mutator? makin memusingkan saja OOP ini!

Kita lihat contoh berikut :
public class Customer
{
    //Field
    private string customerId;

    //Accessor

    public string GetCustomerId()
    {
        return customerId;
    }

    //Mutator

    public void SetCustomerId(string customerId)
    {
        this.customerId = customerId;
    }
}

Kita  punya  sebuah  field  bernama  customerId  dengan  tipe  string  dan  access  modifier  private.
Untuk mengakses  nilai  variabel  customerId  ini  harus  lewat method  GetCustomerId()  terlebuh
dahulu.  Jika  ingin mengubah  nilai  customerId  harus melalui method  SetCustomerId()  dengan
parameter  customerId.  Method  yang  pertama  disebut  Accessor  karena  fungsinya    untuk
mengakses nilai sebuah field, sedangkan yang kedua disebut mutator karena fungsinya mengubah
nilai.

Contoh Penggunaanya :

Customer cust = new Customer();
cust.SetCustomerId("XERIS"); //mengubah variabel customerId
Console.WriteLine(cust.GetCustomerId());//mengakses variabel customerId 

Di  .NET  ada  cara  efesien  untuk  memadukan  Accessor  dan  mutator  ini  dalam  satu  kesatuan
dengan menggunakan sebuah method tunggal yang disebut Property.

Contoh Poperty :

public class Customer
{
    //Field

    private string customerId;
    private string companyName;

    //Property

    public string CustomerId
    {
        get { return customerId; }
        set { customerId = value; }
    }

    public string CompanyName
    {
        get { return companyName; }
        set { companyName = value; }
    }
}

pada property CustomerId, method Accessor diwakili oleh get dan mutator oleh set. Lebih simple
bukan :-)
 
Cara Penggunaannya :

Customer cust = new Customer();

//memodifikasi nilai variabel customerId

cust.CustomerId = "XERIS"; 

//menampilkan nilai variabel customerId

Console.WriteLine(cust.CustomerId); 

Code Lengkap :
public class Customer
{
    private string customerId;
    private string companyName;
    private string contactName;
    private string address;
    private string phone;

    //Constructor Default

    public Customer()
    {

    }

    //Constructor Overloading

    public Customer(string customerId, string companyName,
        string contactName, string address, string phone)
    {
        this.customerId = customerId;
        this.companyName = companyName;
        this.contactName = contactName;
        this.address = address;
        this.phone = phone;

    }

    public string CustomerId
    {
        get { return customerId; }
        set { customerId = value; }
    }

    public string CompanyName
    {
        get { return companyName; }
        set { companyName = value; }
    }

    public string ContactName
    {
        get { return contactName; }
        set { contactName = value; }
    }

    public string Address
    {
        get { return address; }
        set { address = value; }
    }

    public string phone
    { 
        get { return phone; }
        set { phone = value; }
    }
}

Constructor

Sebuah class dapat memiliki 0-n cosntructor. Constructor  ini  sifatnya optional, boleh ada boleh
juga  tidak.  Constructor  sebetulnya  adalah  sebuah method  special  yang  akan  selalu  dieksekusi
ketika class diinstantiasi. Penulisan constructor  harus sama dengan nama class nya . Jika di class
tersebut  tidak memiliki  constructor maka  compiler  akan membuatkan  constructor  default  yang
tidak memiliki implementasi apapun

public class Customer
{
    private string customerId;
    private string companyName;
    private string contactName;
    private string address;
    private string phone;

    //Constructor Default

    public Customer()
    {
    }

    public class Customer
    {
        private string customerId;
        private string companyName;
        private string contactName;
        private string address;
         private string phone;

        //Constructor Default

        public Customer()
        {

        }

        //Constructor Overloading

        public Customer(string customerId, string companyName,
            string contactName, string address, string phone)
        {
            this.customerId = customerId;
            this.companyName = companyName;
            this.contactName = contactName;
            this.address = address;
            this.phone = phone;
        }
    }

    
    public Customer(string customerId, string companyName,
        string contactName, string address, string phone)
    {
        this.customerId = customerId;
        this.companyName = companyName;
        this.contactName = contactName;
        this.address = address;
        this.phone = phone;

      }

 }

Class Customer memiliki 2 buah constructor, yang pertama constructor default  tanpa parameter
dan  implementasi,  dan  constructor  kedua    memiliki  5  parameter.  Keyword  this  menunjukkan
object  aktif  pada  saat  itu.  Jadi  this.customerId  adalah  variabel  field  sedangkan  customerId
setelah sama dengan adalah variabel parameter constructor

Kita bisa memilik banyak constructor dalam satu class, dengan parameter dan implementasi yang
berbeda-beda istilah dalam OOP disebut polymorphism. Dalam polymorphism ini dikenal istilah
overriding  dan  overloading.  Jika  constructor  kita  memiliki  parameter  yang  berbeda  disebut
overloading, jika memiliki parameter yang sama namun implementasi berbeda disebut overriding.
Selain constructor polymorphism juga bisa dikenakan kepada sebuah method.

Apa itu Class?

Salah  satu  teknik yang diperkenalkan OOP adalah Encapsulation atau pengkapsulan. Teknik  ini
menjamin pembungkusan data beserta operasi-operasinya dalam suatu modul yang disebut class.
Saya  sangat  setuju  dengan  pendapat  Bertrand Meyer,  yang  mengatakan  bahwa  class  adalah
modul sekaligus sebuah tipe data. Istilah modul diambil dari paradigma pemrograman terstruktur
yang  bertujuan  mengelompokkan  procedure-procedure  kedalam  kelompok-kelompok  tertentu
sesuai dengan  fungsinya. Class dapat  juga dipandang  sebagai  sebuah blue print/cetak biru yang
membentuk  sebuah  objek.  Bisa  saya  analogikan  kalau  class  adalah  cetakan  kue  maka  objek
(instance  dari  class)  adalah  kue  nya

Configure MS SQL Server 2005 Remote Access

Configure MS SQL Server 2005 Remote Access ( mixed mode )

MS SQL Server 2005 remote access configuration is different from MS SQL Server 2000. Remote access to MS SQL Server 2005 with user and password is required and necessary for any database applications. If MS SQL Server 2005 is originally configured for windows authentication, configuration for remote access ( mixed mode or SQL Server authentication ) needs a little more extra work to get it done.
Here is how to get this done.

1. Configuration in SQL Server Management Studio

Click “All Programs” -> Click “Microsoft SQL Server 2005” -> click “Microsoft SQL Server Management Studio”
Log in to SQL Server 2005 with windows authentication or sa user;
Highlight the server and right click “Properties”;
Highlight “Security”  -> Under “Server authentication”,  choose “SQL Server and Windows authentication mode”;
Highlight “Connections” -> Under “Remote server connections”,  choose “Allow remote connections to this server”;

Click OK to save the settings.

2. Configuration in SQL Server Surface Area Configuration
Click “All Programs” -> Click “Microsoft SQL Server 2005” -> click “Configuration Tools” -> click “SQL Server 2005 Surface Area Configuration”

Click “Surface Area Configuration for Services and Connections” -> click “MSSQLSERVER” -> click “Database engine” -> click “Remote connections ” -> Under “Local and remote connections”, choose “Using TCP/IP only” or other protocols.

Click “Apply” to save the settings.

3. Stop SQL server and restart SQL server
Use “SQL Server Management Studio” or Services in Control Panel to stop SQL Server and then restart the SQL Server. This process is used to initialize the change settings.

4. Test the changes
a. Create the user through “Security” -> “Logins” -> “New Logins…”

b. log in with the newly created user  when “Authentication”  is “SQL Server authentication” under local SQL server or under remote SQL server.