Results 1 to 21 of 21

Thread: [RESOLVED] How to add mathematic operation to update database values!?

Threaded View

  1. #1

    Thread Starter
    Lively Member HOTFIX's Avatar
    Join Date
    Sep 2008
    Posts
    91

    Resolved [RESOLVED] How to add mathematic operation to update database values!?

    Hi…


    I need help to update the item QTY after performing search criteria by adding and subtracting new values which they will be saved to the database after the updating!

    Code:
    Imports System.Data
    Imports System.Data.OleDb
    
    
    Public Class Form2
        Dim frm As New Form1
        Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb"
        Dim Conn As New OleDbConnection(ConStr)
        Dim DataSet1 As New DataSet
        Dim SQLstr As String
        Dim m As String
    
    
        Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    
            DataSet1 = New DataSet
    
            Static m As Integer = 0
            If tbSearch.Text = Trim("") Then Exit Sub
            ExactSearch()
            Conn.Open()
            Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn)
            DataAdapter1.Fill(DataSet1, "store")
    
            Conn.Close()
            tbSearchResulItemPartNumber.DataBindings.Clear()
            tbSearchResultItemDeascriptions.DataBindings.Clear()
            tbSearchResultItemLocation.DataBindings.Clear()
            tbItemQuantitySearchResult.DataBindings.Clear()
    
            tbSearchResulItemPartNumber.DataBindings.Add("Text", DataSet1, "store.Item Part Number")
            tbSearchResultItemDeascriptions.DataBindings.Add("Text", DataSet1, "store.Item Descriptions")
            tbSearchResultItemLocation.DataBindings.Add("Text", DataSet1, "store.Item Location")
            tbItemQuantitySearchResult.DataBindings.Add("Text", DataSet1, "store.Item Quantity")
    
            DataGridView1.DataSource = DataSet1
            DataGridView1.DataMember = "store"
    
            If Me.BindingContext(DataSet1, "store").Count = 0 Then
                MsgBox("No Result??!! ")
                Form1.Show()
                Me.Close()
            End If
    
            Exit Sub
    
        End Sub
    
        Public Sub ExactSearch()
            SQLstr = "SELECT * FROM store WHERE [Item Part Number ]= '" & tbSearch.Text & "'"
        End Sub
    
        
        Private Sub btnBACK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBACK.Click
            Me.Close()
            Form1.Show()
        End Sub
    
       
    
        Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Conn.Open()
            Try
                Dim cmd As OleDbCommand = New OleDbCommand("Select [Item Part Number] from store", Me.Conn)
                Dim reader As OleDbDataReader = cmd.ExecuteReader()
                Dim list As New AutoCompleteStringCollection
                While reader.Read
                    list.Add(reader.Item("Item Part Number"))
                End While
                tbSEARCH.AutoCompleteMode = AutoCompleteMode.SuggestAppend
                tbSEARCH.AutoCompleteSource = AutoCompleteSource.CustomSource
                tbSEARCH.AutoCompleteCustomSource = list
    
            Catch ex As Exception
                Conn.Close()
                Throw ex
    
            End Try
            Conn.Close()
        End Sub
    
        Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbItemQuantityCalculation.KeyPress
            If (Char.IsControl(e.KeyChar) = False) Then
                If (Char.IsDigit(e.KeyChar)) Then
    
                Else
                    e.Handled = True
                    MsgBox("Sorry Only Digits Allowed!!", MsgBoxStyle.Information, "Store Mangement")
                    tbItemQuantityCalculation.Focus()
    
                End If
            End If
        End Sub
    
        
        Private Sub btnSUBTRACT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSUBTRACT.Click
    
        End Sub
    
        Private Sub btnADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADD.Click
    
        End Sub
    End Class

    Any idea about the codes for adding and subtracting

    Regards…
    Last edited by HOTFIX; Jan 9th, 2009 at 08:13 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width