Kodi:
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Public Class Bleresi
Implements INotifyPropertyChanged
#Region " Events "
Public Event PropertyChanged As PropertyChangedEventHandler Implements ComponentModel.INotifyPropertyChanged.PropertyChanged
#End Region
#Region " Declarations"
Private m_CustomerID As Integer
Private m_CustomerName As String
Private m_Company As String
Private m_AddressLine1 As String
Private m_City As String
Private m_Province As String
Private m_PostalCode As String
Private m_Country As String
Private m_Phone As String
Private m_Cell As String
Private m_Fax As String
Private m_Email As String
Private m_Active As Boolean
Private m_dbStatus As dbStatus
#End Region
#Region " Properties"
Public Property CustomerID() As Integer
Get
Return m_CustomerID
End Get
Set(ByVal value As Integer)
m_CustomerID = value
OnPropertyChanged("CustomerID")
End Set
End Property
Public Property CustomerName() As String
Get
Return m_CustomerName
End Get
Set(ByVal value As String)
m_CustomerName = value
OnPropertyChanged("CustomerName")
End Set
End Property
Public Property Company() As String
Get
Return m_Company
End Get
Set(ByVal value As String)
m_Company = value
OnPropertyChanged("Company")
End Set
End Property
Public Property AddressLine1() As String
Get
Return m_AddressLine1
End Get
Set(ByVal value As String)
m_AddressLine1 = value
OnPropertyChanged("AddressLine1")
End Set
End Property
Public Property City() As String
Get
Return m_City
End Get
Set(ByVal value As String)
m_City = value
OnPropertyChanged("City")
End Set
End Property
Public Property Province() As String
Get
Return m_Province
End Get
Set(ByVal value As String)
m_Province = value
OnPropertyChanged("Province")
End Set
End Property
Public Property PostalCode() As String
Get
Return m_PostalCode
End Get
Set(ByVal value As String)
m_PostalCode = value
OnPropertyChanged("PostalCode")
End Set
End Property
Public Property Country() As String
Get
Return m_Country
End Get
Set(ByVal value As String)
m_Country = value
OnPropertyChanged("Country")
End Set
End Property
Public Property Phone() As String
Get
Return m_Phone
End Get
Set(ByVal value As String)
m_Phone = value
OnPropertyChanged("Phone")
End Set
End Property
Public Property Cell() As String
Get
Return m_Cell
End Get
Set(ByVal value As String)
m_Cell = value
OnPropertyChanged("Cell")
End Set
End Property
Public Property Fax() As String
Get
Return m_Fax
End Get
Set(ByVal value As String)
m_Fax = value
OnPropertyChanged("Fax")
End Set
End Property
Public Property Email() As String
Get
Return m_Email
End Get
Set(ByVal value As String)
m_Email = value
OnPropertyChanged("Email")
End Set
End Property
Public Property Active() As Boolean
Get
Return m_Active
End Get
Set(ByVal value As Boolean)
m_Active = value
OnPropertyChanged("Active")
End Set
End Property
Public Property MydbStatus() As dbStatus
Get
Return m_dbStatus
End Get
Set(ByVal value As dbStatus)
m_dbStatus = value
End Set
End Property
#End Region
#Region " Methods"
Protected Sub OnPropertyChanged(ByVal name As String)
If Not Me.MydbStatus = dbStatus.Insert Then
Me.MydbStatus = dbStatus.Update
End If
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
End Sub
Public Sub SaveMe()
Dim conSQL As New SqlCeConnection
Dim comSQL As New SqlCeCommand
conSQL.ConnectionString = My.Settings.dbDrenicaConnectionString
If Not (conSQL.State = ConnectionState.Open) Then
conSQL.Open()
End If
comSQL.Connection = conSQL
Select Case Me.MydbStatus
Case dbStatus.Insert
comSQL.CommandText = "INSERT INTO tblCustomers (CustomerName, CustomerCompany, CustomerAddressLine1, " _
& "CustomerCity, CustomerProvince, CustomerPostalCode, CustomerCountry, CustomerPhone, CustomerCell, " _
& "CustomerFax, CustomerEmail, CustomerStatus) VALUES ('" & Me.CustomerName & "', '" & Me.Company & "', '" _
& Me.AddressLine1 & "', '" & Me.City & "', '" & Me.Province & "', '" & Me.PostalCode & "', '" _
& Me.Country & "', '" & Me.Phone & "', '" & Me.Cell & "', '" & Me.Fax & "', '" & Me.Email & "', '" & Me.Active & "') "
comSQL.ExecuteScalar()
Case dbStatus.Update
comSQL.CommandText = "UPDATE tblCustomers SET " _
& "CustomerName = '" & Me.CustomerName & "', " _
& "CustomerCompany = '" & Me.Company & "', " _
& "CustomerAddressLine1= '" & Me.AddressLine1 & "', " _
& "CustomerCity = '" & Me.City & "', " _
& "CustomerProvince = '" & Me.Province & "', " _
& "CustomerPostalCode = '" & Me.PostalCode & "', " _
& "CustomerCountry = '" & Me.Country & "', " _
& "CustomerPhone = '" & Me.Phone & "', " _
& "CustomerCell = '" & Me.Cell & "', " _
& "CustomerFax = '" & Me.Fax & "', " _
& "CustomerEmail = '" & Me.Email & "', " _
& "CustomerStatus= '" & Me.Active & "' WHERE CustomerID = " & Me.CustomerID
comSQL.ExecuteNonQuery()
End Select
If conSQL.State = ConnectionState.Open Then
conSQL.Close()
End If
conSQL = Nothing
comSQL = Nothing
MsgBox("Shėnimet e blerėsit: " & Me.CustomerName & " janė ruajtur me sukses", MsgBoxStyle.Information)
End Sub
#End Region
#Region " Constructors"
Public Sub New(ByVal inCustomerID As Integer, ByVal inCustomerName As String, ByVal inCompany As String, ByVal inAddress As String,
ByVal inCity As String, ByVal inProvince As String, ByVal inPostalCode As String, ByVal inCountry As String,
ByVal inPhone As String, ByVal inCell As String, ByVal inFax As String, ByVal inEmail As String, ByVal inActive As Boolean)
Me.CustomerID = inCustomerID
Me.CustomerName = inCustomerName
Me.Company = inCompany
Me.AddressLine1 = inAddress
Me.City = inCity
Me.Province = inProvince
Me.PostalCode = inPostalCode
Me.Country = inCountry
Me.Phone = inPhone
Me.Cell = inCell
Me.Fax = inFax
Me.Email = inEmail
Me.Active = inActive
Me.MydbStatus = dbStatus.Unchanged
End Sub
Public Sub New()
Me.MydbStatus = dbStatus.Insert
End Sub
#End Region
End Class
Nese keni pyetje ne lidhje me kodin e postuar ose skenaret aplikimit lirisht pyetni
Krijoni Kontakt