Imports System.Data
Imports System.Data.SqlClient
Partial Class BusinessAssociates_viewquotation
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            g_User = CType(Session("g_User"), System.String)
            g_Company = CType(Session("g_Company"), System.String)
            If Not Request.QueryString("qid") = "" Then
                Dim DsQuotation As New DataSet

                DsQuotation = SelectQuotationTableByQuotationID(Request.QueryString("qid").ToString.Trim)

                If DsQuotation.Tables(0).Rows.Count > 0 Then
                    lbldocument.Text = DsQuotation.Tables(0).Rows(0).Item("V_CRM_HTMLTable")
                    If InStr(lbldocument.Text, "Logos") Then
                        lbldocument.Text = lbldocument.Text.Replace("~/Images/", "../Images/")
                    Else
                        lbldocument.Text = lbldocument.Text.Replace("/Logos/", "~/Images/Logos/")
                    End If
                Else
                    lbldocument.Text = "No Quotation Found"
                End If
            Else
                lbldocument.Text = "No Quotation Found"
            End If
            '            lbldocument.Text = "../Quotations/" & Request.QueryString("qid")
            '           '  lbldocument.Text = Server.HtmlEncode(lbldocument.Text)
        Catch ex As Exception
            lbldocument.Text = "No Quotation Found"
        End Try
    End Sub

    Public Function SelectQuotationTableByQuotationID(ByVal QuotationID As String) As DataSet
        Dim cn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings("Connection4Voffice"))
        Dim objAdapter As SqlDataAdapter
        Dim ObjDS As DataSet

        cn.Open()

        Try
            objAdapter = New SqlDataAdapter("Select_CRMQuotationTableByQuotationID_Proc", cn)
            objAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@QuotationID", SqlDbType.VarChar))

            objAdapter.SelectCommand.Parameters("@QuotationID").Value = QuotationID

            ObjDS = New DataSet
            objAdapter.Fill(ObjDS, "QuotationTable")

            Return ObjDS

        Catch ex As Exception
            Throw ex
        Finally
            cn.Close()
            cn.Dispose()
        End Try

    End Function
End Class
