Click here to Skip to main content

SWEET143 asked:

Open original thread
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
Tags: VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100