01-11-20, 09:49 PM
عند الحفظ يأتي هذا الخطأ مع العلم اني نقلت الكود صحيح من الدورة أفيدوني بارك الله فيكم
لم أعرف حتى مكان الخطأ
كود :
Try
Dim Sql = "Select * From ReceiptOfltems Where VoucherCode=N'" & (VoucherCode.Text) & "'"
Dim Adp As New SqlClient.SqlDataAdapter(Sql, SQLConn)
Dim DS As New DataSet
Adp.Fill(DS)
Dim DT = DS.Tables(0)
If DT.Rows.Count > 0 Then
'******************************************************************************************************************************
VoucherCode.Text = Format(GET_LAST_RECORD("ReceiptOfltems", "Voucherid") + 1, "ROF000000")
SupplierlnVoiceCode.Text = GET_LAST_RECORD("ReceiptOfltems", "Voucherid") + 1
'******************************************************************************************************************************
Else
Dim DR = DT.NewRow
DR!VoucherCode = VoucherCode.Text
DR!VoucherDate = VoucherDate.Value
DR!SupplierCode = SupplierCode.Text
DR!SupplierName = SupplierName.Text
DR!SupplierlnVoiceCode = SupplierlnVoiceCode.Text
DR!SupplierlnvoiceDate = SupplierlnvoiceDate.Value
DR!SupplierInVoiceType = SupplierInVoiceType.Text
DR!SalesTAX = Val(SalesTAX.Text)
DR!Notes = Notes.Text
DR!TotalQty = TotalQty.Text
DR!TotalDiscount = Val(TotalDiscount.Text)
DR!TotalVoucher = Val(TotalVoucher.Text)
DR!TotalArabic = TotalArabic.Text
DR!Status = True
DT.Rows.Add(DR)
Dim Cmd As New SqlClient.SqlCommandBuilder(Adp)
Adp.Update(DT)
End If
BtnNew_Click(Nothing, Nothing)
MsgBox(" تم حفظ سند التوريد فى قاعدة البيانات بنجاح", MsgBoxStyle.Information, "رسالة تأكيد")
Catch ex As Exception
MessageBox.Show(ex.Message, "فشل في الحفظ ", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
كود :
Sub Showrecord(Vcode As String)
DataGridView1.Rows.Clear()
Dim Sql = "Select * From ReceiptOfltems Where VoucherCode=N'" & (Vcode) & "'"
Dim Adp As New SqlClient.SqlDataAdapter(Sql, SQLConn)
Dim DS As New DataSet
Adp.Fill(DS)
Dim DT = DS.Tables(0)
If DT.Rows.Count = 0 Then
MsgBox("عزيزى عفواً لم يتم العثور على السند يرجى التأكد من الرقم", MsgBoxStyle.Exclamation, "تنبيه")
Else
Dim DR = DT.Rows(0)
VoucherCode.Text = CType((DR!VoucherCode), String)
VoucherDate.Text = CType((DR!VoucherDate), String)
SalesTAX.Text = CType((DR!SalesTAX), String)
Notes.Text = CType((DR!Notes), String)
SupplierCode.Text = CType((DR!SupplierCode), String)
SupplierName.Text = CType((DR!SupplierName), String)
SupplierInVoiceType.Text = CType((DR!SupplierInVoiceType), String)
SupplierlnVoiceCode.Text = CType((DR!SupplierlnVoiceCode), String)
SupplierlnvoiceDate.Text = CType((DR!SupplierlnvoiceDate), String)
TotalQty.Text = CType((DR!TotalQty), String)
TotalDiscount.Text = CType((DR!TotalDiscount), String)
TotalVoucher.Text = CType((DR!TotalVoucher), String)
TotalArabic.Text = CType((DR!TotalArabic), String)
DR!Status = True
End If
Adp.Dispose()
DS.Dispose()
DT.Dispose()
End Sub
------------------------
منكم أتعلم
------------------------