Click here to Skip to main content
15,887,296 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my program

form1 program:

Imports System.Net.Mail
Public Class CMS
Dim db As New database
Dim dt As New DataTable
Dim i As Integer = 0
Private Sub addbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addbutton.Click
Dim addfrm As New add
addfrm.addbutton.Text = "add"
addfrm.ShowDialog()
loadgrid()
End Sub

Private Sub editbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles editbutton.Click
If Not yuvapriyagrid.SelectedRows.Count = 0 Then
Dim addfrm As New add
addfrm.id = yuvapriyagrid.SelectedRows(0).Cells(1).Value.ToString
addfrm.Text = "Edit Employee"
addfrm.addbutton.Text = "update"
addfrm.ShowDialog()
loadgrid()
Else
MsgBox("Please select a row")
End If
End Sub

Private Sub deletebutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles deletebutton.Click
If Not yuvapriyagrid.SelectedRows.Count = 0 Then
If MsgBox("Are you sure you want to delete", vbYesNo, "Delete") = vbYes Then
Dim res As Boolean
res = db.executequery("Delete from yuvapriya where id = '" & yuvapriyagrid.SelectedRows(0).Cells(0).Value.ToString & "'")
If res Then
MsgBox("Deleted successfully")
Else
MsgBox("Not Deleted")
End If
End If
Else
MsgBox("Please select a row")
End If
loadgrid()
End Sub

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

loadgrid()

End Sub

Private Sub loadgrid()
Dim db As New database
Dim dt As New DataTable
dt = db.getdt("select id, name, education, age,[address], phonenum, postcode, Email from yuvapriya")
yuvapriyagrid.DataSource = dt
i = 0
For Each row In yuvapriyagrid.Rows
yuvapriyagrid.Rows(i).Cells(0).Value = (1 + i).ToString
i += 1
Next
End Sub

Private Sub searchbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchbutton.Click
If Not TextBox1.Text = String.Empty Then
Dim sql As String = "select id, name, education, age,[address], phonenum, postcode,Email from yuvapriya where " + ComboBox1.SelectedItem.ToString + " like '%" + TextBox1.Text + "%'"
dt = db.getdt(sql)
yuvapriyagrid.DataSource = dt
i = 0
For Each row In yuvapriyagrid.Rows
yuvapriyagrid.Rows(i).Cells(0).Value = (1 + i).ToString
i += 1
Next
Else
loadgrid()
End If
End Sub

Private Sub btnSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendMail.Click
Dim Msg As New MailMessage()
'Sender e-mail address.
Msg.From = New MailAddress("premnarayanant@gmail.com")
'Recipient e-mail address.
Msg.[To].Add(yuvapriyagrid.SelectedRows(0).Cells("Email").Value.ToString)
Msg.Subject = "Conformation mail"
Msg.Body = "Conformation mail
your age is " + yuvapriyagrid.SelectedRows(0).Cells("age").Value.ToString + "
your address is " + yuvapriyagrid.SelectedRows(0).Cells("address").Value.ToString
Msg.IsBodyHtml = True
'your remote SMTP server IP.
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.Credentials = New System.Net.NetworkCredential("premnarayanant@gmail.com", "iyan")
smtp.EnableSsl = True
smtp.Send(Msg)
End Sub
End Class
Posted
Comments
E.F. Nijboer 14-Nov-13 4:41am    
I think you meant magic-pushbutton pattern to decent code...

1 solution

It cannot be done directly.
You will need to rewrite. You can probably reuse some of the query code and stuff but otherwise there will be some redesign.
 
Share this answer
 

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