تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
ممكن مساعدة بخصوص المشكلة هدي
#1
السلام عليكم

اخي وصديقي الغالي عرض علي اكمل المشروع الخاص به بس وحدت بعض المشاكل بالمشروع وهي كالاتي
المشروع خاص بسوبرماركت متكامل وعند الفورم الخاص بالمشريات عند انشاء فاتورة مشتريات عند اضافة صنف جديد كما في بالصورة المرفقة


وهدي عند البحت عن الصنف الخاص وحساب الكمية والخصم والصلاحية والاجمالي والربح كما بالصورة التالية




الي هنا كل شي تمام وعندما اختار اختيار يظهر الخطاء الحالي


وهدا الكود الخاص بالفورم

كود :
Imports System.Data.OleDb

Public Class Item_Serach
   Dim ItemNM As String
   Dim PriceIt As Double
   Dim PrIt As Double


   Public Sub BuyCalcultion()
       Try
           'Dim ItemNM As String = DGV(2, DGV.CurrentRow.Index).Value

           Dim Qty, Discunt, unitPrice, total, totalB, Eran As Double
           '--------------------------------------------------------
           ' ItemNM = DGV(2, DGV.CurrentRow.Index).Value
           PriceIt = Val(DGV(6, DGV.CurrentRow.Index).Value)
           PrIt = PriceIt
           Qty = Val(QtIn.Text)
           Discunt = Val(DiscuontIn.Text) / 100

           '----------------------------------------------------------
           'حساب اجمالي الجمهور
           total = Qty * PrIt
           'حساب اجمالي الشراء
           totalB = total - (total * Discunt)
           'حساب سعر الوحدة
           unitPrice = totalB / Qty
           'حساب الربح المتوقع
           Eran = total - totalB
           '---------------------------------------------------------
           LblTG.Text = total
           LblTS.Text = totalB
           LblUP.Text = unitPrice
           LblEarn.Text = Eran
       Catch ex As Exception

       End Try

   End Sub

   Public Sub NewItem()
       QtIn.Text = 0
       DiscuontIn.Text = 0
       ExpiredIN.Value = Now.Date
       Notes.Text = Nothing

   End Sub
   Private Sub Item_Serach_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       '=====load items table====
       Load_Items()

       ' DGV.DataSource = dt_Items
       Select_All_Items(DGV)
       DataGridViewHeaderText(DGV)
       '=====emptying for new selection ==
       NewItem()
       '===========Focusing for new selection=================
       TxtSerch.Text = Nothing
       TxtSerch.Focus()
       RadioButton2.Checked = True
       BuyCalcultion()
   End Sub
   Public Sub DataGridViewHeaderText(ByVal DGV As DataGridView)
       If DGV.RowCount > 0 Then
           With DGV
               .Columns("ItemID").HeaderText = "رقم الصنف"
               .Columns("ItemID").Width = 90
               .Columns("ItemBarcode").HeaderText = "الباركود"
               .Columns("ItemBarcode").Width = 100
               .Columns("ItemName").HeaderText = "اسم الصنف"
               .Columns("ItemName").Width = 100
               .Columns("ItemGroup").HeaderText = "مجموعة الصنف"
               .Columns("ItemGroup").Width = 100
               .Columns("ItemCompany").HeaderText = "شركة الصنف"
               .Columns("ItemCompany").Width = 100
               .Columns("ItemPlace").HeaderText = "مكان الصنف"
               .Columns("ItemPlace").Width = 100
               .Columns("ItemPrice").HeaderText = "سعر الصنف"
               .Columns("ItemPrice").Width = 100
               .Columns("ItemQty").HeaderText = "كمية الصنف"
               .Columns("ItemQty").Width = 100
               .Columns("ItemLimit").HeaderText = "حد طلبية الصنف"
               .Columns("ItemLimit").Width = 150
               .Columns("ItemMaxDiscound").HeaderText = "اعلا خصم للصنف"
               .Columns("ItemMaxDiscound").Width = 150
               .Columns("ItemEran").HeaderText = "ربح الصنف"
               .Columns("ItemEran").Width = 100
               .Columns("ItemDate").HeaderText = "التاريخ"
               .Columns("ItemDate").Width = 100
               .Columns("ItemTime").HeaderText = "الوقت"
               .Columns("ItemTime").Width = 100
               .Columns("ItemUser").HeaderText = "المسنخدم"
               .Columns("ItemUser").Width = 100
           End With
       End If
   End Sub

   Private Sub TxtSerch_TextChanged(sender As Object, e As EventArgs) Handles TxtSerch.TextChanged
       If RadioButton2.Checked = True Then
           Try
               Dim dv As DataView = dt_Items.DefaultView
               dv.RowFilter = " ItemName LIKE '%" & TxtSerch.Text & "%' "


           Catch ex As Exception
           End Try

       End If
       If RadioButton1.Checked = True Then
           Try
               Dim dv As DataView = dt_Items.DefaultView
               dv.RowFilter = " ItemID = " & TxtSerch.Text & " "
           Catch ex As Exception
           End Try

       End If
       If RadioButton3.Checked = True Then
           Try
               Dim dv As DataView = dt_Items.DefaultView
               dv.RowFilter = " ItemBarcode LIKE '%" & TxtSerch.Text & "%' "
           Catch ex As Exception
           End Try

       End If


   End Sub

   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       If QtIn.Text = 0 Then
           MsgBox("من فضلك ادخل الكمية المانسبة")
           QtIn.Focus()
       ElseIf DiscuontIn.Text = 0 Then
           MsgBox("من فضلك ادخل الخصم المانسب")
           DiscuontIn.Focus()
       ElseIf ExpiredIN.Value = Now.Date Then
           MsgBox("من فضلك ادخل  تاريخ صلاحية الصنف ")
           ExpiredIN.Focus()
       Else


           '==== save the selected item====
           ItemNM = DGV(2, DGV.CurrentRow.Index).Value
           PriceIt = Val(DGV(6, DGV.CurrentRow.Index).Value)

           Dim dt As New DataTable
           Dim cmd As New OleDbCommand
           dt.Clear()
           cmd = New OleDbCommand("Insert Into Operations (BuyID,OperItem,BuyQty,BuyDiscound,BuyNotes,OperItemExp,BuyTotalG,BuyTotalB,BuyUnitPrice,BuyEarn) values (" & BuyPill.BuyID.Text & ",'" & ItemNM & "'," & QtIn.Text & "," & DiscuontIn.Text & ",'" & Notes.Text & "',#" & ExpiredIN.Value & "#," & Val(LblTS.Text) & "," & Val(LblTS.Text) & "," & Val(LblUP.Text) & "," & Val(LblEarn.Text) & ")", con)
           con.Open()
           cmd.ExecuteNonQuery()
           con.Close()
           '=====emptying for new selection ==
           Me.Close()
           '=====load BuyQuery from Form BuyPill
           BuyPill.Load_BuyQ()
           NewItem()

       End If



   End Sub

   Private Sub QtIn_TextChanged(sender As Object, e As EventArgs) Handles QtIn.TextChanged
       BuyCalcultion()
   End Sub

   Private Sub DiscuontIn_TextChanged(sender As Object, e As EventArgs) Handles DiscuontIn.TextChanged
       BuyCalcultion()
   End Sub
   Private Sub DGV_SelectionChanged(sender As Object, e As EventArgs) Handles DGV.SelectionChanged
       BuyCalcultion()

   End Sub
End Class


وهدا كود الاختيار

كود :
rivate Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       If QtIn.Text = 0 Then
           MsgBox("من فضلك ادخل الكمية المانسبة")
           QtIn.Focus()
       ElseIf DiscuontIn.Text = 0 Then
           MsgBox("من فضلك ادخل الخصم المانسب")
           DiscuontIn.Focus()
       ElseIf ExpiredIN.Value = Now.Date Then
           MsgBox("من فضلك ادخل  تاريخ صلاحية الصنف ")
           ExpiredIN.Focus()
       Else


           '==== save the selected item====
           ItemNM = DGV(2, DGV.CurrentRow.Index).Value
           PriceIt = Val(DGV(6, DGV.CurrentRow.Index).Value)

           Dim dt As New DataTable
           Dim cmd As New OleDbCommand
           dt.Clear()
           cmd = New OleDbCommand("Insert Into Operations (BuyID,OperItem,BuyQty,BuyDiscound,BuyNotes,OperItemExp,BuyTotalG,BuyTotalB,BuyUnitPrice,BuyEarn) values (" & BuyPill.BuyID.Text & ",'" & ItemNM & "'," & QtIn.Text & "," & DiscuontIn.Text & ",'" & Notes.Text & "',#" & ExpiredIN.Value & "#," & Val(LblTS.Text) & "," & Val(LblTS.Text) & "," & Val(LblUP.Text) & "," & Val(LblEarn.Text) & ")", con)
           con.Open()
           cmd.ExecuteNonQuery()
           con.Close()
           '=====emptying for new selection ==
           Me.Close()
           '=====load BuyQuery from Form BuyPill
           BuyPill.Load_BuyQ()
           NewItem()

       End If



   End Sub
الرد }}}
تم الشكر بواسطة:
#2
وعليكم السلام...
هل تريد عرض البيانات من الجريد لأداة أخرى؟؟ أو وضحلي الفكرة وسيتم الإصلاح بإذن الله
المبرمج لا يفكر في المشكلة بل في الحل!!
الرد }}}
تم الشكر بواسطة: asemshahen5
#3
اخي الفاصل شكرا علي رد
من خلال فورم فاتورة شراء عند اضافه صنف تظهر نافده الاصناف كما موضح اعلاه وعند تحديد الصنف من خلال DGV متلا وقفنا علي صف
Dgv(6,dgv.currentRow.index)
يعني عند الصف اللي تم اختياره وفي العمود 6 يعني price
من خلال بيانات السعر اقدر احسب الاجمالي والربح …. الخ
فرضت متغير اسمه PriceIt ياخد قيمة السعر في dgv
وعمليات الحسابيه كلها صحيحة
بس تواجهني عند الضغط علي زر اختيار في فورم الاصناف تظهر ريساله الخظاء كما موضحه بالصورة اعلاه
في كود insert
الرد }}}
تم الشكر بواسطة: asemshahen5
#4
(13-07-21, 06:09 PM)y6767 كتب : If IsNothing(DGV.CurrentRow.Cells(6).Value) Then
    PriceIt = 0
Else
    PriceIt = Val(DGV.CurrentRow.Cells(6).Value)
EndIf
نفس الخطاء يظهر
الرد }}}
تم الشكر بواسطة: asemshahen5
#5
(13-07-21, 07:24 PM)y6767 كتب : If IsNothing(DGV.CurrentRow) OrElse IsNothing(DGV.CurrentRow.Cells(6).Value) Then
    PriceIt = 0
Else
    PriceIt = Val(DGV.CurrentRow.Cells(6).Value)
EndIf

احسنت وبارك الله فيك تم حل المشكلة بفضلك وجزاك الله خيرا
الرد }}}
تم الشكر بواسطة: اسامه الهرماوي , asemshahen5



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


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