10-09-19, 01:26 PM
(آخر تعديل لهذه المشاركة : 10-09-19, 01:28 PM {2} بواسطة asemshahen5.)
زر الحفظ كاملا :
PHP كود :
Private Sub Command1_Click()
'إذا كان الجدول فارغ'
Dim flag As Boolean
Dim r, c As Integer
With fox
flag = True
For r = 1 To .Rows - 1
For c = 1 To .Cols - 1
If .TextMatrix(r, c) <> vbNullString Then
flag = False
End If
Next c
Next r
End With
If flag = True Then
MsgBox "لا يمكن حفظ الفاتورة الجدول فارغ"
Exit Sub
End If
'تفقد اذا كان هناك تكست بوكس فارغ في الفورم'
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
MsgBox "تمت عملية الحفظ بنجاح", vbMsgBoxRtlReading + vbInformation, "حفظ فاتورة"
Else
MsgBox "لم يتم حفظ الفاتورة", vbMsgBoxRtlReading + vbInformation, "حفظ فاتورة"
Exit Sub
End If
End If
Next
End If
End Sub
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
