Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient

Public Class clsCRMProspects
    'Variable Declaration

    Private _crmCustomerID As String
    Private _crmDate As Date
    Private _crmCompanyName As String
    Private _crmType As Integer
    Private _crmContactPerson As String
    Private _crmPhoneNo As String
    Private _crmMobileNo As String
    Private _crmCity As String
    Private _crmEmail As String
    Private _crmCompanyID As String
    Private _crmCategory As String
    Private _mode As String
    Private _formName As String
    Private _adminID As String
    Private _companyCustomerMode As Integer
    Private _companytype As Integer
    Private _leadDate As DateTime
    Private _cityId As Integer
    Private _remarks As String
    Private _requirements As String
    Private _companyAddress As String
    Private _crmStatus As Integer
    Private _fromdate As DateTime
    Private _todate As DateTime
    Private crmProspectID As String
    Private crmDiscussionID As String
    Private _scityId As String
    Private _status As String
    Private _prospectTargetdate As DateTime
    Private _prospectCompanyId As String
    Private _prospectEmpId As String
    Private _userID As String
    Private crmcustomerProspectID As String
    Private _prospectInstruction As String
    Private _prospectUserId As String
    Private _prospectAssigndate As DateTime
    Private _prospectIsdeleted As String
    Private _productID As String
    Private _quotationId As String
    Private crmInquiryID As String
    Private _pagename As String
    Private _moduleID As Integer
    Private _purchaseReqKid As String
    Private _quotationCode As String
    Private _prospectSubEmpId As String
    Private _purchaseTargetDate As DateTime
    'Sort
    Private _sortExpression As String
    Private _sortDirection As String
    Private _crmSearchStatus As String
    'property
    Public Property CustomerID() As String
        Get
            Return _crmCustomerID
        End Get
        Set(ByVal value As String)
            _crmCustomerID = value
        End Set
    End Property
    Public Property InquiryID() As String
        Get
            Return crmInquiryID
        End Get
        Set(ByVal value As String)
            crmInquiryID = value
        End Set
    End Property
    Public Property CRM_ProspectID() As String
        Get
            Return crmProspectID
        End Get
        Set(ByVal value As String)
            crmProspectID = value
        End Set
    End Property
    Public Property CRM_CustomerProspectID() As String
        Get
            Return crmcustomerProspectID
        End Get
        Set(ByVal value As String)
            crmcustomerProspectID = value
        End Set
    End Property
    Public Property CRM_DiscussionID() As String
        Get
            Return crmDiscussionID
        End Get
        Set(ByVal value As String)
            crmDiscussionID = value
        End Set
    End Property
    Public Property CrmDatetime() As DateTime
        Get
            Return _crmDate
        End Get
        Set(ByVal value As Date)
            _crmDate = value
        End Set
    End Property
    Public Property CompanyName() As String
        Get
            Return _crmCompanyName
        End Get
        Set(ByVal value As String)
            _crmCompanyName = value
        End Set
    End Property
    Public Property Type() As Integer
        Get
            Return _crmType
        End Get
        Set(ByVal value As Integer)
            _crmType = value
        End Set
    End Property
    Public Property ContactPerson() As String
        Get
            Return _crmContactPerson
        End Get
        Set(ByVal value As String)
            _crmContactPerson = value
        End Set
    End Property
    Public Property PhoneNo() As String
        Get
            Return _crmPhoneNo
        End Get
        Set(ByVal value As String)
            _crmPhoneNo = value
        End Set
    End Property
    Public Property MobileNo() As String
        Get
            Return _crmMobileNo
        End Get
        Set(ByVal value As String)
            _crmMobileNo = value
        End Set
    End Property
    Public Property City() As String
        Get
            Return _crmCity
        End Get
        Set(ByVal value As String)
            _crmCity = value
        End Set
    End Property
    Public Property Email() As String
        Get
            Return _crmEmail
        End Get
        Set(ByVal value As String)
            _crmEmail = value
        End Set
    End Property
    Public Property CompanyID() As String
        Get
            Return _crmCompanyID
        End Get
        Set(ByVal value As String)
            _crmCompanyID = value
        End Set
    End Property
    Public Property ProductID() As String
        Get
            Return _productID
        End Get
        Set(ByVal value As String)
            _productID = value
        End Set
    End Property
    Public Property QuotationID() As String
        Get
            Return _quotationId
        End Get
        Set(ByVal value As String)
            _quotationId = value
        End Set
    End Property
    Public Property Category() As String
        Get
            Return _crmCategory
        End Get
        Set(ByVal value As String)
            _crmCategory = value
        End Set
    End Property
    Public Property LeadDate() As DateTime
        Get
            Return _leadDate
        End Get
        Set(ByVal value As DateTime)
            _leadDate = value
        End Set
    End Property
    Public Property CompanyType() As Integer
        Get
            Return _companytype
        End Get
        Set(ByVal value As Integer)
            _companytype = value
        End Set
    End Property
    Public Property CompanyCustomerMode() As Integer
        Get
            Return _companyCustomerMode
        End Get
        Set(ByVal value As Integer)
            _companyCustomerMode = value
        End Set
    End Property
    Public Property AdminId() As String
        Get
            Return _adminID
        End Get
        Set(ByVal value As String)
            _adminID = value
        End Set
    End Property
    Public Property FormName() As String
        Get
            Return _formName
        End Get
        Set(ByVal value As String)
            _formName = value
        End Set
    End Property
    Public Property Mode() As String
        Get
            Return _mode
        End Get
        Set(ByVal value As String)
            _mode = value
        End Set
    End Property
    Public Property CompanyAddress() As String
        Get
            Return _companyAddress
        End Get
        Set(ByVal value As String)
            _companyAddress = value
        End Set
    End Property
    Public Property CompanyRequirements() As String
        Get
            Return _requirements
        End Get
        Set(ByVal value As String)
            _requirements = value
        End Set
    End Property
    Public Property CRMStatus() As Integer
        Get
            Return _crmStatus
        End Get
        Set(ByVal value As Integer)
            _crmStatus = value
        End Set
    End Property
    Public Property CRMSearchStatus() As String
        Get
            Return _crmSearchStatus
        End Get
        Set(ByVal value As String)
            _crmSearchStatus = value
        End Set
    End Property

    Public Property Status() As String
        Get
            Return _status
        End Get
        Set(ByVal value As String)
            _status = value
        End Set
    End Property
    Public Property CompanyRemarks() As String
        Get
            Return _remarks
        End Get
        Set(ByVal value As String)
            _remarks = value
        End Set
    End Property
    Public Property PurchaseReqQuotationCode() As String
        Get
            Return _quotationCode
        End Get
        Set(ByVal value As String)
            _quotationCode = value
        End Set
    End Property
    Public Property CityId() As Integer
        Get
            Return _cityId
        End Get
        Set(ByVal value As Integer)
            _cityId = value
        End Set
    End Property
    Public Property FromDate() As DateTime
        Get
            Return _fromDate
        End Get
        Set(ByVal value As DateTime)
            _fromDate = value
        End Set
    End Property
    Public Property ToDate() As DateTime
        Get
            Return _toDate
        End Get
        Set(ByVal value As DateTime)
            _toDate = value
        End Set
    End Property
    Public Property CRMAssignProspectTargetDate() As DateTime
        Get
            Return _prospectTargetdate
        End Get
        Set(ByVal value As DateTime)
            _prospectTargetdate = value
        End Set
    End Property
    Public Property CRMAssignProspectAssignDate() As DateTime
        Get
            Return _prospectAssigndate
        End Get
        Set(ByVal value As DateTime)
            _prospectAssigndate = value
        End Set
    End Property
    Public Property CRMAssignProspect_CompanyId() As String
        Get
            Return _prospectCompanyId
        End Get
        Set(ByVal value As String)
            _prospectCompanyId = value
        End Set
    End Property
    Public Property CRMAssignProspect_EmpId() As String
        Get
            Return _prospectEmpId
        End Get
        Set(ByVal value As String)
            _prospectEmpId = value
        End Set
    End Property
    Public Property CRMAssignProspect_SubEmpId() As String
        Get
            Return _prospectSubEmpId
        End Get
        Set(ByVal value As String)
            _prospectSubEmpId = value
        End Set
    End Property
    Public Property CRMAssignProspect_UserId() As String
        Get
            Return _prospectUserId
        End Get
        Set(ByVal value As String)
            _prospectUserId = value
        End Set
    End Property
    Public Property CRMAssignProspect_Instruction() As String
        Get
            Return _prospectInstruction
        End Get
        Set(ByVal value As String)
            _prospectInstruction = value
        End Set
    End Property
    Public Property CRMAssignProspect_IsDeleted() As String
        Get
            Return _prospectIsdeleted
        End Get
        Set(ByVal value As String)
            _prospectIsdeleted = value
        End Set
    End Property
    Public Property SearchCityId() As String
        Get
            Return _scityId
        End Get
        Set(ByVal value As String)
            _scityId = value
        End Set
    End Property
    Public Property UserID() As String
        Get
            Return _userID
        End Get
        Set(ByVal value As String)
            _userID = value
        End Set
    End Property
    Public Property SortExpression() As String
        Get
            Return _sortExpression
        End Get
        Set(ByVal value As String)
            _sortExpression = value
        End Set
    End Property
    Public Property SortDirection() As String
        Get
            Return _sortDirection
        End Get
        Set(ByVal value As String)
            _sortDirection = value
        End Set
    End Property
    Public Property PageName() As String
        Get
            Return _pagename
        End Get
        Set(ByVal value As String)
            _pagename = value
        End Set
    End Property
    Public Property ModuleID() As Integer
        Get
            Return _moduleID
        End Get
        Set(ByVal value As Integer)
            _moduleID = value
        End Set
    End Property
    Public Property PurchaseRequisitionKid() As String
        Get
            Return _purchaseReqKid
        End Get
        Set(ByVal value As String)
            _purchaseReqKid = value
        End Set
    End Property
    Public Property PurchaseRequisitionTargetDate() As DateTime
        Get
            Return _purchaseTargetDate
        End Get
        Set(ByVal value As DateTime)
            _purchaseTargetDate = value
        End Set
    End Property

    'Method
  
    Public Shared Sub AddCRMCustomer(ByVal CRM As clsCRMProspects)
        Dim cn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings("ConnectionVoffice"))
        Dim objAdapter As System.Data.SqlClient.SqlDataAdapter

        cn.Open()

        Dim tran As System.Data.SqlClient.SqlTransaction
        tran = cn.BeginTransaction(IsolationLevel.Serializable)

        Try
            objAdapter = New SqlDataAdapter("Insert_CRMCustomer", cn)
            objAdapter.SelectCommand.Transaction = tran
            objAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CustomerID", SqlDbType.VarChar))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@LeadDate", SqlDbType.DateTime))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CompanyName", SqlDbType.NVarChar, 100))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CompanyType", SqlDbType.Int))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@ContactName", SqlDbType.NVarChar, 100))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@PhoneNo", SqlDbType.NVarChar, 20))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@MobileNo", SqlDbType.NVarChar, 20))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CityID", SqlDbType.Int))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@EmailAddress", SqlDbType.NVarChar, 100))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CompanyAddress", SqlDbType.NVarChar, 500))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Requirements", SqlDbType.Text))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Remarks", SqlDbType.Text))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CategoryName", SqlDbType.NVarChar, 500))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CustomerMode", SqlDbType.Int))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Status", SqlDbType.Int))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@AdminID", SqlDbType.VarChar))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@CompanyID", SqlDbType.VarChar))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@FormName", SqlDbType.VarChar, 50))
            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Mode", SqlDbType.VarChar, 10))

            objAdapter.SelectCommand.Parameters("@CustomerID").Value = CRM.CustomerID
            objAdapter.SelectCommand.Parameters("@LeadDate").Value = CRM.LeadDate
            objAdapter.SelectCommand.Parameters("@CompanyName").Value = CRM.CompanyName
            objAdapter.SelectCommand.Parameters("@CompanyType").Value = CRM.CompanyType
            objAdapter.SelectCommand.Parameters("@ContactName").Value = CRM.ContactPerson
            objAdapter.SelectCommand.Parameters("@PhoneNo").Value = CRM.PhoneNo
            objAdapter.SelectCommand.Parameters("@MobileNo").Value = CRM.MobileNo
            objAdapter.SelectCommand.Parameters("@CityID").Value = CRM.CityId
            objAdapter.SelectCommand.Parameters("@EmailAddress").Value = CRM.Email
            objAdapter.SelectCommand.Parameters("@CompanyAddress").Value = CRM.CompanyAddress
            objAdapter.SelectCommand.Parameters("@Requirements").Value = CRM.CompanyRequirements
            objAdapter.SelectCommand.Parameters("@Remarks").Value = CRM.CompanyRemarks
            objAdapter.SelectCommand.Parameters("@CategoryName").Value = CRM.Category
            
            objAdapter.SelectCommand.Parameters("@CustomerMode").Value = CRM.CompanyCustomerMode
            objAdapter.SelectCommand.Parameters("@Status").Value = CRM.CRMStatus
            objAdapter.SelectCommand.Parameters("@AdminID").Value = CRM.AdminId
            objAdapter.SelectCommand.Parameters("@CompanyID").Value = CRM.CompanyID
            objAdapter.SelectCommand.Parameters("@FormName").Value = CRM.FormName
            objAdapter.SelectCommand.Parameters("@Mode").Value = CRM.Mode


            objAdapter.SelectCommand.ExecuteNonQuery()

            tran.Commit()
        Catch ex As Exception
            tran.Rollback()
            Throw ex

        Finally

            cn.Close()
            cn.Dispose()
        End Try
    End Sub
  
 
End Class
