تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشكلة عند حفظ الفاتورة
#21
سالة دى بتظهر عند اضافة اكتر من صنفين الى dataGriedview وحفظ هذه  الفاتورة تظهر الرسالة دى 
[img=800x600] [/URL][/img]ate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PHP كود :
       If con.State ConnectionState.Open Then con.Close()
 
       Dim strInsert As String " Insert into tb1([Date],[SelMan],[total])values(@Date,@SelMan,@total)"

 
       cmd = New OleDb.OleDbCommand(strInsertcon)
 
       cmd.Parameters.Add(New OleDb.OleDbParameter("@Date"OleDb.OleDbType.VarChar)).Value TextBox1.Text
        cmd
.Parameters.Add(New OleDb.OleDbParameter("@SelMan"OleDb.OleDbType.VarChar)).Value SelMan.Text
        cmd
.Parameters.Add(New OleDb.OleDbParameter("@total"OleDb.OleDbType.VarChar)).Value SelMdataTextBox.Text

        con
.Open()

 
       cmd.ExecuteNonQuery()
 
       cmd = New OleDb.OleDbCommand("select max(id) from tb1"con)
 
       Dim dr As OleDb.OleDbDataReader cmd.ExecuteReader
        dr
.Read()
 
       'اضافة تفاصيل الفاتورة
        Dim ID_tb1 As Integer = dr(0)
        dr.Close()
        Dim code, quant As Integer

        Dim price, total As Double

        strInsert = "Insert into sell(code,ID_tb1,Name,quant,price,total)values(@code,@ID_tb1,@Name,@quant,@price,@total)"
        cmd = New OleDb.OleDbCommand(strInsert, con)

        For i As Integer = 0 To SellDataGridView.RowCount - 2
            code = SellDataGridView.Rows(i).Cells(0).Value
            Name = SellDataGridView.Rows(i).Cells(1).Value
            quant = SellDataGridView.Rows(i).Cells(2).Value
            price = SellDataGridView.Rows(i).Cells(3).Value
            total = SellDataGridView.Rows(i).Cells(4).Value
            cmd = New OleDbCommand(strInsert, con)
            cmd.Parameters.Add(New OleDb.OleDbParameter("@code", OleDb.OleDbType.Integer)).Value = code
            cmd.Parameters.Add(New OleDb.OleDbParameter("@ID_tb1", OleDb.OleDbType.Integer)).Value = ID_tb1
            cmd.Parameters.Add(New OleDb.OleDbParameter("@Name", OleDb.OleDbType.VarChar)).Value = Name
            cmd.Parameters.Add(New OleDb.OleDbParameter("@quant", OleDb.OleDbType.Integer)).Value = quant
            cmd.Parameters.Add(New OleDb.OleDbParameter("@price", OleDb.OleDbType.Currency)).Value = price
            cmd.Parameters.Add(New OleDb.OleDbParameter("@total", OleDb.OleDbType.Currency)).Value = total
            cmd.ExecuteNonQuery()
            SellDataGridView.Rows.RemoveAt(SellDataGridView.CurrentRow.Index)

        Next
        add_number()
        con.Close()
       
    End Sub 

[صورة مرفقة: he4c8u]
الرد }}}
تم الشكر بواسطة: asemshahen5
#22
مفيش اى رد
الرد }}}
تم الشكر بواسطة: asemshahen5
#23
كود :
            
if code="" then msgbox("code Empty"):exit sub
code = SellDataGridView.Rows(i).Cells(0).Value
if Name ="" then msgbox("Name Empty"):exit sub    
Name = SellDataGridView.Rows(i).Cells(1).Value
if quant="" then msgbox("quant Empty"):exit sub    
quant = SellDataGridView.Rows(i).Cells(2).Value
if price="" then msgbox("price Empty"):exit sub 
price = SellDataGridView.Rows(i).Cells(3).Value
if total="" then msgbox("total Empty"):exit sub    
total = SellDataGridView.Rows(i).Cells(4).Value
     
معنى الرسالة يوجد براميتر أو أكثر فارغ ضع له الكود التالي :
الرد }}}
تم الشكر بواسطة: elgokr
#24
السلام عليكم اخي الكريم 
انظر الى حقل name لماذا جعلته رقم وهو نصي حوله الى نص text في قاعدة البيانات

اخي عاطف من بعد السلام عليكم
هذا مثال كامل مع قاعدة بيانات مثل الذي عندك اتمنى ان تحل مشكلتك


الملفات المرفقة
.rar   atef_20.rar (الحجم : 83.8 ك ب / التحميلات : 15)
اعمل الخير وأجرك لا تنتظره فالله خير من إليك يرده
البرمجة ليست مجرد كود بل هي منهج تفكير منطقي لحل المشكلات







الرد }}}
تم الشكر بواسطة: elgokr , asemshahen5
#25
وضعت لك ما تريد في كود الزر Saveintable

عن طريقه تستطيع إضافة ما تريده و تعدل أي قيمة في الجدول ثم تضغط على الزر فيقوم بالحفظ و التعديل في كامل سجلات الجدول


الملفات المرفقة
.zip   Saveintable1.zip (الحجم : 139.94 ك ب / التحميلات : 17)
الرد }}}
تم الشكر بواسطة: elgokr



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم