Ska perse, je i mireseardhur. 
Ja tani dhe sugjerimet dhe kerkesat tjera.
Me butonin e futjes, nese nje artikull nuk ekziston e fut ne subforme me sasine 1 dhe nese ekziston e ngrite sasine per 1. Kurse me butonin e largimit, nese artikulli nuk ekziston jep nje beep, kurse nese ekziston e zvogelon sasine per 1, perderisa sasia mbetet 1, e nese atehere shtyp butonin largo atehere ai arikull largohet nga subforma.
Artikulli duhet te selektohet ne listen e artikujve per te procesuar, sepse se pari detektohet rekordi i artikullit ne subforme qe eshte detektuar ne baze te listes se artikujve.
Implementova dy metoda/funksione te reja, njera qe detekton artikullin e selektuar nga lista e artikujve dhe tjetra qe lexon sasine e artikullit nga databaza para se te zvogelohet dhe nese sasia eshte me e vogel se 2 atehere e fshin rekordin e artikullit.
Kodi PHP:
Option Compare Database
Private Sub Command11_Click()
Dim recordNr As Integer
recordNr = RecordNumber(Me.List9.value)
Dim db As Database
Set db = CurrentDb
If recordNr = 0 Then
db.Execute " INSERT INTO T_FaturaArtikulli " _
& "(FaturaID, ArtikulliID, Sasia) VALUES " _
& "('" & Me.FaturaID.value & "', '" & Me.List9.value & "', 1);"
Else
db.Execute " UPDATE T_FaturaArtikulli " _
& "SET Sasia=Sasia+1 " _
& "WHERE FaturaArtikullID =" & recordNr & ";"
End If
db.Close
Me.T_FaturaArtikulli_Subform.Requery
End Sub
Private Function RecordNumber(value As String) As Integer
Dim crit As String
Dim rsArtikulli As Recordset
crit = "ArtikulliID = '" & value & "'"
Set rsArtikulli = Me.T_FaturaArtikulli_Subform.Form.RecordsetClone
rsArtikulli.FindFirst crit
If rsArtikulli.NoMatch Then
RecordNumber = 0
Else
Me.T_FaturaArtikulli_Subform.Form.Bookmark = rsArtikulli.Bookmark
RecordNumber = (rsArtikulli.Fields(0))
End If
End Function
Private Function sasiaInt(value As Integer) As Integer
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT Sasia " & _
"FROM T_FaturaArtikulli " & _
"WHERE FaturaArtikullID=" & value & ""
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
sasiaInt = rs(0)
rs.Close:
Set rs = Nothing
Set db = Nothing
End Function
Private Sub Command12_Click()
Dim recordNr As Integer
recordNr = RecordNumber(Me.List9.value)
If recordNr = 0 Then
Beep
Else
Dim Sasia As Integer
Sasia = sasiaInt(recordNr)
Dim db As Database
Set db = CurrentDb
If Sasia > 1 Then
db.Execute " UPDATE T_FaturaArtikulli " _
& "SET Sasia=Sasia-1 " _
& "WHERE FaturaArtikullID =" & recordNr & ";"
Else
db.Execute " DELETE FaturaArtikullID " _
& "FROM T_FaturaArtikulli " _
& "WHERE FaturaArtikullID =" & recordNr & ";"
End If
db.Close
Me.T_FaturaArtikulli_Subform.Requery
End If
End Sub
Private Sub List7_Click()
Dim x As Integer
For x = List9.ListCount - 1 To 0 Step -1
List9.RemoveItem (x)
Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT T_Artikulli.Artikulli, " & _
"T_Artikulli.Kategoria FROM T_Artikulli " & _
"WHERE T_Artikulli.Kategoria=" & CInt(Me.List7.value) & ""
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Me.List9.RowSource = rs(0)
Me.List9.Requery
rs.Close:
Set rs = Nothing
Set db = Nothing
End Sub
Krijoni Kontakt