تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشكلة فى حفظ اكتر من صنفين عند حفظ الفاتورة
#1
لسلام عليكم عند مشكلة عندما ادخل اكتر من صنفين فى الداتا جريد فيو واقوم بحفظ الفاتورة فتاتى الرسالة دى 
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

[img=973x800] [/img]
PHP كود :
   Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click

        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 
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
مشكلة فى حفظ اكتر من صنفين عند حفظ الفاتورة - بواسطة atef_020 - 25-04-18, 12:37 PM


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


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