10-09-19, 01:55 PM
هذا هو الحل :
PHP كود :
Private Sub SaveBill()
Dim X As Integer
'تفقد اذا كان هناك تكست بوكس فارغ في الفورم'
For X = 0 To Me.Controls.Count - 1
If TypeOf Me.Controls(X) Is TextBox Then
If Me.Controls(X).Text = "" Then
MsgBox "الرجاء تعبئة الحقول النصية"
Exit Sub
End If
End If
Next X
If MsgBox("هل تريد بالفعل حفظ بيانات الفاتورة", vbYesNo, "") = vbYes Then
Dim I As Integer
For I = 1 To fox.Rows - 1
If Trim$(fox.TextMatrix(I, 0)) <> "" And Val(Trim$(fox.TextMatrix(I, 0))) > 0 Then
Set RS = New ADODB.Recordset
If RS.State = adStateOpen Then RS.Close
RS.CursorLocation = adUseClient
RS.Open "select* from BillItems ", DB, adOpenStatic, adLockPessimistic
RS.AddNew
RS!Id = Val(Trim$(fox.TextMatrix(I, 0)))
RS!Name = Trim$(fox.TextMatrix(I, 1))
RS!Qty = Val(Trim$(fox.TextMatrix(I, 3))) ''3
RS.Update
DoEvents
Set RS2 = New ADODB.Recordset
If RS2.State = adStateOpen Then RS2.Close
RS2.CursorLocation = adUseClient
RS2.Open "Select * From Store Where iD=" & Val(Trim$(fox.TextMatrix(I, 0))), DB, adOpenStatic, adLockPessimistic
If RS2.RecordCount > 0 Then
RS2![noo] = RS2![noo] - Val(Trim$(fox.TextMatrix(I, 3))) ''3
RS2.Update
DoEvents
Else
MsgBox "لم يتم حفظ الفاتورة ", vbMsgBoxRtlReading + vbInformation, "تنبية"
Exit Sub
End If
End If
Next
MsgBox "تمت عملية حفظ الفاتورة ", vbMsgBoxRtlReading + vbInformation, "تنبية"
End If
End Sub
Private Sub Command1_Click()
'إذا كان الجدول فارغ'
Dim flag As Boolean
Dim r, c As Integer
With fox
flag = True
Dim strXX As String
For r = 1 To .Rows - 1
For c = 0 To .Cols - 1
strXX = .TextMatrix(r, c)
If strXX > "" Then
flag = False
Call SaveBill
Exit Sub
End If
Next c
Next r
End With
If flag = True Then
MsgBox "الجدول فارغ الرجاء تعبئته"
Exit Sub
End If
End Sub
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
