Minggu, 11 Juli 2010




















Sub pasif()
txtkduser.Enabled = False
txtnmuser.Enabled = False
txtnofak.Enabled = False
txttgl.Enabled = False
Combo1.Enabled = False
txtnmcs.Enabled = False
txtkdbrg.Enabled = False
txtnmbrg.Enabled = False
txthrg.Enabled = False
txtstock.Enabled = False
txtqty.Enabled = False
txtsub.Enabled = False
txttobay.Enabled = False
txtubay.Enabled = False
txtukem.Enabled = False
txtjam.Enabled = False

txtkduser.BackColor = &H8000000F
txtnmuser.BackColor = &H8000000F
txtnofak.BackColor = &H8000000F
txttgl.BackColor = &H8000000F
Combo1.BackColor = &H8000000F
txtnmcs.BackColor = &H8000000F
txtkdbrg.BackColor = &H8000000F
txtnmbrg.BackColor = &H8000000F
txthrg.BackColor = &H8000000F
txtstock.BackColor = &H8000000F
txtqty.BackColor = &H8000000F
txtsub.BackColor = &H8000000F
txttobay.BackColor = &H8000000F
txtubay.BackColor = &H8000000F
txtukem.BackColor = &H8000000F
txtjam.BackColor = &H8000000F
DBGrid1.Enabled = False
cmdtambah.Enabled = True
cmdsimpan.Enabled = False
cmdbatal.Enabled = False
End Sub

Sub bersih()
txtnofak = ""
Combo1 = ""
txtnmcs = ""
txtkdbar = ""
txtnabar = ""
txthrg = ""
txtstock = ""
txtqty = ""
txtsubtot = ""
txttobay = ""
txtubay = ""
txtukem = ""
End Sub


Private Sub cmdbatal_Click()
bersih
pasif
hapusgrid
End Sub

Private Sub cmdselesai_Click()
bersih
Unload Me
End Sub

Private Sub cmdsimpan_Click()
Data6.Recordset.MoveFirst
X = 1
While Not Data6.Recordset.EOF
data5.Recordset.AddNew
data5.Recordset!nofak_k = txtnofak.Text
data5.Recordset!kdbar = Data6.Recordset!kdbar
data5.Recordset!qty = Data6.Recordset!qty
data5.Recordset!subtot = Data6.Recordset!ubay
Data6.Recordset.MoveNext

X = X + 1
Wend

With data2.Recordset
.AddNew
!nofak = txtnofak.Text
!tgl = txttgl.Text
!kdcustomer = Combo1.Text
!iduser = txtkduser.Text
.Update
End With
With Data7.Recordset
.AddNew
!nofak = txtnofak.Text
!tobay = txttobay.Text
!ubay = txtubay.Text
!ukem = txtukem.Text
.Update
End With

bersih
pasif
cmdtambah.Enabled = True
Call hapusgrid
End Sub
End Sub

Private Sub cmdtambah_Click()
With data2.Recordset
If .BOF And .EOF Then
txtnofak.Text = Format(Date, "yyyy") & Format(Date, "mm") & "001"
Else
.MoveLast
txtnofak.Text = Format(Date, "yyyy") & Format(Date, "mm") & Right(Str(Val(Right(!nofak, 3)) + 1001), 3)
End If
End With
cmdtambah.Enabled = False
cmdsimpan.Enabled = True
cmdbatal.Enabled = True
Combo1.Enabled = True
Combo1.BackColor = &H80000000
Combo1.SetFocus
End Sub

Private Sub Combo1_Click(Area As Integer)
Data3.Recordset.FindFirst "kd_customer = '" & Combo1 & "'"
txtnmcs = Data3.Recordset!nm_customer
txtkdbrg.Enabled = True
txtkdbrg.BackColor = &H80000000
txtkdbrg.SetFocus
End Sub
Sub hapusgrid()
If Data6.Recordset.RecordCount <= 0 Then
Exit Sub
End If
Data6.Recordset.MoveFirst
Do While Not Data6.Recordset.EOF
Data6.Recordset.Delete
Data6.Recordset.MoveNext
Loop
End Sub

Private Sub Form_Activate()
bersih
pasif
txtjam.Alignment = 2
txtjam.FontSize = 18
txtjam.Font = True
data1.Visible = False
data2.Visible = False
Data3.Visible = False
Data4.Visible = False
data5.Visible = False
Data6.Visible = False
Data7.Visible = False
End Sub

Private Sub Timer1_Timer()
txttgl = Date
txtjam = Time
End Sub

Private Sub txtkdbrg_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
With Data4.Recordset
.FindFirst "kd_brg ='" & txtkdbrg & "'"
txtnmbrg.Text = !nm_brg
txthrg.Text = !harga
txtstock.Text = !stock
If .NoMatch Then
MsgBox "kode" + txtkdbrg.Text + " tidak ada", 16, "konfirmasi"
txtnmbrg.Enabled = True
txtnmbrg = ""
txtnmbrg.SetFocus
End If
End With
txtqty.Enabled = True
txtqty = ""
txtqty.BackColor = &H80000000
txtqty.SetFocus
End If
End Sub


Private Sub txtqty_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtsub = Val(txtqty.Text) * Val(txthrg.Text)
X = MsgBox("Mo tambah barang lagi ?", 32 + 4, "lagi")
If X = vbYes Then
With Data6.Recordset
.AddNew
!kdbrg = txtkdbrg.Text
!nmbrg = txtnmbrg.Text
!hrgjual = txthrg.Text
!qty = Val(txtqty.Text)
!bayar = txtsub.Text
.Update
End With
Data4.Recordset.Edit
Data4.Recordset!stock = Val(txtstock.Text) - Val(txtqty.Text)
Data4.Recordset.Update

txttobay.Text = Val(txttobay.Text) + Val(txtsubtot.Text)
txtkdbrg.Enabled = True
txtkdbrg = ""
txtkdbrg.BackColor = &H80000000
txtkdbrg.SetFocus
txtnabar = ""
txthrg = ""
txtstock = ""
txtqty.Enabled = False
txtqty = ""
txtqty.BackColor = &H8000000F
txtsubtot = ""
Else
With Data6.Recordset
.AddNew
!kdbar = txtkdbar.Text
!nabar = txtnabar.Text
!hrgjual = txthrg.Text
!qty = Val(txtqty.Text)
!bayar = txtsubtot.Text
.Update
End With
Data4.Recordset.Edit
Data4.Recordset!stock = Val(txtstock.Text) - Val(txtqty.Text)
Data4.Recordset.Update
txttobay.Text = Val(txttobay.Text) + Val(txtsubtot.Text)
txtkdbar.Enabled = False
txtkdbar.BackColor = &H8000000F
txtqty.Enabled = False
txtqty.BackColor = &H80000000
txtubay.Enabled = True
txtubay.BackColor = &H80000000
txtubay.SetFocus
End If
End If
End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdsimpan.SetFocus
End If
End Sub

Private Sub txtukem_Change()
txtukem = Val(txtbayar) - Val(txttobay)
End Sub

0 comments:

Posting Komentar