السلام عليكم..
ممكن شرح لهذا الكود..؟
Try 042 For i As Integer = 0 To bcD.Count - 1 043 bcD.Position = 0 044 Dim drvD As DataView = bcD.List 045 bcP.Filter = "Product_id=" & drvD.Item(0).Item(1) 046 Dim drvP As DataView = bcP.List 047 DataGridView1.Rows.Add(drvD.Item(0).Item(1), drvP.Item(0).Item(2), drvD.Item(0).Item(2), drvP.Item(0).Item(4), drvP.Item(0).Item(4) * drvD.Item(0).Item(2)) 048 Next 049 Catch ex As Exception 050 MsgBox(ex.Message) 051 End Try 052 053 Try 054 For Each row As DataGridViewRow In DataGridView1.Rows 055 If row.IsNewRow Then Continue For 056 row.HeaderCell.Value = (row.Index + 1).ToString 057 Next 058 Catch ex As Exception 059 MsgBox(ex.Message) 060 End Try 061 End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click 079 Dim sqlmax As String = "select max(invoice_id) FROM invoice_header" 080 Dim Cmd As New SqlCommand(sqlmax, cn) 081 cn.Open() 082 Dim i As Integer = Val(Cmd.ExecuteScalar.ToString) 083 cn.Close() 084 bcM.AddNew() 085 DataGridView1.Rows.Clear() 086 Me.TextBox1.Text = i + 1 087 End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
090 select Case e.ColumnIndex
091 Case 0
092 bcP.Filter = "Product_id=" & Val(DataGridView1.CurrentCell.Value)
093 If bcP.Count > 0 Then
094 Dim drvP As DataView = bcP.List
095 DataGridView1.CurrentRow.Cells(1).Value = drvP.Item(0).Item(2)
096 DataGridView1.CurrentRow.Cells(3).Value = drvP.Item(0).Item(4)
097 Else
098 MsgBox("لا يوجد مادة بهذا الرقم")
099 SendKeys.Send("{UP}")
100 End If
101 Case 2
102 DataGridView1.CurrentRow.Cells(4).Value = DataGridView1.CurrentRow.Cells(3).Value * DataGridView1.CurrentRow.Cells(2).Value
103 DataGridView1.CurrentRow.Cells(4).Style.Format = "#0.000"
104 End select
105 End Sub
106 End Classبانتظاااااار ردكم بفارغ الصبر...
جزااااااااااااااااكم الله كل خير...وزادكم من علمه ونفع بكم الاسلام والمسلمين...