تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
مشكلة فى فاتوره كاشير اكرمكم الله
#5
كود :
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
       Dim pro_code As String = DataGridView1.CurrentRow.Cells(0).Value
       Dim pro_name As String = DataGridView1.CurrentRow.Cells(1).Value
       Dim QTY As String = DataGridView1.CurrentRow.Cells(2).Value
       Dim prise As Decimal = DataGridView1.CurrentRow.Cells(3).Value

       If pro_code = "" Then
           MsgBox("الرجاء عدم ترك خانه رقم الصنف فارغة")
           Return
       End If

       If part_no_Ex(pro_code) = False Then
           If MessageBox.Show("هذا الصنف غير موجود بقاعده البيانات هل تريد تسجيلة ؟؟", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then
               DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
               Return
           End If
           add_pro.TextBox1.Text = pro_code
           add_pro.ShowDialog()
           Return
       End If

       If e.ColumnIndex = 0 Then

           For i As Integer = 0 To DataGridView1.RowCount - 1
               If i <> DataGridView1.CurrentRow.Index AndAlso DataGridView1.Rows(i).Cells(0).Value = pro_code Then

                   Dim existingQty As Integer = Val(DataGridView1.Rows(i).Cells(2).Value)
                   DataGridView1.Rows(i).Cells(2).Value = existingQty + 1

                   DataGridView1.Rows(i).Cells(4).Value = (existingQty + 1) * Val(DataGridView1.Rows(i).Cells(3).Value)

                   DataGridView1.Rows.Remove(DataGridView1.CurrentRow)
                   GoTo UpdateTotal
               End If
           Next

           If con.State = ConnectionState.Open Then
               con.Close()
           End If
           con.Open()
           Dim cmd As New OleDbCommand()
           cmd.Connection = con
           cmd.CommandText = "select * from product where pro_code =@pro_code"
           cmd.Parameters.AddWithValue("@pro_code", pro_code)

           Dim dr As OleDbDataReader = cmd.ExecuteReader
           While dr.Read
               pro_name = dr.Item(1)
               prise = dr.Item(5)
               DataGridView1.CurrentRow.Cells(1).Value = pro_name
               DataGridView1.CurrentRow.Cells(2).Value = 1
               DataGridView1.CurrentRow.Cells(3).Value = prise
               DataGridView1.CurrentRow.Cells(4).Value = prise
           End While
           dr.Close()
           con.Close()

       ElseIf e.ColumnIndex = 2 Then
           Dim total As Decimal
           total = QTY * prise
           DataGridView1.CurrentRow.Cells(4).Value = total
       End If

UpdateTotal:
       Dim sum_total As Decimal = 0
       For i As Integer = 0 To DataGridView1.RowCount - 1
           sum_total += Val(DataGridView1.Rows(i).Cells(4).Value)
       Next
       TextBox3.Text = sum_total

   End Sub
قناتنا على اليوتوب
الرد }}}


الردود في هذا الموضوع
RE: مشكلة فى فاتوره كاشير اكرمكم الله - بواسطة عبد العزيز البسكري - 22-02-25, 03:13 PM


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


يقوم بقرائة الموضوع: