Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports ModCommon
Partial Class LogisticsIformation
    Inherits System.Web.UI.Page
    Shared g_User As String
    Shared g_Company As String
    Shared g_FinYear As String
    Shared Category(10) As String
    Shared LI_Kid As String
    Shared LI_Code As String
    Shared City_Kid As String
    Shared City_Code As String
    Shared i As Integer
    Shared Mode As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("SupplierID") Is Nothing Then
            Response.Redirect("listproduct.aspx?sess=expire")
            Exit Sub
        End If
        If Not IsPostBack Then
            Dvlii.Visible = False
            ddlcity.Items.Clear()
            ddlcountry.Items.Clear()
            ddlstate.Items.Clear()
            g_User = Session("g_User").ToString
            g_Company = Session("g_Company").ToString
            g_FinYear = Session("g_FinYear").ToString
            i = 0
            Dim str As String
            str = Session("ProductID")
            If Session("ProductID") = Nothing Then
                Response.Redirect("List_Product.aspx")
            Else
                ' Session("ID") = Nothing
                'Dim str As String
                'str = Session("ProductID").ToString()
                Dim catid As String
                catid = ReturnValue("Select Product_CategoryID from Product_Master where Product_Kid= '" & Session("ProductID").ToString() & "'and Product_IsDeleted='0' and Product_CompanyId ='" & g_Company & "'")
                FillCategoryName(catid)

                Dim li_ProductId As String
                li_ProductId = ReturnValue("Select li_productId from LogisticInformation where li_productId= '" & Session("ProductID").ToString() & "' and li_Isdeleted='0' and li_CompanyId ='" & g_Company & "'")

                If li_ProductId = "" Then
                    EnableControls(True)
                    Fill_Combo("SELECT distinct Country_Kid, Country_Name FROM Country_Master where Country_IsDeleted='0'and Country_CompanyId='" & g_Company & "' order by Country_Name", ddlcountry)
                    ddlcountry.Items.FindByText("India").Selected = True
                    txtph1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
                    txtfax1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
                    txttffax1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
                    txttfph1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
                    txtmno1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
                    Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)

                    'Fill_Combo("SELECT State_Master.State_Kid, State_Master.State_Name, Country_Master.Country_Name FROM Country_Master INNER JOIN State_Master ON Country_Master.Country_Kid = State_Master.State_CountryId WHERE State_Master.State_CompanyId = '" & g_Company & "' AND State_Master.State_IsDeleted = '0' AND Country_Master.Country_Kid = '" & ddlcountry.SelectedItem.Value & "'", ddlstate)
                    ddlcity.Items.Add("Select")
                    'ddlstate.Items.Add("Select")
                    GenerateLogisticsInformationCode()
                    Mode = "Insert"
                    ddlExisting.Visible = True
                    lblExisting.Visible = True
                    FillExistingDropDown("SELECT li_productid FROM LogisticInformation WHERE li_userid = '" & Session.Item("g_User").ToString.Trim & "' AND li_companyid = '" & g_Company & "' AND li_IsDeleted = N'0'", ddlExisting)

                Else
                    'EnableControls(False)
                    ddlExisting.Visible = False
                    lblExisting.Visible = False
                    Fill_Combo("Select Country_KId, Country_Name from Country_Master where Country_Isdeleted='0' and Country_FinancialYearId = '" & g_FinYear & "'and Country_CompanyId ='" & g_Company & "'order by Country_Name", ddlcountry)
                    ddlcountry.Items.FindByText("India").Selected = True
                    Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_FinancialYearId = '" & g_FinYear & "'and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)
                    ddlcity.Items.Add("Select")
                    ddlstate.Items.Add("Select")
                    'fillgrid()
                    'Fill_Grid("Select * From LogisticInformation where li_productid ='" & Session("ProductID").ToString() & "'and li_isdeleted ='0' and li_financialyearid ='" & g_FinYear & "'and li_CompanyId ='" & g_Company & "'and li_UserId ='" & g_User & "'", gvli)
                    'Fill_Grid("Select convert(varchar(20),li_phno1) +' '+convert(varchar(20),li_phno2) as li From LogisticInformation where li_productid ='" & Session("ProductID").ToString() & "'and li_isdeleted ='0' and li_financialyearid ='" & g_FinYear & "'and li_CompanyId ='" & g_Company & "'and li_UserId ='" & g_User & "'", gvli)
                    Fill_Gridd("SELECT LogisticInformation.Li_Kid, LogisticInformation.li_country, LogisticInformation.li_state, LogisticInformation.li_city, Product_Master.Product_Name AS ProductName, LogisticInformation.li_alprovider AS AlProvider, Country_Master.Country_Name AS CountryName, State_Master.State_Name AS StateName, City_Master.City_Name AS CityName, LogisticInformation.li_add AS LiAdd, CONVERT(varchar(20), LogisticInformation.li_phno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno3) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno4) AS PhoneNo, CONVERT(varchar(20), LogisticInformation.li_fax1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax3) AS FaxNo, LogisticInformation.li_kcpsalutation + ' ' + LogisticInformation.li_kcperson AS ContactPerson, LogisticInformation.li_jtitle AS JobTitle, CONVERT(varchar(20), LogisticInformation.li_mno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_mno2) AS MobileNo, LogisticInformation.li_userid, LogisticInformation.li_companyid, LogisticInformation.li_isDeleted, LogisticInformation.li_productid FROM LogisticInformation INNER JOIN Country_Master ON LogisticInformation.li_country = Country_Master.Country_Kid INNER JOIN State_Master ON LogisticInformation.li_state = State_Master.State_Kid INNER JOIN City_Master ON LogisticInformation.li_city = City_Master.City_Kid INNER JOIN Product_Master ON LogisticInformation.li_productid = Product_Master.Product_Kid WHERE (LogisticInformation.li_companyid = '" & g_Company & "') AND (LogisticInformation.li_isDeleted = '0') AND (LogisticInformation.li_productid = '" & Session.Item("ProductID") & "')", gvli)
                    'LI_Code = ReturnValue("Select li_Code from LogisticInformation where li_productId= '" & Session("ProductID").ToString() & "' and li_Isdeleted='0' and li_FinancialYearId = '" & g_FinYear & "'and li_CompanyId ='" & g_Company & "'and li_UserId='" & g_User & "'")
                    'LI_Kid = ReturnValue("Select li_KId from LogisticInformation where li_productId= '" & Session("ProductID").ToString() & "' and li_Isdeleted='0' and li_FinancialYearId = '" & g_FinYear & "'and li_CompanyId ='" & g_Company & "'and li_UserId='" & g_User & "'")
                    'GetExistingData()
                    'Mode = "Update"
                    EnableControls(True)
                    btnAddMore.Visible = False
                    BtnSaveCount.Visible = False
                End If
            End If
            If Session("AdminID") <> Nothing Then
                btnUpdate.Visible = True
                ddlExisting.Visible = False
                lblExisting.Visible = False

                If gvli.Rows.Count = 0 Then
                    ddlExisting.Visible = True
                    ImageButton4.Visible = True
                    lblExisting.Visible = True
                    BtnSaveCount.Visible = True
                    btnAddMore.Visible = True
                    btnUpdate.Visible = False
                End If

            Else
                btnUpdate.Visible = False
            End If
            If ddlExisting.Visible = False Then
                ImageButton4.Visible = False
                DVli.Visible = True
            Else
                DVli.Visible = False
            End If
        End If
        txtcity.Visible = False
        btnCityAdd.Visible = False
    End Sub
    Public Sub Fill_Gridd(ByVal StrQry As String, ByVal gv As GridView)
        Try
            Dim Con As New SqlConnection(ConfigurationManager.AppSettings("ConnectionString")) 'Define connection variable for connecting to SQL-Server
            If Con.State = ConnectionState.Open Then
                Con.Close()
            End If
            Con.Open()                                             'Open the Connection
            Dim cmd As New SqlCommand(StrQry, Con)                 'Define command variable to execute the query
            Dim dr As SqlDataReader                                'Define DataReader variable for storing the output of the query
            dr = cmd.ExecuteReader                                 'Assign the output of query to DataReader variable
            gv.Columns(1).Visible = True
            gv.DataSource = dr                                     'Set the DataReader Variable as DataSource for the Grid
            gv.DataBind()
            gv.Columns(1).Visible = False
            If Con.State = ConnectionState.Open Then Con.Close() ' If Connection Exists Then Close

            Con = Nothing                                        ' Set Connnection Object as nothing       
            cmd = Nothing                                        ' Set Command Object as nothing
            dr = Nothing                                         ' Set DataReader Object as nothing
        Catch ex As Exception
            ' CreateMessageAlert(gv.Page, ex.Message, "StrKeyVal")     'Display the Error Message
        End Try
    End Sub
    Public Sub FillExistingDropDown(ByVal strQuery As String, ByVal ddl As DropDownList)
        Dim dt1 As DataTable = getTable(strQuery, "PR")
        Dim i As Integer
        Dim Kid As String
        Dim KidBool As Boolean = True
        ddl.ClearSelection()
        For i = 0 To dt1.Rows.Count - 1
            If KidBool = True Then
                Kid = "'" & dt1.Rows(i).Item(0).ToString & "'"
                KidBool = False
            Else
                Kid &= ","
                Kid &= "'" & dt1.Rows(i).Item(0).ToString & "'"

            End If

        Next

        Fill_Combo("Select Product_Kid,Product_Name from Product_Master where Product_SupplierID='" & Session.Item("SupplierID").ToString.Trim & "'and Product_UserID = '" & Session.Item("g_User").ToString().Trim & "' and Product_Kid In ( " & Kid & ")", ddl)

        If ddl.Items.Count > 1 Then
            ddl.Items.Insert(ddl.Items.Count, "Add New")
            'EnableControls(False)
            lblExisting.Visible = True
        Else
            ddl.Visible = False
            lblExisting.Visible = False
            'EnableControls(True)
        End If

    End Sub

    Public Sub Clear()
        txtadd.Text = ""
        txtalprovider.Text = ""
        txtcity.Text = ""
        txteid.Text = ""
        txtfax2.Text = ""
        txtfax3.Text = ""
        txtjtitle.Text = ""
        txtkcperson.Text = ""
        txtmno2.Text = ""
        txtph2.Text = ""
        txtph3.Text = ""
        txtph4.Text = ""
        txtpinno.Text = ""
        txttffax2.Text = ""
        txttffax3.Text = ""
        txttfph2.Text = ""
        txttfph3.Text = ""
        txtwebsite.Text = ""
        ddlcity.Items.Clear()
        ddlcountry.Items.FindByText("India").Selected = True
        If ddlcountry.SelectedIndex > 0 Then
            Fill_Combo("Select State_Kid,State_Name from State_Master where State_IsDeleted='0' and state_CountryId='" & ddlcountry.SelectedValue.Trim & "'and State_CompanyId='" & g_Company.Trim & "'", ddlstate)
        End If
        'ddlstate.Items.Clear()
        ddlcity.Items.Clear()
    End Sub
    Public Sub GetExistingData()
        Dim dt As DataTable
        dt = ReturnDataTable("Select * From LogisticInformation Where li_Kid ='" & LI_Kid & "' and li_Isdeleted = '0' and li_FinancialYearId ='" & g_FinYear & "' and li_CompanyId ='" & g_Company & "'")
        txtalprovider.Text = dt.Rows(0).Item(3).ToString()
        Fill_Combo("Select Country_KId, Country_Name from Country_Master where Country_Isdeleted='0' and Country_FinancialYearId = '" & g_FinYear & "'and Country_CompanyId ='" & g_Company & "'order by Country_Name", ddlcountry)
        ddlcountry.Items.FindByValue(dt.Rows(0).Item(4).ToString()).Selected = True
        Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_FinancialYearId = '" & g_FinYear & "'and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)
        ddlstate.Items.FindByValue(dt.Rows(0).Item(5).ToString()).Selected = True
        Fill_Combo("Select City_KId, City_Name from City_Master where City_Isdeleted='0' and City_FinancialYearId = '" & g_FinYear & "'and City_StateId ='" & ddlstate.SelectedItem.Value & "' and City_CompanyId ='" & g_Company & "'order by City_Name", ddlcity)
        ddlcity.Items.FindByValue(dt.Rows(0).Item(6).ToString()).Selected = True
        ddlcity.Items.Add("-ADD NEW-")
        txtadd.Text = dt.Rows(0).Item(7).ToString()
        txtpinno.Text = dt.Rows(0).Item(8).ToString()
        txtph1.Text = dt.Rows(0).Item(9).ToString()
        txtph2.Text = dt.Rows(0).Item(10).ToString()
        txtph3.Text = dt.Rows(0).Item(11).ToString()
        txtph4.Text = dt.Rows(0).Item(12).ToString()
        txtfax1.Text = dt.Rows(0).Item(13).ToString()
        txtfax2.Text = dt.Rows(0).Item(14).ToString()
        txtfax3.Text = dt.Rows(0).Item(15).ToString()
        txttfph1.Text = dt.Rows(0).Item(16).ToString()
        txttfph2.Text = dt.Rows(0).Item(17).ToString()
        txttfph3.Text = dt.Rows(0).Item(18).ToString()
        txttffax1.Text = dt.Rows(0).Item(19).ToString()
        txttffax2.Text = dt.Rows(0).Item(20).ToString()
        txttffax3.Text = dt.Rows(0).Item(21).ToString()
        Dim str As String
        str = dt.Rows(0).Item(22).ToString()
        ddlkcperson.Items.FindByText(dt.Rows(0).Item(22).ToString()).Selected = True
        txtkcperson.Text = dt.Rows(0).Item(23).ToString()
        txtjtitle.Text = dt.Rows(0).Item(24).ToString()
        txtmno1.Text = dt.Rows(0).Item(25).ToString()
        txtmno2.Text = dt.Rows(0).Item(26).ToString()
        txtwebsite.Text = dt.Rows(0).Item(27).ToString()
        txteid.Text = dt.Rows(0).Item(28).ToString()
        If dt.Rows(0).Item(29).ToString() = "Y" Then
            rbn_yes.Checked = True
            rbn_no.Checked = False
        End If
        If dt.Rows(0).Item(29).ToString() = "N" Then
            rbn_yes.Checked = False
            rbn_no.Checked = True
        End If
        dt.Clear()

    End Sub
    Public Sub FillCategoryName(ByVal Catid As String)
        Dim dt As DataTable
        dt = ReturnDataTable("Select * From Category_Master Where Category_Kid ='" & Catid & "' and Category_Isdeleted = '0' and Category_FinancialYearId ='" & g_FinYear & "' and Category_CompanyId ='" & g_Company & "'")
        Dim ParentId As String
        ParentId = dt.Rows(0).Item(3).ToString()
        If ParentId = "Root Category" Then
            'Label1.Text += dt.Rows(0).Item(2).ToString()
            'Dim CategoryName(10) As String
            Dim j As Integer
            Category(i) = dt.Rows(0).Item(2).ToString() & "  >>  "
            'Array.Reverse(Category)
            For j = 0 To i
                Label1.Text += Category(i)
                i = i - 1
            Next
            Exit Sub
        Else
            Category(i) = dt.Rows(0).Item(2).ToString() & "  >>  "
            i = i + 1
            'Label1.Text += dt.Rows(0).Item(2).ToString() & "  >>  "
            FillCategoryName(dt.Rows(0).Item(3).ToString())
        End If
        dt.Clear()
        'GridView1.DataSource = dt
        'GridView1.DataBind()
    End Sub
    Protected Sub GenerateLogisticsInformationCode()
        Try
            Dim i As String
            Dim qry As String
            Dim code As String
            LI_Kid = NewPrimaryKey(Me)
            i = "1"
            i = Format(Val(i), "000")
            While True
                code = "LI" & "/" & Year(Date.Today) & "/" & Format(Month(Date.Today), "00") & "/" & Day(Date.Today) & "/" & i
                qry = "select count(*) from LogisticsInformation where li_Code='" & code & "'"
                If IsAlreadyPresent(qry) Then
                    i = Val(i) + 1
                    i = Format(Val(i), "000")
                Else
                    LI_Code = code
                    Exit Sub
                End If
            End While
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "StrKeyVal")     'Display the Error Message
        End Try
    End Sub

    Protected Sub BtnSkipCount_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSkipCount.Click
        Response.Redirect("StockingWarehouseinformation.aspx")
    End Sub

    Protected Sub BtnSaveCount_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnSaveCount.Click
        'Dim i As Integer
        'i=CType(txtmno2.Text, Int32)
        GenerateLogisticsInformationCode()
        If txtfax2.Text = "" Then
            txtfax2.Text = "0"
        End If
        If txtfax3.Text = "" Then
            txtfax3.Text = "0"
        End If
        Dim rad As String
        If rbn_yes.Checked = True Then
            rad = "Y"
        Else
            rad = "N"
        End If
        Dim Con As New SqlConnection
        Dim cmd As New SqlCommand
        Con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        cmd.Connection = Con
        cmd.CommandText = "LogisticInformation_Proc"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add(New SqlParameter("@li_Kid", SqlDbType.NVarChar, 10)).Value = CType(LI_Kid, String)
        cmd.Parameters.Add(New SqlParameter("@li_Code", SqlDbType.NVarChar, 25)).Value = CType(LI_Code, String)
        cmd.Parameters.Add(New SqlParameter("@li_ProductID", SqlDbType.NVarChar, 10)).Value = Session("ProductID")
        cmd.Parameters.Add(New SqlParameter("@li_alprovider", SqlDbType.NVarChar, 50)).Value = txtalprovider.Text
        cmd.Parameters.Add(New SqlParameter("@li_Country", SqlDbType.NVarChar, 10)).Value = ddlcountry.SelectedItem.Value.Trim
        cmd.Parameters.Add(New SqlParameter("@li_State", SqlDbType.NVarChar, 10)).Value = ddlstate.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_City", SqlDbType.NVarChar, 10)).Value = ddlcity.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_add", SqlDbType.NVarChar, 100)).Value = txtadd.Text
        cmd.Parameters.Add(New SqlParameter("@li_pinno", SqlDbType.Int)).Value = CType(txtpinno.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno1", SqlDbType.NVarChar, 50)).Value = txtph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_phno2", SqlDbType.Int)).Value = CType(txtph2.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno3", SqlDbType.Int)).Value = CType(txtph3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno4", SqlDbType.NVarChar, 50)).Value = txtph4.Text
        cmd.Parameters.Add(New SqlParameter("@li_fax1", SqlDbType.NVarChar, 50)).Value = txtfax1.Text
        cmd.Parameters.Add(New SqlParameter("@li_fax2", SqlDbType.Int)).Value = CType(txtfax2.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_fax3", SqlDbType.Int)).Value = CType(txtfax3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_tfphno1", SqlDbType.NVarChar, 50)).Value = txttfph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno2", SqlDbType.NVarChar, 50)).Value = txttfph2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno3", SqlDbType.NVarChar, 50)).Value = txttfph3.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax1", SqlDbType.NVarChar, 50)).Value = txttffax1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax2", SqlDbType.NVarChar, 50)).Value = txttffax2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax3", SqlDbType.NVarChar, 50)).Value = txttffax3.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcpsalutation", SqlDbType.VarChar, 50)).Value = ddlkcperson.SelectedItem.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcperson", SqlDbType.VarChar, 50)).Value = txtkcperson.Text
        cmd.Parameters.Add(New SqlParameter("@li_jtitle", SqlDbType.VarChar, 50)).Value = txtjtitle.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno1", SqlDbType.NVarChar, 50)).Value = txtmno1.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno2", SqlDbType.Decimal)).Value = CType(txtmno2.Text, Decimal)
        cmd.Parameters.Add(New SqlParameter("@li_website", SqlDbType.NVarChar, 50)).Value = txtwebsite.Text
        cmd.Parameters.Add(New SqlParameter("@li_eid", SqlDbType.NVarChar, 50)).Value = txteid.Text
        cmd.Parameters.Add(New SqlParameter("@li_odstracking", SqlDbType.NVarChar, 1)).Value = rad
        cmd.Parameters.Add(New SqlParameter("@li_FinancialYearId", SqlDbType.NVarChar, 10)).Value = g_FinYear
        cmd.Parameters.Add(New SqlParameter("@li_CompanyId", SqlDbType.NVarChar, 10)).Value = g_Company
        cmd.Parameters.Add(New SqlParameter("@li_UserId", SqlDbType.NVarChar, 10)).Value = g_User
        cmd.Parameters.Add(New SqlParameter("@FormName", SqlDbType.NVarChar, 50)).Value = "Logistics Information"
        cmd.Parameters.Add(New SqlParameter("@Mode", SqlDbType.NVarChar, 10)).Value = "Insert"
        If Con.State = ConnectionState.Open Then
            Con.Close()
        End If
        Con.Open()
        cmd.ExecuteNonQuery()
        Con.Close()
        Con.Dispose()
        Response.Redirect("StockingWarehouseinformation.aspx")
    End Sub

    Protected Sub rbn_no_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbn_no.CheckedChanged
        If rbn_no.Checked = True Then
            rbn_yes.Checked = False
        Else
            rbn_yes.Checked = False
        End If
    End Sub

    Protected Sub rbn_yes_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbn_yes.CheckedChanged
        If rbn_yes.Checked = True Then
            rbn_no.Checked = False
        Else
            rbn_no.Checked = False
        End If
    End Sub

    Protected Sub ddlcountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlcountry.SelectedIndexChanged

        txtph1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
        If txtph1.Text = "" Then
            txtph1.Enabled = True
        Else
            txtph1.Enabled = False
        End If
        txtfax1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
        If txtfax1.Text = "" Then
            txtfax1.Enabled = True
        Else
            txtfax1.Enabled = False
        End If
        txttffax1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
        If txttffax1.Text = "" Then
            txttffax1.Enabled = True
        Else
            txttffax1.Enabled = False
        End If
        txttfph1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
        If txttfph1.Text = "" Then
            txttfph1.Enabled = True
        Else
            txttfph1.Enabled = False
        End If
        txtmno1.Text = ReturnValue("Select Country_ISDCode from Country_Master where Country_Isdeleted ='0' and Country_Kid ='" & ddlcountry.SelectedItem.Value & "'and Country_CompanyId ='" & g_Company & "'")
        If txtmno1.Text = "" Then
            txtmno1.Enabled = True
        Else
            txtmno1.Enabled = False
        End If
        If ddlcountry.SelectedIndex > 0 Then
            Fill_Combo("Select State_Kid,State_Name from State_Master where State_IsDeleted='0' and state_CountryId='" & ddlcountry.SelectedValue.Trim & "'and State_CompanyId='" & g_Company.Trim & "'", ddlstate)
        End If
        ddlstate.Items.Clear()
        Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_FinancialYearId = '" & g_FinYear & "'and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)
        'ddlcity.Items.Clear()
        ddlcity.Items.Add("Select")
    End Sub

    Protected Sub ddlstate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlstate.SelectedIndexChanged
        ddlcity.Items.Clear()
        Fill_Combo("Select City_Kid,City_Name from City_Master where City_IsDeleted='0' and City_StateId='" & ddlstate.SelectedValue.Trim & "'", ddlcity)
        ddlcity.Items.Add("-ADD NEW-")
    End Sub

    Protected Sub btnCityAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCityAdd.Click
        'If (txtcity.Text = "") Then
        '    CreateMessageAlert(Me, "Please Enter City Name...!!!", "StrKeyVal")
        '    txtcity.Focus()
        '    Exit Sub
        'End If
        GenerateCityCode()
        Dim Con As New SqlConnection
        Dim cmd As New SqlCommand
        Con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        cmd.Connection = Con
        cmd.CommandText = "City_Master_Proc"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add(New SqlParameter("@City_Kid", Data.SqlDbType.NVarChar, 10)).Value = City_Kid
        cmd.Parameters.Add(New SqlParameter("@City_Code", Data.SqlDbType.NVarChar, 25)).Value = City_Code
        cmd.Parameters.Add(New SqlParameter("@City_Name", Data.SqlDbType.NVarChar, 100)).Value = txtcity.Text
        cmd.Parameters.Add(New SqlParameter("@City_StateID", Data.SqlDbType.NVarChar, 10)).Value = ddlstate.SelectedValue
        cmd.Parameters.Add(New SqlParameter("@City_CompanyID", Data.SqlDbType.NVarChar, 10)).Value = g_Company
        cmd.Parameters.Add(New SqlParameter("@City_FinancialYearId", Data.SqlDbType.NVarChar, 10)).Value = g_FinYear
        cmd.Parameters.Add(New SqlParameter("@City_UserID", Data.SqlDbType.NVarChar, 10)).Value = g_User
        cmd.Parameters.Add(New SqlParameter("@FormName", Data.SqlDbType.NVarChar, 0)).Value = Me.Title.ToString
        cmd.Parameters.Add(New SqlParameter("@Mode", Data.SqlDbType.Char, 15)).Value = "Insert"
        If Con.State = ConnectionState.Open Then
            Con.Close()
        End If
        Con.Open()
        cmd.ExecuteNonQuery()
        Con.Close()
        Con.Dispose()
        Fill_Combo("Select City_KId, City_Name from City_Master where City_Isdeleted='0' and City_FinancialYearId = '" & g_FinYear & "'and City_StateId ='" & ddlstate.SelectedItem.Value & "' and City_CompanyId ='" & g_Company & "'order by City_Name", ddlcity)
        ddlcity.Items.FindByText(txtcity.Text).Selected = True
    End Sub

    Protected Sub ddlcity_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlcity.SelectedIndexChanged
        If (ddlcity.SelectedItem.Value = "-ADD NEW-") Then
            txtcity.Visible = True
            btnCityAdd.Visible = True
        Else
            txtcity.Visible = False
            btnCityAdd.Visible = False
        End If


    End Sub

    Protected Sub GenerateCityCode()
        Try
            Dim i As String
            Dim qry As String
            Dim code As String
            City_Kid = NewPrimaryKey(Me)
            i = "1"
            i = Format(Val(i), "000")
            While True
                code = "CC" & "/" & Year(Date.Today) & "/" & Format(Month(Date.Today), "00") & "/" & Day(Date.Today) & "/" & i
                qry = "select count(*) from CityMaster where City_Code='" & code & "'"
                If IsAlreadyPresent(qry) Then
                    i = Val(i) + 1
                    i = Format(Val(i), "000")
                Else
                    City_Code = code
                    Exit Sub
                End If
            End While
        Catch ex As Exception
            CreateMessageAlert(Me, ex.Message, "StrKeyVal")     'Display the Error Message
        End Try
    End Sub


    Protected Sub btnAddMore_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddMore.Click
        If txtfax2.Text = "" Then
            txtfax2.Text = "0"
        End If
        If txtfax3.Text = "" Then
            txtfax3.Text = "0"
        End If
        Dim rad As String
        If rbn_yes.Checked = True Then
            rad = "Y"
        Else
            rad = "N"
        End If
        GenerateLogisticsInformationCode()
        Dim Con As New SqlConnection
        Dim cmd As New SqlCommand
        Con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        cmd.Connection = Con
        cmd.CommandText = "LogisticInformation_Proc"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add(New SqlParameter("@li_Kid", SqlDbType.NVarChar, 10)).Value = CType(LI_Kid, String)
        cmd.Parameters.Add(New SqlParameter("@li_Code", SqlDbType.NVarChar, 25)).Value = CType(LI_Code, String)
        cmd.Parameters.Add(New SqlParameter("@li_ProductID", SqlDbType.NVarChar, 10)).Value = Session("ProductID")
        cmd.Parameters.Add(New SqlParameter("@li_alprovider", SqlDbType.NVarChar, 50)).Value = txtalprovider.Text
        cmd.Parameters.Add(New SqlParameter("@li_Country", SqlDbType.NVarChar, 10)).Value = ddlcountry.SelectedItem.Value.Trim
        cmd.Parameters.Add(New SqlParameter("@li_State", SqlDbType.NVarChar, 10)).Value = ddlstate.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_City", SqlDbType.NVarChar, 10)).Value = ddlcity.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_add", SqlDbType.NVarChar, 100)).Value = txtadd.Text
        cmd.Parameters.Add(New SqlParameter("@li_pinno", SqlDbType.Int)).Value = CType(txtpinno.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno1", SqlDbType.NVarChar, 50)).Value = txtph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_phno2", SqlDbType.Int)).Value = CType(txtph2.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno3", SqlDbType.Int)).Value = CType(txtph3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno4", SqlDbType.NVarChar, 50)).Value = txtph4.Text
        cmd.Parameters.Add(New SqlParameter("@li_fax1", SqlDbType.NVarChar, 50)).Value = txtfax1.Text
        If txtfax2.Text = "" Then
        Else

            cmd.Parameters.Add(New SqlParameter("@li_fax2", SqlDbType.Int)).Value = CType(txtfax2.Text, Int32)
        End If
        cmd.Parameters.Add(New SqlParameter("@li_fax3", SqlDbType.Int)).Value = CType(txtfax3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_tfphno1", SqlDbType.NVarChar, 50)).Value = txttfph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno2", SqlDbType.NVarChar, 50)).Value = txttfph2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno3", SqlDbType.NVarChar, 50)).Value = txttfph3.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax1", SqlDbType.NVarChar, 50)).Value = txttffax1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax2", SqlDbType.NVarChar, 50)).Value = txttffax2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax3", SqlDbType.NVarChar, 50)).Value = txttffax3.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcpsalutation", SqlDbType.VarChar, 50)).Value = ddlkcperson.SelectedItem.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcperson", SqlDbType.VarChar, 50)).Value = txtkcperson.Text
        cmd.Parameters.Add(New SqlParameter("@li_jtitle", SqlDbType.VarChar, 50)).Value = txtjtitle.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno1", SqlDbType.NVarChar, 50)).Value = txtmno1.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno2", SqlDbType.Decimal)).Value = CType(txtmno2.Text, Decimal)
        cmd.Parameters.Add(New SqlParameter("@li_website", SqlDbType.NVarChar, 50)).Value = txtwebsite.Text
        cmd.Parameters.Add(New SqlParameter("@li_eid", SqlDbType.NVarChar, 50)).Value = txteid.Text
        cmd.Parameters.Add(New SqlParameter("@li_odstracking", SqlDbType.NVarChar, 1)).Value = rad
        cmd.Parameters.Add(New SqlParameter("@li_FinancialYearId", SqlDbType.NVarChar, 10)).Value = g_FinYear
        cmd.Parameters.Add(New SqlParameter("@li_CompanyId", SqlDbType.NVarChar, 10)).Value = g_Company
        cmd.Parameters.Add(New SqlParameter("@li_UserId", SqlDbType.NVarChar, 10)).Value = g_User
        cmd.Parameters.Add(New SqlParameter("@FormName", SqlDbType.NVarChar, 50)).Value = "Logistics Information"
        cmd.Parameters.Add(New SqlParameter("@Mode", SqlDbType.NVarChar, 10)).Value = "Insert"
        If Con.State = ConnectionState.Open Then
            Con.Close()
        End If
        Con.Open()
        cmd.ExecuteNonQuery()
        Con.Close()
        Con.Dispose()
        DVli.Visible = True
        Fill_Gridd("SELECT LogisticInformation.li_KID, LogisticInformation.li_country, LogisticInformation.li_state, LogisticInformation.li_city, Product_Master.Product_Name AS ProductName, LogisticInformation.li_alprovider AS AlProvider, Country_Master.Country_Name AS CountryName, State_Master.State_Name AS StateName, City_Master.City_Name AS CityName, LogisticInformation.li_add AS LiAdd, CONVERT(varchar(20), LogisticInformation.li_phno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno3) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno4) AS PhoneNo, CONVERT(varchar(20), LogisticInformation.li_fax1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax3) AS FaxNo, LogisticInformation.li_kcpsalutation + ' ' + LogisticInformation.li_kcperson AS ContactPerson, LogisticInformation.li_jtitle AS JobTitle, CONVERT(varchar(20), LogisticInformation.li_mno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_mno2) AS MobileNo, LogisticInformation.li_userid, LogisticInformation.li_companyid, LogisticInformation.li_isDeleted, LogisticInformation.li_productid FROM LogisticInformation INNER JOIN Country_Master ON LogisticInformation.li_country = Country_Master.Country_Kid INNER JOIN State_Master ON LogisticInformation.li_state = State_Master.State_Kid INNER JOIN City_Master ON LogisticInformation.li_city = City_Master.City_Kid INNER JOIN Product_Master ON LogisticInformation.li_productid = Product_Master.Product_Kid WHERE (LogisticInformation.li_userid = '" & g_User & "') AND (LogisticInformation.li_companyid = '" & g_Company & "') AND (LogisticInformation.li_isDeleted = '0') AND (LogisticInformation.li_productid = '" & Session.Item("ProductID") & "')", gvlii)
        Clear()
    End Sub
    Private Sub EnableControls(ByVal bool As Boolean)

        txtadd.Enabled = bool
        txtalprovider.Enabled = bool
        txtcity.Enabled = bool
        txteid.Enabled = bool
        txtfax1.Enabled = bool
        txtfax2.Enabled = bool
        txtfax3.Enabled = bool
        txtjtitle.Enabled = bool
        txtkcperson.Enabled = bool
        txtmno1.Enabled = bool


        txtmno2.Enabled = bool
        txtph1.Enabled = bool
        txtph2.Enabled = bool
        txtph3.Enabled = bool
        txtph4.Enabled = bool

        txtpinno.Enabled = bool
        txttffax1.Enabled = bool
        txttffax2.Enabled = bool
        txttffax3.Enabled = bool
        txttfph1.Enabled = bool
        txttfph2.Enabled = bool
        txttfph3.Enabled = bool
        txtwebsite.Enabled = bool
        ddlcity.ClearSelection()
        ddlcity.Enabled = bool
        ddlcountry.ClearSelection()
        ddlcountry.Enabled = bool
        ddlkcperson.Enabled = bool
        ddlstate.ClearSelection()
        ddlstate.Enabled = bool
    End Sub
    Protected Sub ddlExisting_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlExisting.SelectedIndexChanged
        If ddlExisting.SelectedIndex > 0 Then
            If ddlExisting.SelectedItem.Text = "Add New" Then
                EnableControls(True)
                Clear()
                Fill_Combo("SELECT distinct Country_Kid, Country_Name FROM Country_Master where Country_IsDeleted='0'and Country_CompanyId='" & g_Company & "' order by Country_Name", ddlcountry)
                ddlcountry.Items.FindByText("India").Selected = True
                Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_FinancialYearId = '" & g_FinYear & "'and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)
                gvli.Visible = False
                DVli.Visible = False
                GenerateLogisticsInformationCode()
            Else
                GenerateLogisticsInformationCode()
                gvli.Visible = True
                DVli.Visible = True
                EnableControls(False)
                Dim Kid As String = ddlExisting.SelectedItem.Value
                Fill_Gridd("SELECT LogisticInformation.li_KID, LogisticInformation.li_country, LogisticInformation.li_state, LogisticInformation.li_city, Product_Master.Product_Name AS ProductName, LogisticInformation.li_alprovider AS AlProvider, Country_Master.Country_Name AS CountryName, State_Master.State_Name AS StateName, City_Master.City_Name AS CityName, LogisticInformation.li_add AS LiAdd, CONVERT(varchar(20), LogisticInformation.li_phno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno3) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno4) AS PhoneNo, CONVERT(varchar(20), LogisticInformation.li_fax1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax3) AS FaxNo, LogisticInformation.li_kcpsalutation + ' ' + LogisticInformation.li_kcperson AS ContactPerson, LogisticInformation.li_jtitle AS JobTitle, CONVERT(varchar(20), LogisticInformation.li_mno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_mno2) AS MobileNo, LogisticInformation.li_userid, LogisticInformation.li_companyid, LogisticInformation.li_isDeleted, LogisticInformation.li_productid FROM LogisticInformation INNER JOIN Country_Master ON LogisticInformation.li_country = Country_Master.Country_Kid INNER JOIN State_Master ON LogisticInformation.li_state = State_Master.State_Kid INNER JOIN City_Master ON LogisticInformation.li_city = City_Master.City_Kid INNER JOIN Product_Master ON LogisticInformation.li_productid = Product_Master.Product_Kid WHERE (LogisticInformation.li_userid = '" & g_User & "') AND (LogisticInformation.li_companyid = '" & g_Company & "') AND (LogisticInformation.li_isDeleted = '0') AND (LogisticInformation.li_productid = '" & Kid & "')", gvli)
                'GetDataTable()
                
            End If
        Else
            EnableControls(False)
            Clear()
            DVli.Visible = False
        End If
    End Sub

    Protected Sub gvli_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvli.SelectedIndexChanged

        EnableControls(True)
        Dim dt As DataTable
        dt = ReturnDataTable("Select * From LogisticInformation Where li_Kid ='" & RemoveLiterals(gvli.SelectedRow.Cells(1).Text.ToString.Trim) & "' and li_Isdeleted = '0' and li_CompanyId ='" & g_Company & "'")
        LI_Kid = dt.Rows(0).Item("li_Kid").ToString()
        LI_Code = dt.Rows(0).Item("Li_Code").ToString()
        txtalprovider.Text = dt.Rows(0).Item(3).ToString()
        Fill_Combo("Select Country_KId, Country_Name from Country_Master where Country_Isdeleted='0' and Country_CompanyId ='" & g_Company & "'order by Country_Name", ddlcountry)
        ddlcountry.ClearSelection()
        Try
            ddlcountry.Items.FindByValue(dt.Rows(0).Item(4).ToString()).Selected = True
        Catch ex As Exception

        End Try
        Fill_Combo("Select State_KId, State_Name from State_Master where State_CountryId ='" & ddlcountry.SelectedItem.Value & "'and State_Isdeleted='0' and State_CompanyId ='" & g_Company & "'order by State_Name", ddlstate)
        ddlstate.ClearSelection()
        Try
            ddlstate.Items.FindByValue(dt.Rows(0).Item(5).ToString()).Selected = True
        Catch ex As Exception

        End Try
        Fill_Combo("Select City_KId, City_Name from City_Master where City_Isdeleted='0' and City_StateId ='" & ddlstate.SelectedItem.Value & "' and City_CompanyId ='" & g_Company & "'order by City_Name", ddlcity)
        ddlcity.ClearSelection()
        Try
            ddlcity.Items.FindByValue(dt.Rows(0).Item(6).ToString()).Selected = True
        Catch ex As Exception

        End Try
        ddlcity.Items.Add("-ADD NEW-")
        txtadd.Text = dt.Rows(0).Item(7).ToString()
        txtpinno.Text = dt.Rows(0).Item(8).ToString()
        txtph1.Text = dt.Rows(0).Item(9).ToString()
        txtph2.Text = dt.Rows(0).Item(10).ToString()
        txtph3.Text = dt.Rows(0).Item(11).ToString()
        txtph4.Text = dt.Rows(0).Item(12).ToString()
        txtfax1.Text = dt.Rows(0).Item(13).ToString()
        Try
            If dt.Rows(0).Item(14) = "0" Then
                txtfax2.Text = ""
            Else
                txtfax2.Text = dt.Rows(0).Item(14).ToString()
            End If
        Catch ex As Exception
            txtfax2.Text = ""
        End Try
        Try
            If dt.Rows(0).Item(15) = "0" Then
                txtfax2.Text = ""
            Else
                txtfax3.Text = dt.Rows(0).Item(15).ToString()
            End If
        Catch ex As Exception
            txtfax3.Text = ""
        End Try

        txttfph1.Text = dt.Rows(0).Item(16).ToString()
        txttfph2.Text = dt.Rows(0).Item(17).ToString()
        txttfph3.Text = dt.Rows(0).Item(18).ToString()
        txttffax1.Text = dt.Rows(0).Item(19).ToString()
        txttffax2.Text = dt.Rows(0).Item(20).ToString()
        txttffax3.Text = dt.Rows(0).Item(21).ToString()
        Dim str As String
        str = dt.Rows(0).Item(22).ToString()
        Try
            ddlkcperson.Items.FindByText(dt.Rows(0).Item(22).ToString()).Selected = True
        Catch ex As Exception
            ddlkcperson.ClearSelection()
        End Try
        txtkcperson.Text = dt.Rows(0).Item(23).ToString()
        txtjtitle.Text = dt.Rows(0).Item(24).ToString()
        txtmno1.Text = dt.Rows(0).Item(25).ToString()
        txtmno2.Text = dt.Rows(0).Item(26).ToString()
        txtwebsite.Text = dt.Rows(0).Item(27).ToString()
        txteid.Text = dt.Rows(0).Item(28).ToString()
        If dt.Rows(0).Item(29).ToString() = "Y" Then
            rbn_yes.Checked = True
            rbn_no.Checked = False
        End If
        If dt.Rows(0).Item(29).ToString() = "N" Then
            rbn_yes.Checked = False
            rbn_no.Checked = True
        End If
        dt.Clear()

    End Sub

    Protected Sub gvlii_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvlii.SelectedIndexChanged

    End Sub

    Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        If txtfax2.Text = "" Then
            txtfax2.Text = "0"
        End If
        If txtfax3.Text = "" Then
            txtfax3.Text = "0"
        End If
        Dim rad As String
        If rbn_yes.Checked = True Then
            rad = "Y"
        Else
            rad = "N"
        End If
        Dim Con As New SqlConnection
        Dim cmd As New SqlCommand
        Con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
        cmd.Connection = Con
        cmd.CommandText = "LogisticInformation_Proc"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add(New SqlParameter("@li_Kid", SqlDbType.NVarChar, 10)).Value = CType(LI_Kid, String)
        cmd.Parameters.Add(New SqlParameter("@li_Code", SqlDbType.NVarChar, 25)).Value = CType(LI_Code, String)
        cmd.Parameters.Add(New SqlParameter("@li_ProductID", SqlDbType.NVarChar, 10)).Value = Session("ProductID")
        cmd.Parameters.Add(New SqlParameter("@li_alprovider", SqlDbType.NVarChar, 50)).Value = txtalprovider.Text
        cmd.Parameters.Add(New SqlParameter("@li_Country", SqlDbType.NVarChar, 10)).Value = ddlcountry.SelectedItem.Value.Trim
        cmd.Parameters.Add(New SqlParameter("@li_State", SqlDbType.NVarChar, 10)).Value = ddlstate.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_City", SqlDbType.NVarChar, 10)).Value = ddlcity.SelectedItem.Value
        cmd.Parameters.Add(New SqlParameter("@li_add", SqlDbType.NVarChar, 100)).Value = txtadd.Text
        cmd.Parameters.Add(New SqlParameter("@li_pinno", SqlDbType.Int)).Value = CType(txtpinno.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno1", SqlDbType.NVarChar, 50)).Value = txtph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_phno2", SqlDbType.Int)).Value = CType(txtph2.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno3", SqlDbType.Int)).Value = CType(txtph3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_phno4", SqlDbType.NVarChar, 50)).Value = txtph4.Text
        cmd.Parameters.Add(New SqlParameter("@li_fax1", SqlDbType.NVarChar, 50)).Value = txtfax1.Text
        If txtfax2.Text = "" Then
        Else

            cmd.Parameters.Add(New SqlParameter("@li_fax2", SqlDbType.Int)).Value = CType(txtfax2.Text, Int32)
        End If
        cmd.Parameters.Add(New SqlParameter("@li_fax3", SqlDbType.Int)).Value = CType(txtfax3.Text, Int32)
        cmd.Parameters.Add(New SqlParameter("@li_tfphno1", SqlDbType.NVarChar, 50)).Value = txttfph1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno2", SqlDbType.NVarChar, 50)).Value = txttfph2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tfphno3", SqlDbType.NVarChar, 50)).Value = txttfph3.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax1", SqlDbType.NVarChar, 50)).Value = txttffax1.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax2", SqlDbType.NVarChar, 50)).Value = txttffax2.Text
        cmd.Parameters.Add(New SqlParameter("@li_tffax3", SqlDbType.NVarChar, 50)).Value = txttffax3.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcpsalutation", SqlDbType.VarChar, 50)).Value = ddlkcperson.SelectedItem.Text
        cmd.Parameters.Add(New SqlParameter("@li_kcperson", SqlDbType.VarChar, 50)).Value = txtkcperson.Text
        cmd.Parameters.Add(New SqlParameter("@li_jtitle", SqlDbType.VarChar, 50)).Value = txtjtitle.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno1", SqlDbType.NVarChar, 50)).Value = txtmno1.Text
        cmd.Parameters.Add(New SqlParameter("@li_mno2", SqlDbType.Decimal)).Value = CType(txtmno2.Text, Decimal)
        cmd.Parameters.Add(New SqlParameter("@li_website", SqlDbType.NVarChar, 50)).Value = txtwebsite.Text
        cmd.Parameters.Add(New SqlParameter("@li_eid", SqlDbType.NVarChar, 50)).Value = txteid.Text
        cmd.Parameters.Add(New SqlParameter("@li_odstracking", SqlDbType.NVarChar, 1)).Value = rad
        cmd.Parameters.Add(New SqlParameter("@li_FinancialYearId", SqlDbType.NVarChar, 10)).Value = g_FinYear
        cmd.Parameters.Add(New SqlParameter("@li_CompanyId", SqlDbType.NVarChar, 10)).Value = g_Company
        cmd.Parameters.Add(New SqlParameter("@li_UserId", SqlDbType.NVarChar, 10)).Value = g_User
        cmd.Parameters.Add(New SqlParameter("@FormName", SqlDbType.NVarChar, 50)).Value = "Logistics Information"
        cmd.Parameters.Add(New SqlParameter("@Mode", SqlDbType.NVarChar, 10)).Value = "Update"
        If Con.State = ConnectionState.Open Then
            Con.Close()
        End If
        Con.Open()
        cmd.ExecuteNonQuery()
        Con.Close()
        Con.Dispose()
        CreateMessageAlert(Me, "Record Was Successfully Updated.", "StrKeyVal")
        Fill_Gridd("SELECT LogisticInformation.li_KID, LogisticInformation.li_country, LogisticInformation.li_state, LogisticInformation.li_city, Product_Master.Product_Name AS ProductName, LogisticInformation.li_alprovider AS AlProvider, Country_Master.Country_Name AS CountryName, State_Master.State_Name AS StateName, City_Master.City_Name AS CityName, LogisticInformation.li_add AS LiAdd, CONVERT(varchar(20), LogisticInformation.li_phno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno3) + ' ' + CONVERT(varchar(20), LogisticInformation.li_phno4) AS PhoneNo, CONVERT(varchar(20), LogisticInformation.li_fax1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax2) + ' ' + CONVERT(varchar(20), LogisticInformation.li_fax3) AS FaxNo, LogisticInformation.li_kcpsalutation + ' ' + LogisticInformation.li_kcperson AS ContactPerson, LogisticInformation.li_jtitle AS JobTitle, CONVERT(varchar(20), LogisticInformation.li_mno1) + ' ' + CONVERT(varchar(20), LogisticInformation.li_mno2) AS MobileNo, LogisticInformation.li_userid, LogisticInformation.li_companyid, LogisticInformation.li_isDeleted, LogisticInformation.li_productid FROM LogisticInformation INNER JOIN Country_Master ON LogisticInformation.li_country = Country_Master.Country_Kid INNER JOIN State_Master ON LogisticInformation.li_state = State_Master.State_Kid INNER JOIN City_Master ON LogisticInformation.li_city = City_Master.City_Kid INNER JOIN Product_Master ON LogisticInformation.li_productid = Product_Master.Product_Kid WHERE (LogisticInformation.li_userid = '" & g_User & "') AND (LogisticInformation.li_companyid = '" & g_Company & "') AND (LogisticInformation.li_isDeleted = '0') AND (LogisticInformation.li_productid = '" & Session.Item("ProductID") & "')", gvli)
        Clear()
    End Sub
End Class
