03-05-18, 08:33 PM
السلام عليكم
الاخوة الاعزاء
انا اعمل على مشروع خاص سوبر ماركت الان حصلتي لي هذه المشكلة وهي اضافة المنتجات وحفظها في جدول الخاص بالفاتورة علما اني اعمل على vb.net2013 an mysql
اليكم الكود والخطا الذي يظهر لدي
بانتظار ردودكم الكريمة
الاخوة الاعزاء
انا اعمل على مشروع خاص سوبر ماركت الان حصلتي لي هذه المشكلة وهي اضافة المنتجات وحفظها في جدول الخاص بالفاتورة علما اني اعمل على vb.net2013 an mysql
اليكم الكود والخطا الذي يظهر لدي
كود :
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class add_or
Dim dal As New dataaccess
Public ToDo As String = "add"
Public id As Integer
Sub claertext()
Textname.Clear()
Textphon.Clear()
Textloc.Clear()
Textnum.Clear()
Textprice.Clear()
Textpricetak.Clear()
Textpro.Clear()
Textqasd1.Clear()
Textqasd2.Clear()
TextBname.Clear()
TextBkl.Clear()
End Sub
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
Sub num3()
End Sub
Private Sub Butsave_Click(sender As Object, e As EventArgs) Handles Butsave.Click
Try
Dim query As String
If ToDo = "add" Then
query = "INSERT INTO cust (cu_name,cu_phone,cu_work,cu_loc,cu_k_name,cuk_phone,cu_pro,cu_num,cu_mdfoah,cu_price,cu_qasd1,cu_qasd2,cu_notee,cu_datt,cu_datget) VALUES (@cu_name,@cu_phone,@cu_work,@cu_loc,@cu_k_name,@cuk_phone,@cu_pro,@cu_num,@cu_mdfoah,@cu_price,@cu_qasd1,@cu_qasd2,@cu_notee,@cu_datt,@cu_datget)"
Else
query = "UPDATE cust SET cu_name=@cu_name,cu_phone=@cu_phone,cu_work=@cu_work,cu_loc=@cu_loc,cu_k_name=@cu_k_name,cuk_phone=@cuk_phone,cu_pro=@cu_pro,cu_num=@cu_num,cu_price=@cu_price,cu_mdfoah=@cu_mdfoah,cu_qasd1=@cu_qasd1,cu_qasd2=@cu_qasd2,cu_notee=@cu_notee,cu_datt=@cu_datt,cu_datget=@cu_datget WHERE id= " & id
End If
cmd = New MySqlCommand(query, con)
cmd.Parameters.Add("@cu_name", MySqlDbType.VarChar, 200).Value = Textname.Text
cmd.Parameters.Add("@cu_phone", MySqlDbType.VarChar, 200).Value = Textphon.Text
cmd.Parameters.Add("@cu_work", MySqlDbType.VarChar, 200).Value = Textwork.Text
cmd.Parameters.Add("@cu_loc", MySqlDbType.VarChar, 200).Value = Textloc.Text
cmd.Parameters.Add("@cu_k_name", MySqlDbType.VarChar, 200).Value = TextBname.Text
cmd.Parameters.Add("@cuk_phone", MySqlDbType.VarChar, 200).Value = TextBkph.Text
cmd.Parameters.Add("@cu_pro", MySqlDbType.VarChar, 200).Value = Textpro.Text
cmd.Parameters.Add("@cu_num", MySqlDbType.VarChar, 200).Value = Textnum.Text
cmd.Parameters.Add("@cu_mdfoah", MySqlDbType.VarChar, 200).Value = Textpricetak.Text
cmd.Parameters.Add("@cu_price", MySqlDbType.VarChar, 200).Value = Textprice.Text
cmd.Parameters.Add("@cu_qasd1", MySqlDbType.VarChar, 200).Value = Textqasd1.Text
cmd.Parameters.Add("@cu_qasd2", MySqlDbType.VarChar, 200).Value = Textqasd2.Text
cmd.Parameters.Add("@cu_notee", MySqlDbType.VarChar, 200).Value = Textnot.Text
cmd.Parameters.Add("@cu_datt", MySqlDbType.Date).Value = DateTimetak.Value
cmd.Parameters.Add("@cu_datget", MySqlDbType.Date).Value = DateTiget.Value
dal.OP_CON()
cmd.ExecuteNonQuery()
cmd = New MySqlCommand("select max(id) from invoices", con)
Dim dr As MySqlDataReader = cmd.ExecuteReader
dr.Read()
Dim id_or As Integer = dr(0)
query = "insert into invoices (textpro,textnum,textprice,textqasd1,textqasd2,labbaqy) values(@textpro,@textnum,@textprice,@textqasd1,@textqasd2,@labbaqy) "
For i As Integer = 0 To DataG.RowCount - 1
id = DataG.Rows(i).Cells(0).Value
Textpro = DataG.Rows(i).Cells(1).Value
Textnum = DataG.Rows(i).Cells(2).Value
Textprice = DataG.Rows(i).Cells(3).Value
Textqasd1 = DataG.Rows(i).Cells(4).Value
Textqasd2 = DataG.Rows(i).Cells(5).Value
Labbaqy = DataG.Rows(i).Cells(6).Value
cmd.Parameters.Add("@Textpro", MySqlDbType.VarChar, 200).Value = Textpro
cmd.Parameters.Add("@Textnum", MySqlDbType.VarChar, 200).Value = Textpro
cmd.Parameters.Add("@Textprice", MySqlDbType.VarChar, 200).Value = Textnum
cmd.Parameters.Add("@Textqasd1", MySqlDbType.VarChar, 200).Value = Textprice
cmd.Parameters.Add("@Textqasd2", MySqlDbType.VarChar, 200).Value = Textqasd2
cmd.Parameters.Add("@Labbaqy", MySqlDbType.VarChar, 200).Value = Labbaqy
cmd.ExecuteNonQuery()
Next
dr.Close()
dal.CL_CON()
claertext()
MsgBox("تم حفظ البيانات بنجاح شكرا لكم", MsgBoxStyle.Information, "الاضافة")
Catch ex As Exception
MsgBox(ex.Message)
Finally
dal.CL_CON()
End Try
End Sub
Private Sub ButtORDER_Click(sender As Object, e As EventArgs)
Dim frm As New cat_ord
frm.ShowDialog()
Textpro.Text = frm.DataGpro.CurrentRow.Cells(2).Value
Textprice.Text = frm.DataGpro.CurrentRow.Cells(7).Value
End Sub
Private Sub Butcalos_Click(sender As Object, e As EventArgs) Handles Butcalos.Click
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("المتبقي")
DataG.DataSource = Dt
End Sub
Private Sub add_or_Load(sender As Object, e As EventArgs) Handles MyBase.Load
num3()
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.DateT.Text = DateTiget.Text
print_cus.Texttyp.Text = DateTiget.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.LDateT.Text = DateTiget.Text
print_cus.LTexttyp.Text = DateTiget.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, "تنبيه")
Textpro.Clear()
Textprice.Clear()
Textnum.Clear()
Textpro.Focus()
End If
dr.Close()
Catch ex As Exception
Exit Sub
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(0) = Textpro.Text
row(1) = Textpro.Text
row(2) = Textnum.Text
row(3) = Textprice.Text
row(4) = Textqasd1.Text
row(5) = Textqasd2.Text
row(6) = Labbaqy.Text
Dt.Rows.Add(row)
Me.DataG.DataSource = Dt
Textpro.Clear()
Textprice.Clear()
Textnum.Clear()
Textpro.Focus()
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
Textpro.Text = Me.DataG.CurrentRow.Cells(0).Value
Textpro.Text = Me.DataG.CurrentRow.Cells(1).Value
Textnum.Text = Me.DataG.CurrentRow.Cells(2).Value
Textprice.Text = Me.DataG.CurrentRow.Cells(3).Value
Textqasd1.Text = Me.DataG.CurrentRow.Cells(4).Value
Textqasd2.Text = Me.DataG.CurrentRow.Cells(5).Value
Labbaqy.Text = Me.DataG.CurrentRow.Cells(6).Value
DataG.Rows.RemoveAt(DataG.CurrentRow.Index)
Catch ex As Exception
Exit Sub
End Try
End Sub
End Class
بانتظار ردودكم الكريمة