protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            ValidateForceSaleValue();
            try
            {                
                ValidateIssurance();
                RobotTableAdapters.CollateralType_PropertyTableAdapter robot = new RobotTableAdapters.CollateralType_PropertyTableAdapter();
                RobotTableAdapters.InsuranceTableAdapter robotInsuranceTable = new RobotTableAdapters.InsuranceTableAdapter();

                //initialize values
                int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
                int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);
                double varForceSaleValue = 0; double varOpenMarketValue = 0;
                varForceSaleValue = Convert.ToDouble(ForceSaleValue.Text);
                varOpenMarketValue = Convert.ToDouble(OpenMarketValue.Text);

                //insert values into CollateralType_Property and retrieve max id as collateralDetailsId
                int collateralDetailsId = Convert.ToInt32(robot.Proc_insert_property(OwnershipLink.Text, Location.Text, Convert.ToInt32(state_id.SelectedValue), Name_ColDocument.Text, RefNo_ColDocument.Text, AddressWithLandMark.Text,
                   Convert.ToInt32(PropertyType_id.SelectedValue), varForceSaleValue, varOpenMarketValue, "NULL", Convert.ToDateTime(DateOfValuation.Value), Convert.ToInt32(PropertyDevelopmentStatus.SelectedValue),
                    OccupancyStatus_id.SelectedValue, collateralId, -1, Convert.ToInt32(NameOfValuer.SelectedValue), -1, property_desc.Text, "NULL"));
                hiddenDetailsId.Text = collateralDetailsId.ToString();

                //see if he filled the insurance form, then run the block of code that will do the insrt into insurance table
                if (insuranceStatusId.SelectedValue == "1")
                {
                    int varPeriodOfInsuranceCover = 0; double varAmountInsured = 0;
                    varPeriodOfInsuranceCover = Convert.ToInt32(PeriodOfInsuranceCover.Text);
                    varAmountInsured = Convert.ToDouble(AmountInsured.Text);

                    robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), Convert.ToInt32(InsuranceCover_id.SelectedValue), collateralDetailsId, CollateralTypeId,
                        InsuranceCompany.Text, Convert.ToDateTime(DateOfInsurance.Value), varPeriodOfInsuranceCover, varAmountInsured, keyClause.Text, -1, Convert.ToInt32(InsuranceCompany.SelectedValue));
                }

                else
                {
                    robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), null, collateralDetailsId, CollateralTypeId,
                        null, DateTime.Now, null, null, null, Smart.GetEmployeeID(), null);
                }

                //enable and move focus to next tab, disable current tab
                ASPxPageControl1.TabPages[1].Enabled = true;

                //documenttype_id.SelectedIndex = 2;
                ASPxPageControl1.ActiveTabIndex = 1;
            }
            catch (Exception ex)
            {
                _errorMessageProperty.Text = ex.Message;
            }
        }
        catch (Exception _ex)
        {
           _errorMessageProperty_1.Text = _ex.Message;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       try
        {
            ValidateIssurance();
            // new RobotTableAdapters.InsuranceCompanyTableAdapter().Insert();

            RobotTableAdapters.CollateralType_SalaryContractTableAdapter robot = new RobotTableAdapters.CollateralType_SalaryContractTableAdapter();
            RobotTableAdapters.InsuranceTableAdapter robotInsuranceTable = new RobotTableAdapters.InsuranceTableAdapter();
            //initialize values
            int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
            int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);


            double varValueOfContract = 0; double varAPG = 0;

            varValueOfContract = Convert.ToDouble(ValueOfContract.Text);
            varAPG = Convert.ToDouble(APG.Text);

            //insert values into CollateralType_Cash  and retrieve max id as collateralDetailsId
            int collateralDetailsId = Convert.ToInt32(robot.proc_insert_contract(NameOfInsuringBody.Text, OriginalContractor.Text, Convert.ToDateTime(ContractAwardDate.Value),
                                        PurposeOfContract.Text, RefNo.Text, varValueOfContract, varAPG, TenureOfContract.Text, Convert.ToDateTime(MaturityDate.Value),
                                        collateralId, Smart.GetEmployeeID(), thirdparty.Text, "NULL",2));

            hiddenDetailsId.Text = collateralDetailsId.ToString();
            //see if he filled the insurance form, then run the block of code that will do the insrt into insurance table
            if (FinInsuranceStatus_id.SelectedValue == "1" || FinInsuranceStatus_id.SelectedValue == "3")
            {
                int varPeriodOfInsuranceCover = 0; double varAmountInsured = 0;
                varPeriodOfInsuranceCover = Convert.ToInt32(FinPeriodofInsuranceCover.Text);
                varAmountInsured = Convert.ToDouble(FinAmountInsured.Text);

                robotInsuranceTable.Insert(Convert.ToInt32(FinInsuranceStatus_id.SelectedValue), Convert.ToInt32(InsuranceCover.SelectedValue), collateralDetailsId, CollateralTypeId,
                    FinInsuranceCompany.Text, Convert.ToDateTime(FinDateOfInsurance.Value), varPeriodOfInsuranceCover, varAmountInsured, FinKeyClause.Text, Smart.GetEmployeeID(), Convert.ToInt32(FinInsuranceCompany.SelectedValue));

            }
            else
            {
                robotInsuranceTable.Insert(Convert.ToInt32(FinInsuranceStatus_id.SelectedValue), null, collateralDetailsId, CollateralTypeId,
                    null, null, null, null, null, Smart.GetEmployeeID(), null);
            }



            //enable and move focus to next tab, disable current tab
            ASPxPageControl1.TabPages[1].Enabled = true;

            ASPxPageControl1.ActiveTabIndex = 1;
        }
        catch (Exception ex)
        {
          _errorMessageSalary.Text = ex.Message;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      //  new RobotTableAdapters.InsuranceCompanyTableAdapter().Insert();
        try
        {
            ValidateIssurance();
            RobotTableAdapters.CollateralType_StockHypoTableAdapter robot = new RobotTableAdapters.CollateralType_StockHypoTableAdapter();
            RobotTableAdapters.InsuranceTableAdapter robotInsuranceTable = new RobotTableAdapters.InsuranceTableAdapter();
            //initialize values
            int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
            int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);


            int varTypeOfStock = 0; int varInsuranceCover_id = 0;
            double varValueOfStock = 0; int varFrequencyOfValuation = 0;
            varTypeOfStock = Convert.ToInt32(TypeOfStock_id.SelectedValue);
            varValueOfStock = Convert.ToDouble(ValueOfStock_total.Text);
            varFrequencyOfValuation = Convert.ToInt32(FrequencyOfValuation.SelectedValue);
            varInsuranceCover_id = Convert.ToInt32(InsuranceCover_id.SelectedValue);

            //insert values into CollateralType_Cash  and retrieve max id as collateralDetailsId
            int collateralDetailsId = Convert.ToInt32(robot.proc_insert_stockHypo(varTypeOfStock, ListOfStock.Text, InvoiceNo.Text,
                                        -1, varValueOfStock, NameOfStockValuer.Text, DateTime.Now, MethodOfValuation.Text, varFrequencyOfValuation,
                                        varInsuranceCover_id, collateralId, Smart.GetEmployeeID(), varFrequencyOfValuation, "NULL"));

            hiddenDetailsId.Text = collateralDetailsId.ToString();
            //see if he filled the insurance form, then run the block of code that will do the insrt into insurance table
            if (insuranceStatusId.SelectedValue == "1")
            {
                int varPeriodOfInsuranceCover = 0; double varAmountInsured = 0;
                varPeriodOfInsuranceCover = Convert.ToInt32(StockPeriodOfInsuranceCover.Text);
                varAmountInsured = Convert.ToDouble(StockAmountInsured.Text);

                robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), Convert.ToInt32(InsuranceCover_id.SelectedValue), collateralDetailsId, CollateralTypeId,
                    InsuranceCompany.Text, DateTime.Now, varPeriodOfInsuranceCover, varAmountInsured, StockKeyClause.Text, Smart.GetEmployeeID(), Convert.ToInt32(InsuranceCompany.SelectedValue));
            }
            else
            {
                robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), null, collateralDetailsId, CollateralTypeId,
                    null, DateTime.Now, null, null, null, Smart.GetEmployeeID(), null);
            }


            //enable and move focus to next tab, disable current tab
            ASPxPageControl1.TabPages[1].Enabled = true;


            ASPxPageControl1.ActiveTabIndex = 1;
        }
        catch (Exception ex)
        {
            _errorMessageStock.Text = ex.Message;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      //  new RobotTableAdapters.InsuranceCompanyTableAdapter().Insert();
        try
        {
            ValidateIssurance();
            RobotTableAdapters.CollateralType_CarEquipTableAdapter robot = new RobotTableAdapters.CollateralType_CarEquipTableAdapter();
            RobotTableAdapters.InsuranceTableAdapter robotInsuranceTable = new RobotTableAdapters.InsuranceTableAdapter();

            //initialize values
            int collateralId = Convert.ToInt32(Request.QueryString["collateralId"]);
            int CollateralTypeId = Convert.ToInt32(Request.QueryString["CollateralTypeId"]);

            double varValueAsAtDate = 0;

            varValueAsAtDate = Convert.ToDouble(ValueAsAtDate.Text);


            //insert values into CollateralType_CarEquipTableAdapter and retrieve max id as collateralDetailsId
            int collateralDetailsId = Convert.ToInt32(robot.proc_insert_car(TypeOfCarEquip.Text, Make.Text, YearOfManufacture.SelectedItem.Text, varValueAsAtDate, ChassisNo.Text,
                -1, collateralId, Smart.GetEmployeeID(), "NULL"));

            hiddenDetailsId.Text = collateralDetailsId.ToString();
            //see if he filled the insurance form, then run the block of code that will do the insrt into insurance table
            if (insuranceStatusId.SelectedValue == "1")
            {
                int varPeriodOfInsuranceCover = 0; double varAmountInsured = 0;
                varPeriodOfInsuranceCover = Convert.ToInt32(PeriodOfInsuranceCover.Text);
                varAmountInsured = Convert.ToDouble(AmountInsured.Text);

                robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), Convert.ToInt32(InsuranceCover_id.SelectedValue), collateralDetailsId, CollateralTypeId,
                    InsuranceCompany.Text, Convert.ToDateTime(DateOfInsurance.Value), varPeriodOfInsuranceCover, varAmountInsured, keyClause.Text, Smart.GetEmployeeID(), Convert.ToInt32(InsuranceCompany.SelectedValue));
            }
            else
            {
                robotInsuranceTable.Insert(Convert.ToInt32(insuranceStatusId.SelectedValue), -1, collateralDetailsId, CollateralTypeId,
                    "", null, -1, 0, null, Smart.GetEmployeeID(), -1);
            }

            //enable and move focus to next tab, disable current tab
            ASPxPageControl1.TabPages[1].Enabled = true;


            ASPxPageControl1.ActiveTabIndex = 1;
        }
        catch (Exception ex)
        {
            _errorMessageCar.Text = ex.Message;
        }
    }