Hi all,
I'm hanged out with my application.,I 've a form in that when i click submit button,I want to enter the details from the textboxes in the form to a dataset table.I did it,but the problem is that I want to add multiple rows in that datatable(at runtime).Also I want to export table to a crystal report which is another form.Help me please!!
The form code
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Public Class Form2
Function errormsg()
MsgBox("Fill the required fields")
Return 0
End Function
Function clearall()
nam.Clear()
dm.Clear()
off.Clear()
ph.Clear()
pd.Clear()
ad.Clear()
sd.Clear()
ms.Clear()
bs.Clear()
hra.Clear()
pf.Clear()
ta.Clear()
total.Clear()
esi.Clear()
adv.Clear()
total.Clear()
Return 0
End Function
Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear.Click
clearall()
End Sub
Private Sub ad_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ad.TextChanged
sd.Text = Val(pd.Text) + Val(off.Text) + Val(ph.Text) - Val(ad.Text)
End Sub
Private Sub off_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles off.TextChanged
sd.Text = Val(pd.Text) + Val(off.Text) + Val(ph.Text) - Val(ad.Text)
End Sub
Private Sub ph_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ph.TextChanged
sd.Text = Val(pd.Text) + Val(off.Text) + Val(ph.Text) - Val(ad.Text)
End Sub
Private Sub pd_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles pd.TextChanged
sd.Text = Val(pd.Text) + Val(off.Text) + Val(ph.Text) - Val(ad.Text)
End Sub
Private Sub ms_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ms.TextChanged
hra.Text = Val(ms.Text) * 25 / 100
bs.Text = Val(ms.Text) * 60 / 100
ta.Text = Val(ms.Text) * 15 / 100
esi.Text = Val(ms.Text) * 1.75 / 100
pf.Text = Val(bs.Text) * 12 / 100
total.Text = Val(bs.Text) + Val(hra.Text) + Val(ta.Text) - (Val(pf.Text) + Val(esi.Text) + Val(adv.Text))
End Sub
Private Sub adv_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles adv.TextChanged
total.Text = Val(bs.Text) + Val(hra.Text) + Val(ta.Text) - (Val(pf.Text) + Val(esi.Text) + Val(adv.Text))
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
desg.SelectedIndex = 0
month.SelectedIndex = 0
End Sub
Private Sub submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit.Click
Dim name, desi, mth As String
Dim dm1, off1, ph1, pd1, ad1, sd1 As Integer
Dim bs1, ms1, hra1, pf1, esi1, total1, adv1, ta1 As Double
name = nam.Text
desi = desg.SelectedItem
mth = month.SelectedItem
dm1 = Val(dm.Text)
off1 = Val(off.Text)
ph1 = Val(ph.Text)
pd1 = Val(pd.Text)
ad1 = Val(ad.Text)
sd1 = Val(sd.Text)
ms1 = Val(ms.Text)
bs1 = Val(bs.Text)
hra1 = Val(hra.Text)
pf1 = Val(pf.Text)
ta1 = Val(ta.Text)
esi1 = Val(esi.Text)
total1 = Val(total.Text)
adv1 = Val(adv.Text)
bs1 = Val(bs.Text)
If nam.Text = "" Then
errormsg()
End If
If ms.Text = "" Then
errormsg()
End If
Dim test As New Class1
test.t = test.ds.Tables.Add("salary")
test.t.Columns.Add("Name", Type.GetType("System.String"))
test.t.Columns.Add("Desg", Type.GetType("System.String"))
test.t.Columns.Add("Dim", Type.GetType("System.Int32"))
test.t.Columns.Add("Off", Type.GetType("System.Int32"))
test.t.Columns.Add("Paid", Type.GetType("System.Int32"))
test.t.Columns.Add("Present", Type.GetType("System.Int32"))
test.t.Columns.Add("Absent", Type.GetType("System.Int32"))
test.t.Columns.Add("Salary", Type.GetType("System.Int32"))
test.t.Columns.Add("Maximum", Type.GetType("System.Double"))
test.t.Columns.Add("Basic", Type.GetType("System.Double"))
test.t.Columns.Add("HRA", Type.GetType("System.Double"))
test.t.Columns.Add("TA", Type.GetType("System.Double"))
test.t.Columns.Add("PF", Type.GetType("System.Double"))
test.t.Columns.Add("ESI", Type.GetType("System.Double"))
test.t.Columns.Add("Advance", Type.GetType("System.Double"))
test.t.Columns.Add("Total", Type.GetType("System.Double"))
test.r = test.t.NewRow()
test.r("Name") = name
test.r("Desg") = desi
test.r("Dim") = dm1
test.r("Off") = off1
test.r("Paid") = ph1
test.r("Present") = pd1
test.r("Absent") = ad1
test.r("Salary") = sd1
test.r("Maximum") = ms1
test.r("Basic") = bs1
test.r("HRA") = hra1
test.r("TA") = ta1
test.r("PF") = pf1
test.r("ESI") = esi1
test.r("Advance") = adv1
test.r("Total") = total1
test.t.Rows.Add(test.r)
clearall()
End Sub
Private Sub month_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles month.SelectedIndexChanged
Dim ch As Integer
ch = month.SelectedIndex
Select Case ch
Case 0
dm.Text = 31
Case 1
dm.Text = 28
Case 2
dm.Text = 31
Case 3
dm.Text = 30
Case 4
dm.Text = 31
Case 5
dm.Text = 30
Case 6
dm.Text = 31
Case 7
dm.Text = 31
Case 8
dm.Text = 30
Case 9
dm.Text = 31
Case 10
dm.Text = 30
Case 11
dm.Text = 31
End Select
End Sub
End Class
This is my form
http://imagehosting.nazdrovia.net/images/form2.gif