Click here to Skip to main content
13,043,092 members (65,618 online)

multiplying and coding for derived attributes to appear whenever 2 attributes will be mutiplied

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
        sql = " Select * from Orders"
        Dim da As New OleDb.OleDbDataAdapter(sql, myconnection)
        Dim dt As New DataTable("tblOrder")
        dgv1.DataSource = dt.DefaultView

    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")
        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
    End Sub
    Private Sub btnAdd_Click(sender As System.Object, e As System.EventArgs) Handles btnAdd.Click
    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, VB.NET


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
Web01 | 2.8.170713.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
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