Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table w/c is in the data grid view... it has 4 attributes ID,Description,Unit Price and Unit Quanity... now part of the task is whenever New record was added, automatically the Unit Price and The Unit Quantity will be multiplied and a derived attribute w/c is Total Price will appear ... What Code will I use to perform this and where will it will inserted?


Imports System.Data.OleDb
Public Class frmMain

    Dim myconnection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\order\Order\Order\Orders.accdb")

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sql As String
        myconnection.Open()

        sql = " Select * from Orders"

        Dim da As New OleDb.OleDbDataAdapter(sql, myconnection)
        Dim dt As New DataTable("tblOrder")

        da.Fill(dt)
        dgv1.DataSource = dt.DefaultView
        RefreshDGV()

        myconnection.Close()


    End Sub


    Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
        Dim sqlsearch As String
        sqlsearch = "SELECT * FROM Orders WHERE ID LIKE '%" & txtSearch.Text & "%'" & " OR Description LIKE '%" & txtSearch.Text & "%'"

        Dim da As New OleDbDataAdapter(sqlsearch, myconnection)
        Dim dt As New DataTable("Orders")
        da.Fill(dt)
        dgv1.DataSource = dt.DefaultView


    End Sub

    Private Sub cboSearch_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboSearch.SelectedIndexChanged
        

        If Not cboSearch.Text = cboSearch.SelectedText Then
            btnSave.Enabled = True
        End If


        Dim MyVariable As String

        MyVariable = cboSearch.Text

        MsgBox(MyVariable)

    End Sub

    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
        frmAdd.Show()
    End Sub

    Private Sub RefreshDGV()

    End Sub

    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click

      
       
    End Sub
End Class
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900