VERSION 5.00
Begin VB.Form frmPeminjaman 
   Caption         =   ". . : :  P E M I N J A M A N  : : . ."
   ClientHeight    =   7545
   ClientLeft      =   2280
   ClientTop       =   2850
   ClientWidth     =   8310
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7545
   ScaleWidth      =   8310
   Begin VB.ListBox lsTampungStock 
      Height          =   840
      Left            =   960
      TabIndex        =   38
      Top             =   6480
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.TextBox txtTampungJumlah 
      Height          =   375
      Left            =   2040
      TabIndex        =   37
      Top             =   6840
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.TextBox txtTampungId 
      Height          =   375
      Left            =   2040
      TabIndex        =   36
      Top             =   6480
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.ListBox lsAkhir 
      Height          =   840
      Left            =   4920
      TabIndex        =   34
      Top             =   6600
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.TextBox txtNoTrans 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5760
      Locked          =   -1  'True
      TabIndex        =   32
      Top             =   720
      Width           =   2415
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "&Cancel"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6840
      TabIndex        =   31
      Top             =   5280
      Width           =   1215
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "&Save"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6840
      TabIndex        =   30
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmdNew 
      Caption         =   "&New"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   6840
      TabIndex        =   29
      Top             =   3840
      Width           =   1215
   End
   Begin VB.TextBox txtTemp 
      Height          =   375
      Left            =   3600
      TabIndex        =   28
      Top             =   6480
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.TextBox txtAkhir 
      Height          =   375
      Left            =   3600
      TabIndex        =   27
      Top             =   6840
      Visible         =   0   'False
      Width           =   1215
   End
   Begin VB.TextBox txtBayar 
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3600
      TabIndex        =   25
      Top             =   5880
      Width           =   2055
   End
   Begin VB.CommandButton cmdGetFilm 
      Caption         =   "..."
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "Arial Black"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5880
      TabIndex        =   24
      Top             =   3600
      Width           =   495
   End
   Begin VB.ListBox lsJumlah 
      Enabled         =   0   'False
      Height          =   1620
      Left            =   4440
      TabIndex        =   23
      Top             =   4080
      Width           =   1215
   End
   Begin VB.ListBox lsJudul 
      Enabled         =   0   'False
      Height          =   1620
      Left            =   3000
      TabIndex        =   22
      Top             =   4080
      Width           =   1215
   End
   Begin VB.ListBox lsGenre 
      Enabled         =   0   'False
      Height          =   1620
      Left            =   1560
      TabIndex        =   21
      Top             =   4080
      Width           =   1215
   End
   Begin VB.ListBox lsIDFilm 
      Enabled         =   0   'False
      Height          =   1620
      Left            =   120
      TabIndex        =   20
      Top             =   4080
      Width           =   1215
   End
   Begin VB.TextBox txtJumlah 
      Enabled         =   0   'False
      Height          =   375
      Left            =   4440
      TabIndex        =   15
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox txtJudul 
      Height          =   375
      Left            =   3000
      Locked          =   -1  'True
      TabIndex        =   14
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox txtGenre 
      Height          =   375
      Left            =   1560
      Locked          =   -1  'True
      TabIndex        =   13
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox txtId 
      Height          =   375
      Left            =   120
      Locked          =   -1  'True
      TabIndex        =   12
      Top             =   3600
      Width           =   1215
   End
   Begin VB.TextBox txtTglPinjam 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5760
      Locked          =   -1  'True
      TabIndex        =   5
      Top             =   1680
      Width           =   2415
   End
   Begin VB.TextBox txtTglKembali 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5760
      Locked          =   -1  'True
      TabIndex        =   4
      Top             =   2520
      Width           =   2415
   End
   Begin VB.TextBox txtTelp 
      Height          =   375
      Left            =   1440
      Locked          =   -1  'True
      TabIndex        =   3
      Top             =   2520
      Width           =   2415
   End
   Begin VB.TextBox txtAlamat 
      Height          =   375
      Left            =   1440
      Locked          =   -1  'True
      TabIndex        =   2
      Top             =   1920
      Width           =   2415
   End
   Begin VB.TextBox txtNama 
      Height          =   375
      Left            =   1440
      Locked          =   -1  'True
      TabIndex        =   1
      Top             =   1320
      Width           =   2415
   End
   Begin VB.ComboBox cboIdAngg 
      Enabled         =   0   'False
      Height          =   315
      Left            =   1440
      TabIndex        =   0
      Top             =   720
      Width           =   2415
   End
   Begin VB.Label Label13 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "TRANSAKSI PEMINJAMAN FILM"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   495
      Left            =   240
      TabIndex        =   35
      Top             =   120
      Width           =   7935
   End
   Begin VB.Label Label12 
      BackStyle       =   0  'Transparent
      Caption         =   "No Transaksi"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   3960
      TabIndex        =   33
      Top             =   720
      Width           =   1935
   End
   Begin VB.Label Label11 
      BackStyle       =   0  'Transparent
      Caption         =   "TOTAL BAYAR"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   1920
      TabIndex        =   26
      Top             =   5880
      Width           =   1695
   End
   Begin VB.Label Label10 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Jumlah"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   4440
      TabIndex        =   19
      Top             =   3360
      Width           =   1215
   End
   Begin VB.Label Label9 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Judul"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   3000
      TabIndex        =   18
      Top             =   3360
      Width           =   1215
   End
   Begin VB.Label Label8 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Genre"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   1560
      TabIndex        =   17
      Top             =   3360
      Width           =   1215
   End
   Begin VB.Label Label7 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "ID Film"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   120
      TabIndex        =   16
      Top             =   3360
      Width           =   1215
   End
   Begin VB.Line Line1 
      BorderWidth     =   5
      X1              =   0
      X2              =   10320
      Y1              =   3120
      Y2              =   3120
   End
   Begin VB.Label Label6 
      Alignment       =   2  'Center
      BackStyle       =   0  'Transparent
      Caption         =   "Tanggal DiKembalikan"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   495
      Left            =   3960
      TabIndex        =   11
      Top             =   2400
      Width           =   1935
   End
   Begin VB.Label Label5 
      BackStyle       =   0  'Transparent
      Caption         =   "Tanggal  Pinjam"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   3960
      TabIndex        =   10
      Top             =   1680
      Width           =   1935
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "Telp"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   240
      TabIndex        =   9
      Top             =   2520
      Width           =   1335
   End
   Begin VB.Label Label3 
      BackStyle       =   0  'Transparent
      Caption         =   "Alamat"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   240
      TabIndex        =   8
      Top             =   1920
      Width           =   1335
   End
   Begin VB.Label Label2 
      BackStyle       =   0  'Transparent
      Caption         =   "Nama"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   240
      TabIndex        =   7
      Top             =   1320
      Width           =   1335
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "ID Anggota"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   375
      Left            =   240
      TabIndex        =   6
      Top             =   720
      Width           =   1335
   End
End
Attribute VB_Name = "frmPeminjaman"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim oldsize As Long
Dim bantu As Boolean
   
Private Sub Form_Resize()
    If Me.Width = oldsize Then
        Exit Sub
    Else
        CenterC Me
        oldsize = Me.Width
    End If
    If Me.Width <> 8430 Then Me.Width = 8430
    If Me.Height <> 6900 Then Me.Height = 6900
End Sub

Sub bersih1()
    cboIdAngg = ""
    txtNama = ""
    txtAlamat = ""
    txtTelp = ""
    txtTglPinjam = ""
    txtTglKembali = ""
    txtNoTrans = ""
End Sub

Sub bersih2()
    txtId = ""
    txtGenre = ""
    txtJudul = ""
    txtJumlah = ""
End Sub

Sub bersih3()
    lsIDFilm.Clear
    lsGenre.Clear
    lsJudul.Clear
    lsJumlah.Clear
    txtBayar = ""
    txtTemp = ""
    txtAkhir = ""
    lsAkhir.Clear
    lsTampungStock.Clear
End Sub

Sub aktif1()
    cboIdAngg.Enabled = Not cboIdAngg.Enabled
    cmdNew.Enabled = Not cmdNew.Enabled
    cmdCancel.Enabled = Not cmdCancel.Enabled
    cmdSave.Enabled = Not cmdSave.Enabled
End Sub

Sub aktif2()
    txtJumlah.Enabled = Not txtJumlah.Enabled
    lsIDFilm.Enabled = Not lsIDFilm.Enabled
    lsGenre.Enabled = Not lsGenre.Enabled
    lsJudul.Enabled = Not lsJudul.Enabled
    lsJumlah.Enabled = Not lsJumlah.Enabled
    cmdGetFilm.Enabled = Not cmdGetFilm.Enabled
End Sub

Private Sub cboIdAngg_Click()
    If rec.State = 1 Then rec.Close
    rec.Open "select * from T_Anggota where [Id Anggota]='" & cboIdAngg & "'"
    txtNama = rec!Nama
    txtAlamat = rec!Alamat
    txtTelp = rec!Telp
    aktif2
End Sub

Private Sub cmdCancel_Click()
Dim a
Dim tmp
    If rec.State = 1 Then rec.Close
        For a = 0 To lsIDFilm.ListCount - 1
            conn.Execute "update T_Film set [Stock]='" & Val(lsJumlah.List(a)) + (lsTampungStock.List(a) - lsJumlah.List(a)) & "'where [Id Film]='" & lsIDFilm.List(a) & "'"
        Next a
    bersih1
    bersih2
    bersih3
    aktif1
    aktif2
End Sub

Private Sub cmdGetFilm_Click()
    frmViewDataFilm.Show 1
    frmPeminjaman.txtJumlah.SetFocus
End Sub

Private Sub cmdNew_Click()
Dim thkom, threc, no
    thkom = Format(Date, "MM/YY")
    If rec.State = 1 Then rec.Close
    rec.Open "select [No Transaksi] from Head_Peminjaman", conn, 3, 3
    If Not rec.EOF Then
        rec.MoveLast
        threc = Mid(rec("No Transaksi"), 9, 5)
        If threc = thkom Then
            no = Val(Right(rec("No Transaksi"), 3)) + 1
            no = "DVD/OUT/" & threc & "/" & String(3 - Len(no), "0") & no
        Else
            no = "DVD/OUT/" & thkom & "/001"
        End If
    Else
        no = "DVD/OUT/" & thkom & "/001"
    End If
    txtNoTrans = no
    aktif1
    txtTglPinjam = Format(Date, "DD-MMMM-YYYY")
    cboIdAngg.SetFocus
End Sub

Private Sub cmdSave_Click()
Dim a
    If bantu = False Then
        txtJumlah.SetFocus
        
    Else
        conn.Execute "INSERT INTO Head_Peminjaman([No Transaksi],[Tanggal PInjam],[Tanggal Kembali],[Id Anggota],Total) VALUES('" & txtNoTrans & "','" & txtTglPinjam & "','" & txtTglKembali & "','" & cboIdAngg & "','" & txtBayar & "')"
        For a = 0 To lsIDFilm.ListCount - 1
            conn.Execute "INSERT INTO Detail_Peminjaman([No Transaksi],[Id Film],Jumlah,Status)  VALUES('" & txtNoTrans & "','" & lsIDFilm.List(a) & "','" & lsJumlah.List(a) & "','Out')"
            conn.Execute "UPDATE T_Film SET [Stock] = '" & lsAkhir.List(a) & "' where [Id Film] = '" & lsIDFilm.List(a) & "'"
        Next a
        bersih1
        bersih2
        bersih3
        aktif1
        aktif2
    End If
End Sub

Private Sub Form_Load()
    IdAngg
    Me.Height = 6870
    Me.Width = 9165
    CenterC Me
    oldsize = Me.Width
End Sub

Private Sub lsIDFilm_DblClick()
Dim a
Dim temp
Dim tmp
    a = lsIDFilm.ListIndex
    txtTampungId = lsIDFilm.List(a)
    txtTampungJumlah = lsJumlah.List(a)
    lsIDFilm.RemoveItem (a)
    lsJudul.RemoveItem (a)
    lsGenre.RemoveItem (a)
    lsJumlah.RemoveItem (a)
    If rec.State = 1 Then rec.Close
        rec.Open "select Stock from T_Film where [Id Film]= '" & txtTampungId & "'", conn
        tmp = rec!Stock
        conn.Execute "update T_Film set [Stock]='" & Val(tmp) + txtTampungJumlah & "'where [Id Film]='" & txtTampungId & "'"
End Sub

Private Sub txtJumlah_Change()
    If IsNumeric(txtJumlah) = False Then
        txtJumlah = ""
        
    End If
End Sub

Private Sub txtJumlah_KeyPress(KeyAscii As Integer)
Dim tmp
Dim a
    If txtJumlah = vbNullString Then
        txtJumlah.SetFocus
    Else
        If KeyAscii = vbKeyReturn Then
            If rec.State = 1 Then rec.Close
            rec.Open "select Stock from T_Film where [Id Film]= '" & txtId & "'", conn
                If txtJumlah > rec!Stock Then
                    MsgBox "Stock Tidak Ada", vbInformation
                    txtJumlah = ""
                    txtJumlah.SetFocus
                Else
                    If rec.State = 1 Then rec.Close
                    rec.Open "select Stock from T_Film where [Id Film]= '" & txtId & "'", conn
                    tmp = rec!Stock
                    lsTampungStock.AddItem rec!Stock
                    txtAkhir = tmp - txtJumlah
                    lsIDFilm.AddItem txtId
                    lsGenre.AddItem txtGenre
                    lsJudul.AddItem txtJudul
                    lsJumlah.AddItem txtJumlah
                    lsAkhir.AddItem txtAkhir
                    cmdGetFilm.SetFocus
                    KeyAscii = 0
                    txtTemp = Val(txtTemp) + Val(txtJumlah)
                    txtBayar = txtTemp * 5000
                    
                    conn.Execute "update T_Film set [Stock]='" & tmp - Val(txtJumlah) & "' where [Id Film]='" & txtId & "'"

                    If lsJumlah.ListCount = 4 Then
                    
                    Else
                        tglpinjam
                    End If
                    bersih2
                End If
        End If
    End If
    bantu = True
End Sub

Function tglpinjam()
'Dim tmp
Dim tglkhusus
Dim hasil
'    tglkhusus = CInt(Format(Date + 10, "DD"))
    hasil = hasil + txtJumlah
'    tgl = Format(Now, "DD")
'    tmp = CInt(tgl) + 5
    If txtTglKembali = "" Then
        txtTglKembali = Format(Date + (txtTemp * 2), "DD-MMMM-YYYY")
    Else
        If hasil > 3 Then
            If hasil < 10 Then
                txtTglKembali = Format(Date + 8, "DD-MMMM-YYYY")
            Else
                txtTglKembali = Format(Date + 10, "DD-MMMM-YYYY")
            End If
        Else
            txtTglKembali = Format(Date + (txtTemp * 2), "DD-MMMM-YYYY")
'        hasil = CInt(Left(txtTglKembali, 2))
'        If hasil = tmp Then
'            txtTglKembali = Format(Now + 5, "DD-MMMM-YYYY")
'        Else
'            txtTglKembali = Format(Date + (txtTemp * 2), "DD-MMMM-YYYY")
'        End If
        End If
    End If
End Function

Sub IdAngg()
Dim a
    With rec
        If .State = 1 Then .Close
            .Open "select [Id Anggota] from T_Anggota", conn
            For a = 1 To .RecordCount
                cboIdAngg.AddItem ![Id Anggota]
                .MoveNext
            Next a
    End With
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim cepat As Long
    cepat = 1000
    While Left + Width < Screen.Width
        DoEvents
        Left = Left + cepat
    Wend
    While Top - Height < Screen.Height
        DoEvents
        Top = Top + cepat
    Wend
    Unload Me
End Sub


