Quantity problem in vb 2005

Συζητήσεις για τις γλώσσες του dot Net και για του Visual Studio της Microsoft

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
dem
Δημοσιεύσεις: 2
Εγγραφή: 29 Μάιος 2009 12:39

Quantity problem in vb 2005

Δημοσίευση από dem » 29 Μάιος 2009 13:00

καλημέρα παιδιά.κάνω ένα μικρό project στο κολέγιο και θα ήθελα τι βοήθεια σας σχετικά με το κώδικα.

Έχω λοιπόν μια forma πώλησης στην οποια υπάρχουν κάποια textboxes που μπορείς να διαλέξεις ένα προϊόν και να το εισάγεις σε ένα datagrid view.Επίσης έχω αλλα 3 textboxes το Reorder level το Units in stock και το units in order

Το τι θέλω να κάνω είναι όταν ένας πελάτης θέλει να aγοράσει κάτι να μπορεί να γίνετε verify ότι υπάρχει η ποσότητα αυτή και όταν η forma φυλαχτεί να γίνετε αφαίρεση τις ποσότητας που έχει αγοραστή από εκείνη την ποσότητα που ίππαρχοι στο σύστημα και αν η ποσότητα είναι κάτω του ορίου στο σύστημα να δίνη ένα μήνυμα πως χρειάζεται να γίνει παραγγελια στον supplier
ξέχασα να σας πω ότι χρησιμοποιώ την visual basic προ 2005 και είναι link από ms access 2003

Έχω δοκιμάσει πιο παλιά κάποιο κώδικα χωρίς όμως tip να λειτουργεί σχεδόν.παρακαλώ βοηθήστε με το κώδικα:)

Μπορώ επίσης αν ζητηθεί εδώ να δώσω το κώδικα όλης

Άβαταρ μέλους
virxen75
Δημοσιεύσεις: 493
Εγγραφή: 18 Φεβ 2009 00:17
Τοποθεσία: ΗΡΑΚΛΕΙΟ ΚΡΗΤΗΣ

Quantity problem in vb 2005

Δημοσίευση από virxen75 » 29 Μάιος 2009 13:33

στείλε τον κώδικα να δω τι έχεις κάνει μέχρι τώρα και πως
και αν μπορώ θα σε βοηθήσω

dem
Δημοσιεύσεις: 2
Εγγραφή: 29 Μάιος 2009 12:39

Quantity problem in vb 2005

Δημοσίευση από dem » 29 Μάιος 2009 13:39

Here is the code:)

Public Class Norders
Private im As Object

Private Sub Norders_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If OrderIDTextBox.Text.Length = 0 Then
MessageBox.Show("Please enter orderID")
OrderIDTextBox.Focus()
Exit Sub
End If
End Sub
Private Sub OrdersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
Me.Validate()
Me.OrdersBindingSource.EndEdit()
Me.OrdersTableAdapter.Update(Me.NicolaouDBDataSet.Orders)

End Sub

Private Sub movenext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movenext.Click
OrdersBindingSource.MoveNext()
End Sub

Private Sub moveprevius_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles moveprevius.Click
OrdersBindingSource.MovePrevious()
End Sub

Private Sub movelast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movelast.Click
OrdersBindingSource.MoveLast()
End Sub

Private Sub movefirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles movefirst.Click
OrdersBindingSource.MoveFirst()
End Sub

Private Sub addrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addrec.Click
Me.NicolaouDBDataSet.OrdersDetails.Clear()
TotalorderTextBox.Text = String.Empty
OrdersBindingSource.AddNew()



End Sub

Private Sub delrec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delrec.Click
OrdersBindingSource.RemoveCurrent()
End Sub

Private Sub OrdersDetailsBindingSourceBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OrdersBindingNavigatorSaveItem.Click
Me.Validate()
Me.OrdersDetailsBindingSource.EndEdit()
Me.OrdersDetailsTableAdapter.Update(Me.NicolaouDBDataSet.OrdersDetails)
Me.OrdersDetailsDataGridView.Refresh()
TotalSum()
If BonusCardTextBox1.Text.Length > 0 Then

Dim Totalorder As String = Decimal.Parse(TotalorderTextBox.Text)
Dim dbcon As New OleDb.OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data " & "Source=D:\NicolaouDB.mdb ; User Id = ; " & _
"Password = ")
dbcon.Open()
Dim dbcmd As New OleDb.OleDbCommand
dbcmd.Connection = dbcon
dbcmd.CommandText = "Update Customers Set Points = Points + ? Where BonusCard = ? "
dbcmd.Parameters.Add("@points", OleDb.OleDbType.Decimal).Value = TotalorderTextBox.Text
dbcmd.Parameters.Add("@BonusCard", OleDb.OleDbType.VarChar).Value = BonusCardTextBox1.Text
dbcmd.ExecuteNonQuery()
Else
MessageBox.Show("You could have earned " & Integer.Parse(TotalorderTextBox.Text) & " points with this order if you had a bonus card.")
End If

End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim bsource As BindingSource = Me.OrdersDetailsDataGridView.DataSource
Dim ds As DataSet = DirectCast(bsource.DataSource, DataSet)
Dim orderdetailstable As New DataTable
Dim dr As DataRow = ds.Tables("OrdersDetails").NewRow
dr("OrderID") = OrderIDTextBox.Text
dr("ProductID") = ProductIDComboBox.SelectedValue
dr("UnitPrice") = UnitPriceTextBox.Text
dr("Quantity") = QuantityTextBox.Text
dr("Proname") = ProductNameTextBox1.Text
dr("Discount") = DiscountTextBox.Text
dr("Total records") = 0
dr("Total") = Convert.ToDecimal(UnitPriceTextBox.Text.ToString()) * Convert.ToDecimal(QuantityTextBox.Text.ToString())

ds.Tables("OrdersDetails").Rows.Add(dr)

TotalSum()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
OrdersDetailsDataGridView.Rows.Remove(OrdersDetailsDataGridView.CurrentRow)

TotalSum()
End Sub



Private Sub TotalSum()
Dim sum As Decimal = 0
For Each row As DataGridViewRow In OrdersDetailsDataGridView.Rows
row.Cells(6).Value = row.Cells(4).Value * row.Cells(3).Value
sum += row.Cells(6).Value

Next
If DiscountTextBox.Text.Length > 0 Then
Dim Discount As Decimal = (sum * Integer.Parse(DiscountTextBox.Text)) / 100
sum = sum - Discount

txtAppliedDiscount.Text = Discount.ToString
End If
Me.TotalorderTextBox.Text = sum
Me.TotalorderTextBox.Text = sum.ToString("0.00")
OrdersDetailsDataGridView.Columns(6).DefaultCellStyle.Format = ("0.00")


End Sub



Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
OrdersDetailsDataGridView.Rows.Remove(OrdersDetailsDataGridView.CurrentRow)
End Sub


Private Sub email_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles email.Click
Nemail.Show()
End Sub

Private Sub callendar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles callendar.Click
Ncalendar.Show()
End Sub

Private Sub touch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles touch.Click
Process.Start("osk.exe")
End Sub

Private Sub info_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles info.Click
NicolaouInfos.Show()
End Sub




Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
'TODO: This line of code loads data into the 'NicolaouDBDataSet.Purchase' table. You can move, or remove it, as needed.
Me.PurchaseTableAdapter.Fill(Me.NicolaouDBDataSet.Purchase)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.purchasedetails' table. You can move, or remove it, as needed.
Me.PurchasedetailsTableAdapter.Fill(Me.NicolaouDBDataSet.Purchasedetails)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.OrdersDetails' table. You can move, or remove it, as needed.
Me.OrdersDetailsTableAdapter.Fill(Me.NicolaouDBDataSet.OrdersDetails)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.Customers' table. You can move, or remove it, as needed.
Me.CustomersTableAdapter.Fill(Me.NicolaouDBDataSet.Customers)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.Employees' table. You can move, or remove it, as needed.
Me.EmployeesTableAdapter.Fill(Me.NicolaouDBDataSet.Employees)

'TODO: This line of code loads data into the 'NicolaouDBDataSet.Orders' table. You can move, or remove it, as needed.
Me.OrdersTableAdapter.Fill(Me.NicolaouDBDataSet.Orders)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.OrdersDetails' table. You can move, or remove it, as needed.
Me.OrdersDetailsTableAdapter.Fill(Me.NicolaouDBDataSet.OrdersDetails)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.Products' table. You can move, or remove it, as needed.
Me.ProductsTableAdapter.Fill(Me.NicolaouDBDataSet.Products)
'TODO: This line of code loads data into the 'NicolaouDBDataSet.Suppliers' table. You can move, or remove it, as needed.
Me.SuppliersTableAdapter.Fill(Me.NicolaouDBDataSet.Suppliers)

TotalSum()
End Sub



Private Sub QuantityTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles QuantityTextBox.KeyDown
If Val(QuantityTextBox.Text) > Val(UnitsInStockTextBox.Text) Then
MsgBox("YOU CROSS THE SALES STOCK LIMIT", 0 + 48, "Nagrial's Information")
QuantityTextBox.Focus()
Exit Sub
End If
If ReorderLevelTextBox.Text = "" Then
ReorderLevelTextBox.Focus()
Exit Sub
End If
If QuantityTextBox.Text = "" Then
QuantityTextBox.Focus()
Exit Sub
End If

UnitsInStockTextBox.Text = CStr(Val(UnitsInStockTextBox.Text) - CDbl(QuantityTextBox.Text))

End Sub


Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click

End Sub
End Class

Άβαταρ μέλους
virxen75
Δημοσιεύσεις: 493
Εγγραφή: 18 Φεβ 2009 00:17
Τοποθεσία: ΗΡΑΚΛΕΙΟ ΚΡΗΤΗΣ

Quantity problem in vb 2005

Δημοσίευση από virxen75 » 30 Μάιος 2009 01:48

στείλε ένα zip με το project και την βάση

Απάντηση

Επιστροφή στο “dot Net και Visual Studio”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες