Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
how can i do it. i set in sql server 2005 the balance column formula=feeamount-receved.,
Posted
Comments
Tejas Vaishnav 21-Mar-14 3:05am    
Its Windows form application or Web site

1 solution

I have define static fee amount you should use your actual columns.

VB
Public Class Form12
    Public oCn As New System.Data.SqlClient.SqlConnection("Data Source=(local);Initial Catalog=MyDatabase;Uid=sa")
    Dim dv As New DataView

    Private Sub Form12_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        fill_grid()
    End Sub

    Sub fill_grid()
        If oCn.State = ConnectionState.Closed Then
            oCn.Open()
        End If
        Me.DataGridView1.Rows.Clear()
        Dim cmd As New SqlClient.SqlCommand("SELECT * from mst_scheme", oCn)
        Dim da As New SqlClient.SqlDataAdapter(cmd)
        Dim ds As New DataSet("bpl")
        Dim i As Integer = 0

        da.Fill(ds, "bpl")

        If ds.Tables(0).Rows.Count > 0 Then
            While (i <> ds.Tables(0).Rows.Count)
                Me.DataGridView1.Rows.Add()
                Me.DataGridView1.Item(0, i).Value = i + 1
                Me.DataGridView1.Item(1, i).Value = ds.Tables(0).Rows(i).Item("scheme_name").ToString
                Me.DataGridView1.Item(2, i).Value = 1000
                Me.DataGridView1.Item(4, i).Value = Me.DataGridView1.Item(2, i).Value - Me.DataGridView1.Item(3, i).Value
                i = i + 1
            End While
        End If

    End Sub

    Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        If Me.DataGridView1.Rows.Count > 0 Then
            If e.ColumnIndex = 3 Then
                Me.DataGridView1.Item(4, e.RowIndex).Value = Me.DataGridView1.Item(2, e.RowIndex).Value - Me.DataGridView1.Item(3, e.RowIndex).Value
            End If
        End If
    End Sub
End Class
 
Share this answer
 
v2
Comments
Aravindba 21-Mar-14 5:51am    
dont post full code,just ask what they try and try solve errors only and some little bit lines,this is not good for beginners,any way for ur solution 5+
sohail awr 21-Mar-14 5:57am    
ok

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