Imports System.Data.SqlClient
Imports ModCommon
Imports System.Data.Sql
Imports System.Data
Partial Class Productwise_Supplier_Report
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Session("AdminID") Is Nothing Then
                Response.Redirect("AdminLogin.aspx?sesn=expire")
                Exit Sub
            End If
      
            If Page.IsPostBack = False Then
                If Session("AdminID") = Nothing Then
                    Response.Redirect("AdminLogin.aspx")
                End If
                txtProductCode.Focus()
            End If
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "strKeyVal")
        End Try
    End Sub
    Protected Sub fillgrid()
        Try
            Dim con As New SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
            Dim sqlstr As String
            sqlstr = "SELECT Supplier_Master.Supplier_Name AS [Supplier Name], Supplier_Master.Supplier_Kid,   isnull(Supplier_Master.Supplier_Address,'N.A.') + ', ' + isnull(City_Master.City_Name,'') AS [Supplier Address],  isnull(Supplier_Master.Supplier_TelCityCode,'') + '-' + isnull(Supplier_Master.Supplier_TelNumber,'') AS [Telephone No],Product_Master.Product_Image[Product Image],Product_Master.Product_Name[Product_Name] FROM  Product_Master INNER JOIN   Supplier_Master ON Product_Master.Product_SupplierId = Supplier_Master.Supplier_Kid Left outer JOIN    City_Master ON Supplier_Master.Supplier_CityId = City_Master.City_Kid WHERE     (Supplier_Master.Supplier_IsDeleted = N'0') AND (Product_Master.Product_IsDeleted = N'0') AND  (Product_Master.Product_Code = '" & txtProductCode.Text.Trim & "') AND (Product_Master.Product_CompanyId = '" & Session("g_Company") & "')"
            ' Dim cmd As New SqlCommand(sqlstr, con)"
            Dim adptr As New SqlDataAdapter(sqlstr, con)
            Dim bdataset As New DataSet
            adptr.Fill(bdataset, "buyer")
            dvproductwisesupp.DataSource = bdataset
            dvproductwisesupp.DataBind()
            adptr.Dispose()
            con.Dispose()
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "strKeyVal")
        End Try
    End Sub


  

    Protected Sub Btnfindsupplier_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            fillgrid()
            'txtProductCode.Text = ""
            Session("Code") = txtProductCode.Text

        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "StrKeyVal")
        End Try
    End Sub

    Protected Sub lnkSuppliername_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
            Dim lnksupplier As LinkButton = CType(sender, LinkButton)
            Dim supplierid As String = RemoveLiterals(lnksupplier.CommandArgument.Trim)
            Response.Redirect("../suppliers/List_Product.aspx?Kid=" & supplierid)
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "strKeyVal")
        End Try
    End Sub
End Class
