protected void gvGovtSaving_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.UpdateCommandName)
            {
                bool             isUpdated        = false;
                string           relationCode     = string.Empty;
                GridEditableItem gridEditableItem = (GridEditableItem)e.Item;
                e.Canceled = true;
                //gridEditableItem.OwnerTableView.IsItemInserted = false;

                GovtSavingNPId = int.Parse(gvGovtSaving.MasterTableView.DataKeyValues[e.Item.ItemIndex]["CGSNP_GovtSavingNPId"].ToString());
                Button btnGovtSubmit = (Button)e.Item.FindControl("btnGovtSubmit");

                DropDownList ddlDebtIssuerCode       = (DropDownList)e.Item.FindControl("ddlDebtIssuerCode");
                TextBox      txtCurrentValue         = (TextBox)e.Item.FindControl("txtCurrentValue");
                TextBox      txtDepositDate          = (TextBox)e.Item.FindControl("txtDepositDate");
                TextBox      txtMaturityValue        = (TextBox)e.Item.FindControl("txtMaturityValue");
                TextBox      txtMaturityDate         = (TextBox)e.Item.FindControl("txtMaturityDate");
                TextBox      txtDepositAmount        = (TextBox)e.Item.FindControl("txtDepositAmount");
                TextBox      txtInterstRate          = (TextBox)e.Item.FindControl("txtInterstRate");
                DropDownList ddlInterestBasis        = (DropDownList)e.Item.FindControl("ddlInterestBasis");
                DropDownList ddlSimpleInterestFC     = (DropDownList)e.Item.FindControl("ddlSimpleInterestFC");
                DropDownList ddlCompoundInterestFC   = (DropDownList)e.Item.FindControl("ddlCompoundInterestFC");
                TextBox      txtInterestAmtCredited  = (TextBox)e.Item.FindControl("txtInterestAmtCredited");
                TextBox      txtAssetParticulars     = (TextBox)e.Item.FindControl("txtAssetParticulars");
                RadioButton  rbtnAccumulated         = (RadioButton)e.Item.FindControl("rbtnAccumulated");
                TextBox      txtSubsqntDepositAmount = (TextBox)e.Item.FindControl("txtSubsqntDepositAmount");
                TextBox      txtSubsqntDepositDate   = (TextBox)e.Item.FindControl("txtSubsqntDepositDate");
                DropDownList ddlDepositFrequency     = (DropDownList)e.Item.FindControl("ddlDepositFrequency");
                TextBox      txtRemarks       = (TextBox)e.Item.FindControl("txtRemarks");
                TextBox      txtAccOpenDate   = (TextBox)e.Item.FindControl("txtAccOpenDate");
                TextBox      txtAccountWith   = (TextBox)e.Item.FindControl("txtAccountWith");
                TextBox      txtAccountNumber = (TextBox)e.Item.FindControl("txtAccountNumber");


                Button             btnAcctInsert = (Button)e.Item.FindControl("btnAcctInsert");
                CustomerAccountsVo newAccountVo  = new CustomerAccountsVo();
                if (btnGovtSubmit.Visible == true)
                {
                    customerAccountsVo        = (CustomerAccountsVo)Session["customerAccountVo"];
                    Session["govtSavingsVo"]  = govtSavingsBo.GetGovtSavingsDetails(GovtSavingNPId);
                    govtSavingsVo             = (GovtSavingsVo)Session["govtSavingsVo"];
                    govtSavingsVo.PortfolioId = govtSavingsVo.GoveSavingsPortfolioId;
                    if (ddlDebtIssuerCode != null && ddlDebtIssuerCode.SelectedItem.Value != string.Empty)
                    {
                        govtSavingsVo.DebtIssuerCode = ddlDebtIssuerCode.SelectedItem.Value.ToString();
                    }

                    govtSavingsVo.Name = txtAssetParticulars.Text;

                    if (txtCurrentValue != null && txtCurrentValue.Text != "")
                    {
                        govtSavingsVo.CurrentValue = float.Parse(txtCurrentValue.Text);
                    }



                    if (txtDepositDate != null && txtDepositDate.Text != "")
                    {
                        govtSavingsVo.PurchaseDate = DateTime.Parse(txtDepositDate.Text.ToString());
                    }

                    if (txtMaturityValue != null && txtMaturityValue.Text != "")
                    {
                        govtSavingsVo.MaturityValue = float.Parse(txtMaturityValue.Text);
                    }
                    if (txtMaturityDate != null && txtMaturityDate.Text != "")
                    {
                        govtSavingsVo.MaturityDate = DateTime.Parse(txtMaturityDate.Text.ToString());
                    }
                    if (txtDepositAmount != null && txtDepositAmount.Text != "")
                    {
                        govtSavingsVo.DepositAmt = float.Parse(txtDepositAmount.Text);
                    }
                    if (txtInterstRate != null && txtInterstRate.Text != "")
                    {
                        govtSavingsVo.InterestRate = float.Parse(txtInterstRate.Text);
                    }
                    if (ddlInterestBasis != null)
                    {
                        govtSavingsVo.InterestBasisCode = ddlInterestBasis.SelectedItem.Value.ToString();
                    }

                    if (govtSavingsVo.InterestBasisCode == "SI")
                    {
                        govtSavingsVo.InterestPayableFrequencyCode  = ddlSimpleInterestFC.SelectedItem.Value.ToString();
                        govtSavingsVo.CompoundInterestFrequencyCode = "NA";
                    }
                    else if (govtSavingsVo.InterestBasisCode == "CI")
                    {
                        govtSavingsVo.InterestPayableFrequencyCode  = "NA";
                        govtSavingsVo.CompoundInterestFrequencyCode = ddlCompoundInterestFC.SelectedItem.Value.ToString();
                    }
                    else
                    {
                        govtSavingsVo.InterestBasisCode = null;
                    }

                    if (rbtnAccumulated.Checked)
                    {
                        govtSavingsVo.IsInterestAccumalated = 1;
                        if (txtInterestAmtCredited != null && txtInterestAmtCredited.Text != string.Empty)
                        {
                            govtSavingsVo.InterestAmtAccumalated = float.Parse(txtInterestAmtCredited.Text);
                        }
                        govtSavingsVo.InterestAmtPaidOut = 0;
                    }
                    else
                    {
                        govtSavingsVo.IsInterestAccumalated = 0;
                        if (txtInterestAmtCredited != null && txtInterestAmtCredited.Text != string.Empty)
                        {
                            govtSavingsVo.InterestAmtPaidOut = float.Parse(txtInterestAmtCredited.Text);
                        }
                        govtSavingsVo.InterestAmtAccumalated = 0;
                    }

                    //Post Office Recurring Deposit Account- Subsequent deposit details
                    if (govtSavingsVo.AssetInstrumentCategoryCode != null && govtSavingsVo.AssetInstrumentCategoryCode.ToString().Trim() == "GSRD")
                    {
                        if (txtSubsqntDepositAmount != null && txtSubsqntDepositAmount.Text != string.Empty)
                        {
                            govtSavingsVo.SubsqntDepositAmount = float.Parse(txtSubsqntDepositAmount.Text.Trim());
                        }
                        if (txtSubsqntDepositDate != null && txtSubsqntDepositDate.Text != string.Empty)
                        {
                            govtSavingsVo.SubsqntDepositDate = Convert.ToDateTime(txtSubsqntDepositDate.Text);
                        }

                        if (ddlDepositFrequency != null && ddlDepositFrequency.SelectedValue != string.Empty)
                        {
                            govtSavingsVo.DepositFrequencyCode = ddlDepositFrequency.SelectedValue;
                        }
                    }

                    govtSavingsVo.Remarks = txtRemarks.Text;
                    govtSavingsBo.UpdateGovtSavingsNP(govtSavingsVo, userVo.UserId);
                }
                else if (btnAcctInsert.Visible == true)
                {
                }
            }
            if (e.CommandName == RadGrid.PerformInsertCommandName)
            {
                int              i                = 0;
                bool             blResult         = false;
                GridEditableItem gridEditableItem = (GridEditableItem)e.Item;

                Button btnAcctInsert = (Button)e.Item.FindControl("btnAcctInsert");

                //gridEditableItem.OwnerTableView.IsItemInserted = false;

                if (hdnCondition.Value != "1")
                {
                    gvGovtSaving.MasterTableView.IsItemInserted = true;
                    e.Item.Edit        = true;
                    e.Canceled         = true;
                    hdnCondition.Value = "1";
                }
                else
                {
                    gvGovtSaving.MasterTableView.IsItemInserted = false;
                    e.Item.Edit        = false;
                    e.Canceled         = false;
                    hdnCondition.Value = "0";
                }



                //Account details control defined........
                TextBox      txtAccountNumber      = (TextBox)e.Item.FindControl("txtAccountNumber");
                DropDownList ddlCategory           = (DropDownList)e.Item.FindControl("ddlCategory");
                RadioButton  rbtnNo                = (RadioButton)e.Item.FindControl("rbtnNo");
                RadioButton  rbtnYes               = (RadioButton)e.Item.FindControl("rbtnYes");
                DropDownList ddlModeOfHolding      = (DropDownList)e.Item.FindControl("ddlModeOfHolding");
                TextBox      txtAccountSource      = (TextBox)e.Item.FindControl("txtAccountSource");
                RadGrid      gvJointHoldersList    = (RadGrid)e.Item.FindControl("gvJointHoldersList");
                TextBox      txtAccOpenDate        = (TextBox)e.Item.FindControl("txtAccOpenDate");
                TextBox      txtAccountId          = (TextBox)e.Item.FindControl("txtAccountId");
                TextBox      txtAccountWith        = (TextBox)e.Item.FindControl("txtAccountWith");
                Label        lblInstrumentCategory = (Label)e.Item.FindControl("lblInstrumentCategory");


                //Govt saving control defined........


                Button             btnGovtSubmit           = (Button)e.Item.FindControl("btnGovtSubmit");
                DropDownList       ddlDebtIssuerCode       = (DropDownList)e.Item.FindControl("ddlDebtIssuerCode");
                TextBox            txtCurrentValue         = (TextBox)e.Item.FindControl("txtCurrentValue");
                TextBox            txtDepositDate          = (TextBox)e.Item.FindControl("txtDepositDate");
                TextBox            txtMaturityValue        = (TextBox)e.Item.FindControl("txtMaturityValue");
                TextBox            txtMaturityDate         = (TextBox)e.Item.FindControl("txtMaturityDate");
                TextBox            txtDepositAmount        = (TextBox)e.Item.FindControl("txtDepositAmount");
                TextBox            txtInterstRate          = (TextBox)e.Item.FindControl("txtInterstRate");
                DropDownList       ddlInterestBasis        = (DropDownList)e.Item.FindControl("ddlInterestBasis");
                DropDownList       ddlSimpleInterestFC     = (DropDownList)e.Item.FindControl("ddlSimpleInterestFC");
                DropDownList       ddlCompoundInterestFC   = (DropDownList)e.Item.FindControl("ddlCompoundInterestFC");
                TextBox            txtInterestAmtCredited  = (TextBox)e.Item.FindControl("txtInterestAmtCredited");
                TextBox            txtAssetParticulars     = (TextBox)e.Item.FindControl("txtAssetParticulars");
                RadioButton        rbtnAccumulated         = (RadioButton)e.Item.FindControl("rbtnAccumulated");
                TextBox            txtSubsqntDepositAmount = (TextBox)e.Item.FindControl("txtSubsqntDepositAmount");
                TextBox            txtSubsqntDepositDate   = (TextBox)e.Item.FindControl("txtSubsqntDepositDate");
                DropDownList       ddlDepositFrequency     = (DropDownList)e.Item.FindControl("ddlDepositFrequency");
                TextBox            txtRemarks            = (TextBox)e.Item.FindControl("txtRemarks");
                HtmlGenericControl divGovtSavings        = (HtmlGenericControl)e.Item.FindControl("divGovtSavings");
                DropDownList       ddlgovtModeofHoldings = (DropDownList)e.Item.FindControl("ddlgovtModeofHoldings");

                CustomerAccountsVo customerAccountsVo = new CustomerAccountsVo();
                //divGovtSavings.Visible = true;
                HtmlGenericControl divAccout = (HtmlGenericControl)e.Item.FindControl("divAccout");


                if (btnAcctInsert.Visible == true)
                {
                    customerAccountsVo.AssetClass    = "GS";
                    customerAccountsVo.AccountNum    = txtAccountNumber.Text;
                    customerAccountsVo.AssetCategory = ddlCategory.SelectedItem.Value.ToString();
                    customerAccountsVo.CustomerId    = customerVo.CustomerId;
                    customerAccountsVo.PortfolioId   = int.Parse(ddlPortfolio.SelectedItem.Value.ToString());;
                    if (rbtnNo.Checked)
                    {
                        customerAccountsVo.IsJointHolding = 0;
                    }
                    if (rbtnYes.Checked)
                    {
                        customerAccountsVo.IsJointHolding = 1;
                    }
                    customerAccountsVo.ModeOfHolding = ddlModeOfHolding.SelectedItem.Value.ToString();
                    customerAccountsVo.AccountSource = txtAccountSource.Text;
                    accountId = customerAccountBo.CreateCustomerGovtSavingAccount(customerAccountsVo, userVo.UserId);
                    customerAccountsVo.AccountId = accountId;

                    customerAccountAssociationVo.AccountId  = accountId;
                    customerAccountAssociationVo.CustomerId = customerVo.CustomerId;
                    foreach (GridDataItem gvRow in gvJointHoldersList.Items)
                    {
                        CheckBox chk = (CheckBox)gvRow.FindControl("cbRecons");
                        if (chk.Checked)
                        {
                            i++;
                        }
                    }
                    if (i != 0)
                    {
                        //    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Please select a record!');", true);
                        //}
                        //else
                        //{
                        foreach (GridDataItem gdi in gvJointHoldersList.Items)
                        {
                            if (((CheckBox)gdi.FindControl("cbRecons")).Checked == true)
                            {
                                int selectedRow = gdi.ItemIndex + 1;
                                customerAccountAssociationVo.AssociationId   = Convert.ToInt32(gvJointHoldersList.MasterTableView.DataKeyValues[selectedRow - 1]["AssociationId"].ToString());
                                customerAccountAssociationVo.AssociationType = "Joint Holder";
                                customerAccountBo.CreateGovtSavingsAccountAssociation(customerAccountAssociationVo, userVo.UserId);
                            }
                        }
                    }

                    if (blResult)
                    {
                        Session["customerAccountVo"] = customerAccountsVo;
                    }
                    if (customerAccountsVo.AccountOpeningDate != DateTime.MinValue)
                    {
                        txtAccOpenDate.Text = customerAccountsVo.AccountOpeningDate.ToShortDateString();
                    }
                    txtAccountId.Text = customerAccountsVo.AccountNum.ToString();
                    if (customerAccountsVo.AccountSource != null)
                    {
                        txtAccountWith.Text = customerAccountsVo.AccountSource.ToString();
                    }
                    if (customerAccountsVo.AssetCategory != null)
                    {
                        lblInstrumentCategory.Text = customerAccountsVo.AssetCategory.ToString();
                    }
                    ddlModeOfHolding.SelectedValue      = customerAccountsVo.ModeOfHolding.Trim();
                    ddlgovtModeofHoldings.SelectedValue = customerAccountsVo.ModeOfHolding.Trim();
                    Session["customerAccountVo"]        = customerAccountsVo;
                    divGovtSavings.Visible = true;
                    btnAcctInsert.Visible  = false;
                    btnGovtSubmit.Visible  = true;
                }
                else if (btnGovtSubmit.Visible == true)
                {
                    customerAccountsVo           = (CustomerAccountsVo)Session["customerAccountVo"];
                    customerAccountsVo.AccountId = customerAccountsVo.AccountId;//Convert.ToInt32(txtAccountId.Text);
                    if (txtAccOpenDate != null && txtAccOpenDate.Text != string.Empty)
                    {
                        customerAccountsVo.AccountOpeningDate = Convert.ToDateTime(txtAccOpenDate.Text);
                    }

                    customerAccountsVo.AccountSource = txtAccountWith.Text;
                    govtSavingsVo.PortfolioId        = customerAccountsVo.PortfolioId;
                    govtSavingsVo.AccountId          = customerAccountsVo.AccountId;
                    govtSavingsVo.AssetGroupCode     = customerAccountsVo.AssetClass;

                    govtSavingsVo.AssetInstrumentCategoryCode = customerAccountsVo.AssetCategory;

                    if (ddlDebtIssuerCode != null && ddlDebtIssuerCode.SelectedItem.Value != string.Empty)
                    {
                        govtSavingsVo.DebtIssuerCode = ddlDebtIssuerCode.SelectedItem.Value.ToString();
                    }

                    govtSavingsVo.Name = txtAssetParticulars.Text;

                    if (txtCurrentValue != null && txtCurrentValue.Text != "")
                    {
                        govtSavingsVo.CurrentValue = float.Parse(txtCurrentValue.Text);
                    }



                    if (txtDepositDate != null && txtDepositDate.Text != "")
                    {
                        govtSavingsVo.PurchaseDate = DateTime.Parse(txtDepositDate.Text.ToString());
                    }

                    if (txtMaturityValue != null && txtMaturityValue.Text != "")
                    {
                        govtSavingsVo.MaturityValue = float.Parse(txtMaturityValue.Text);
                    }
                    if (txtMaturityDate != null && txtMaturityDate.Text != "")
                    {
                        govtSavingsVo.MaturityDate = DateTime.Parse(txtMaturityDate.Text.ToString());
                    }
                    if (txtDepositAmount != null && txtDepositAmount.Text != "")
                    {
                        govtSavingsVo.DepositAmt = float.Parse(txtDepositAmount.Text);
                    }
                    if (txtInterstRate != null && txtInterstRate.Text != "")
                    {
                        govtSavingsVo.InterestRate = float.Parse(txtInterstRate.Text);
                    }
                    if (ddlInterestBasis != null)
                    {
                        govtSavingsVo.InterestBasisCode = ddlInterestBasis.SelectedItem.Value.ToString();
                    }

                    if (govtSavingsVo.InterestBasisCode == "SI")
                    {
                        govtSavingsVo.InterestPayableFrequencyCode  = ddlSimpleInterestFC.SelectedItem.Value.ToString();
                        govtSavingsVo.CompoundInterestFrequencyCode = "NA";
                    }
                    else if (govtSavingsVo.InterestBasisCode == "CI")
                    {
                        govtSavingsVo.InterestPayableFrequencyCode  = "NA";
                        govtSavingsVo.CompoundInterestFrequencyCode = ddlCompoundInterestFC.SelectedItem.Value.ToString();
                    }
                    else
                    {
                        govtSavingsVo.InterestBasisCode = null;
                    }

                    if (rbtnAccumulated.Checked)
                    {
                        govtSavingsVo.IsInterestAccumalated = 1;
                        if (txtInterestAmtCredited != null && txtInterestAmtCredited.Text != string.Empty)
                        {
                            govtSavingsVo.InterestAmtAccumalated = float.Parse(txtInterestAmtCredited.Text);
                        }
                        govtSavingsVo.InterestAmtPaidOut = 0;
                    }
                    else
                    {
                        govtSavingsVo.IsInterestAccumalated = 0;
                        if (txtInterestAmtCredited != null && txtInterestAmtCredited.Text != string.Empty)
                        {
                            govtSavingsVo.InterestAmtPaidOut = float.Parse(txtInterestAmtCredited.Text);
                        }
                        govtSavingsVo.InterestAmtAccumalated = 0;
                    }

                    //Post Office Recurring Deposit Account- Subsequent deposit details
                    if (customerAccountsVo.AssetCategory != null && customerAccountsVo.AssetCategory.ToString().Trim() == "GSRD")
                    {
                        if (txtSubsqntDepositAmount != null && txtSubsqntDepositAmount.Text != string.Empty)
                        {
                            govtSavingsVo.SubsqntDepositAmount = float.Parse(txtSubsqntDepositAmount.Text.Trim());
                        }
                        if (txtSubsqntDepositDate != null && txtSubsqntDepositDate.Text != string.Empty)
                        {
                            govtSavingsVo.SubsqntDepositDate = Convert.ToDateTime(txtSubsqntDepositDate.Text);
                        }

                        if (ddlDepositFrequency != null && ddlDepositFrequency.SelectedValue != string.Empty)
                        {
                            govtSavingsVo.DepositFrequencyCode = ddlDepositFrequency.SelectedValue;
                        }
                    }

                    govtSavingsVo.Remarks = txtRemarks.Text;
                    bool bResult = govtSavingsBo.CreateGovtSavingsNP(govtSavingsVo, userVo.UserId);
                    //btnAcctInsert.Visible = true;
                    //btnGovtSubmit.Visible = false;
                    BindGovtSavingGrid();
                }
                divAccout.Visible = false;
                //gridEditableItem.OwnerTableView.IsItemInserted = false;
                divGovtSavings.Visible = true;
            }
            if (e.CommandName == "Delete")
            {
                GovtSavingNPId = int.Parse(gvGovtSaving.MasterTableView.DataKeyValues[e.Item.ItemIndex]["CGSNP_GovtSavingNPId"].ToString());
                govtSavingsBo.DeleteGovtSavingsPortfolio(GovtSavingNPId);
                BindGovtSavingGrid();
            }
            // BindGovtSavingGrid();
        }