Hi guys.. I'm currently developing a system for a medical clinic. I want to know how (if ever) to implement delegates in my class. This is the sample of my class:
Code:Public Class clsSite Inherits clsDatabase Private m_SiteId As String = String.Empty Private m_SiteDescription As String = String.Empty Public Property SiteId() As String Get Return m_SiteId End Get Set(ByVal value As String) m_SiteId = value End Set End Property Public Property SiteDescription() As String Get Return m_SiteDescription End Get Set(ByVal value As String) m_SiteDescription = value End Set End Property Public Function InsertSite(ByVal giveSiteId As String, ByVal giveSiteDescription As String) As Boolean Dim boolReturnValue As Boolean = True Dim strSql As String = String.Empty m_SiteId = giveSiteId.Trim m_SiteDescription = giveSiteDescription.Trim.ToUpper strSql = "INSERT INTO `mf_site`" & _ "(`site_id`,`site_description`)" & _ "VALUES" & _ "(" & _ "'" & m_SiteId & "'," & _ "'" & m_SiteDescription & "'" & _ ")" If Not ExecuteQuery(strSql) Then boolReturnValue = False Return boolReturnValue End Function Public Function UpdateSite(ByVal giveSiteId As String, ByVal giveSiteDescription As String) As Boolean Dim boolReturnValue As Boolean = True Dim strSql As String = String.Empty m_SiteId = giveSiteId.Trim m_SiteDescription = giveSiteDescription.Trim.ToUpper strSql = "UPDATE `mf_site` SET" & Space$(1) & _ "`site_description`='" & m_SiteDescription & "' " & _ "WHERE `site_id`='" & m_SiteId & "'" If Not ExecuteQuery(strSql) Then boolReturnValue = False Return boolReturnValue End Function Public Function DeleteSite(ByVal giveSiteId As String) As Boolean Dim boolReturnValue As Boolean = True Dim strSql As String = String.Empty m_SiteId = giveSiteId.Trim strSql = "DELETE FROM mf_site" & " " & _ "WHERE site_id='" & m_SiteId & "'" If Not ExecuteQuery(strSql) Then boolReturnValue = False Return boolReturnValue End Function Public Function SearchSite(ByVal giveSiteId As String) As Boolean Dim boolReturnVale As Boolean = True Dim strSql As String = String.Empty Try strSql = "SELECT * FROM mf_site WHERE site_id = '" & giveSiteId & "' ORDER BY site_id" Call ExecuteQuery(strSql) DbReader = DbCommand.ExecuteReader While DbReader.Read m_SiteId = DbReader("site_id") m_SiteDescription = DbReader("site_description") End While Catch ex As Exception Call ShowErrorMessage() boolReturnVale = False Finally DbReader.Close() DbCommand.Dispose() End Try Return boolReturnVale End Function Public Function GenerateSiteId() As String Dim strReturnValue As String = String.Empty Dim strSql As String = String.Empty Try strSql = "SELECT MAX(site_id) AS max_site_id FROM mf_site" Call ExecuteQuery(strSql) Dim strSiteId As String = String.Empty Dim iCtr As Integer = 1 DbReader = DbCommand.ExecuteReader While DbReader.Read If Not IsDBNull(DbReader("max_site_id")) Then iCtr = CInt(Right$(DbReader("max_site_id"), 10)) + 1 End If strSiteId = "SID-" & Format$(iCtr, "0000000000") Exit While End While strReturnValue = strSiteId Catch ex As Exception Call ShowErrorMessage() strReturnValue = String.Empty Finally DbReader.Close() DbCommand.Dispose() End Try Return strReturnValue End Function Public Sub DisplaySiteList(ByVal objListView As ListView, Optional ByVal giveSearchString As String = "") Dim strSql As String = String.Empty Try ' Adding ListView Columns objListView.GridLines = True objListView.View = View.Details objListView.Columns.Clear() objListView.Columns.Add("#", 50, HorizontalAlignment.Center) objListView.Columns.Add("Id", 100, HorizontalAlignment.Left) objListView.Columns.Add("Description", 155, HorizontalAlignment.Left) If giveSearchString.Trim = String.Empty Then strSql = "SELECT * FROM mf_site ORDER BY site_id" Else strSql = "SELECT *" & " " strSql = strSql & "FROM mf_site" & " " strSql = strSql & "WHERE 1 = 1" & " " strSql = strSql & "AND (site_description LIKE '%" & giveSearchString & "%'" & " " strSql = strSql & ") ORDER BY site_id" End If Call ExecuteQuery(strSql) Dim strSite(objListView.Columns.Count) As String Dim itmSite As ListViewItem Dim iCtr As Integer = 1 objListView.Items.Clear() DbReader = DbCommand.ExecuteReader While DbReader.Read strSite(0) = iCtr strSite(1) = DbReader("site_id") strSite(2) = DbReader("site_description") itmSite = New ListViewItem(strSite) objListView.Items.Add(itmSite) iCtr = iCtr + 1 End While ' autosize listview data by width For Each col As ColumnHeader In objListView.Columns col.Width = -2 Next col Catch ex As Exception Call ShowErrorMessage() Finally DbReader.Close() DbCommand.Dispose() End Try End Sub Public Sub SiteComboList(ByVal objComboBox As ComboBox) Dim strSql As String = String.Empty Try strSql = "SELECT `site_description` FROM mf_site ORDER BY site_id" Call ExecuteQuery(strSql) objComboBox.Items.Clear() DbReader = DbCommand.ExecuteReader While DbReader.Read objComboBox.Items.Add(DbReader("site_description")) End While Catch ex As Exception Call ShowErrorMessage() Finally DbReader.Close() DbCommand.Dispose() End Try End Sub Public Function GetSiteIdByDescription(ByVal giveSiteDescription As String) As String Dim strReturnValue As String = String.Empty Dim strSql As String = String.Empty Try strSql = "SELECT `site_id` FROM `mf_site` WHERE `site_description`='" & giveSiteDescription & "'" Call ExecuteQuery(strSql) DbReader = DbCommand.ExecuteReader While DbReader.Read strReturnValue = DbReader("site_id") Exit While End While Catch ex As Exception Call ShowErrorMessage() strReturnValue = String.Empty Finally DbReader.Close() DbCommand.Dispose() End Try Return strReturnValue End Function End Class


LinkBack URL
About LinkBacks

Reply With Quote
