Académique Documents
Professionnel Documents
Culture Documents
SqlClient
Public Class frmEmployees
Sub division()
Try
con = New SqlConnection(cs)
con.Open()
adp = New SqlDataAdapter()
adp.SelectCommand = New SqlCommand("SELECT distinct RTRIM(division)
FROM signatories", con)
ds = New DataSet("ds")
adp.Fill(ds)
dtable = ds.Tables(0)
cmbDivision.Items.Clear()
For Each drow As DataRow In dtable.Rows
cmbDivision.Items.Add(drow(0).ToString())
Next
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClose.Click
Me.Close()
End Sub
Sub Reset()
txtDivision.Text = ""
cmbDivision.Text = ""
txtContactPerson.Text = ""
txtContactNo.Text = ""
txtSearchByContactPerson.Text = ""
txtContactPerson.Focus()
Getdata()
btnSave.Enabled = True
btnDelete.Enabled = False
btnUpdate.Enabled = False
txtContactPerson.Focus()
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNew.Click
Reset()
End Sub
If rdr.Read() Then
MessageBox.Show("Record Already Existed!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.[Error])
If (rdr IsNot Nothing) Then
rdr.Close()
End If
Return
End If
Try
Dim RowsAffected As Integer = 0
con = New SqlConnection(cs)
con.Open()
Dim cq As String = "delete from signatories where ID=@d1"
cmd = New SqlCommand(cq)
cmd.Parameters.AddWithValue("@d1", Val(txtID.Text))
cmd.Connection = con
RowsAffected = cmd.ExecuteNonQuery()
If RowsAffected > 0 Then
LogFunc(lblUser.Text, "deleted the signatory having Employee Name
'" & txtContactPerson.Text & "' and Position '" & txtContactNo.Text & "'")
MessageBox.Show("Successfully deleted", "Record",
MessageBoxButtons.OK, MessageBoxIcon.Information)
Getdata()
Reset()
Else
MessageBox.Show("No Record found", "Sorry", MessageBoxButtons.OK,
MessageBoxIcon.Information)
Reset()
End If
If con.State = ConnectionState.Open Then
con.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.[Error])
End Try
End Sub
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDelete.Click
Try
If MessageBox.Show("Do you really want to delete this record?",
"Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) =
Windows.Forms.DialogResult.Yes Then
DeleteRecord()
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)
End Try
End Sub