Imports System
Imports System.Data
Imports System.Data.SqlClient

Partial Class Product_TOF
    Inherits System.Web.UI.Page
    Shared Category1(50) As String
    Shared i As Integer
    Shared g_User As String
    Shared g_Company As String
    Shared g_FinYear As String
    Dim strcon As String = ConfigurationSettings.AppSettings.Item("ConnectionString")
    Dim con As New SqlConnection(strcon)
    Dim cmd As New SqlCommand
    Dim dr As SqlDataReader
    Shared TaxKid As String
    'Shared Session("ProductID").ToString.Trim As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Session("SupplierID") Is Nothing And Session("AdminID") = Nothing Then
                tblerror.Visible = True
                TABLE1.Visible = False
                Table2.Visible = False
                btnclose1.Attributes.Add("onclick", "javascript:window.close();")

                Exit Sub
            End If
            tblerror.Visible = False
            TABLE1.Visible = True
            Table2.Visible = False
            If Not IsPostBack Then
                i = 0
                'rwTaxEntry.Visible = False
                'rwTaxGrid.Visible = False

                'g_User = Session("g_User").ToString
                'g_Company = Session("g_Company").ToString
                'g_FinYear = Session("g_FinYear").ToString
                'Session("ProductID").ToString.Trim = Session("ProductID").ToString.Trim
                'GetExisting()
                'PageLoadData()

                If (Request.QueryString("Product") <> Nothing) Then
                    Session("ProductID") = Request.QueryString("Product").ToString
                End If

                txtjCSTAgainstCForm.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtjEduCess.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtjExciseDuty.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtjHigherEduCess.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtjVat.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtjCST.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                txtOtherCharges.Attributes.Add("onkeypress", "return CheckNumericValue(event)")
                btnClose.Attributes.Add("onclick", "javascript:window.close();")
                btnContinue.Attributes.Add("onclick", "javascript:window.close();")
                btncls.Attributes.Add("onclick", "javascript:window.close();")

                ''lblhelp.Attributes.Add("onmouseover", "fixedtooltip('Hello <BR/> Shahid <BR/> Vora',this,event,'100px');")
                ''lblhelp.Attributes.Add("onmouseout", "delayhidetip();")
                '' lblhelp.Attributes.Add("onmouseover", "fixedtooltip('" & mycategory & "',this,event,'200px');")
                'Dim id As String = Session("SupplierID")
                If Session("SupplierID") Is Nothing Then
                    Response.Redirect("listproduct.aspx")
                End If

                If Session("ProductID") Is Nothing Then
                    ' Response.Redirect("list_product.aspx")
                    TABLE1.Visible = False
                    Table2.Visible = True
                    tblerror.Visible = False
                Else
                    GetExistingVat()
                End If



                'If Session("AdminID") = Nothing Then
                '    'ControlDisable(False)

                '    'gvSuppRegTax.Columns(0).Visible = False
                '    ' gvSuppOct.Columns(0).Visible = False
                '    ' gvSuppFre.Columns(0).Visible = False
                '    'btnSuppRegNewTax.Visible = True
                '    ' btnSuppOctNew.Visible = True
                '    ' btnSuppFreNew.Visible = True
                'Else
                '    ControlDisable(True)

                '    'gvSuppRegTax.Columns(0).Visible = True
                '    '  gvSuppOct.Columns(0).Visible = True
                '    '     gvSuppFre.Columns(0).Visible = True
                '    'btnSuppRegNewTax.Visible = False
                '    '   btnSuppOctNew.Visible = False
                '    '    btnSuppFreNew.Visible = False
                'End If

            End If
            lblMSG.Visible = False
        Catch
        End Try
    End Sub

    Public Sub GetExistingVat()
        Dim dt As DataTable
        dt = ReturnDataTable("Select * From ProductVat where ProductVat_ProductId ='" & Session("ProductID").ToString() & "'")
        If dt.Rows.Count > 0 Then

            If IsDBNull(dt.Rows(0).Item("ProductVat_ITCHSCode")) Or dt.Rows(0).Item("ProductVat_ITCHSCode").ToString = "" Then
            Else
                lbljITCHCode.Visible = True
                txtjITCHCode.Visible = False
                lbljITCHCode.Text = dt.Rows(0).Item("ProductVat_ITCHSCode").ToString()
                lnkjITCHCode.Visible = False
                lnkjITCHCode.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjITCHCode.Visible = True
                    lnkjITCHCode.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_BTNNo")) Or dt.Rows(0).Item("ProductVat_BTNNo").ToString = "" Then
            Else
                lbljBTNNo.Visible = True
                txtjBTNNo.Visible = False
                lbljBTNNo.Text = dt.Rows(0).Item("ProductVat_BTNNo").ToString()
                lnkjBTNNo.Visible = False
                lnkjBTNNo.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjBTNNo.Visible = True
                    lnkjBTNNo.Text = "Edit"
                End If
            End If


            If IsDBNull(dt.Rows(0).Item("ProductVat_ExciseDateRemark")) Or dt.Rows(0).Item("ProductVat_ExciseDateRemark").ToString = "" Then
            Else
                lbljExciseDateRemarks.Visible = True
                txtjExciseDateRemarks.Visible = False
                lbljExciseDateRemarks.Text = dt.Rows(0).Item("ProductVat_ExciseDateRemark").ToString()
                lnkjExciseDateRemarks.Visible = False
                lnkjExciseDateRemarks.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjExciseDateRemarks.Visible = True
                    lnkjExciseDateRemarks.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_SalesTaxRemark")) Or dt.Rows(0).Item("ProductVat_SalesTaxRemark").ToString = "" Then
            Else
                lbljSalesTaxRemarks.Visible = True
                txtjSalesTaxRemarks.Visible = False
                lbljSalesTaxRemarks.Text = dt.Rows(0).Item("ProductVat_SalesTaxRemark").ToString()
                lnkjSalesTaxRemarks.Visible = False
                lnkjSalesTaxRemarks.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjSalesTaxRemarks.Visible = True
                    lnkjSalesTaxRemarks.Text = "Edit"
                End If
            End If


            If IsDBNull(dt.Rows(0).Item("ProductVat_ExciseDuty")) Or dt.Rows(0).Item("ProductVat_ExciseDuty").ToString = "" Then
                lnkjExciseDuty.CausesValidation = False
                txtjExciseDuty.Enabled = False
            Else
                lnkjExciseDuty.CausesValidation = False
                lbljExciseDuty.Visible = True
                txtjExciseDuty.Visible = False
                If dt.Rows(0).Item("ProductVat_ExciseDuty").ToString() = "No" Then
                    lbljExciseDuty.Visible = False
                    Label2.Visible = False
                    rbljIsExciseDuty.SelectedValue = "No"
                Else
                    rbljIsExciseDuty.SelectedValue = "Yes"
                End If
                rbljIsExciseDuty.Enabled = False
                lbljExciseDuty.Text = dt.Rows(0).Item("ProductVat_ExciseDuty").ToString()
                lnkjExciseDuty.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjExciseDuty.Visible = True
                    lnkjExciseDuty.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_EduCess")) Or dt.Rows(0).Item("ProductVat_EduCess").ToString = "" Then
                lnkjEduCess.CausesValidation = False
                txtjEduCess.Enabled = False
            Else
                lnkjEduCess.CausesValidation = False
                lbljEduCess.Visible = True
                txtjEduCess.Visible = False
                If dt.Rows(0).Item("ProductVat_EduCess").ToString() = "No" Then
                    rbljIsEduCess.SelectedValue = "No"
                    Label6.Visible = False
                    lbljEduCess.Visible = False
                Else
                    rbljIsEduCess.SelectedValue = "Yes"
                End If
                rbljIsEduCess.Enabled = False
                lbljEduCess.Text = dt.Rows(0).Item("ProductVat_EduCess").ToString()
                lnkjEduCess.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjEduCess.Visible = True
                    lnkjEduCess.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_HigherEduCess")) Or dt.Rows(0).Item("ProductVat_HigherEduCess").ToString = "" Then
                lnkjHigherEduCess.CausesValidation = False
                txtjHigherEduCess.Enabled = False
            Else
                lnkjHigherEduCess.CausesValidation = False
                lbljHigherEduCess.Visible = True
                txtjHigherEduCess.Visible = False
                If dt.Rows(0).Item("ProductVat_HigherEduCess").ToString() = "No" Then
                    rbljIsHigherEduCess.SelectedValue = "No"
                    Label7.Visible = False
                    lbljHigherEduCess.Visible = False
                Else
                    rbljIsHigherEduCess.SelectedValue = "Yes"
                End If
                rbljIsHigherEduCess.Enabled = False
                lbljHigherEduCess.Text = dt.Rows(0).Item("ProductVat_HigherEduCess").ToString()
                lnkjHigherEduCess.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjHigherEduCess.Visible = True
                    lnkjHigherEduCess.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_Vat")) Or dt.Rows(0).Item("ProductVat_Vat").ToString = "" Then
                lnkjVat.CausesValidation = False
                txtjVat.Enabled = False
            Else
                lnkjVat.CausesValidation = False
                lbljVat.Visible = True
                txtjVat.Visible = False
                If dt.Rows(0).Item("ProductVat_Vat").ToString() = "No" Then
                    rbljIsVat.SelectedValue = "No"
                    Label9.Visible = False
                    lbljVat.Visible = False
                Else
                    rbljIsVat.SelectedValue = "Yes"
                End If
                rbljIsVat.Enabled = False
                lbljVat.Text = dt.Rows(0).Item("ProductVat_Vat").ToString()
                lnkjVat.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjVat.Visible = True
                    lnkjVat.Text = "Edit"
                End If
            End If


            If IsDBNull(dt.Rows(0).Item("ProductVat_CSTAgainstC")) Or dt.Rows(0).Item("ProductVat_CSTAgainstC").ToString = "" Then
                lnkjCSTAgainstCForm.CausesValidation = False
                txtjCSTAgainstCForm.Enabled = False
            Else
                lnkjCSTAgainstCForm.CausesValidation = False
                lbljCSTAgainstCForm.Visible = True
                txtjCSTAgainstCForm.Visible = False
                If dt.Rows(0).Item("ProductVat_CSTAgainstC").ToString() = "No" Then
                    rbljIsCSTAgainstCForm.SelectedValue = "No"
                    Label11.Visible = False
                    lbljCSTAgainstCForm.Visible = False
                Else
                    rbljIsCSTAgainstCForm.SelectedValue = "Yes"
                End If
                rbljIsCSTAgainstCForm.Enabled = False
                lbljCSTAgainstCForm.Text = dt.Rows(0).Item("ProductVat_CSTAgainstC").ToString()
                lnkjCSTAgainstCForm.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjCSTAgainstCForm.Visible = True
                    lnkjCSTAgainstCForm.Text = "Edit"
                End If
            End If

            If IsDBNull(dt.Rows(0).Item("ProductVat_CST")) Or dt.Rows(0).Item("ProductVat_CST").ToString = "" Then
                lnkjCST.CausesValidation = False
                txtjCST.Enabled = False
            Else
                lnkjCST.CausesValidation = False
                lbljCST.Visible = True
                txtjCST.Visible = False
                If dt.Rows(0).Item("ProductVat_CST").ToString() = "No" Then
                    rbljIsCST.SelectedValue = "No"
                    Label10.Visible = False
                    lbljCST.Visible = False
                Else
                    rbljIsCST.SelectedValue = "Yes"
                End If
                rbljIsCST.Enabled = False
                lbljCST.Text = dt.Rows(0).Item("ProductVat_CST").ToString()
                lnkjCST.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjCST.Visible = True
                    lnkjCST.Text = "Edit"
                End If
            End If

            'for Other Charges
            If IsDBNull(dt.Rows(0).Item("ProductVat_OtherCharges")) Or dt.Rows(0).Item("ProductVat_OtherCharges").ToString = "" Then
                lnkOtherCharges.CausesValidation = False
                txtOtherCharges.Enabled = False
            Else
                lnkOtherCharges.CausesValidation = False
                lblOtherCharges.Visible = True
                txtOtherCharges.Visible = False
                If dt.Rows(0).Item("ProductVat_OtherCharges").ToString() = "No" Then
                    rdbIsOtherCharges.SelectedValue = "No"
                    Label3.Visible = False
                    lbljCST.Visible = False
                    lblOtherCharges.Visible = False
                Else
                    rdbIsOtherCharges.SelectedValue = "Yes"
                    lblOtherCharges.Visible = True
                End If
                rdbIsOtherCharges.Enabled = False
                lblOtherCharges.Text = dt.Rows(0).Item("ProductVat_OtherCharges").ToString()
                lnkOtherCharges.Visible = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkOtherCharges.Visible = True
                    lnkOtherCharges.Text = "Edit"
                End If
            End If


            'other Charges Remarks
            If IsDBNull(dt.Rows(0).Item("ProductVat_OtherChargesRemark")) Or dt.Rows(0).Item("ProductVat_OtherChargesRemark").ToString = "" Then

                txtOtherChargesRemark.Enabled = False
            Else
                lblOtherChargeRemarks.Visible = True
                txtOtherChargesRemark.Visible = False

                If lblOtherCharges.Text <> "" And lblOtherCharges.Text <> "No" Then
                    lblOtherChargeRemarks.Text = dt.Rows(0).Item("ProductVat_OtherChargesRemark").ToString()
                Else
                    lblOtherChargeRemarks.Text = ""
                End If


            End If

            Dim check As String
            check = ReturnValue("Select ProductVat_ExciseDuty from ProductVat where ProductVat_ProductId ='" & Session("ProductId") & "' and ProductVat_Isdeleted ='0'")

            If check.ToString = "" Or check.ToString = "No" Then
                lnkjEduCess.Enabled = False
                lnkjHigherEduCess.Enabled = False
                rbljIsEduCess.Enabled = False
                rbljIsHigherEduCess.Enabled = False
                'showmessage("First Check Excise Duty Yes.", lblMSG)
                Exit Sub
            End If


        Else
            lnkjEduCess.Enabled = False
            lnkjHigherEduCess.Enabled = False
            rbljIsEduCess.Enabled = False
            rbljIsHigherEduCess.Enabled = False

            txtjCST.Enabled = False
            txtjCSTAgainstCForm.Enabled = False
            txtjEduCess.Enabled = False
            txtjExciseDuty.Enabled = False
            txtjHigherEduCess.Enabled = False
            txtjVat.Enabled = False
            txtOtherCharges.Enabled = False
            txtOtherChargesRemark.Enabled = False
            lnkjCST.CausesValidation = False
            lnkjCSTAgainstCForm.CausesValidation = False
            lnkjEduCess.CausesValidation = False
            lnkjExciseDuty.CausesValidation = False
            lnkjHigherEduCess.CausesValidation = False
            lnkjVat.CausesValidation = False
            lnkOtherCharges.CausesValidation = False




        End If


    End Sub

    'Public Sub GetExisting()
    '    Try

    '        Dim dt As DataTable = ReturnDataTable("Select * From Product_Master Where Product_SupplierID = '" & Session("SupplierID").ToString & "'and Product_Kid = '" & Session("ProductID").ToString.Trim & "'and Product_IsDeleted = '0'")
    '        System.Threading.Thread.Sleep(1000)
    '        If dt.Rows.Count > 0 Then
    '            lblCat.Text = ""
    '            FillCategoryName(RemoveLiterals(dt.Rows(0).Item("Product_CategoryId").ToString.Trim))
    '            Try
    '                If IsDBNull(dt.Rows(0).Item("Product_Image")) Or dt.Rows(0).Item("Product_Image").ToString = "" Then
    '                Else
    '                    imgProduct.ImageUrl = "~\Upload Image\Product Image\UploadImages\" & dt.Rows(0).Item("Product_Image").ToString()
    '                    Dim imgpath As String
    '                    imgpath = Server.MapPath(imgProduct.ImageUrl)
    '                    KeepAspectRatioNew(imgProduct, imgpath, 208, 176)

    '                End If
    '            Catch
    '            End Try

    '            Try
    '                If IsDBNull(dt.Rows(0).Item("Product_Code")) Or dt.Rows(0).Item("Product_Code").ToString = "" Then
    '                Else
    '                    Label4.Text = dt.Rows(0).Item("Product_Code").ToString()
    '                End If
    '            Catch
    '            End Try

    '            If IsDBNull(dt.Rows(0).Item("Product_Name")) Or dt.Rows(0).Item("Product_Name").ToString = "" Then
    '            Else
    '                Label8.Text = dt.Rows(0).Item("Product_Name").ToString()
    '            End If


    '            If IsDBNull(dt.Rows(0).Item("Product_MarketPriceType")) Or dt.Rows(0).Item("Product_MarketPriceType").ToString = "" Then
    '            Else
    '                Try
    '                    Label43.Text = ReturnValue("Select Unit_Name from Unit_Master where Unit_Kid ='" & dt.Rows(0).Item("Product_MarketPriceType").ToString() & "'and Unit_IsDeleted ='0'")
    '                Catch
    '                End Try

    '            End If

    '            If IsDBNull(dt.Rows(0).Item("Product_MarketPrice")) Or dt.Rows(0).Item("Product_MarketPrice").ToString = "" Then
    '            Else
    '                Label43.Text += "  " & dt.Rows(0).Item("Product_MarketPrice").ToString()

    '            End If

    '            If IsDBNull(dt.Rows(0).Item("Product_AtcoPriceType")) Or dt.Rows(0).Item("Product_AtcoPriceType").ToString = "" Then
    '            Else
    '                Try

    '                    Label45.Text = ReturnValue("Select Unit_Name from Unit_Master where Unit_Kid ='" & dt.Rows(0).Item("Product_AtcoPriceType").ToString() & "'and Unit_IsDeleted ='0'")

    '                Catch
    '                End Try
    '            End If


    '            If IsDBNull(dt.Rows(0).Item("Product_AtcoPrice")) Or dt.Rows(0).Item("Product_AtcoPrice").ToString = "" Then
    '            Else
    '                Label45.Text += "  " & dt.Rows(0).Item("Product_AtcoPrice").ToString()
    '            End If

    '            If IsDBNull(dt.Rows(0).Item("Product_BrandId")) Or dt.Rows(0).Item("Product_BrandId").ToString = "" Then
    '            Else
    '                Try
    '                    Label47.Text = ReturnValue("Select Brand_Name from Brand_Master where Brand_Kid ='" & dt.Rows(0).Item("Product_BrandId").ToString() & "'and Brand_IsDeleted ='0'")

    '                Catch ex As Exception
    '                End Try
    '            End If

    '            If IsDBNull(dt.Rows(0).Item("Product_ModelNo")) Or dt.Rows(0).Item("Product_ModelNo").ToString = "" Then

    '            Else
    '                Label49.Text = dt.Rows(0).Item("Product_ModelNo").ToString()

    '            End If

    '        End If
    '    Catch
    '    End Try
    'End Sub
    'Public Sub FillCategoryName(ByVal Catid As String)
    '    Dim dt As DataTable
    '    dt = ReturnDataTable("Select Category_name, category_parentid From Category_Master Where Category_Kid ='" & Catid & "' and Category_Isdeleted = '0' and Category_CompanyId ='" & Session("g_Company").ToString & "'")
    '    If dt.Rows.Count > 0 Then
    '        Dim ParentId As String
    '        ParentId = dt.Rows(0).Item("category_parentid").ToString()
    '        If ParentId = "Root Category" Then
    '            'Label1.Text += dt.Rows(0).Item(2).ToString()
    '            'Dim CategoryName(10) As String
    '            Dim j As Integer
    '            Category1(i) = dt.Rows(0).Item("Category_name").ToString() & "  >  "
    '            'Array.Reverse(Category)
    '            For j = 0 To i
    '                lblCat.Text += Category1(i)
    '                i = i - 1
    '            Next
    '            Exit Sub
    '        Else
    '            Category1(i) = dt.Rows(0).Item("Category_name").ToString() & "  >  "
    '            i = i + 1
    '            'Label1.Text += dt.Rows(0).Item(2).ToString() & "  >  "
    '            FillCategoryName(dt.Rows(0).Item("category_parentid").ToString())
    '        End If
    '    Else
    '        lblCat.Text = ""
    '        lblCat.Visible = False
    '    End If

    '    'GridView1.DataSource = dt
    '    'GridView1.DataBind()
    'End Sub

    Protected Sub lnkjITCHCode_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjITCHCode.Click
        Try
            If lnkjITCHCode.Text = "Edit" Then
                txtjITCHCode.Visible = True
                lbljITCHCode.Visible = False
                txtjITCHCode.Text = lbljITCHCode.Text
                lnkjITCHCode.Text = "Update"
                lnkjITCHCode.CausesValidation = True
            Else
                If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                    ExecuteQuery("Update ProductVat Set ProductVat_ITCHSCode = '" & txtjITCHCode.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    System.Threading.Thread.Sleep(1000)
                Else
                    ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_ITCHSCode, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjITCHCode.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    System.Threading.Thread.Sleep(1000)
                End If
                lbljITCHCode.Visible = True
                lbljITCHCode.Text = ReturnValue("Select ProductVat_ITCHSCode from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjITCHCode.Visible = False
                lnkjITCHCode.Visible = False
                lnkjITCHCode.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjITCHCode.Text = "Edit"
                    lnkjITCHCode.Visible = True
                End If
            
            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try
    End Sub

    Protected Sub rbljIsExciseDuty_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsExciseDuty.SelectedIndexChanged

        If rbljIsExciseDuty.SelectedValue = "Yes" Then
            lnkjExciseDuty.CausesValidation = True
            txtjExciseDuty.Enabled = True
            txtjExciseDuty.Text = ""
            requiredexciseduty.InitialValue = ""
        Else
            lnkjExciseDuty.CausesValidation = False
            txtjExciseDuty.Enabled = False
            txtjExciseDuty.Text = "Excise Duty"
            requiredexciseduty.InitialValue = "Excise Duty"
        End If

    End Sub

    Protected Sub rbljIsEduCess_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsEduCess.SelectedIndexChanged

        If rbljIsEduCess.SelectedValue = "Yes" Then
            lnkjEduCess.CausesValidation = True
            txtjEduCess.Enabled = True
            requiredEduCess.InitialValue = ""
            txtjEduCess.Text = ""

        Else
            lnkjEduCess.CausesValidation = False
            txtjEduCess.Enabled = False
            requiredEduCess.InitialValue = "Education Cess"
            txtjEduCess.Text = "Education Cess"
        End If

    End Sub

    Protected Sub rbljIsHigherEduCess_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsHigherEduCess.SelectedIndexChanged

        If rbljIsHigherEduCess.SelectedValue = "Yes" Then
            lnkjHigherEduCess.CausesValidation = True
            txtjHigherEduCess.Enabled = True
            txtjHigherEduCess.Text = ""
            requiredHigherEdu.InitialValue = ""
        Else
            lnkjHigherEduCess.CausesValidation = False
            txtjHigherEduCess.Enabled = False
            txtjHigherEduCess.Text = "Higher Edu Cess"
            requiredHigherEdu.InitialValue = "Higher Edu Cess"
        End If


    End Sub

    Protected Sub rbljIsVat_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsVat.SelectedIndexChanged

        If rbljIsVat.SelectedValue = "Yes" Then
            lnkjVat.CausesValidation = True
            txtjVat.Enabled = True
            txtjVat.Text = ""
            requiredVAT.InitialValue = ""

        Else
            lnkjVat.CausesValidation = False
            txtjVat.Enabled = False
            txtjVat.Text = "VAT"
            requiredVAT.InitialValue = "VAT"
        End If


    End Sub

    Protected Sub rbljIsCST_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsCST.SelectedIndexChanged

        If rbljIsCST.SelectedValue = "Yes" Then
            lnkjCST.CausesValidation = True
            txtjCST.Enabled = True
            txtjCST.Text = ""
            requiredCST.InitialValue = ""

        Else
            lnkjCST.CausesValidation = False
            txtjCST.Enabled = False
            txtjCST.Text = "CST"
            requiredCST.InitialValue = "CST"
        End If

    End Sub

    Protected Sub rbljIsCSTAgainstCForm_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbljIsCSTAgainstCForm.SelectedIndexChanged

        If rbljIsCSTAgainstCForm.SelectedValue = "Yes" Then
            lnkjCSTAgainstCForm.CausesValidation = True
            txtjCSTAgainstCForm.Enabled = True
            txtjCSTAgainstCForm.Text = ""
            requiredCSTAgainstC.InitialValue = ""

        Else
            lnkjCSTAgainstCForm.CausesValidation = False
            txtjCSTAgainstCForm.Enabled = False
            txtjCSTAgainstCForm.Text = "CST Against C Form"
            requiredCSTAgainstC.InitialValue = "CST Against C Form"
        End If


    End Sub

    Protected Sub lnkjBTNNo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjBTNNo.Click

        Try
            If lnkjBTNNo.Text = "Edit" Then
                txtjBTNNo.Visible = True
                lbljBTNNo.Visible = False
                txtjBTNNo.Text = lbljBTNNo.Text
                lnkjBTNNo.Text = "Update"
                lnkjBTNNo.CausesValidation = True
            Else
                If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                    ExecuteQuery("Update ProductVat Set ProductVat_BTNNo = '" & txtjBTNNo.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    System.Threading.Thread.Sleep(1000)
                Else
                    ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_BTNNo, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjBTNNo.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    System.Threading.Thread.Sleep(1000)
                End If
                lbljBTNNo.Visible = True
                lbljBTNNo.Text = ReturnValue("Select ProductVat_BTNNo from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjBTNNo.Visible = False
                lnkjBTNNo.Visible = False
                lnkjBTNNo.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjBTNNo.Text = "Edit"
                    lnkjBTNNo.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

    Protected Sub lnkjExciseDateRemarks_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjExciseDateRemarks.Click

        Try
            If lnkjExciseDateRemarks.Text = "Edit" Then
                txtjExciseDateRemarks.Visible = True
                lbljExciseDateRemarks.Visible = False
                txtjExciseDateRemarks.Text = lbljExciseDateRemarks.Text
                lnkjExciseDateRemarks.Text = "Update"
                lnkjExciseDateRemarks.CausesValidation = True
            Else
                If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                    ExecuteQuery("Update ProductVat Set ProductVat_ExciseDateRemark = '" & txtjExciseDateRemarks.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    System.Threading.Thread.Sleep(1000)
                Else
                    ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_ExciseDateRemark, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjExciseDateRemarks.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    System.Threading.Thread.Sleep(1000)
                End If
                lbljExciseDateRemarks.Visible = True
                lbljExciseDateRemarks.Text = ReturnValue("Select ProductVat_ExciseDateRemark from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjExciseDateRemarks.Visible = False
                lnkjExciseDateRemarks.Visible = False
                lnkjExciseDateRemarks.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjExciseDateRemarks.Text = "Edit"
                    lnkjExciseDateRemarks.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

    Protected Sub lnkjSalesTaxRemarks_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjSalesTaxRemarks.Click

        Try
            If lnkjSalesTaxRemarks.Text = "Edit" Then
                txtjSalesTaxRemarks.Visible = True
                lbljSalesTaxRemarks.Visible = False
                txtjSalesTaxRemarks.Text = lbljSalesTaxRemarks.Text
                lnkjSalesTaxRemarks.Text = "Update"
                lnkjSalesTaxRemarks.CausesValidation = True
            Else
                If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                    ExecuteQuery("Update ProductVat Set ProductVat_SalesTaxRemark = '" & txtjSalesTaxRemarks.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    System.Threading.Thread.Sleep(1000)
                Else
                    ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_SalesTaxRemark, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjSalesTaxRemarks.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    System.Threading.Thread.Sleep(1000)
                End If
                lbljSalesTaxRemarks.Visible = True
                lbljSalesTaxRemarks.Text = ReturnValue("Select ProductVat_SalesTaxRemark from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjSalesTaxRemarks.Visible = False
                lnkjSalesTaxRemarks.Visible = False
                lnkjSalesTaxRemarks.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjSalesTaxRemarks.Text = "Edit"
                    lnkjSalesTaxRemarks.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub


    Protected Sub lnkjExciseDuty_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjExciseDuty.Click

        Try
            If lnkjExciseDuty.Text = "Edit" Then
                If lbljExciseDuty.Text = "No" Then
                    rbljIsExciseDuty.SelectedValue = "No"
                    txtjExciseDuty.Enabled = False
                   
                Else
                    rbljIsExciseDuty.SelectedValue = "Yes"
                    txtjExciseDuty.Enabled = True
                    txtjExciseDuty.Text = lbljExciseDuty.Text
                End If
                txtjExciseDuty.Visible = True
                rbljIsExciseDuty.Enabled = True
                lbljExciseDuty.Visible = False
                lnkjExciseDuty.Text = "Update"
                lnkjExciseDuty.CausesValidation = True
            Else

                If rbljIsExciseDuty.SelectedValue = "No" Then

                    Label2.Visible = False
                    lbljExciseDuty.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_ExciseDuty = '" & rbljIsExciseDuty.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_ExciseDuty, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsExciseDuty.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                    lnkjEduCess.Enabled = False
                    lnkjHigherEduCess.Enabled = False
                    rbljIsEduCess.Enabled = False
                    rbljIsHigherEduCess.Enabled = False
                Else
                    lnkjEduCess.Enabled = True
                    lnkjHigherEduCess.Enabled = True
                    rbljIsEduCess.Enabled = True
                    rbljIsHigherEduCess.Enabled = True
                    Label2.Visible = True
                    lbljExciseDuty.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_ExciseDuty = '" & txtjExciseDuty.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_ExciseDuty, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjExciseDuty.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                End If

                rbljIsExciseDuty.Enabled = False
                lbljExciseDuty.Text = ReturnValue("Select ProductVat_ExciseDuty from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjExciseDuty.Visible = False
                lnkjExciseDuty.Visible = False
                lnkjExciseDuty.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjExciseDuty.Text = "Edit"
                    lnkjExciseDuty.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

    Protected Sub lnkjEduCess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjEduCess.Click

        Try


            Dim check As String
            check = ReturnValue("Select ProductVat_ExciseDuty from ProductVat where ProductVat_ProductId ='" & Session("ProductId") & "' and ProductVat_Isdeleted ='0'")

            If check.ToString = "" Or check.ToString = "No" Then
                showmessage("First Check Excise Duty Yes.", lblMSG)
                Exit Sub
            End If

            If lnkjEduCess.Text = "Edit" Then
                If lbljEduCess.Text = "No" Then
                    rbljIsEduCess.SelectedValue = "No"
                    txtjEduCess.Enabled = False
                Else
                    rbljIsEduCess.SelectedValue = "Yes"
                    txtjEduCess.Enabled = True
                    txtjEduCess.Text = lbljEduCess.Text
                End If
                txtjEduCess.Visible = True
                rbljIsEduCess.Enabled = True
                lbljEduCess.Visible = False
                lnkjEduCess.Text = "Update"
                lnkjEduCess.CausesValidation = True
            Else

                If rbljIsEduCess.SelectedValue = "No" Then
                    Label6.Visible = False
                    lbljEduCess.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_EduCess = '" & rbljIsEduCess.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_EduCess, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsEduCess.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                Else
                    Label6.Visible = True
                    lbljEduCess.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_EduCess = '" & txtjEduCess.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_EduCess, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjEduCess.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                End If

                rbljIsEduCess.Enabled = False
                lbljEduCess.Text = ReturnValue("Select ProductVat_EduCess from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjEduCess.Visible = False
                lnkjEduCess.Visible = False
                lnkjEduCess.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjEduCess.Text = "Edit"
                    lnkjEduCess.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try


    End Sub

    Protected Sub lnkjHigherEduCess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjHigherEduCess.Click

        Try

            Dim check As String
            check = ReturnValue("Select ProductVat_ExciseDuty from ProductVat where ProductVat_ProductId ='" & Session("ProductId") & "' and ProductVat_Isdeleted ='0'")

            If check.ToString = "" Or check.ToString = "No" Then
                showmessage("First Check Excise Duty Yes.", lblMSG)
                Exit Sub
            End If

            If lnkjHigherEduCess.Text = "Edit" Then
                If lbljHigherEduCess.Text = "No" Then
                    rbljIsHigherEduCess.SelectedValue = "No"
                    txtjHigherEduCess.Enabled = False
                Else
                    rbljIsHigherEduCess.SelectedValue = "Yes"
                    txtjHigherEduCess.Enabled = True
                    txtjHigherEduCess.Text = lbljHigherEduCess.Text
                End If
                txtjHigherEduCess.Visible = True
                rbljIsHigherEduCess.Enabled = True
                lbljHigherEduCess.Visible = False
                lnkjHigherEduCess.Text = "Update"
                lnkjHigherEduCess.CausesValidation = True
            Else

                If rbljIsHigherEduCess.SelectedValue = "No" Then
                    Label7.Visible = False
                    lbljHigherEduCess.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_HigherEduCess = '" & rbljIsHigherEduCess.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_HigherEduCess, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsHigherEduCess.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                Else
                    Label7.Visible = True
                    lbljHigherEduCess.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_HigherEduCess = '" & txtjHigherEduCess.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_HigherEduCess, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjHigherEduCess.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                End If

                rbljIsHigherEduCess.Enabled = False
                lbljHigherEduCess.Text = ReturnValue("Select ProductVat_HigherEduCess from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjHigherEduCess.Visible = False
                lnkjHigherEduCess.Visible = False
                lnkjHigherEduCess.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjHigherEduCess.Text = "Edit"
                    lnkjHigherEduCess.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try



    End Sub

    Protected Sub lnkjVat_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjVat.Click


        Try
            If lnkjVat.Text = "Edit" Then
                If lbljVat.Text = "No" Then
                    rbljIsVat.SelectedValue = "No"
                    txtjVat.Enabled = False
                Else
                    rbljIsVat.SelectedValue = "Yes"
                    txtjVat.Enabled = True
                    txtjVat.Text = lbljVat.Text
                End If
                txtjVat.Visible = True
                rbljIsVat.Enabled = True
                lbljVat.Visible = False
                lnkjVat.Text = "Update"
                lnkjVat.CausesValidation = True
            Else

                If rbljIsVat.SelectedValue = "No" Then
                    Label9.Visible = False
                    lbljVat.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_Vat = '" & rbljIsVat.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_Vat, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsVat.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                Else
                    Label9.Visible = True
                    lbljVat.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_Vat = '" & txtjVat.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_Vat, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjVat.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                End If

                rbljIsVat.Enabled = False
                lbljVat.Text = ReturnValue("Select ProductVat_Vat from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjVat.Visible = False
                lnkjVat.Visible = False
                lnkjVat.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjVat.Text = "Edit"
                    lnkjVat.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try




    End Sub

    Protected Sub lnkjCST_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjCST.Click

        Try
            If lnkjCST.Text = "Edit" Then
                If lbljCST.Text = "No" Then
                    rbljIsCST.SelectedValue = "No"
                    txtjCST.Enabled = False
                Else
                    rbljIsCST.SelectedValue = "Yes"
                    txtjCST.Enabled = True
                    txtjCST.Text = lbljCST.Text
                End If
                txtjCST.Visible = True
                rbljIsCST.Enabled = True
                lbljCST.Visible = False
                lnkjCST.Text = "Update"
                lnkjCST.CausesValidation = True
            Else

                If rbljIsCST.SelectedValue = "No" Then
                    Label10.Visible = False
                    lbljCST.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_CST = '" & rbljIsCST.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_CST, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsCST.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                Else
                    Label10.Visible = True
                    lbljCST.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_CST = '" & txtjCST.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                        System.Threading.Thread.Sleep(1000)
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_CST, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjCST.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                        System.Threading.Thread.Sleep(1000)
                    End If
                End If

                rbljIsCST.Enabled = False
                'lbljCST.Visible = True
                lbljCST.Text = ReturnValue("Select ProductVat_CST from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjCST.Visible = False
                lnkjCST.Visible = False
                lnkjCST.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjCST.Text = "Edit"
                    lnkjCST.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

    Protected Sub lnkjCSTAgainstCForm_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkjCSTAgainstCForm.Click

        Try
            If lnkjCSTAgainstCForm.Text = "Edit" Then
                If lbljCSTAgainstCForm.Text = "No" Then
                    rbljIsCSTAgainstCForm.SelectedValue = "No"
                    txtjCSTAgainstCForm.Enabled = False
                Else
                    rbljIsCSTAgainstCForm.SelectedValue = "Yes"
                    txtjCSTAgainstCForm.Enabled = True
                    txtjCSTAgainstCForm.Text = lbljCSTAgainstCForm.Text
                End If
                txtjCSTAgainstCForm.Visible = True
                rbljIsCSTAgainstCForm.Enabled = True
                lbljCSTAgainstCForm.Visible = False
                lnkjCSTAgainstCForm.Text = "Update"
                lnkjCSTAgainstCForm.CausesValidation = True
            Else

                If rbljIsCSTAgainstCForm.SelectedValue = "No" Then
                    Label11.Visible = False
                    lbljCSTAgainstCForm.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_CSTAgainstC = '" & rbljIsCSTAgainstCForm.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_CSTAgainstC, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rbljIsCSTAgainstCForm.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    End If
                Else
                    Label11.Visible = True
                    lbljCSTAgainstCForm.Visible = True
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_CSTAgainstC = '" & txtjCSTAgainstCForm.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_CSTAgainstC, ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtjCSTAgainstCForm.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    End If
                End If

                rbljIsCSTAgainstCForm.Enabled = False
                lbljCSTAgainstCForm.Text = ReturnValue("Select ProductVat_CSTAgainstC from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtjCSTAgainstCForm.Visible = False
                lnkjCSTAgainstCForm.Visible = False
                lnkjCSTAgainstCForm.CausesValidation = False
                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkjCSTAgainstCForm.Text = "Edit"
                    lnkjCSTAgainstCForm.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

    Protected Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    End Sub

    Protected Sub lnkOtherCharges_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkOtherCharges.Click
        Try
            If lnkOtherCharges.Text = "Edit" Then
                If lblOtherCharges.Text = "No" Then
                    rdbIsOtherCharges.SelectedValue = "No"
                    txtOtherCharges.Enabled = False
                    txtOtherChargesRemark.Enabled = False

                Else
                    rdbIsOtherCharges.SelectedValue = "Yes"
                    txtOtherCharges.Enabled = True
                    txtOtherCharges.Text = lblOtherCharges.Text
                    requiredothercharge.InitialValue = ""
                    txtOtherChargesRemark.Enabled = True
                    txtOtherChargesRemark.Text = lblOtherChargeRemarks.Text
                End If
                txtOtherCharges.Visible = True
                txtOtherChargesRemark.Visible = True
                rdbIsOtherCharges.Enabled = True
                lblOtherCharges.Visible = False
                lblOtherChargeRemarks.Visible = False
                lnkOtherCharges.Text = "Update"
                lnkOtherCharges.CausesValidation = True
            Else

                If rdbIsOtherCharges.SelectedValue = "No" Then
                    Label3.Visible = False
                    lblOtherCharges.Visible = False
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_OtherCharges = '" & rdbIsOtherCharges.SelectedValue.ToString & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_OtherCharges,ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & rdbIsOtherCharges.SelectedValue.ToString & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    End If
                Else
                    Label3.Visible = True
                    lblOtherCharges.Visible = True
                    '' for other Charges Amount & Remarks
                    If IsAlreadyPresent("select count(*) from ProductVat where ProductVat_ProductId='" & Session("ProductId") & "'") Then
                        ExecuteQuery("Update ProductVat Set ProductVat_OtherCharges = '" & txtOtherCharges.Text.Trim & "',ProductVat_OtherChargesRemark = '" & txtOtherChargesRemark.Text.Trim & "' where ProductVat_ProductId = '" & RemoveLiterals(Session("ProductID").ToString()) & "'")
                    Else
                        ExecuteQuery("insert into ProductVat(ProductVat_Kid,ProductVat_Code, ProductVat_ProductId, ProductVat_OtherCharges,ProductVat_OtherChargesRemark ProductVat_FinancialYearId, ProductVat_CompanyId, ProductVat_UserId, ProductVat_IsDeleted) Values ( '" & NewPrimaryKey(Me) & "', '" & Generate_Code("select count(*) from ProductVat where ProductVat_Code='", "PV") & "', '" & Session("ProductId").ToString & "', '" & txtOtherCharges.Text & "' , '" & txtOtherChargesRemark.Text & "' , '" & Session("g_FinYear").ToString() & "','" & Session("g_Company").ToString() & "', '" & Session("g_User") & "', '0')")
                    End If

                   
                End If

                rdbIsOtherCharges.Enabled = False
                lblOtherCharges.Text = ReturnValue("Select ProductVat_OtherCharges from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                txtOtherCharges.Visible = False
                txtOtherChargesRemark.Visible = False
                lnkOtherCharges.Visible = False
                lnkOtherCharges.CausesValidation = False
                lblOtherChargeRemarks.Visible = True
                If lblOtherCharges.Text <> "No" Then
                    lblOtherChargeRemarks.Text = ReturnValue("Select ProductVat_OtherChargesRemark from ProductVat Where ProductVat_ProductId ='" & Session("ProductID") & "'and ProductVat_IsDeleted = '0'")
                Else
                    lblOtherChargeRemarks.Text = ""
                End If


                If Session("AdminID") <> Nothing Or Session("AdminID") = Nothing Then
                    lnkOtherCharges.Text = "Edit"
                    lnkOtherCharges.Visible = True
                End If

            End If
        Catch ex As Exception
            'Response.Output.Write("Server error: " & ex.Message.ToString.ToUpperInvariant())
        End Try

    End Sub

   

   
    Protected Sub rdbIsOtherCharges_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdbIsOtherCharges.SelectedIndexChanged
        If rdbIsOtherCharges.SelectedValue = "Yes" Then
            lnkOtherCharges.CausesValidation = True
            txtOtherCharges.Enabled = True
            txtOtherChargesRemark.Enabled = True
            requiredOtherChargeRemark.InitialValue = ""
            txtOtherCharges.Text = ""
            requiredothercharge.InitialValue = ""

        Else
            lnkOtherCharges.CausesValidation = False
            txtOtherChargesRemark.Enabled = False
            txtOtherCharges.Enabled = False
            txtOtherChargesRemark.Text = ""
            txtOtherCharges.Text = "Other Charges"
            requiredothercharge.InitialValue = ""
            requiredOtherChargeRemark.InitialValue = "Remark"

        End If
    End Sub

    
End Class
