Hello,
Am having a problem with updating my underlying business object from my win form grid. I have a class and a collection that implements IBindingList. The class contains a line item collection which is bound to the grid(component one grid). When I enter a new record the object gets the values without any problem and the record is saved. However fetching the same record and editing it, the properties of my object are not updated. I am wondering what it is am doing wrong. below is the code for the classes and collections and form load code. I will really appreciate any help from anyone because at the moment am confused since I thought that by implementing the IBindingList interface the two way update, form to object and object to form, is taken care of.
Master class
Option Explicit On
Option Strict On
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Text
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class ServiceQuotationMaster
Inherits PCTLTransactionsHeaderBaseClass
Implements INotifyPropertyChanged
Implements IEditableObject
#Region "Declarations"
Private objDAL As New PCTLDataTier.DataLayer
Private strSQL As String
Private _GrandFreightCharges As Double
Private _GrandOtherCharges As Double
Private _CostingSheetNo As Integer
Private _InquiryNo As Integer
Private _PreviousQuotationNo As Integer
Private _FileExtension As String
Private _DestinationLoc As String
Private _SourceLoc As String
Private _QuotationType As String
Private WithEvents _ServiceQuotationLineItems As New BusinessTier.QuotationsServicesDetails
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Friend Event RemoveMe(ByVal objQuotation As BusinessTier.ServiceQuotationMaster)
#End Region
#Region "Properties"
Public Property CostingSheetNo() As Integer
Get
Return Me._CostingSheetNo
End Get
Set(ByVal value As Integer)
If Me._CostingSheetNo <> value Then
Me._CostingSheetNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("CostingSheetNo"))
End If
End Set
End Property
Public Property GrandFreightCharges() As Double
Get
Return Me._GrandFreightCharges
End Get
Set(ByVal value As Double)
If Me._GrandFreightCharges <> value Then
Me._GrandFreightCharges = CDbl(FormatNumber(IIf(IsDBNull(value), 0, value), 2))
Me.OnPropertyChanged(New PropertyChangedEventArgs("GrandFreightCharges"))
End If
End Set
End Property
Public Property GrandOtherCharges() As Double
Get
Return Me._GrandOtherCharges
End Get
Set(ByVal value As Double)
If Me._GrandOtherCharges <> value Then
Me._GrandOtherCharges = CDbl(FormatNumber(IIf(IsDBNull(value), 0, value), 2))
Me.OnPropertyChanged(New PropertyChangedEventArgs("GrandOtherCharges"))
End If
End Set
End Property
Public Property InquiryNo() As Integer
Get
Return Me._InquiryNo
End Get
Set(ByVal value As Integer)
If Me._InquiryNo <> value Then
Me._InquiryNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("InquiryNo"))
End If
End Set
End Property
Public Property PreviousQuotationNo() As Integer
Get
Return Me._PreviousQuotationNo
End Get
Set(ByVal value As Integer)
If Me._PreviousQuotationNo <> value Then
Me._PreviousQuotationNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("InquiryNo"))
End If
End Set
End Property
Public Property QuotationType() As String
Get
Return Me._QuotationType
End Get
Set(ByVal value As String)
If Me._QuotationType <> value Then
Me._QuotationType = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("QuotationType"))
End If
End Set
End Property
Public Property ServiceQuotationLineItems() As BusinessTier.QuotationsServicesDetails
Get
Return Me._ServiceQuotationLineItems
End Get
Set(ByVal value As BusinessTier.QuotationsServicesDetails)
Me._ServiceQuotationLineItems = DirectCast(IIf(IsDBNull(value), Nothing, value), BusinessTier.QuotationsServicesDetails)
Me.OnPropertyChanged(New PropertyChangedEventArgs("ServiceQuotationLineItems"))
End Set
End Property
Public Property FileExtension() As String
Get
Return Me._FileExtension
End Get
Set(ByVal value As String)
Me._FileExtension = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("FileExtension"))
End Set
End Property
#End Region
#Region "Methods"
Public Sub GetPathAndExtension(ByVal strSourceLoc As String, ByVal strFileExtension As String)
Try
If strSourceLoc <> "" Then
_SourceLoc = strSourceLoc
FileExtension = strFileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Protected Overridable Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
Try
RaiseEvent PropertyChanged(Me, e)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Sub Clear()
Try
CompanyCode = "" : VoucherShortCode = "" : TransactionCode = 0 : TransactionDate = Nothing : CostingSheetNo = 0
InquiryNo = 0 : IsRevised = 0 : QuotationType = "" : PreviousQuotationNo = 0 : CurrencyCode = "" : IsApproved = 0
IsCancel = 0 : ApprovedBy = "" : ApprovedDateTime = Nothing : CreatedBy = "" : CreatedDateTime = Nothing
RejectedBy = "" : RejectedDateTime = Nothing : Comments = "" : TDate = Nothing : GrandDiscountTotal = 0
GrandVATTotal = 0 : GrandSubTotal = 0 : GrandFreightCharges = 0 : GrandOtherCharges = 0 : GrandNetTotal = 0
BaseCurrencyExchangeRate = 0 : ReferenceNumber = "" : FileExtension = ""
ServiceQuotationLineItems = Nothing
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Overrides Function Delete() As Integer
Try
strSQL = "DELETE tblQuotationMaster WHERE CompanyCode='" & CompanyCode & "' AND QuotationNo=" & TransactionCode & ""
Return objDAL.ExecQuery(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function Edit() As Integer
Try
Dim cmd As New OracleCommand
Dim constr As String = "User Id=ADMIN;Password=accesslight;Data Source=NTL"
Dim con As OracleConnection = New OracleConnection(constr)
con.Open()
' provide read access to the file
Dim Fs As FileStream = New FileStream(_SourceLoc, FileMode.Open, FileAccess.Read)
' Create a byte array of file stream length
Dim ImageData As Byte()
ReDim ImageData(CInt(Fs.Length))
'Read block of bytes from stream into the byte array
Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
'Close the File Stream
Fs.Close()
strSQL = "BEGIN " & _
"UPDATE TBLQUOTATIONMASTER SET VOUCHERSHRTCODE ='" & VoucherShortCode & "'," & _
"QUOTATIONDT='" & TransactionDate & "',COSTINGSHEETNO=" & TransactionCode & "," & _
"INQUIRYNO=" & InquiryNo & ",ISREVISED=" & IsRevised & "," & _
"QUOTATIONTYPE='" & QuotationType & "',PREVIOUSQUOTATIONNO=" & PreviousQuotationNo & "," & _
"CURRCODE='" & CurrencyCode & "',ISAPPROVED=" & IsApproved & ",ISCANCEL=" & IsCancel & "," & _
"APPROVEDBY='" & ApprovedBy & "',APPROVEDDTTIME='" & ApprovedDateTime & "',CREATEBY='" & CreatedBy & "'," & _
"CREATEDDTTIME='" & CreatedDateTime & "',REJECTEDBY='" & RejectedBy & "'," & _
"REJECTEDDTTIME='" & RejectedDateTime & "',COMMENTS='" & Comments & "',TDATE='" & TDate & "'," & _
"GRANDTOTALDISCOUNT=" & GrandDiscountTotal & ",GRANDTOTALVAT=" & GrandVATTotal & "," & _
"GRANDSUBTOTAL=" & GrandSubTotal & ",GRANDFREIGHTCHARGES=" & GrandFreightCharges & "," & _
"GRANDOTHERCHARGES=" & GrandOtherCharges & ",GRANDNETTOTAL=" & GrandNetTotal & "," & _
"BASECURREXCHANGERATE =" & BaseCurrencyExchangeRate & ",TERMSANDCONDITION =:1," & _
"REFNUMBER='" & ReferenceNumber & "',FILEEXTENSION='" & FileExtension & "' " & _
"WHERE COMPANYCODE='" & CompanyCode & "' AND QUOTATIONNO=" & TransactionCode & ";" & _
"End ;"
cmd.CommandText = strSQL
cmd.Connection = con
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
cmd.CommandType = CommandType.Text
' Bind the parameter as OracleDbType.Blob
' to command for inserting image
Dim param As OracleParameter = cmd.Parameters.Add("blobtodb", OracleDbType.Blob)
param.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param.Value = ImageData
Return cmd.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function GetRecords(ByVal strSQL As String) As System.Data.DataSet
Try
Return objDAL.ExecuteQry(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Overrides Function GetSequenceNumber() As Integer
Try
strSQL = "SELECT SEQQUOTATIONNO.NextVal FROM DUAL"
Return objDAL.QueryNextSequence(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Overrides Function Save() As Integer
Try
Dim cmd As New OracleCommand
Dim constr As String = "User Id=ADMIN;Password=accesslight;Data Source=NTL"
Dim con As OracleConnection = New OracleConnection(constr)
con.Open()
' provide read access to the file
Dim Fs As FileStream = New FileStream(_SourceLoc, FileMode.Open, FileAccess.Read)
' Create a byte array of file stream length
Dim ImageData As Byte()
ReDim ImageData(CInt(Fs.Length))
'Read block of bytes from stream into the byte array
Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
'Close the File Stream
Fs.Close()
strSQL = "BEGIN " & _
"INSERT INTO TBLQUOTATIONMASTER (COMPANYCODE,VOUCHERSHRTCODE,QUOTATIONNO,QUOTATIONDT," & _
"COSTINGSHEETNO,INQUIRYNO,ISREVISED,QUOTATIONTYPE,PREVIOUSQUOTATIONNO," & _
"CURRCODE,ISAPPROVED,ISCANCEL,APPROVEDBY,APPROVEDDTTIME,CREATEBY," & _
"CREATEDDTTIME,REJECTEDBY,REJECTEDDTTIME,COMMENTS,TDATE,GRANDTOTALDISCOUNT," & _
"GRANDTOTALVAT,GRANDSUBTOTAL,GRANDFREIGHTCHARGES,GRANDOTHERCHARGES,GRANDNETTOTAL," & _
"BASECURREXCHANGERATE,TERMSANDCONDITION,REFNUMBER,FILEEXTENSION) " & _
"VALUES ('" & CompanyCode & "','" & VoucherShortCode & "'," & TransactionCode & "," & _
"'" & TransactionDate & "'," & CostingSheetNo & "," & InquiryNo & "," & _
"" & IsRevised & ",'" & QuotationType & "'," & PreviousQuotationNo & "," & _
"'" & CurrencyCode & "'," & IsApproved & "," & IsCancel & "," & _
"'" & ApprovedBy & "','" & ApprovedDateTime & "','" & CreatedBy & "'," & _
"'" & CreatedDateTime & "','" & RejectedBy & "','" & RejectedDateTime & "'," & _
"'" & Comments & "','" & TDate & "'," & GrandDiscountTotal & "," & _
"" & GrandVATTotal & "," & GrandSubTotal & "," & GrandFreightCharges & "," & _
"" & GrandOtherCharges & "," & GrandNetTotal & "," & BaseCurrencyExchangeRate & "," & _
" :1 ,'" & ReferenceNumber & "','" & FileExtension & "');" & _
"END ;"
cmd.CommandText = strSQL
cmd.Connection = con
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
cmd.CommandType = CommandType.Text
' Bind the parameter as OracleDbType.Blob
' to command for inserting image
Dim param As OracleParameter = cmd.Parameters.Add("blobtodb", OracleDbType.Blob)
param.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param.Value = ImageData
Return cmd.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
#End Region
#Region "IEditableObject"
Private _Editing As Boolean
Private _IsAddNew As Boolean = True
Private _oldCompanyCode As String
Private _oldVoucherShrtCode As String
Private _oldTransactionCode As Integer
Private _oldTransactionDate As Date
Private _oldCostingsheetno As Integer
Private _oldInquiryNo As Integer
Private _oldIsRevised As Integer
Private _oldQuotationType As String
Private _oldPreviousQuotationNo As Integer
Private _oldCurrCode As String
Private _oldIsApproved As Integer
Private _oldIsCacel As Integer
Private _oldApoprovedBy As String
Private _oldApprovedDTTime As Date
Private _oldCreateBy As String
Private _oldCreatedDTTime As Date
Private _oldRejectedBy As String
Private _oldRejectedDTTime As Date
Private _oldComments As String
Private _oldTDate As Date
Private _oldGrandDiscAmt As Double
Private _oldGrandVATAmt As Double
Private _oldGrandSubTotal As Double
Private _oldGrandFreightCharges As Double
Private _oldGrandOtherCharges As Double
Private _oldGrandNetTotal As Double
Private _oldBaseCurrExchRate As Double
Private _oldFileExtension As String
Private _oldRefNumber As String
Public Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit
Try
If Not _Editing Then
_Editing = True
_oldApoprovedBy = ApprovedBy : _oldApprovedDTTime = ApprovedDateTime : _oldBaseCurrExchRate = BaseCurrencyExchangeRate
_oldComments = Comments : _oldCompanyCode = CompanyCode : _oldCostingsheetno = CostingSheetNo
_oldCreateBy = CreatedBy : _oldCreatedDTTime = CreatedDateTime : _oldCurrCode = CurrencyCode
_oldGrandDiscAmt = GrandDiscountTotal : _oldGrandFreightCharges = GrandFreightCharges
_oldGrandFreightCharges = GrandFreightCharges : _oldGrandNetTotal = GrandNetTotal
_oldGrandOtherCharges = GrandOtherCharges : _oldGrandSubTotal = GrandSubTotal
_oldGrandVATAmt = GrandVATTotal : _oldInquiryNo = InquiryNo : _oldIsApproved = IsApproved
_oldIsCacel = IsCancel : _oldIsRevised = IsRevised : _oldPreviousQuotationNo = PreviousQuotationNo
_oldQuotationType = QuotationType : _oldRefNumber = ReferenceNumber : _oldRejectedBy = RejectedBy
_oldRejectedDTTime = RejectedDateTime : _oldTDate = TDate
_oldTransactionCode = TransactionCode : _oldTransactionDate = TransactionDate
_oldFileExtension = FileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit
Try
If _Editing = True Then
_Editing = False
ApprovedBy = _oldApoprovedBy : ApprovedDateTime = _oldApprovedDTTime : BaseCurrencyExchangeRate = _oldBaseCurrExchRate
Comments = _oldComments : CompanyCode = _oldCompanyCode : CostingSheetNo = _oldCostingsheetno
CreatedBy = _oldCreateBy : CreatedDateTime = _oldCreatedDTTime : CurrencyCode = _oldCurrCode
GrandDiscountTotal = _oldGrandDiscAmt : GrandFreightCharges = _oldGrandFreightCharges
GrandFreightCharges = _oldGrandFreightCharges : GrandNetTotal = _oldGrandNetTotal
GrandOtherCharges = _oldGrandOtherCharges : GrandSubTotal = _oldGrandSubTotal
GrandVATTotal = _oldGrandVATAmt : InquiryNo = _oldInquiryNo : IsApproved = _oldIsApproved
IsCancel = _oldIsCacel : IsRevised = _oldIsRevised : PreviousQuotationNo = _oldPreviousQuotationNo
QuotationType = _oldQuotationType : ReferenceNumber = _oldRefNumber : RejectedBy = _oldRejectedBy
RejectedDateTime = _oldRejectedDTTime : TDate = _oldTDate
TransactionCode = _oldTransactionCode : TransactionDate = _oldTransactionDate
FileExtension = _oldFileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub EndEdit() Implements System.ComponentModel.IEditableObject.EndEdit
Try
_Editing = False : _IsAddNew = False
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
#End Region
End Class
Option Explicit On
Option Strict On
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Text
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class ServiceQuotationMaster
Inherits PCTLTransactionsHeaderBaseClass
Implements INotifyPropertyChanged
Implements IEditableObject
#Region "Declarations"
Private objDAL As New PCTLDataTier.DataLayer
Private strSQL As String
Private _GrandFreightCharges As Double
Private _GrandOtherCharges As Double
Private _CostingSheetNo As Integer
Private _InquiryNo As Integer
Private _PreviousQuotationNo As Integer
Private _FileExtension As String
Private _DestinationLoc As String
Private _SourceLoc As String
Private _QuotationType As String
Private WithEvents _ServiceQuotationLineItems As New BusinessTier.QuotationsServicesDetails
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Friend Event RemoveMe(ByVal objQuotation As BusinessTier.ServiceQuotationMaster)
#End Region
#Region "Properties"
Public Property CostingSheetNo() As Integer
Get
Return Me._CostingSheetNo
End Get
Set(ByVal value As Integer)
If Me._CostingSheetNo <> value Then
Me._CostingSheetNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("CostingSheetNo"))
End If
End Set
End Property
Public Property GrandFreightCharges() As Double
Get
Return Me._GrandFreightCharges
End Get
Set(ByVal value As Double)
If Me._GrandFreightCharges <> value Then
Me._GrandFreightCharges = CDbl(FormatNumber(IIf(IsDBNull(value), 0, value), 2))
Me.OnPropertyChanged(New PropertyChangedEventArgs("GrandFreightCharges"))
End If
End Set
End Property
Public Property GrandOtherCharges() As Double
Get
Return Me._GrandOtherCharges
End Get
Set(ByVal value As Double)
If Me._GrandOtherCharges <> value Then
Me._GrandOtherCharges = CDbl(FormatNumber(IIf(IsDBNull(value), 0, value), 2))
Me.OnPropertyChanged(New PropertyChangedEventArgs("GrandOtherCharges"))
End If
End Set
End Property
Public Property InquiryNo() As Integer
Get
Return Me._InquiryNo
End Get
Set(ByVal value As Integer)
If Me._InquiryNo <> value Then
Me._InquiryNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("InquiryNo"))
End If
End Set
End Property
Public Property PreviousQuotationNo() As Integer
Get
Return Me._PreviousQuotationNo
End Get
Set(ByVal value As Integer)
If Me._PreviousQuotationNo <> value Then
Me._PreviousQuotationNo = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("InquiryNo"))
End If
End Set
End Property
Public Property QuotationType() As String
Get
Return Me._QuotationType
End Get
Set(ByVal value As String)
If Me._QuotationType <> value Then
Me._QuotationType = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("QuotationType"))
End If
End Set
End Property
Public Property ServiceQuotationLineItems() As BusinessTier.QuotationsServicesDetails
Get
Return Me._ServiceQuotationLineItems
End Get
Set(ByVal value As BusinessTier.QuotationsServicesDetails)
Me._ServiceQuotationLineItems = DirectCast(IIf(IsDBNull(value), Nothing, value), BusinessTier.QuotationsServicesDetails)
Me.OnPropertyChanged(New PropertyChangedEventArgs("ServiceQuotationLineItems"))
End Set
End Property
Public Property FileExtension() As String
Get
Return Me._FileExtension
End Get
Set(ByVal value As String)
Me._FileExtension = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("FileExtension"))
End Set
End Property
#End Region
#Region "Methods"
Public Sub GetPathAndExtension(ByVal strSourceLoc As String, ByVal strFileExtension As String)
Try
If strSourceLoc <> "" Then
_SourceLoc = strSourceLoc
FileExtension = strFileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Protected Overridable Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
Try
RaiseEvent PropertyChanged(Me, e)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Sub Clear()
Try
CompanyCode = "" : VoucherShortCode = "" : TransactionCode = 0 : TransactionDate = Nothing : CostingSheetNo = 0
InquiryNo = 0 : IsRevised = 0 : QuotationType = "" : PreviousQuotationNo = 0 : CurrencyCode = "" : IsApproved = 0
IsCancel = 0 : ApprovedBy = "" : ApprovedDateTime = Nothing : CreatedBy = "" : CreatedDateTime = Nothing
RejectedBy = "" : RejectedDateTime = Nothing : Comments = "" : TDate = Nothing : GrandDiscountTotal = 0
GrandVATTotal = 0 : GrandSubTotal = 0 : GrandFreightCharges = 0 : GrandOtherCharges = 0 : GrandNetTotal = 0
BaseCurrencyExchangeRate = 0 : ReferenceNumber = "" : FileExtension = ""
ServiceQuotationLineItems = Nothing
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Overrides Function Delete() As Integer
Try
strSQL = "DELETE tblQuotationMaster WHERE CompanyCode='" & CompanyCode & "' AND QuotationNo=" & TransactionCode & ""
Return objDAL.ExecQuery(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function Edit() As Integer
Try
Dim cmd As New OracleCommand
Dim constr As String = "User Id=ADMIN;Password=accesslight;Data Source=NTL"
Dim con As OracleConnection = New OracleConnection(constr)
con.Open()
' provide read access to the file
Dim Fs As FileStream = New FileStream(_SourceLoc, FileMode.Open, FileAccess.Read)
' Create a byte array of file stream length
Dim ImageData As Byte()
ReDim ImageData(CInt(Fs.Length))
'Read block of bytes from stream into the byte array
Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
'Close the File Stream
Fs.Close()
strSQL = "BEGIN " & _
"UPDATE TBLQUOTATIONMASTER SET VOUCHERSHRTCODE ='" & VoucherShortCode & "'," & _
"QUOTATIONDT='" & TransactionDate & "',COSTINGSHEETNO=" & TransactionCode & "," & _
"INQUIRYNO=" & InquiryNo & ",ISREVISED=" & IsRevised & "," & _
"QUOTATIONTYPE='" & QuotationType & "',PREVIOUSQUOTATIONNO=" & PreviousQuotationNo & "," & _
"CURRCODE='" & CurrencyCode & "',ISAPPROVED=" & IsApproved & ",ISCANCEL=" & IsCancel & "," & _
"APPROVEDBY='" & ApprovedBy & "',APPROVEDDTTIME='" & ApprovedDateTime & "',CREATEBY='" & CreatedBy & "'," & _
"CREATEDDTTIME='" & CreatedDateTime & "',REJECTEDBY='" & RejectedBy & "'," & _
"REJECTEDDTTIME='" & RejectedDateTime & "',COMMENTS='" & Comments & "',TDATE='" & TDate & "'," & _
"GRANDTOTALDISCOUNT=" & GrandDiscountTotal & ",GRANDTOTALVAT=" & GrandVATTotal & "," & _
"GRANDSUBTOTAL=" & GrandSubTotal & ",GRANDFREIGHTCHARGES=" & GrandFreightCharges & "," & _
"GRANDOTHERCHARGES=" & GrandOtherCharges & ",GRANDNETTOTAL=" & GrandNetTotal & "," & _
"BASECURREXCHANGERATE =" & BaseCurrencyExchangeRate & ",TERMSANDCONDITION =:1," & _
"REFNUMBER='" & ReferenceNumber & "',FILEEXTENSION='" & FileExtension & "' " & _
"WHERE COMPANYCODE='" & CompanyCode & "' AND QUOTATIONNO=" & TransactionCode & ";" & _
"End ;"
cmd.CommandText = strSQL
cmd.Connection = con
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
cmd.CommandType = CommandType.Text
' Bind the parameter as OracleDbType.Blob
' to command for inserting image
Dim param As OracleParameter = cmd.Parameters.Add("blobtodb", OracleDbType.Blob)
param.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param.Value = ImageData
Return cmd.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function GetRecords(ByVal strSQL As String) As System.Data.DataSet
Try
Return objDAL.ExecuteQry(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Overrides Function GetSequenceNumber() As Integer
Try
strSQL = "SELECT SEQQUOTATIONNO.NextVal FROM DUAL"
Return objDAL.QueryNextSequence(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Overrides Function Save() As Integer
Try
Dim cmd As New OracleCommand
Dim constr As String = "User Id=ADMIN;Password=accesslight;Data Source=NTL"
Dim con As OracleConnection = New OracleConnection(constr)
con.Open()
' provide read access to the file
Dim Fs As FileStream = New FileStream(_SourceLoc, FileMode.Open, FileAccess.Read)
' Create a byte array of file stream length
Dim ImageData As Byte()
ReDim ImageData(CInt(Fs.Length))
'Read block of bytes from stream into the byte array
Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
'Close the File Stream
Fs.Close()
strSQL = "BEGIN " & _
"INSERT INTO TBLQUOTATIONMASTER (COMPANYCODE,VOUCHERSHRTCODE,QUOTATIONNO,QUOTATIONDT," & _
"COSTINGSHEETNO,INQUIRYNO,ISREVISED,QUOTATIONTYPE,PREVIOUSQUOTATIONNO," & _
"CURRCODE,ISAPPROVED,ISCANCEL,APPROVEDBY,APPROVEDDTTIME,CREATEBY," & _
"CREATEDDTTIME,REJECTEDBY,REJECTEDDTTIME,COMMENTS,TDATE,GRANDTOTALDISCOUNT," & _
"GRANDTOTALVAT,GRANDSUBTOTAL,GRANDFREIGHTCHARGES,GRANDOTHERCHARGES,GRANDNETTOTAL," & _
"BASECURREXCHANGERATE,TERMSANDCONDITION,REFNUMBER,FILEEXTENSION) " & _
"VALUES ('" & CompanyCode & "','" & VoucherShortCode & "'," & TransactionCode & "," & _
"'" & TransactionDate & "'," & CostingSheetNo & "," & InquiryNo & "," & _
"" & IsRevised & ",'" & QuotationType & "'," & PreviousQuotationNo & "," & _
"'" & CurrencyCode & "'," & IsApproved & "," & IsCancel & "," & _
"'" & ApprovedBy & "','" & ApprovedDateTime & "','" & CreatedBy & "'," & _
"'" & CreatedDateTime & "','" & RejectedBy & "','" & RejectedDateTime & "'," & _
"'" & Comments & "','" & TDate & "'," & GrandDiscountTotal & "," & _
"" & GrandVATTotal & "," & GrandSubTotal & "," & GrandFreightCharges & "," & _
"" & GrandOtherCharges & "," & GrandNetTotal & "," & BaseCurrencyExchangeRate & "," & _
" :1 ,'" & ReferenceNumber & "','" & FileExtension & "');" & _
"END ;"
cmd.CommandText = strSQL
cmd.Connection = con
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
cmd.CommandType = CommandType.Text
' Bind the parameter as OracleDbType.Blob
' to command for inserting image
Dim param As OracleParameter = cmd.Parameters.Add("blobtodb", OracleDbType.Blob)
param.Direction = ParameterDirection.Input
' Assign Byte Array to Oracle Parameter
param.Value = ImageData
Return cmd.ExecuteNonQuery()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
#End Region
#Region "IEditableObject"
Private _Editing As Boolean
Private _IsAddNew As Boolean = True
Private _oldCompanyCode As String
Private _oldVoucherShrtCode As String
Private _oldTransactionCode As Integer
Private _oldTransactionDate As Date
Private _oldCostingsheetno As Integer
Private _oldInquiryNo As Integer
Private _oldIsRevised As Integer
Private _oldQuotationType As String
Private _oldPreviousQuotationNo As Integer
Private _oldCurrCode As String
Private _oldIsApproved As Integer
Private _oldIsCacel As Integer
Private _oldApoprovedBy As String
Private _oldApprovedDTTime As Date
Private _oldCreateBy As String
Private _oldCreatedDTTime As Date
Private _oldRejectedBy As String
Private _oldRejectedDTTime As Date
Private _oldComments As String
Private _oldTDate As Date
Private _oldGrandDiscAmt As Double
Private _oldGrandVATAmt As Double
Private _oldGrandSubTotal As Double
Private _oldGrandFreightCharges As Double
Private _oldGrandOtherCharges As Double
Private _oldGrandNetTotal As Double
Private _oldBaseCurrExchRate As Double
Private _oldFileExtension As String
Private _oldRefNumber As String
Public Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit
Try
If Not _Editing Then
_Editing = True
_oldApoprovedBy = ApprovedBy : _oldApprovedDTTime = ApprovedDateTime : _oldBaseCurrExchRate = BaseCurrencyExchangeRate
_oldComments = Comments : _oldCompanyCode = CompanyCode : _oldCostingsheetno = CostingSheetNo
_oldCreateBy = CreatedBy : _oldCreatedDTTime = CreatedDateTime : _oldCurrCode = CurrencyCode
_oldGrandDiscAmt = GrandDiscountTotal : _oldGrandFreightCharges = GrandFreightCharges
_oldGrandFreightCharges = GrandFreightCharges : _oldGrandNetTotal = GrandNetTotal
_oldGrandOtherCharges = GrandOtherCharges : _oldGrandSubTotal = GrandSubTotal
_oldGrandVATAmt = GrandVATTotal : _oldInquiryNo = InquiryNo : _oldIsApproved = IsApproved
_oldIsCacel = IsCancel : _oldIsRevised = IsRevised : _oldPreviousQuotationNo = PreviousQuotationNo
_oldQuotationType = QuotationType : _oldRefNumber = ReferenceNumber : _oldRejectedBy = RejectedBy
_oldRejectedDTTime = RejectedDateTime : _oldTDate = TDate
_oldTransactionCode = TransactionCode : _oldTransactionDate = TransactionDate
_oldFileExtension = FileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit
Try
If _Editing = True Then
_Editing = False
ApprovedBy = _oldApoprovedBy : ApprovedDateTime = _oldApprovedDTTime : BaseCurrencyExchangeRate = _oldBaseCurrExchRate
Comments = _oldComments : CompanyCode = _oldCompanyCode : CostingSheetNo = _oldCostingsheetno
CreatedBy = _oldCreateBy : CreatedDateTime = _oldCreatedDTTime : CurrencyCode = _oldCurrCode
GrandDiscountTotal = _oldGrandDiscAmt : GrandFreightCharges = _oldGrandFreightCharges
GrandFreightCharges = _oldGrandFreightCharges : GrandNetTotal = _oldGrandNetTotal
GrandOtherCharges = _oldGrandOtherCharges : GrandSubTotal = _oldGrandSubTotal
GrandVATTotal = _oldGrandVATAmt : InquiryNo = _oldInquiryNo : IsApproved = _oldIsApproved
IsCancel = _oldIsCacel : IsRevised = _oldIsRevised : PreviousQuotationNo = _oldPreviousQuotationNo
QuotationType = _oldQuotationType : ReferenceNumber = _oldRefNumber : RejectedBy = _oldRejectedBy
RejectedDateTime = _oldRejectedDTTime : TDate = _oldTDate
TransactionCode = _oldTransactionCode : TransactionDate = _oldTransactionDate
FileExtension = _oldFileExtension
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub EndEdit() Implements System.ComponentModel.IEditableObject.EndEdit
Try
_Editing = False : _IsAddNew = False
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
#End Region
End Class
Detail Class
Option Explicit On
Option Strict On
Imports System.ComponentModel
Public Class QuotationServiceDetail
Inherits PCTLTransactionsDetailBaseClass
Implements IEditableObject
#Region "Declarations"
Private objDAL As New PCTLDataTier.DataLayer
Private strSQL As String
Private _ServiceTypeID As Integer
Private _ServiceName As String
Private _objQuotationMaster As New BusinessTier.ServiceQuotationMaster
Public Event ServiceName_Changed As EventHandler
Public Event ServiceTypeID_Changed As EventHandler
Friend Event RemoveMe(ByVal objQuotationServiceDetail As BusinessTier.QuotationServiceDetail)
#End Region
#Region "Properties"
Public Property ServiceName() As String
Get
Return _ServiceName
End Get
Set(ByVal value As String)
_ServiceName = CStr(IIf(IsDBNull(value), Nothing, value))
RaiseEvent ServiceName_Changed(Me, New EventArgs)
End Set
End Property
Public Property ServiceTypeID() As Integer
Get
Return _ServiceTypeID
End Get
Set(ByVal value As Integer)
_ServiceTypeID = CInt(IIf(IsDBNull(value), 0, value))
RaiseEvent ServiceTypeID_Changed(Me, New EventArgs)
End Set
End Property
#End Region
#Region "IEditableObject"
Public IsEditing As Boolean
Public IsAddNew As Boolean
Private _oldCompanyCode As String
Private _oldVoucherShortCode As String
Private _oldTransactionCode As Integer
Private _oldSerialNumber As Integer
Private _oldServiceName As String
Private _oldServiceTypeId As Integer
Private _oldQuantity As Double
Private _oldRate As Double
Private _oldVATPercent As Double
Private _oldVATAmount As Double
Private _oldDiscountPercent As Double
Private _oldDiscountAmount As Double
Private _oldSubTotal As Double
Private _oldNetTotal As Double
Public Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit
Try
If IsEditing = True Then
_oldCompanyCode = CompanyCode : _oldDiscountAmount = DiscountAmount : _oldDiscountPercent = DiscountPercentage
_oldNetTotal = NetTotal : _oldQuantity = Quantity : _oldRate = Rate : _oldSerialNumber = SerialNumber
_oldServiceName = ServiceName : _oldServiceTypeId = ServiceTypeID : _oldSubTotal = SubTotal
_oldTransactionCode = TransactionCode : _oldVATAmount = VATAmount : _oldVATPercent = VATPercentage
_oldVoucherShortCode = VoucherShrtCode
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit
Try
If IsEditing = True Then
CompanyCode = _oldCompanyCode : DiscountAmount = _oldDiscountAmount : DiscountPercentage = _oldDiscountPercent
NetTotal = _oldNetTotal : Quantity = _oldQuantity : Rate = _oldRate : SerialNumber = _oldSerialNumber
ServiceName = _oldServiceName : ServiceTypeID = _oldServiceTypeId : SubTotal = _oldSubTotal
TransactionCode = _oldTransactionCode : VATAmount = _oldVATAmount : VATPercentage = _oldVATPercent
VoucherShrtCode = _oldVoucherShortCode
IsEditing = False
ElseIf IsAddNew = True Then
RaiseEvent RemoveMe(Me)
IsAddNew = False
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub EndEdit() Implements System.ComponentModel.IEditableObject.EndEdit
Try
IsEditing = False : IsAddNew = False
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
#End Region
#Region "Functions"
Public Overrides Function Delete() As Integer
Try
strSQL = "DELETE tblQuotationServiceDt WHERE CompanyCode='" & CompanyCode & "' AND QuotationNo=" & TransactionCode & ""
Return objDAL.ExecQuery(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function Edit() As Integer
Try
strSQL = "UPDATE ADMIN.TBLQUOTATIONSERVICEDT SET VOUCHERSHRTCODE ='" & VoucherShrtCode & "'," & _
"SERIALNUMBER=" & SerialNumber & ",SERVICETYPEID=" & ServiceTypeID & "," & _
"QUANTITY=" & Quantity & ",RATE=" & Rate & ",VATPERCENTAGE=" & VATPercentage & "," & _
"VATAMOUNT=" & VATAmount & ",DISCPERCENT=" & DiscountPercentage & ",DISCAMOUNT=" & DiscountAmount & "," & _
"SUBTOTAL=" & SubTotal & ",NETTOTAL=" & NetTotal & " " & _
"WHERE COMPANYCODE='" & CompanyCode & "'AND QUOTATIONNO=" & TransactionCode & ""
Return objDAL.ExecQuery(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
Public Overrides Function GetRecords(ByVal sqlStmt As String) As System.Data.DataSet
Try
Return objDAL.ExecuteQry(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Overrides Function Save() As Integer
Try
strSQL = "INSERT INTO ADMIN.TBLQUOTATIONSERVICEDT (COMPANYCODE,VOUCHERSHRTCODE,QUOTATIONNO,SERIALNUMBER," & _
"SERVICETYPEID,QUANTITY,RATE,VATPERCENTAGE,VATAMOUNT,DISCPERCENT,DISCAMOUNT,SUBTOTAL,NETTOTAL) " & _
"VALUES ('" & CompanyCode & "','" & VoucherShrtCode & "'," & TransactionCode & "," & _
"" & SerialNumber & "," & ServiceTypeID & "," & Quantity & "," & _
"" & Rate & "," & VATPercentage & "," & VATAmount & "," & _
"" & DiscountPercentage & "," & DiscountAmount & "," & SubTotal & "," & NetTotal & ")"
Return objDAL.ExecQuery(strSQL)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return 0
End Try
End Function
#End Region
Public Sub New(ByRef _QuotationMaster As BusinessTier.ServiceQuotationMaster)
Try
_objQuotationMaster = _QuotationMaster
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
End Class
Master Collection
Option Explicit On
Option Strict On
Imports System.ComponentModel
Imports System.Data
Imports System.IO
Imports System.Text
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class ServicesQuotationsMaster
Inherits System.Collections.CollectionBase
Implements IBindingList
Default Public ReadOnly Property Item(ByVal index As Integer) As BusinessTier.ServiceQuotationMaster
Get
Return CType(List(index), BusinessTier.ServiceQuotationMaster)
End Get
End Property
Public Sub Delete(ByVal objQuotation As BusinessTier.ServiceQuotationMaster)
Try
List.Remove(objQuotation)
objQuotation.Delete()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub AddIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.AddIndex
End Sub
Public Function AddNew() As Object Implements System.ComponentModel.IBindingList.AddNew
Try
Dim item As New BusinessTier.ServiceQuotationMaster
List.Add(item)
Return item
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public ReadOnly Property AllowEdit() As Boolean Implements System.ComponentModel.IBindingList.AllowEdit
Get
Return True
End Get
End Property
Public ReadOnly Property AllowNew() As Boolean Implements System.ComponentModel.IBindingList.AllowNew
Get
Return True
End Get
End Property
Public ReadOnly Property AllowRemove() As Boolean Implements System.ComponentModel.IBindingList.AllowRemove
Get
Return True
End Get
End Property
Public Sub ApplySort(ByVal [property] As System.ComponentModel.PropertyDescriptor, ByVal direction As System.ComponentModel.ListSortDirection) Implements System.ComponentModel.IBindingList.ApplySort
End Sub
Public Function Find(ByVal [property] As System.ComponentModel.PropertyDescriptor, ByVal key As Object) As Integer Implements System.ComponentModel.IBindingList.Find
Try
Dim idx As Integer
Dim result As Integer = -1
For idx = 0 To Me.List.Count - 1
Dim value As Object = [property].GetValue(Me.List(idx))
If (value Is key) Then
result = idx
End If
If (result <> -1) Then
Return result
End If
Next
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public ReadOnly Property IsSorted() As Boolean Implements System.ComponentModel.IBindingList.IsSorted
Get
Return False
End Get
End Property
Public Event ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Implements System.ComponentModel.IBindingList.ListChanged
Public Sub RemoveIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.RemoveIndex
End Sub
Public Sub RemoveSort() Implements System.ComponentModel.IBindingList.RemoveSort
End Sub
Public ReadOnly Property SortDirection() As System.ComponentModel.ListSortDirection Implements System.ComponentModel.IBindingList.SortDirection
Get
End Get
End Property
Public ReadOnly Property SortProperty() As System.ComponentModel.PropertyDescriptor Implements System.ComponentModel.IBindingList.SortProperty
Get
End Get
End Property
Public ReadOnly Property SupportsChangeNotification() As Boolean Implements System.ComponentModel.IBindingList.SupportsChangeNotification
Get
Return True
End Get
End Property
Public ReadOnly Property SupportsSearching() As Boolean Implements System.ComponentModel.IBindingList.SupportsSearching
Get
Return False
End Get
End Property
Public ReadOnly Property SupportsSorting() As Boolean Implements System.ComponentModel.IBindingList.SupportsSorting
Get
Return False
End Get
End Property
Private _BindingList As System.ComponentModel.IBindingList
Protected Overrides Sub OnClearComplete()
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.Reset, 0))
End Sub
Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)
AddHandler CType(value, BusinessTier.ServiceQuotationMaster).RemoveMe, AddressOf Delete
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemAdded, index))
End Sub
Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemDeleted, index))
End Sub
Protected Overrides Sub OnSetComplete(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemChanged, index))
End Sub
Public Sub New()
Try
If TypeOf List Is IBindingList Then
_BindingList = DirectCast(List, IBindingList)
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub New(ByVal strCompanyCode As String)
Try
If TypeOf List Is IBindingList Then
_BindingList = DirectCast(List, IBindingList)
End If
List.Clear()
Dim dtResults As New DataTable
Dim objDAL As New PCTLDataTier.DataLayer
Dim strSQL As String
strSQL = "SELECT COMPANYCODE,VOUCHERSHRTCODE,QUOTATIONNO,QUOTATIONDT,COSTINGSHEETNO,INQUIRYNO,ISREVISED," & _
"QUOTATIONTYPE,PREVIOUSQUOTATIONNO,CURRCODE,ISAPPROVED,ISCANCEL,APPROVEDBY,APPROVEDDTTIME," & _
"CREATEBY,CREATEDDTTIME,REJECTEDBY,REJECTEDDTTIME,COMMENTS,TDATE,GRANDTOTALDISCOUNT," & _
"GRANDTOTALVAT,GRANDSUBTOTAL,GRANDFREIGHTCHARGES,GRANDOTHERCHARGES,GRANDNETTOTAL," & _
"BASECURREXCHANGERATE,REFNUMBER FROM ADMIN.TBLQUOTATIONMASTER WHERE CompanyCode='" & strCompanyCode & "'"
dtResults.Clear()
dtResults = objDAL.ExecuteQry(strSQL).Tables("tblRecords")
If dtResults.Rows.Count > 0 Then
For Each drResults As DataRow In dtResults.Rows
Dim objQuotation As New BusinessTier.ServiceQuotationMaster
With objQuotation
.ApprovedBy = CStr(IIf(IsDBNull(drResults.Item("APPROVEDBY")), Nothing, drResults.Item("APPROVEDBY")))
.ApprovedDateTime = CDate(IIf(IsDBNull(drResults.Item("APPROVEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("APPROVEDDTTIME")), DateFormat.ShortDate)))
.BaseCurrencyExchangeRate = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("BASECURREXCHANGERATE")), 0, drResults.Item("BASECURREXCHANGERATE")), 2))
.Comments = CStr(IIf(IsDBNull(drResults.Item("COMMENTS")), Nothing, drResults.Item("COMMENTS")))
.CompanyCode = CStr(IIf(IsDBNull(drResults.Item("COMPANYCODE")), Nothing, drResults.Item("COMPANYCODE")))
.CostingSheetNo = CInt(IIf(IsDBNull(drResults.Item("COSTINGSHEETNO")), 0, drResults.Item("COSTINGSHEETNO")))
.CreatedBy = CStr(IIf(IsDBNull(drResults.Item("CREATEBY")), Nothing, drResults.Item("CREATEBY")))
.CreatedDateTime = CDate(IIf(IsDBNull(drResults.Item("CREATEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("CREATEDDTTIME")), DateFormat.ShortDate)))
.CurrencyCode = CStr(IIf(IsDBNull(drResults.Item("CURRCODE")), Nothing, drResults.Item("CURRCODE")))
.GrandDiscountTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDTOTALDISCOUNT")), 0, drResults.Item("GRANDTOTALDISCOUNT")), 2))
.GrandFreightCharges = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDFREIGHTCHARGES")), 0, drResults.Item("GRANDFREIGHTCHARGES")), 2))
.GrandNetTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDNETTOTAL")), 0, drResults.Item("GRANDNETTOTAL")), 2))
.GrandOtherCharges = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDOTHERCHARGES")), 0, drResults.Item("GRANDOTHERCHARGES")), 2))
.GrandSubTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDSUBTOTAL")), 0, drResults.Item("GRANDSUBTOTAL")), 2))
.GrandVATTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDTOTALVAT")), 0, drResults.Item("GRANDTOTALVAT")), 2))
.InquiryNo = CInt(IIf(IsDBNull(drResults.Item("INQUIRYNO")), 0, drResults.Item("INQUIRYNO")))
.IsApproved = CInt(IIf(IsDBNull(drResults.Item("ISAPPROVED")), 0, drResults.Item("ISAPPROVED")))
.IsCancel = CInt(IIf(IsDBNull(drResults.Item("ISCANCEL")), 0, drResults.Item("ISCANCEL")))
.IsRevised = CInt(IIf(IsDBNull(drResults.Item("ISREVISED")), 0, drResults.Item("ISREVISED")))
.PreviousQuotationNo = CInt(IIf(IsDBNull(drResults.Item("PREVIOUSQUOTATIONNO")), 0, drResults.Item("PREVIOUSQUOTATIONNO")))
.QuotationType = CStr(IIf(IsDBNull(drResults.Item("QUOTATIONTYPE")), Nothing, drResults.Item("QUOTATIONTYPE")))
.ReferenceNumber = CStr(IIf(IsDBNull(drResults.Item("REFNUMBER")), Nothing, drResults.Item("REFNUMBER")))
.RejectedBy = CStr(IIf(IsDBNull(drResults.Item("REJECTEDBY")), Nothing, drResults.Item("REJECTEDBY")))
.RejectedDateTime = CDate(IIf(IsDBNull(drResults.Item("REJECTEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("REJECTEDDTTIME")), DateFormat.ShortDate)))
.TDate = CDate(IIf(IsDBNull(drResults.Item("TDATE")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("TDATE")), DateFormat.ShortDate)))
.TransactionCode = CInt(IIf(IsDBNull(drResults.Item("QUOTATIONNO")), 0, drResults.Item("QUOTATIONNO")))
.TransactionDate = CDate(IIf(IsDBNull(drResults.Item("QUOTATIONDT")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("QUOTATIONDT")), DateFormat.ShortDate)))
.VoucherShortCode = CStr(IIf(IsDBNull(drResults.Item("VOUCHERSHRTCODE")), Nothing, drResults.Item("VOUCHERSHRTCODE")))
.ServiceQuotationLineItems.LoadRows(.TransactionCode, .CompanyCode)
GetTermsAndConditions(.TransactionCode, .CompanyCode)
End With
List.Add(objQuotation)
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Sub GetTermsAndConditions(ByVal intQuotationNo As Integer, ByVal strCompanyCode As String)
Try
' Connect to database
Dim cmd As New OracleCommand
Dim constr As String = "User Id=ADMIN;Password=accesslight;Data Source=NTL"
Dim con As OracleConnection = New OracleConnection(constr)
con.Open()
' Note: Modify the Destination location of the File
Dim DestinationLoc As String = My.Application.Info.DirectoryPath & "\Temp\TermsAndConditionsQuotationNo" & intQuotationNo & " .doc"
' Create Anonymous PL/SQL block string
Dim strSQL As String = " BEGIN " & _
" SELECT TERMSANDCONDITION INTO :1 FROM" & _
" ADMIN.TBLQUOTATIONMASTER WHERE CompanyCode = '" & strCompanyCode & "'" & _
" AND QuotationNO = " & intQuotationNo & ";" & _
" End ;"
cmd.CommandText = strSQL
cmd.Connection = con
' Since executing an anonymous PL/SQL block, setting the command type
' as Text instead of StoredProcedure
cmd.CommandType = CommandType.Text
' Bind the parameter as OracleDbType.Blob
' to command for inserting image
Dim param As OracleParameter = cmd.Parameters.Add("blobtodb", OracleDbType.Blob)
param.Direction = ParameterDirection.Output
cmd.ExecuteNonQuery()
' Save the retrieved image to the DestinationLoc in the file system
' Create a byte array
Dim byteData As Byte()
Dim Paramvalue As OracleBlob
Paramvalue = CType(cmd.Parameters(0).Value, OracleBlob)
' fetch the value of Oracle parameter into the byte array
byteData = CType((Paramvalue.Value), Byte())
' get the length of the byte array
Dim ArraySize As Integer = New Integer()
ArraySize = byteData.GetUpperBound(0)
' Write the Blob data fetched from database to the filesystem at
' the destination location
Dim fs1 As FileStream = New FileStream(DestinationLoc, FileMode.OpenOrCreate, FileAccess.Write)
fs1.Write(byteData, 0, ArraySize)
fs1.Close()
MsgBox("For terms and conditions please view " & DestinationLoc & ".", MsgBoxStyle.Information, My.Application.Info.Title)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub LoadRows(ByVal intQuotationNumber As Integer, ByVal strCompanyCode As String)
Try
If TypeOf List Is IBindingList Then
_BindingList = DirectCast(List, IBindingList)
End If
List.Clear()
Dim dtResults As New DataTable
Dim objDAL As New PCTLDataTier.DataLayer
Dim strSQL As String
strSQL = "SELECT COMPANYCODE,VOUCHERSHRTCODE,QUOTATIONNO,QUOTATIONDT,COSTINGSHEETNO,INQUIRYNO,ISREVISED," & _
"QUOTATIONTYPE,PREVIOUSQUOTATIONNO,CURRCODE,ISAPPROVED,ISCANCEL,APPROVEDBY,APPROVEDDTTIME," & _
"CREATEBY,CREATEDDTTIME,REJECTEDBY,REJECTEDDTTIME,COMMENTS,TDATE,GRANDTOTALDISCOUNT," & _
"GRANDTOTALVAT,GRANDSUBTOTAL,GRANDFREIGHTCHARGES,GRANDOTHERCHARGES,GRANDNETTOTAL," & _
"BASECURREXCHANGERATE,REFNUMBER FROM ADMIN.TBLQUOTATIONMASTER " & _
"WHERE CompanyCode='" & strCompanyCode & "' AND QUOTATIONNO=" & intQuotationNumber & ""
dtResults.Clear()
dtResults = objDAL.ExecuteQry(strSQL).Tables("tblRecords")
If dtResults.Rows.Count > 0 Then
For Each drResults As DataRow In dtResults.Rows
Dim objQuotation As New BusinessTier.ServiceQuotationMaster
With objQuotation
.ApprovedBy = CStr(IIf(IsDBNull(drResults.Item("APPROVEDBY")), Nothing, drResults.Item("APPROVEDBY")))
.ApprovedDateTime = CDate(IIf(IsDBNull(drResults.Item("APPROVEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("APPROVEDDTTIME")), DateFormat.ShortDate)))
.BaseCurrencyExchangeRate = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("BASECURREXCHANGERATE")), 0, drResults.Item("BASECURREXCHANGERATE")), 2))
.Comments = CStr(IIf(IsDBNull(drResults.Item("COMMENTS")), Nothing, drResults.Item("COMMENTS")))
.CompanyCode = CStr(IIf(IsDBNull(drResults.Item("COMPANYCODE")), Nothing, drResults.Item("COMPANYCODE")))
.CostingSheetNo = CInt(IIf(IsDBNull(drResults.Item("COSTINGSHEETNO")), 0, drResults.Item("COSTINGSHEETNO")))
.CreatedBy = CStr(IIf(IsDBNull(drResults.Item("CREATEBY")), Nothing, drResults.Item("CREATEBY")))
.CreatedDateTime = CDate(IIf(IsDBNull(drResults.Item("CREATEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("CREATEDDTTIME")), DateFormat.ShortDate)))
.CurrencyCode = CStr(IIf(IsDBNull(drResults.Item("CURRCODE")), Nothing, drResults.Item("CURRCODE")))
.GrandDiscountTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDTOTALDISCOUNT")), 0, drResults.Item("GRANDTOTALDISCOUNT")), 2))
.GrandFreightCharges = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDFREIGHTCHARGES")), 0, drResults.Item("GRANDFREIGHTCHARGES")), 2))
.GrandNetTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDNETTOTAL")), 0, drResults.Item("GRANDNETTOTAL")), 2))
.GrandOtherCharges = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDOTHERCHARGES")), 0, drResults.Item("GRANDOTHERCHARGES")), 2))
.GrandSubTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDSUBTOTAL")), 0, drResults.Item("GRANDSUBTOTAL")), 2))
.GrandVATTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("GRANDTOTALVAT")), 0, drResults.Item("GRANDTOTALVAT")), 2))
.InquiryNo = CInt(IIf(IsDBNull(drResults.Item("INQUIRYNO")), 0, drResults.Item("INQUIRYNO")))
.IsApproved = CInt(IIf(IsDBNull(drResults.Item("ISAPPROVED")), 0, drResults.Item("ISAPPROVED")))
.IsCancel = CInt(IIf(IsDBNull(drResults.Item("ISCANCEL")), 0, drResults.Item("ISCANCEL")))
.IsRevised = CInt(IIf(IsDBNull(drResults.Item("ISREVISED")), 0, drResults.Item("ISREVISED")))
.PreviousQuotationNo = CInt(IIf(IsDBNull(drResults.Item("PREVIOUSQUOTATIONNO")), 0, drResults.Item("PREVIOUSQUOTATIONNO")))
.QuotationType = CStr(IIf(IsDBNull(drResults.Item("QUOTATIONTYPE")), Nothing, drResults.Item("QUOTATIONTYPE")))
.ReferenceNumber = CStr(IIf(IsDBNull(drResults.Item("REFNUMBER")), Nothing, drResults.Item("REFNUMBER")))
.RejectedBy = CStr(IIf(IsDBNull(drResults.Item("REJECTEDBY")), Nothing, drResults.Item("REJECTEDBY")))
.RejectedDateTime = CDate(IIf(IsDBNull(drResults.Item("REJECTEDDTTIME")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("REJECTEDDTTIME")), DateFormat.ShortDate)))
.TDate = CDate(IIf(IsDBNull(drResults.Item("TDATE")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("TDATE")), DateFormat.ShortDate)))
.TransactionCode = CInt(IIf(IsDBNull(drResults.Item("QUOTATIONNO")), 0, drResults.Item("QUOTATIONNO")))
.TransactionDate = CDate(IIf(IsDBNull(drResults.Item("QUOTATIONDT")), FormatDateTime(Today, DateFormat.ShortDate), FormatDateTime(CDate(drResults.Item("QUOTATIONDT")), DateFormat.ShortDate)))
.VoucherShortCode = CStr(IIf(IsDBNull(drResults.Item("VOUCHERSHRTCODE")), Nothing, drResults.Item("VOUCHERSHRTCODE")))
.ServiceQuotationLineItems.LoadRows(.TransactionCode, .CompanyCode)
GetTermsAndConditions(.TransactionCode, .CompanyCode)
End With
List.Add(objQuotation)
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
End Class
Detail Collection
Option Explicit On
Option Strict On
Imports System.ComponentModel
Public Class QuotationsServicesDetails
Inherits System.Collections.CollectionBase
Implements IBindingList
Implements INotifyPropertyChanged
#Region "Declarations"
Private _QuotationMaster As BusinessTier.ServiceQuotationMaster
Private _CompanyCode As String
Private _VoucherShrtCode As String
Private _ServiceName As String
Private _TransactionCode As Integer
Private _SerialNumber As Integer
Private _ServiceTypeID As Integer
Private _CurrentIndex As Integer
Private _Quantity As Double
Private _Rate As Double
Private _VATPercentage As Double
Private _VATAmount As Double
Private _DiscountPercentage As Double
Private _DiscountAmount As Double
Private _SubTotal As Double
Private _NetTotal As Double
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
#End Region
#Region "Properties"
Public Property CompanyCode() As String
Get
Return Me._CompanyCode
End Get
Set(ByVal value As String)
Me._CompanyCode = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("CompanyCode"))
End Set
End Property
Public Property VoucherShrtCode() As String
Get
Return Me._VoucherShrtCode
End Get
Set(ByVal value As String)
Me._VoucherShrtCode = CStr(IIf(IsDBNull(value), Nothing, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("VoucherShrtCode"))
End Set
End Property
Public Property TransactionCode() As Integer
Get
Return Me._TransactionCode
End Get
Set(ByVal value As Integer)
Me._TransactionCode = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("TransactionCode"))
End Set
End Property
Public Property DiscountAmount() As Double
Get
Return Me._DiscountAmount
End Get
Set(ByVal value As Double)
Me._DiscountAmount = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("DiscountAmount"))
End Set
End Property
Public Property DiscountPercentage() As Double
Get
Return Me._DiscountPercentage
End Get
Set(ByVal value As Double)
Me._DiscountPercentage = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("DiscountPercentage"))
End Set
End Property
Public Property NetTotal() As Double
Get
Return Me._NetTotal
End Get
Set(ByVal value As Double)
Me._NetTotal = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("NetTotal"))
End Set
End Property
Public Property Quantity() As Double
Get
Return Me._Quantity
End Get
Set(ByVal value As Double)
Me._Quantity = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("Quantity"))
End Set
End Property
Public Property Rate() As Double
Get
Return Me._Rate
End Get
Set(ByVal value As Double)
Me._Rate = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("Rate"))
End Set
End Property
Public Property SerialNumber() As Integer
Get
Return Me._SerialNumber
End Get
Set(ByVal value As Integer)
Me._SerialNumber = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("SerialNumber"))
End Set
End Property
Public Property ServiceTypeID() As Integer
Get
Return Me._ServiceTypeID
End Get
Set(ByVal value As Integer)
Me._ServiceTypeID = CInt(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("serviceTypeID"))
End Set
End Property
Public Property ServiceName() As String
Get
Return Me._ServiceName
End Get
Set(ByVal value As String)
Me._ServiceName = CStr(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("ServiceName"))
End Set
End Property
Public Property SubTotal() As Double
Get
Return Me._SubTotal
End Get
Set(ByVal value As Double)
Me._SubTotal = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("SubTotal"))
End Set
End Property
Public Property VATAmount() As Double
Get
Return Me._VATAmount
End Get
Set(ByVal value As Double)
Me._VATAmount = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("VATAmount"))
End Set
End Property
Public Property VATPercentage() As Double
Get
Return Me._VATPercentage
End Get
Set(ByVal value As Double)
Me._VATPercentage = CDbl(IIf(IsDBNull(value), 0, value))
Me.OnPropertyChanged(New PropertyChangedEventArgs("VATPercentage"))
End Set
End Property
#End Region
#Region "Default Property"
Default Public ReadOnly Property Item(ByVal index As Integer) As BusinessTier.QuotationServiceDetail
Get
Return CType(List(index), BusinessTier.QuotationServiceDetail)
End Get
End Property
#End Region
Public Sub Delete(ByVal objQuotationServiceDetail As BusinessTier.QuotationServiceDetail)
Try
List.Remove(objQuotationServiceDetail)
objQuotationServiceDetail.Delete()
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub AddIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.AddIndex
End Sub
Public Function AddNew() As Object Implements System.ComponentModel.IBindingList.AddNew
Try
Dim item As New BusinessTier.QuotationServiceDetail(_QuotationMaster)
List.Add(item)
Return item
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public ReadOnly Property AllowEdit() As Boolean Implements System.ComponentModel.IBindingList.AllowEdit
Get
Return True
End Get
End Property
Public ReadOnly Property AllowNew() As Boolean Implements System.ComponentModel.IBindingList.AllowNew
Get
Return True
End Get
End Property
Public ReadOnly Property AllowRemove() As Boolean Implements System.ComponentModel.IBindingList.AllowRemove
Get
Return True
End Get
End Property
Public Sub ApplySort(ByVal [property] As System.ComponentModel.PropertyDescriptor, ByVal direction As System.ComponentModel.ListSortDirection) Implements System.ComponentModel.IBindingList.ApplySort
Throw New NotSupportedException
End Sub
Public Function Find(ByVal [property] As System.ComponentModel.PropertyDescriptor, ByVal key As Object) As Integer Implements System.ComponentModel.IBindingList.Find
Try
Dim idx As Integer
Dim result As Integer = -1
For idx = 0 To Me.List.Count - 1
Dim value As Object = [property].GetValue(Me.List(idx))
If (value Is key) Then
result = idx
End If
If (result <> -1) Then
Return result
End If
Next
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Function
Public Function Find(ByVal propertyName As String, ByVal key As Object) As Integer
Try
Dim findProperty As System.ComponentModel.PropertyDescriptor = Nothing
If Len(propertyName) > 0 Then
Dim itemType As Type = GetType(BusinessTier.QuotationServiceDetail)
For Each prop As System.ComponentModel.PropertyDescriptor In System.ComponentModel.TypeDescriptor.GetProperties(itemType)
If UCase(prop.Name) = UCase(propertyName) Then
findProperty = prop
Exit For
End If
Next
End If
'Return Find(findProperty, key)
Return mBindingList.Find(findProperty, key)
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, My.Application.Info.Title)
End Try
End Function
Private mBindingList As System.ComponentModel.IBindingList
Public ReadOnly Property IsSorted() As Boolean Implements System.ComponentModel.IBindingList.IsSorted
Get
Return False
End Get
End Property
Public Event ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Implements System.ComponentModel.IBindingList.ListChanged
Public Sub RemoveIndex(ByVal [property] As System.ComponentModel.PropertyDescriptor) Implements System.ComponentModel.IBindingList.RemoveIndex
End Sub
Public Sub RemoveSort() Implements System.ComponentModel.IBindingList.RemoveSort
End Sub
Public ReadOnly Property SortDirection() As System.ComponentModel.ListSortDirection Implements System.ComponentModel.IBindingList.SortDirection
Get
End Get
End Property
Public ReadOnly Property SortProperty() As System.ComponentModel.PropertyDescriptor Implements System.ComponentModel.IBindingList.SortProperty
Get
End Get
End Property
Public ReadOnly Property SupportsChangeNotification() As Boolean Implements System.ComponentModel.IBindingList.SupportsChangeNotification
Get
Return True
End Get
End Property
Public ReadOnly Property SupportsSearching() As Boolean Implements System.ComponentModel.IBindingList.SupportsSearching
Get
Return False
End Get
End Property
Public ReadOnly Property SupportsSorting() As Boolean Implements System.ComponentModel.IBindingList.SupportsSorting
Get
Return False
End Get
End Property
Private _BindingList As System.ComponentModel.IBindingList
Protected Overrides Sub OnClearComplete()
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.Reset, 0))
End Sub
Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)
AddHandler CType(value, BusinessTier.QuotationServiceDetail).RemoveMe, AddressOf Delete
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemAdded, index))
End Sub
Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemDeleted, index))
End Sub
Protected Overrides Sub OnSetComplete(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
RaiseEvent ListChanged(Me, New ListChangedEventArgs(ListChangedType.ItemChanged, index))
End Sub
Public Sub New()
Try
If TypeOf List Is IBindingList Then
_BindingList = DirectCast(List, IBindingList)
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Sub New(ByVal strCompanyCode As String)
Try
List.Clear()
Dim dtResults As New DataTable
Dim objDAL As New PCTLDataTier.DataLayer
Dim strSQL As String
strSQL = "SELECT * FROM tblQuotationServiceDT WHERE CompanyCode='" & strCompanyCode & "'"
dtResults.Clear()
dtResults = objDAL.ExecuteQry(strSQL).Tables("tblRecords")
If dtResults.Rows.Count > 0 Then
For Each drResults As DataRow In dtResults.Rows
Dim objQuotationServiceDetail As New BusinessTier.QuotationServiceDetail(_QuotationMaster)
With objQuotationServiceDetail
.CompanyCode = CStr(IIf(IsDBNull(drResults.Item("CompanyCode")), Nothing, drResults.Item("CompanyCode")))
.DiscountAmount = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("DiscAmount")), 0, drResults.Item("DiscAmount")), 2))
.DiscountPercentage = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("DiscPercent")), 0, drResults.Item("DiscPercent")), 2))
.Quantity = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("Quantity")), 0, drResults.Item("Quantity")), 2))
.Rate = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("Rate")), 0, drResults.Item("Rate")), 2))
.SerialNumber = CInt(IIf(IsDBNull(drResults.Item("SerialNumber")), 0, drResults.Item("SerialNumber")))
.ServiceTypeID = CInt(IIf(IsDBNull(drResults.Item("ServiceTypeID")), 0, drResults.Item("ServiceTypeID")))
.ServiceName = GetServiceName(.ServiceTypeID)
.SubTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("SubTotal")), 0, drResults.Item("SubTotal")), 2))
.TransactionCode = CInt(IIf(IsDBNull(drResults.Item("QuotationNo")), 0, drResults.Item("QuotationNo")))
.VATAmount = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("VATAmount")), 0, drResults.Item("VATAmount")), 2))
.VATPercentage = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("VATPercentage")), 0, drResults.Item("VATPercentage")), 2))
.VoucherShrtCode = CStr(IIf(IsDBNull(drResults.Item("VoucherShrtCode")), Nothing, drResults.Item("VoucherShrtCode")))
End With
List.Add(objQuotationServiceDetail)
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Public Sub LoadRows(ByVal intQuotationNO As Integer, ByVal strCompanyCode As String)
Try
List.Clear()
Dim dtResults As New DataTable
Dim objDAL As New PCTLDataTier.DataLayer
Dim strSQL As String
strSQL = "SELECT * FROM tblQuotationServiceDT WHERE CompanyCode='" & strCompanyCode & "' AND QuotationNo=" & intQuotationNO & ""
dtResults.Clear()
dtResults = objDAL.ExecuteQry(strSQL).Tables("tblRecords")
If dtResults.Rows.Count > 0 Then
For Each drResults As DataRow In dtResults.Rows
Dim objQuotationServiceDetail As New BusinessTier.QuotationServiceDetail(_QuotationMaster)
With objQuotationServiceDetail
.CompanyCode = CStr(IIf(IsDBNull(drResults.Item("CompanyCode")), Nothing, drResults.Item("CompanyCode")))
.DiscountAmount = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("DiscAmount")), 0, drResults.Item("DiscAmount")), 2))
.DiscountPercentage = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("DiscPercent")), 0, drResults.Item("DiscPercent")), 2))
.NetTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("NetTotal")), 0, drResults.Item("NetTotal")), 2))
.Quantity = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("Quantity")), 0, drResults.Item("Quantity")), 2))
.Rate = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("Rate")), 0, drResults.Item("Rate")), 2))
.SerialNumber = CInt(IIf(IsDBNull(drResults.Item("SerialNumber")), 0, drResults.Item("SerialNumber")))
.ServiceTypeID = CInt(IIf(IsDBNull(drResults.Item("ServiceTypeID")), 0, drResults.Item("ServiceTypeID")))
.ServiceName = GetServiceName(.ServiceTypeID)
.SubTotal = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("SubTotal")), 0, drResults.Item("SubTotal")), 2))
.TransactionCode = CInt(IIf(IsDBNull(drResults.Item("QuotationNo")), 0, drResults.Item("QuotationNo")))
.VATAmount = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("VATAmount")), 0, drResults.Item("VATAmount")), 2))
.VATPercentage = CDbl(FormatNumber(IIf(IsDBNull(drResults.Item("VATPercentage")), 0, drResults.Item("VATPercentage")), 2))
.VoucherShrtCode = CStr(IIf(IsDBNull(drResults.Item("VoucherShrtCode")), Nothing, drResults.Item("VoucherShrtCode")))
End With
List.Add(objQuotationServiceDetail)
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Function GetServiceName(ByVal intServiceID As Integer) As String
Try
Dim dtResults As New DataTable
Dim objServiceType As New BusinessTier.ServiceType
Dim strSQL As String
strSQL = "SELECT ServiceTypeName FROM tblServiceTypeMaster WHERE ServiceTypeID=" & intServiceID
dtResults.Clear()
dtResults = objServiceType.GetRecords(strSQL).Tables("tblRecords")
If dtResults.Rows.Count > 0 Then
For Each drResults As DataRow In dtResults.Rows
Return CStr(IIf(IsDBNull(drResults.Item("ServiceTypeName")), Nothing, drResults.Item("ServiceTypeName")))
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
Return Nothing
End Try
End Function
Protected Overridable Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
Try
RaiseEvent PropertyChanged(Me, e)
Catch ex As Exception
Throw New Exception(ex.Message.ToString)
End Try
End Sub
Private Sub QuotationServiceDTItemList_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles Me.ListChanged
Try
_CurrentIndex = (e.NewIndex)
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.Critical, My.Application.Info.Title)
End Try
End Sub
End Class
Form Load Code
cboCurrency.DataBindings.Add("SelectedValue", objServiceQuotation, "CurrencyCode")
chkIsApproved.DataBindings.Add("Checked", objServiceQuotation, "IsApproved")
chkIsCancelled.DataBindings.Add("Checked", objServiceQuotation, "IsCancel")
chkIsRevised.DataBindings.Add("Checked", objServiceQuotation, "IsRevised")
dtpTransactionDate.DataBindings.Add("Text", objServiceQuotation, "TransactionDate")
lblCostingSheetNo.DataBindings.Add("Text", objServiceQuotation, "CostingSheetNo")
lblInquiryNo.DataBindings.Add("Text", objServiceQuotation, "InquiryNo")
lblNetTotal.DataBindings.Add("Text", objServiceQuotation, "GrandNetTotal")
lblPrevQuotationNo.DataBindings.Add("Text", objServiceQuotation, "PreviousQuotationNo")
lblQuotationNumber.DataBindings.Add("Text", objServiceQuotation, "TransactionCode")
lblSubTotal.DataBindings.Add("Text", objServiceQuotation, "GrandSubTotal")
lblTotalDiscount.DataBindings.Add("Text", objServiceQuotation, "GrandDiscountTotal")
lblTotalVAT.DataBindings.Add("Text", objServiceQuotation, "GrandVATTotal")
txtComments.DataBindings.Add("Text", objServiceQuotation, "Comments")
grdServiceQuotationDetails.SetDataBinding(objServiceQuotation, "ServiceQuotationLineItems", True)
Please check the code and let me know where am going wrong. I will really appreciate.
|