الان انا حللت مشكلة الكود الييظهر لكن ظهرت مشكلة اخرى وهي اني بتطلع رسالة تمت الاضافة ولكن لما ارجع الى قاعدة البيانات او الى الاستعراض كافة المواد لا اجد شي
كود :
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