تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] مشكلة في اسماء الاصناف في فاتورة المبيعات
#9
كود العملية الحسابية لفاتورة مبيعات
لكن الكود لا يعمل الا عند الضغط على الداتا جريد فيو
اريد ان اجعل الكود يقوم بالعملية الحسابية عند نزول الاصناف بدون الضغط داخل الداتا جريد فيو
Public Sub Salecalc()
       Try
           'اجمالي البيع
           'total = qty*price
           DataGridView1(7, DataGridView1.CurrentRow.Index).Value = Val(DataGridView1(6, DataGridView1.CurrentRow.Index).Value) * Val(DataGridView1(2, DataGridView1.CurrentRow.Index).Value)
           'اجمالي الربح
           'totalb = total - (total * Qty)
           DataGridView1(9, DataGridView1.CurrentRow.Index).Value = Val(DataGridView1(7, DataGridView1.CurrentRow.Index).Value) - (Val(DataGridView1(7, DataGridView1.CurrentRow.Index).Value) * (Val(DataGridView1(8, DataGridView1.CurrentRow.Index).Value) / 100))
           'اجمالي الشراء
           DataGridView1(11, DataGridView1.CurrentRow.Index).Value = Val(DataGridView1(10, DataGridView1.CurrentRow.Index).Value) * DataGridView1(6, DataGridView1.CurrentRow.Index).Value
           ' الأرباح
           ' earn = total - totalb
           DataGridView1(12, DataGridView1.CurrentRow.Index).Value = Val(DataGridView1(9, DataGridView1.CurrentRow.Index).Value) - DataGridView1(11, DataGridView1.CurrentRow.Index).Value

           Dim total, totalb, count, earn As Double
           For i As Integer = 0 To DataGridView1.Rows.Count - 1
               total = total + Val(DataGridView1(9, DataGridView1.Rows(i).Index).Value)
               totalb = totalb + Val(DataGridView1(11, DataGridView1.Rows(i).Index).Value)
               count = DataGridView1.Rows.Count
               earn = total - totalb
               'percent = (1 - (totalb / total)) * 100
           Next
           SaleTotal.Text = total
           'SaleTotalS.Text = totalb
           SaleItemCount.Text = count
           SaleEarn.Text = earn
           'SaleMines.Text = Math.Round(percent, 2)
       Catch ex As Exception

       End Try

==============
المشكلة الاخرى في كود البحث
عند البحث على نفس الصنف في نفس الفاتورة يقوم بوضعه في سطر اخر ولا يقوم بجمعه في سطر واحد
وعند طلب صنف معين يقوم بوضع قيمة 0 للصنف وعند الطلب مرة اخرى تنزل القيمة  1 ولا يقوم بالعملية الحسابية الا عند تحرير الداتا جريد
أريد جعل القيمة بدل الصفر تنزل رقم 1
Using dp As New OleDb.OleDbDataAdapter("SELECT * FROM [Items] WHERE [ItemBarCode] = @Code", con)
           dp.SelectCommand.Parameters.AddWithValue("@Code", TxtSearch.Text)
           Dim dt_itm As New DataTable

           If dp.Fill(dt_itm) > 0 Then
               Dim r As DataRow = dt_itm.Rows(0)

               DataGridView1.ClearSelection()

               Dim dgvRow As DataGridViewRow = (From x In Me.DataGridView1.Rows Where x.Cells(0).Value = r("ItemBarCode")).SingleOrDefault
               If IsNothing(dgvRow) Then

                   DataGridView1.Rows.Add(r("ItemBarCode"), r("ItemName"), r("ItemPrice"), 1)

                   DataGridView1.FirstDisplayedScrollingRowIndex = DataGridView1.Rows.Count - 1
                   DataGridView1.Rows(DataGridView1.Rows.Count - 1).Selected = True
               Else

                   dgvRow.Cells(6).Value += 1

                   DataGridView1.FirstDisplayedScrollingRowIndex = dgvRow.Index
                   DataGridView1.Rows(dgvRow.Index).Selected = True
               End If
               Salecalc()

               TxtSearch.Clear()
               TxtSearch.Select()

           End If
قاعدة البيانات المستخدمة اكسس 2010
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: مشكلة في اسماء الاصناف في فاتورة المبيعات - بواسطة ملهمـ - 22-11-17, 02:55 AM


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


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