المشاركات : 186
المواضيع 53
الإنتساب : May 2017
السمعة :
4
الشكر: 151
تم شكره 102 مرات في 64 مشاركات
السلام عليكم
اخوتي احبتي الاعزاء
حصلت معي مشكلة
وهي عند الاضافة الى جدول معين في قاعدة البيانات بتم الاضافة ولكن بشكل مختلف يعني ينظاف المدخلات ولكن عند الاستعلام بيظهر عندي اسم المدخل
يعني لو ظفت تلفظيون بيظهر معاه هذه ا لجملة
System.Windows.Forms.TextBox, Text: تلفزيون
طبعا هذا في كل الجدول والامر الاخر ان الجدول بنظاف مرتين معا مع العلم انا عامل تفريغ للحقول وتظهر رسالة تفيد تم الاضافة لكن بينظام مرتين
ما هي المشكلة
المشاركات : 1,545
المواضيع 33
الإنتساب : Jul 2016
السمعة :
255
الشكر: 6532
تم شكره 4339 مرات في 1696 مشاركات
08-05-18, 06:28 PM
(آخر تعديل لهذه المشاركة : 08-05-18, 06:29 PM {2} بواسطة sendbad100.)
وعليكم السلام ارفق
المشروع
او مثال مصغر في مكان المشكلة
كي يتمكن الاخوة من مراجعت الكود
المشاركات : 186
المواضيع 53
الإنتساب : May 2017
السمعة :
4
الشكر: 151
تم شكره 102 مرات في 64 مشاركات
08-05-18, 06:36 PM
(آخر تعديل لهذه المشاركة : 08-05-18, 07:15 PM {2} بواسطة فراس الغزي.)
السلام عليكم
اخي العزيز
الان انا حللت مشكلة الكود الييظهر لكن ظهرت مشكلة اخرى وهي اني بتطلع رسالة تمت الاضافة ولكن لما ارجع الى قاعدة البيانات او الى الاستعراض كافة المواد لا اجد شي
هذا كود الصفحة الي فيها المشكلة
كود :
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class add_or
Public ToDo As String = "add"
Public id As Integer
Dim dal As New dataaccess
Sub num()
Labtotal.Text = Val(Textnum.Text) * Val(Textprice.Text)
Laqasd.Text = Val(Textqasd1.Text)
End Sub
Sub num2()
Label21.Text = Val(Labtotal.Text) / Val(Textqasd1.Text)
Laqasd.Text = Textqasd1.Text
End Sub
Private Sub Butcalos_Click(sender As Object, e As EventArgs)
Close()
End Sub
Private Sub Textnum_TextChanged_1(sender As Object, e As EventArgs) Handles Textprice.TextChanged, Textnum.TextChanged
Try
num()
Catch ex As Exception
Exit Sub
End Try
End Sub
Dim Dt As New DataTable
Sub satDateSRC()
'Dt.Columns.Add("#")
'Dt.Columns.Add("اسم العميل")
'Dt.Columns.Add("أسم المادة")
'Dt.Columns.Add("الكمية")
'Dt.Columns.Add("سعر المادة")
'Dt.Columns.Add("عدد الاقصاد")
'Dt.Columns.Add("الاقصاد المدفوعة")
'Dt.Columns.Add("المتبقي")
'DataG.DataSource = Dt
Dt.Rows.Clear()
adapter = New MySqlDataAdapter("select * from invoices", con)
adapter.Fill(Dt)
Me.DataG.DataSource = Dt
DataG.Columns(0).HeaderText = "التسسلسل"
DataG.Columns(1).HeaderText = "اسم العميل"
DataG.Columns(2).HeaderText = "أسم المادة"
DataG.Columns(3).HeaderText = "الكمية "
DataG.Columns(4).HeaderText = "سعر لمادة"
DataG.Columns(5).HeaderText = "عدد الاقصاد"
DataG.Columns(6).HeaderText = " الاقصاد المدفوعة"
DataG.Columns(7).HeaderText = "المبلغ الباقي"
End Sub
Private Sub add_or_Load(sender As Object, e As EventArgs) Handles MyBase.Load
satDateSRC()
End Sub
Private Sub Textqasd1_TextChanged(sender As Object, e As EventArgs) Handles Textqasd1.TextChanged
num2()
End Sub
Private Sub Textpricetak_TextChanged(sender As Object, e As EventArgs) Handles Textpricetak.TextChanged
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Textpricetak.Text = Label21.Text
Labbaqy.Text = Val(Labtotal.Text) - Val(Lamd.Text)
Lamd.Text = Val(Label21.Text) * Val(Textqasd2.Text)
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
print_cus.textname.Text = Textname.Text
print_cus.Textnum.Text = Textnum.Text
print_cus.Textprice.Text = Labtotal.Text
print_cus.Textmdfoa.Text = Textpricetak.Text
print_cus.Textbaqa.Text = Labbaqy.Text
print_cus.Latextname.Text = Textname.Text
End Sub
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
print_cus.Ltextname.Text = Textname.Text
print_cus.LTextnum.Text = Textnum.Text
print_cus.LTextprice.Text = Labtotal.Text
print_cus.LTextmdfoa.Text = Textpricetak.Text
print_cus.LTextbaqa.Text = Labbaqy.Text
print_cus.Labtextname.Text = Textname.Text
End Sub
Private Sub Butprint_Click(sender As Object, e As EventArgs) Handles Butprint.Click
Timer2.Start()
Timer3.Start()
print_cus.ShowDialog()
End Sub
Private Sub Textpro_KeyDown(sender As Object, e As KeyEventArgs) Handles Textpro.KeyDown
If e.KeyCode = Keys.Enter Then
Try
cmd = New MySqlCommand("Select SellingPrice_q, MaterialName from Materials where MaterialBarCode = " & Textpro.Text, con)
con.Open()
Dim dr As MySqlDataReader = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
Textpro.Text = dr(1)
Textprice.Text = dr(0)
Textnum.Focus()
Else
MsgBox("هذا المنتج غير موجود في سجلاتك ", MsgBoxStyle.Exclamation, "تنبيه")
End If
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End If
End Sub
Private Sub Textqasd2_KeyDown(sender As Object, e As KeyEventArgs) Handles Textqasd2.KeyDown
If e.KeyCode = Keys.Enter Then
Dim row As DataRow = Dt.NewRow
row(1) = Textname.Text
row(2) = Textpro.Text
row(3) = Textnum.Text
row(4) = Textprice.Text
row(5) = Textqasd1.Text
row(6) = Textqasd2.Text
row(7) = Labbaqy.Text
Dt.Rows.Add(row)
Me.DataG.DataSource = Dt
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
DataG.Rows.RemoveAt(DataG.CurrentRow.Index)
Catch ex As Exception
Exit Sub
End Try
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dt.Rows.Clear()
Me.DataG.DataSource = Dt
End Sub
Private Sub DataG_DoubleClick(sender As Object, e As EventArgs) Handles DataG.DoubleClick
Try
Textname.Text = Me.DataG.CurrentRow.Cells(1).Value
Textpro.Text = Me.DataG.CurrentRow.Cells(2).Value
Textnum.Text = Me.DataG.CurrentRow.Cells(3).Value
Textprice.Text = Me.DataG.CurrentRow.Cells(4).Value
Textqasd1.Text = Me.DataG.CurrentRow.Cells(5).Value
Textqasd2.Text = Me.DataG.CurrentRow.Cells(6).Value
Labbaqy.Text = Me.DataG.CurrentRow.Cells(7).Value
DataG.Rows.RemoveAt(DataG.CurrentRow.Index)
Catch ex As Exception
Exit Sub
End Try
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Butsave.Click
con.Open()
Dim query As String
If ToDo = "add" Then
query = "insert into invoices (id_user,codpro,extnumpro,extprice,qasd1,qasd2,abbaqy) values(@id_user,@codpro,@extnumpro,@extprice,@qasd1,@qasd2,@abbaqy) "
Else
query = "updata invoice set id_user=@id_user,codpro=@codpro,extnumpro=@extnumpro,extprice=@extprice,qasd1=@qasd1,qasd2=@qasd2,abbaqy=@abbaqy where id= " & id
End If
cmd = New MySqlCommand(query, con)
cmd.Parameters.Add(New MySqlParameter("@id_user", MySqlDbType.VarChar, 200)).Value = Textname
cmd.Parameters.Add(New MySqlParameter("@codpro", MySqlDbType.VarChar, 200)).Value = Textpro
cmd.Parameters.Add(New MySqlParameter("@extnumpro", MySqlDbType.VarChar, 200)).Value = Textnum
cmd.Parameters.Add(New MySqlParameter("@extprice", MySqlDbType.VarChar, 200)).Value = Textprice
cmd.Parameters.Add(New MySqlParameter("@qasd1", MySqlDbType.VarChar, 200)).Value = Textqasd1
cmd.Parameters.Add(New MySqlParameter("@qasd2", MySqlDbType.VarChar, 200)).Value = Textqasd2
cmd.Parameters.Add(New MySqlParameter("@abbaqy", MySqlDbType.VarChar, 200)).Value = Labbaqy
cmd.ExecuteNonQuery()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم اضافة المنتجات بنجاح")
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles Textscrech.TextChanged
Try
Dim DtCopy As DataTable = Dt.Copy
Dim dv As DataView = DtCopy.DefaultView
dv.RowFilter = "id+id_user like '%" & Textscrech.Text & "%'"
DataG.DataSource = dv
Catch ex As Exception
Exit Sub
End Try
End Sub
End Class
proo.zip (الحجم : 48.49 ك ب / التحميلات : 35)
اخوان هذا المشروع مع القاعدة اتمنى منكم المساعدة وفقكم الله
المشاركات : 230
المواضيع 17
الإنتساب : Apr 2018
السمعة :
49
الشكر: 603
تم شكره 456 مرات في 201 مشاركات
اعتقد انك نسيت امتداد ال text في كود الحفظ
كود :
cmd = New MySqlCommand(query, con)
cmd.Parameters.Add(New MySqlParameter("@id_user", MySqlDbType.VarChar, 200)).Value = Textname.Text
cmd.Parameters.Add(New MySqlParameter("@codpro", MySqlDbType.VarChar, 200)).Value = Textpro.Text
cmd.Parameters.Add(New MySqlParameter("@extnumpro", MySqlDbType.VarChar, 200)).Value = Textnum.Text
cmd.Parameters.Add(New MySqlParameter("@extprice", MySqlDbType.VarChar, 200)).Value = Textprice.Text
cmd.Parameters.Add(New MySqlParameter("@qasd1", MySqlDbType.VarChar, 200)).Value = Textqasd1.Text
cmd.Parameters.Add(New MySqlParameter("@qasd2", MySqlDbType.VarChar, 200)).Value = Textqasd2.Text
cmd.Parameters.Add(New MySqlParameter("@abbaqy", MySqlDbType.VarChar, 200)).Value = Labbaqy.Text
con.Open()
cmd.ExecuteNonQuery()
لا إله إلا الله وحده لا شريك له له الملك وله الحمد وهو على كل شئ قدير
سبحان الله وبحمده سبحان الله العظيم
سبحان الله والحمد لله ولا إله إلا الله والله أكبر ولا حول ولا قوة إلا بالله العلى العظيم
رب أغفر لي
|