protected void lnk_Edit_Command(object sender, CommandEventArgs e)
    {
        try
        {
            //to clear controls
            ClearControls();
            rcmb_FinancialYear.Enabled = false;

            LoadFinancialPeriods(); //To load financial periods

            //To fetch data based on CommandArgument
            SMHR_PENSION_INT_REG_UNREG _objPensionInt = new SMHR_PENSION_INT_REG_UNREG();
            _objPensionInt.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
            _objPensionInt.INT_ID          = Convert.ToInt32(e.CommandArgument);
            _objPensionInt.OPERATION       = operation.Get;

            DataTable dt = BLL.get_PensionIntOnRegtUnRegtAmt(_objPensionInt);

            if (dt.Rows.Count > 0)
            {
                lblInterestID.Text = Convert.ToString(dt.Rows[0]["INT_ID"]);
                rcmb_FinancialYear.SelectedIndex = rcmb_FinancialYear.Items.FindItemIndexByValue(Convert.ToString(dt.Rows[0]["INT_PERIOD_ID"]));
                rtxt_Registered.Text             = Convert.ToString(dt.Rows[0]["INT_REGISTERED_AMT"]);
                rtxt_UnRegistered.Text           = Convert.ToString(dt.Rows[0]["INT_UNREGISTERED_AMT"]);
                rtxt_Normal.Text = Convert.ToString(dt.Rows[0]["INT_NORMAL_AMT"]);
            }
            else
            {
                ClearControls();
            }
            if (Convert.ToInt32(Session["WRITEFACILITY"]) == 2)
            {
                btn_Update.Visible = false;
            }
            else
            {
                btn_Update.Visible = true;
            }

            btn_Save.Visible = false;
            RMP_IntrstOnRegstUnRegstAcct.SelectedIndex = 1;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnRegUnRegAcct", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
 private void LoadGrid()
 {
     try
     {
         SMHR_PENSION_INT_REG_UNREG objPensionInt = new SMHR_PENSION_INT_REG_UNREG();
         objPensionInt.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
         objPensionInt.OPERATION       = operation.Select;
         DataTable dtPensionInt = BLL.get_PensionIntOnRegtUnRegtAmt(objPensionInt);
         Rg_IntrstOnRegstUnRegstAcct.DataSource = dtPensionInt;
     }
     catch (Exception ex)
     {
         SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnRegUnRegAcct", ex.StackTrace, DateTime.Now);
         Response.Redirect("~/Frm_ErrorPage.aspx");
     }
 }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            if (rcmb_FinancialYear.SelectedIndex <= 0)
            {
                BLL.ShowMessage(this, "Please Select Financial Year");
                return;
            }

            SMHR_PENSION_INT_REG_UNREG _objPensionInt = new SMHR_PENSION_INT_REG_UNREG();
            _objPensionInt.ORGANISATION_ID      = Convert.ToInt32(Session["ORG_ID"]);
            _objPensionInt.INT_PERIOD_ID        = Convert.ToInt32(rcmb_FinancialYear.SelectedValue);
            _objPensionInt.INT_REGISTERED_AMT   = Convert.ToDecimal(rtxt_Registered.Text);
            _objPensionInt.INT_UNREGISTERED_AMT = Convert.ToDecimal(rtxt_UnRegistered.Text);
            _objPensionInt.INT_NORMAL_AMT       = Convert.ToDecimal(rtxt_Normal.Text);

            switch (((Button)sender).ID.ToUpper())
            {
            case "BTN_SAVE":

                //To check if similar record exists
                _objPensionInt.OPERATION = operation.Check;
                if (BLL.set_PensionIntOnRegtUnRegtAcct(_objPensionInt))
                {
                    BLL.ShowMessage(this, "Record already exists with similar data");
                    return;
                }

                _objPensionInt.OPERATION   = operation.Insert;
                _objPensionInt.CREATEDBY   = Convert.ToInt32(Session["User_ID"]);
                _objPensionInt.CREATEDDATE = DateTime.Now;

                if (BLL.set_PensionIntOnRegtUnRegtAcct(_objPensionInt))
                {
                    BLL.ShowMessage(this, "Information Saved Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Saved");
                }
                break;

            case "BTN_UPDATE":
                _objPensionInt.OPERATION   = operation.Update;
                _objPensionInt.INT_ID      = Convert.ToInt32(lblInterestID.Text);
                _objPensionInt.CREATEDBY   = Convert.ToInt32(Session["User_ID"]);
                _objPensionInt.CREATEDDATE = DateTime.Now;

                if (BLL.set_PensionIntOnRegtUnRegtAcct(_objPensionInt))
                {
                    BLL.ShowMessage(this, "Information Updated Successfully");
                }
                else
                {
                    BLL.ShowMessage(this, "Information Not Updated");
                }
                break;

            default:
                break;
            }
            RMP_IntrstOnRegstUnRegstAcct.SelectedIndex = 0;
            ClearControls();
            LoadGrid();
            Rg_IntrstOnRegstUnRegstAcct.DataBind();
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_IntrstOnRegUnRegAcct", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }