11-07-21, 07:29 PM
السلام عليكم
اخي وصديقي الغالي عرض علي اكمل المشروع الخاص به بس وحدت بعض المشاكل بالمشروع وهي كالاتي
المشروع خاص بسوبرماركت متكامل وعند الفورم الخاص بالمشريات عند انشاء فاتورة مشتريات عند اضافة صنف جديد كما في بالصورة المرفقة
وهدي عند البحت عن الصنف الخاص وحساب الكمية والخصم والصلاحية والاجمالي والربح كما بالصورة التالية
الي هنا كل شي تمام وعندما اختار اختيار يظهر الخطاء الحالي
وهدا الكود الخاص بالفورم
وهدا كود الاختيار
اخي وصديقي الغالي عرض علي اكمل المشروع الخاص به بس وحدت بعض المشاكل بالمشروع وهي كالاتي
المشروع خاص بسوبرماركت متكامل وعند الفورم الخاص بالمشريات عند انشاء فاتورة مشتريات عند اضافة صنف جديد كما في بالصورة المرفقة
وهدي عند البحت عن الصنف الخاص وحساب الكمية والخصم والصلاحية والاجمالي والربح كما بالصورة التالية
الي هنا كل شي تمام وعندما اختار اختيار يظهر الخطاء الحالي
وهدا الكود الخاص بالفورم
كود :
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