using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;
using System.Text;
using System.Collections.Generic;

public partial class Dispense_ATM_Rep : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadBranches();
            loadStatus();
            loadModifyReasons();
            loadValues(sender, e);
            loadCurrency();
        }

        //this.pnl_confirmation_recon.Visible = false;
        //this.pnl_confirmation_glentry.Visible = false;
        //lblError.Text = "";
        //lblError1.Text = "";
    }

    private void loadValues(object sender, EventArgs e)
    {
        if (Request.QueryString["atmno"] != null)
        {
            if (Request.QueryString["status"] == null)
            {
                txtTerminal.Text = Request.QueryString["atmno"];

                if (Request.QueryString["pReplDate"] != null)
                    txtprevrepldate.Text = Request.QueryString["pReplDate"];

                if (Request.QueryString["pReplTime"] != null)
                    txtprevtime.Text = Request.QueryString["pReplTime"];

                if (Request.QueryString["ReplDate"] != null)
                   txtrepldate.Text = Request.QueryString["ReplDate"];

                if (Request.QueryString["ReplTime"] != null)
                    txtrepltime.Text = Request.QueryString["ReplTime"];

                btnSearch_Click(sender, e);

                //row1.Visible = true;
                //lblTime.Visible = true;
                //txtTime.Visible = true;

                repltime.Visible = true;
                prev_repl.Visible = true;
            }

            else
            {
                if (Request.QueryString["status"] == "4")
                {
                    if (Request.QueryString["ReplDate"] != null)
                        txtrepldate.Text = Request.QueryString["ReplDate"];

                    //pnlSearch.Visible = false;
                    //pnlResult.Visible = false;
                    //pnlControls.Visible = true;
                    getEJMissingReplenishmentData();
                }

            }

        }
        else
        {
            //row1.Visible = false;
            //lblTime.Visible = false;
            //txtTime.Visible = false;

            repltime.Visible = false;
            prev_repl.Visible = false;
        }
    }

    private void loadBranches()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.Get_Branches";

        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_branches", OracleType.Cursor).Direction = ParameterDirection.Output;

        oracom.Parameters["p_lang"].Value = "EN";

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        DropDownList1.DataSource = ds;
        DropDownList1.DataBind();

        oracon.Close();
    }

    private void loadCurrency()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.get_repl_curr";

        oracom.Parameters.Add("p_repl_curr", OracleType.Cursor).Direction = ParameterDirection.Output;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlCurrency.DataSource = ds;
        ddlCurrency.DataBind();

        DropDownList2.DataSource = ds;
        DropDownList2.DataBind();

        oracon.Close();
    }

    private void loadStatus()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.get_repl_status";

        oracom.Parameters.Add("p_status", OracleType.Cursor).Direction = ParameterDirection.Output;


        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlStatus.DataSource = ds;
        ddlStatus.DataBind();

        oracon.Close();
    }

    private void loadModifyReasons()
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.Get_Repl_Mod_Reasons";

        oracom.Parameters.Add("p_reasons", OracleType.Cursor).Direction = ParameterDirection.Output;


        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        ddlModifyReason.DataSource = ds;
        ddlModifyReason.DataBind();

        ddlModifyReason.Items.Insert(0, "------ Reasons ------");

        oracon.Close();
    }

    private void loadResult(int pageSize, int pageNumber)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.get_atm_replenishments";


        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;


        oracom.Parameters["p_atm_num"].Value = txtTerminal.Text;
        oracom.Parameters["p_prev_repl_date"].Value = txtprevrepldate.Text;
        oracom.Parameters["p_prev_repl_time"].Value = txtprevtime.Text;
        //oracom.Parameters["p_repl_date"].Value = txtrepldate.Text;
        oracom.Parameters["p_repl_date"].Value = pickrepldate.Text;
        oracom.Parameters["p_repl_time"].Value = txtrepltime.Text;
        oracom.Parameters["p_page_size"].Value = pageSize;
        oracom.Parameters["p_page_num"].Value = pageNumber;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
        oracon.Close();

        GridView1.DataSource = ds;
        GridView1.DataBind();
        if (pageNumber == 1)
        {
            ddlPages.Items.Clear();
            for (int i = 1; i <= nop; i++)
            {
                ddlPages.Items.Add(i.ToString());
            }
        }
    }

    private void viewClaims(string fromdate, string todate, string fromtime, string totime, int index, int pageSize, int pageNumber)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "claim_process.get_atm_claims_for_period";


        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rec_type", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["p_atm_num"].Value = txtTerminal.Text;
        oracom.Parameters["p_rec_type"].Value = "009";
        oracom.Parameters["p_from_date"].Value = fromdate;
        oracom.Parameters["p_to_date"].Value = todate;
        oracom.Parameters["p_from_time"].Value = fromtime;
        oracom.Parameters["p_to_time"].Value = totime;

        oracom.Parameters["p_page_size"].Value = pageSize;
        oracom.Parameters["p_page_num"].Value = pageNumber;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
        oracon.Close();

        GridView2.DataSource = ds;
        GridView2.DataBind();
        if (pageNumber == 1)
        {
            DropDownList3.Items.Clear();
            for (int i = 1; i <= nop; i++)
            {
                DropDownList3.Items.Add(i.ToString());
            }
        }
    }

    private void getEJMissingReplenishmentData()
    {
        pnlReadOnly.Visible = true;
        //loadBranches();

        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.get_replinfo_ejmissing";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_cur", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_type", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_openBal", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_closeBal", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;


        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;


        oracom.Parameters["p_atm_num"].Value = Request.QueryString["atmno"];
        oracom.Parameters["p_repl_date"].Value = txtprevrepldate.Text;
        oracom.Parameters["p_repl_time"].Value = Request.QueryString["ReplTime"].Replace(":", "");
        oracom.Parameters["p_repl_cur"].Value = Request.QueryString["replCurrency"];
        oracom.Parameters["p_atm_type"].Value = Request.QueryString["type"];
        oracom.Parameters["p_openBal"].Value = getNumber(Request.QueryString["openingBalance"]);
        oracom.Parameters["p_closeBal"].Value = getNumber(Request.QueryString["closingBalance"]);

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        #region "Filling Controls"
        ViewState["rowid"] = ds.Tables[0].Rows[0]["rid"].ToString();
        ViewState["acctNo"] = ds.Tables[0].Rows[0]["acct_number"].ToString();
        txtEJREPLGLATMDifference.Text = ds.Tables[0].Rows[0]["ej_repl_difference"].ToString();
        string terminalID = ds.Tables[0].Rows[0]["terminal_id"].ToString();
        string branchID = ds.Tables[0].Rows[0]["branch_code"].ToString();

        DropDownList1.SelectedValue = branchID;
        txtATMNumberAdd.Text = terminalID;
        DropDownList1.Enabled = false;
        txtATMNumberAdd.Enabled = false;

        TextBox5.Enabled = false;
        TextBox7.Enabled = true;
        TextBox8.Enabled = true;

        //txtaprevrepldate.Text = ds.Tables[0].Rows[0]["prev_replenishment_date"].ToString();
        txtaprevrepldate.Text = ds.Tables[0].Rows[0]["prev_replenishment_date"].ToString();

        txtPreTime.Text = ds.Tables[0].Rows[0]["prev_replenishment_time"].ToString();

        //txtarepldate.Text = ds.Tables[0].Rows[0]["replenishment_date"].ToString();
        txtarepldate.Text = ds.Tables[0].Rows[0]["replenishment_date"].ToString();
        txtRepTime.Text = ds.Tables[0].Rows[0]["replenishment_time"].ToString();
        TextBox5.Text = ds.Tables[0].Rows[0]["replenishment_currency"].ToString();
        TextBox6.Text = ds.Tables[0].Rows[0]["amount_dispensed"].ToString();
        TextBox7.Text = ds.Tables[0].Rows[0]["amount_frm_vault"].ToString();
        TextBox8.Text = ds.Tables[0].Rows[0]["amount_to_vault"].ToString();
        ddlStatus.SelectedValue = ds.Tables[0].Rows[0]["status_code"].ToString();
        txtrecdate.Text = ds.Tables[0].Rows[0]["record_date"].ToString();
        TextBox11.Text = ds.Tables[0].Rows[0]["opening_balance"].ToString();
        TextBox12.Text = ds.Tables[0].Rows[0]["closing_balance"].ToString();
        TextBox11.Enabled = false;
        TextBox12.Enabled = false;
        txtGlDifference.Text = ds.Tables[0].Rows[0]["gl_atm_difference"].ToString();
        TextBox14.Text = ds.Tables[0].Rows[0]["ej_atm_difference"].ToString();
        txtOverAllDiffer.Text = ds.Tables[0].Rows[0]["overall_atm_diff"].ToString();

        TextBox16.Text = ds.Tables[0].Rows[0]["rec_type_code"].ToString();
        TextBox17.Text = ds.Tables[0].Rows[0]["verified_date"].ToString();
        TextBox18.Text = ds.Tables[0].Rows[0]["verified_time"].ToString();
        TextBox19.Text = ds.Tables[0].Rows[0]["sw_amount_dispensed"].ToString();
        TextBox1.Text = ds.Tables[0].Rows[0]["error_description"].ToString();
        TextBox3.Text = ds.Tables[0].Rows[0]["GL_amount_dispensed"].ToString();
        if (ds.Tables[0].Rows[0]["Modify_Reason"].ToString().Length > 0)
            ddlModifyReason.SelectedValue = ds.Tables[0].Rows[0]["Modify_Reason"].ToString();
        if (ds.Tables[0].Rows[0]["from_b24"].ToString() == "Y")
            chkFromBase24.Checked = true;
        txtClAdd.Text = ds.Tables[0].Rows[0]["ej_print_flag"].ToString();
        txtBANCS.Text = ds.Tables[0].Rows[0]["bancs_recon_result"].ToString();
        TextBox20.Text = ds.Tables[0].Rows[0]["b24_amount_dispensed"].ToString();
        TextBox21.Text = ds.Tables[0].Rows[0]["b24_amount_frm_vault"].ToString();
        TextBox22.Text = ds.Tables[0].Rows[0]["b24_amount_to_vault"].ToString();

        txtB24Time.Text = ds.Tables[0].Rows[0]["b24_rpl_time"].ToString();
        txtPrevB24Time.Text = ds.Tables[0].Rows[0]["b24_p_rpl_time"].ToString();

        txtUser.Text = ds.Tables[0].Rows[0]["created_by"].ToString();
        txtUserDate.Text = ds.Tables[0].Rows[0]["create_date"].ToString();

        txtdateB24Date.Text = ds.Tables[0].Rows[0]["b24_rpl_date"].ToString();
        txtdateB24PrevDate.Text = ds.Tables[0].Rows[0]["b24_p_rpl_date"].ToString();

        //pnlControls.Visible = true;
        //pnlResult.Enabled = false;

        ViewState["mode"] = "u";

        Session["fromdate"] = ds.Tables[0].Rows[0]["prev_repl_date"].ToString();
        Session["todate"] = ds.Tables[0].Rows[0]["repl_date"].ToString();
        Session["fromtime"] = ds.Tables[0].Rows[0]["prev_repl_time"].ToString();
        Session["totime"] = ds.Tables[0].Rows[0]["repl_time"].ToString();
        //viewClaims(Session["fromdate"].ToString(), Session["todate"].ToString(), Session["fromtime"].ToString(), Session["totime"].ToString(), index, Helper.gridSize(), 1);

        /*IJR
         31-Jan-2012
         Add Functionlaity to Get the Diverted Amount for the ATM
         */
        if (chkFromBase24.Checked)
            txtDivertedSAR.Text = "NA";
        else
        {
            oracom = new OracleCommand();
            oracom.Connection = oracon;

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "atm_replenishment_editor.get_atm_diverted";

            oracom.Parameters.Clear();
            oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_pre_clear_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_pre_clear_time", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_msg_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_msg_time", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_amount_SAR", OracleType.Number).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_amount_USD", OracleType.Number).Direction = ParameterDirection.Output;

            oracom.Parameters["p_atm_id"].Value = txtATMNumberAdd.Text.Substring(txtATMNumberAdd.Text.Length - 4);
            oracom.Parameters["p_pre_clear_date"].Value = txtaprevrepldate.Text;
            if (txtPreTime.Text.Length > 0)
                oracom.Parameters["p_pre_clear_time"].Value = txtPreTime.Text.Substring(0, 5);
            else
                oracom.Parameters["p_pre_clear_time"].Value = OracleString.Null;
            oracom.Parameters["p_msg_date"].Value = txtarepldate.Text;
            oracom.Parameters["p_msg_time"].Value = txtRepTime.Text.Substring(0, 5);

            da = new OracleDataAdapter(oracom);
            ds = new DataSet();
            da.Fill(ds);
            txtDivertedSAR.Text = oracom.Parameters["p_amount_SAR"].Value.ToString();
            txtDivertedUSD.Text = oracom.Parameters["p_amount_USD"].Value.ToString();

        }

        /*IHJ 06-06-2012
         Add Functionlity to get the Dropped Tranasctions for Finacle
         */

        oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.getDebitCreditFinacleDropped";

        oracom.Parameters.Clear();
        oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_pre_clear_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_pre_clear_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_msg_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_msg_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        //oracom.Parameters.Add("p_re_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_Credit", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Debit", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_nonDrop", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["p_atm_id"].Value = txtATMNumberAdd.Text;
        oracom.Parameters["p_pre_clear_date"].Value = txtaprevrepldate.Text;



        if (txtPreTime.Text == "")
            oracom.Parameters["p_pre_clear_time"].Value = "000000";
        else
            oracom.Parameters["p_pre_clear_time"].Value = txtPreTime.Text.Substring(0, 5).Replace(":", "") + "00";

        oracom.Parameters["p_msg_date"].Value = txtarepldate.Text;
        if (txtRepTime.Text == "")
            oracom.Parameters["p_msg_time"].Value = "000000";
        else
            oracom.Parameters["p_msg_time"].Value = txtRepTime.Text.Substring(0, 5).Replace(":", "") + "00";

        da = new OracleDataAdapter(oracom);
        ds = new DataSet();
        da.Fill(ds);
        //txtDebitDrop.Text = oracom.Parameters["p_Credit"].Value.ToString();
        ////txtCreditDrop.Text = oracom.Parameters["p_Credit"].Value.ToString();
        //// txtNonDrop.Text = oracom.Parameters["p_nonDrop"].Value.ToString();
        grDropDetails.DataSource = null;
        grFinacleReplDet.DataSource = null;

        grDropDetails.DataSource = null;
        grDropDetails.DataBind();
        grFinacleReplDet.DataSource = null;
        grFinacleReplDet.DataBind();

        #endregion

    }

    private void getReplenishmentData(string fromdate, string todate, string fromtime, string totime, int pageSize, int pageNumber)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.getChannelsReplenishment";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_re_code", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["p_atm_id"].Value = txtTerminal.Text;
        oracom.Parameters["p_from_date"].Value = fromdate;
        oracom.Parameters["p_to_date"].Value = todate;
        oracom.Parameters["p_from_time"].Value = fromtime;
        oracom.Parameters["p_to_time"].Value = totime;

        oracom.Parameters["p_re_code"].Value = int.Parse(ddlRepType.SelectedValue);


        oracom.Parameters["p_page_size"].Value = pageSize;
        oracom.Parameters["p_page_num"].Value = pageNumber;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);

        int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
        oracon.Close();

        grFinacleReplDet.DataSource = ds;
        grFinacleReplDet.DataBind();
        if (pageNumber == 1)
        {
            ddlChangeReplIndex.Items.Clear();
            for (int i = 1; i <= nop; i++)
            {
                ddlChangeReplIndex.Items.Add(i.ToString());
            }
        }
    }

    protected void ddlChangeReplIndex_SelectedIndexChanged(object sender, EventArgs e)
    {
        getReplenishmentData(txtdateB24PrevDate.Text.ToString(), txtdateB24Date.Text.ToString(),
            txtPrevB24Time.Text.Replace(":", ""), txtB24Time.Text.Replace(":", ""), Helper.gridSize(), int.Parse(ddlChangeReplIndex.SelectedValue));
    }

    protected void ddlDropDetails_SelectedIndexChanged(object sender, EventArgs e)
    {
        getDropDetails(Helper.gridSize(), int.Parse(ddlDropDetails.SelectedValue));
        Page.RegisterStartupScript("showgrid3", "<script language = JavaScript> showgrid3();</script>");
    }

    protected void btnGetData_Click(object sender, EventArgs e)
    {
        if (ddlChangeReplIndex.Items.Count < 1)
        {
            getReplenishmentData(txtdateB24PrevDate.Text.ToString(), txtdateB24Date.Text.ToString(),
                txtPrevB24Time.Text.Replace(":", ""), txtB24Time.Text.Replace(":", ""), Helper.gridSize(), 1);
        }
        else
            getReplenishmentData(txtdateB24PrevDate.Text.ToString(), txtdateB24Date.Text.ToString(),
                txtPrevB24Time.Text.Replace(":", ""), txtB24Time.Text.Replace(":", ""), Helper.gridSize(), int.Parse(ddlChangeReplIndex.SelectedValue));

        Page.RegisterStartupScript("showgrid2", "<script language = JavaScript> showgrid2();</script>");
    }


    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if(txtTerminal.Text !="")
        {
            txtrepltime.Text = pickrepltime.Text;
            //pnlResult.Visible = true;
            //pnlControls.Visible = false;
            //pnlResult.Enabled = true;

            if (txtrepldate.Text != "")
            {
                string d, m, y;
                string[] values = txtrepldate.Text.Split('-');
                d = values[0].ToString();
                m = values[1].ToString();
                y = values[2].Substring(2).ToString();

                pickrepldate.Text = y + m + d;
            }
            else pickrepldate.Text = "";

            loadResult(Helper.gridSize(), 1);

            grFinacleReplDet.DataSource = null;
            grFinacleReplDet.DataBind();
            grDropDetails.DataSource = null;
            grDropDetails.DataBind();

            RepSResults.Visible = true;
        }
        else
        {
            Notifications.showMessage("You have to enter the ATM No", this, Notifications.errorMessage, false);
            return;
        }
        
    }

    protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadResult(Helper.gridSize(), int.Parse(ddlPages.SelectedValue));
    }

    protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
    {
        int index = int.Parse(ViewState["index"].ToString());
        viewClaims(Session["fromdate"].ToString(), Session["todate"].ToString(), Session["fromtime"].ToString(), Session["totime"].ToString(), index, Helper.gridSize(), int.Parse(DropDownList3.SelectedValue));
        Page.RegisterStartupScript("showgrid", "<script language = JavaScript> showgrid();</script>");
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Notifications.showModal("modal-xl", this);

        DropDownList1.Enabled = true;
        txtATMNumberAdd.Enabled = true;
        clear();
        //txtarepldate.Visible = false;
        //txtaprevrepldate.Visible = false;
        //aprevrepldate.Visible = true;
        //arepldate.Visible = true;
        TextBox5.Enabled = true;
        TextBox6.Enabled = true;
        TextBox7.Enabled = true;
        TextBox8.Enabled = true;


        //pnlControls.Visible = true;
        //pnlResult.Enabled = false;
        ViewState["mode"] = "a";

        DropDownList1.SelectedIndex = 0;
        pnlReadOnly.Visible = false;

        ddlCurrency.Visible = true;
        TextBox5.Visible = false;
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("e"))
        {
            Notifications.showModal("modal-xl", this);

            pnlReadOnly.Visible = true;
            ddlCurrency.Visible = false;
            TextBox5.Visible = true;
            clear();
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            string acctNo = GridView1.Rows[index].Cells[6].Text.Trim();
            ViewState["acctNo"] = acctNo;

            string DBConnection = Helper.dbConnection();

            OracleConnection oracon = new OracleConnection(DBConnection);
            oracon.Open();

            OracleCommand oracom = new OracleCommand();
            oracom.Connection = oracon;

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "atm_replenishment_editor.get_repl_by_id";


            oracom.Parameters.Add("p_rid", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

            oracom.Parameters["p_rid"].Value = rowID;
            oracom.Parameters["p_lang"].Value = "EN";

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            DropDownList2.SelectedValue = ds.Tables[0].Rows[0]["repl_curr"].ToString();
            txtEJREPLGLATMDifference.Text = ds.Tables[0].Rows[0]["ej_repl_difference"].ToString();
            string terminalID = ds.Tables[0].Rows[0]["terminal_id"].ToString();
            string branchID = ds.Tables[0].Rows[0]["branch_code"].ToString();

            //DropDownList1.SelectedValue = branchID;
            txtATMNumberAdd.Text = terminalID;
            DropDownList1.Enabled = false;
            txtATMNumberAdd.Enabled = false;

            TextBox5.Enabled = false;
            TextBox7.Enabled = false;
            TextBox8.Enabled = false;

            //txtaprevrepldate.Text = ds.Tables[0].Rows[0]["prev_replenishment_date"].ToString();
            txtaprevrepldate.Text = ds.Tables[0].Rows[0]["prev_replenishment_date"].ToString();

            txtPreTime.Text = ds.Tables[0].Rows[0]["prev_replenishment_time"].ToString();

            txtarepldate.Text = ds.Tables[0].Rows[0]["replenishment_date"].ToString();
            txtarepldate.Text = ds.Tables[0].Rows[0]["replenishment_date"].ToString();//

            txtRepTime.Text = ds.Tables[0].Rows[0]["replenishment_time"].ToString();//GridView1.Rows[index].Cells[4].Text.ToString();
            TextBox5.Text = ds.Tables[0].Rows[0]["replenishment_currency"].ToString();//GridView1.Rows[index].Cells[2].Text.ToString();
            TextBox6.Text = ds.Tables[0].Rows[0]["amount_dispensed"].ToString();//GridView1.Rows[index].Cells[11].Text.ToString();
            TextBox7.Text = ds.Tables[0].Rows[0]["amount_frm_vault"].ToString();//GridView1.Rows[index].Cells[12].Text.ToString();
            TextBox8.Text = ds.Tables[0].Rows[0]["amount_to_vault"].ToString();//GridView1.Rows[index].Cells[13].Text.ToString();
            ddlStatus.SelectedValue = ds.Tables[0].Rows[0]["status_code"].ToString();//GridView1.Rows[index].Cells[24].Text.ToString();
            txtrecdate.Text = ds.Tables[0].Rows[0]["record_date"].ToString();//GridView1.Rows[index].Cells[14].Text.ToString();
            TextBox11.Text = ds.Tables[0].Rows[0]["opening_balance"].ToString();//GridView1.Rows[index].Cells[16].Text.ToString();
            //IRfan_mod 1702226
            lbl_Disp_A.Text = ds.Tables[0].Rows[0]["disp_a"].ToString();
            lbl_Disp_B.Text = ds.Tables[0].Rows[0]["disp_b"].ToString();
            lbl_Disp_C.Text = ds.Tables[0].Rows[0]["disp_c"].ToString();
            lbl_Disp_D.Text = ds.Tables[0].Rows[0]["disp_d"].ToString();
            lbl_Disp_E.Text = ds.Tables[0].Rows[0]["disp_e"].ToString();
            txt_Disp_A.Text = ds.Tables[0].Rows[0]["tot_disp_a"].ToString();
            txt_Disp_B.Text = ds.Tables[0].Rows[0]["tot_disp_b"].ToString();
            txt_Disp_C.Text = ds.Tables[0].Rows[0]["tot_disp_c"].ToString();
            txt_Disp_D.Text = ds.Tables[0].Rows[0]["tot_disp_d"].ToString();
            txt_Disp_E.Text = ds.Tables[0].Rows[0]["tot_disp_e"].ToString();

            txtGlRetract.Text = ds.Tables[0].Rows[0]["gl_ret_amt"].ToString();
            //Ends

            //if (ds.Tables[0].Rows[0]["opening_balance"].ToString ().Length >0)
            //{
            //    if (double.Parse(ds.Tables[0].Rows[0]["opening_balance"].ToString()) > 0)
            //        TextBox11.ReadOnly = true;
            //    else
            //        TextBox11.ReadOnly = false;
            //}
            //else
            //    TextBox11.ReadOnly = false;


            TextBox12.Text = ds.Tables[0].Rows[0]["closing_balance"].ToString();//GridView1.Rows[index].Cells[17].Text.ToString();
            //if (ds.Tables[0].Rows[0]["closing_balance"].ToString().Length != 0)
            //{
            //    if (double.Parse(ds.Tables[0].Rows[0]["closing_balance"].ToString()) > 0)
            //        TextBox12.ReadOnly = true;
            //    else
            //        TextBox12.ReadOnly = false;
            //}
            TextBox11.Enabled = false;
            TextBox12.Enabled = false;
            txtGlDifference.Text = ds.Tables[0].Rows[0]["gl_atm_difference"].ToString();//GridView1.Rows[index].Cells[18].Text.ToString();
            TextBox14.Text = ds.Tables[0].Rows[0]["ej_atm_difference"].ToString();//GridView1.Rows[index].Cells[19].Text.ToString();
            txtOverAllDiffer.Text = ds.Tables[0].Rows[0]["overall_atm_diff"].ToString();//GridView1.Rows[index].Cells[20].Text.ToString();
            //if (double.Parse(ds.Tables[0].Rows[0]["overall_atm_diff"].ToString()) > 0)
            //{
            //    TextBox11.ReadOnly = false;
            //    TextBox12.ReadOnly = false;
            //    TextBox11.Enabled = true;
            //    TextBox12.Enabled = true;
            //}
            //else
            //{
            //    TextBox11.Enabled = false; ;
            //    TextBox12.Enabled  = false;
            //}
            TextBox16.Text = ds.Tables[0].Rows[0]["rec_type_code"].ToString();//GridView1.Rows[index].Cells[21].Text.ToString();
            TextBox17.Text = ds.Tables[0].Rows[0]["verified_date"].ToString();//GridView1.Rows[index].Cells[22].Text.ToString();
            TextBox18.Text = ds.Tables[0].Rows[0]["verified_time"].ToString();//GridView1.Rows[index].Cells[23].Text.ToString();
            TextBox19.Text = ds.Tables[0].Rows[0]["sw_amount_dispensed"].ToString();//GridView1.Rows[index].Cells[15].Text.ToString();
            TextBox1.Text = ds.Tables[0].Rows[0]["error_description"].ToString();//GridView1.Rows[index].Cells[25].Text.ToString();
            TextBox3.Text = ds.Tables[0].Rows[0]["GL_amount_dispensed"].ToString();//GridView1.Rows[index].Cells[26].Text.ToString();
            if (ds.Tables[0].Rows[0]["Modify_Reason"].ToString().Length > 0)
            {
                if (ds.Tables[0].Rows[0]["Modify_Reason"].ToString() == "0")
                    ddlModifyReason.SelectedIndex = -1;
                else
                    ddlModifyReason.SelectedValue = ds.Tables[0].Rows[0]["Modify_Reason"].ToString();//GridView1.Rows[index].Cells[27].Text.ToString();
            }
            if (ds.Tables[0].Rows[0]["from_b24"].ToString() == "Y")
                chkFromBase24.Checked = true;
            txtClAdd.Text = ds.Tables[0].Rows[0]["ej_print_flag"].ToString();//GridView1.Rows[index].Cells[29].Text.ToString();
            txtBANCS.Text = ds.Tables[0].Rows[0]["bancs_recon_result"].ToString();//GridView1.Rows[index].Cells[30].Text.ToString();

            TextBox20.Text = ds.Tables[0].Rows[0]["b24_amount_dispensed"].ToString();//GridView1.Rows[index].Cells[31].Text.ToString();
            TextBox21.Text = ds.Tables[0].Rows[0]["b24_amount_frm_vault"].ToString();//GridView1.Rows[index].Cells[32].Text.ToString();
            TextBox22.Text = ds.Tables[0].Rows[0]["b24_amount_to_vault"].ToString();//GridView1.Rows[index].Cells[33].Text.ToString();

            txtB24Time.Text = ds.Tables[0].Rows[0]["b24_rpl_time"].ToString();//GridView1.Rows[index].Cells[34].Text.ToString();
            txtPrevB24Time.Text = ds.Tables[0].Rows[0]["b24_p_rpl_time"].ToString();//GridView1.Rows[index].Cells[35].Text.ToString();

            txtUser.Text = ds.Tables[0].Rows[0]["created_by"].ToString();//GridView1.Rows[index].Cells[36].Text.ToString();
            txtUserDate.Text = ds.Tables[0].Rows[0]["create_date"].ToString();//GridView1.Rows[index].Cells[37].Text.ToString();

            txtdateB24Date.Text = ds.Tables[0].Rows[0]["b24_rpl_date"].ToString();//GridView1.Rows[index].Cells[38].Text.ToString();
            txtdateB24PrevDate.Text = ds.Tables[0].Rows[0]["b24_p_rpl_date"].ToString();//GridView1.Rows[index].Cells[39].Text.ToString();

            //pnlControls.Visible = true;
            //pnlResult.Enabled = false;

            ViewState["mode"] = "u";
            ViewState["rowid"] = rowID;
            ViewState["index"] = index;
            Session["fromdate"] = ds.Tables[0].Rows[0]["prev_repl_date"].ToString();
            Session["todate"] = ds.Tables[0].Rows[0]["repl_date"].ToString();
            Session["fromtime"] = ds.Tables[0].Rows[0]["prev_repl_time"].ToString();
            Session["totime"] = ds.Tables[0].Rows[0]["repl_time"].ToString();
            viewClaims(Session["fromdate"].ToString(), Session["todate"].ToString(), Session["fromtime"].ToString(), Session["totime"].ToString(), index, Helper.gridSize(), 1);

            /*IJR
             31-Jan-2012
             Add Functionlaity to Get the Diverted Amount for the ATM
             */
            if (chkFromBase24.Checked)
                txtDivertedSAR.Text = "NA";
            else
            {
                oracom = new OracleCommand();
                oracom.Connection = oracon;

                oracom.CommandType = CommandType.StoredProcedure;
                oracom.CommandText = "atm_replenishment_editor.get_atm_diverted";

                oracom.Parameters.Clear();
                oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
                oracom.Parameters.Add("p_pre_clear_date", OracleType.VarChar).Direction = ParameterDirection.Input;
                oracom.Parameters.Add("p_pre_clear_time", OracleType.VarChar).Direction = ParameterDirection.Input;
                oracom.Parameters.Add("p_msg_date", OracleType.VarChar).Direction = ParameterDirection.Input;
                oracom.Parameters.Add("p_msg_time", OracleType.VarChar).Direction = ParameterDirection.Input;
                oracom.Parameters.Add("p_amount_SAR", OracleType.Number).Direction = ParameterDirection.Output;
                oracom.Parameters.Add("p_amount_USD", OracleType.Number).Direction = ParameterDirection.Output;

                oracom.Parameters["p_atm_id"].Value = txtATMNumberAdd.Text.Substring(txtATMNumberAdd.Text.Length - 4);
                oracom.Parameters["p_pre_clear_date"].Value = txtaprevrepldate.Text;
                if (txtPreTime.Text.Length > 0)
                    oracom.Parameters["p_pre_clear_time"].Value = txtPreTime.Text.Substring(0, 5);
                else
                    oracom.Parameters["p_pre_clear_time"].Value = OracleString.Null;
                oracom.Parameters["p_msg_date"].Value = txtarepldate.Text;
                if (txtRepTime.Text.Length > 0)
                    oracom.Parameters["p_msg_time"].Value = txtRepTime.Text.Substring(0, 5);
                else
                    oracom.Parameters["p_msg_time"].Value = OracleString.Null;

                da = new OracleDataAdapter(oracom);
                ds = new DataSet();
                da.Fill(ds);
                txtDivertedSAR.Text = oracom.Parameters["p_amount_SAR"].Value.ToString();
                txtDivertedUSD.Text = oracom.Parameters["p_amount_USD"].Value.ToString();

            }

            /*IHJ 06-06-2012
             Add Functionlity to get the Dropped Tranasctions for Finacle
             */

            oracom = new OracleCommand();
            oracom.Connection = oracon;

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "atm_replenishment_editor.getDebitCreditFinacleDropped";

            oracom.Parameters.Clear();
            oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_pre_clear_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_pre_clear_time", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_msg_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_msg_time", OracleType.VarChar).Direction = ParameterDirection.Input;
            //oracom.Parameters.Add("p_re_code", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_Credit", OracleType.Number).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_Debit", OracleType.Number).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_nonDrop", OracleType.Number).Direction = ParameterDirection.Output;

            oracom.Parameters["p_atm_id"].Value = txtATMNumberAdd.Text;
            oracom.Parameters["p_pre_clear_date"].Value = txtaprevrepldate.Text;



            if (txtPreTime.Text == "")
                oracom.Parameters["p_pre_clear_time"].Value = "000000";
            else
                oracom.Parameters["p_pre_clear_time"].Value = txtPreTime.Text.Substring(0, 5).Replace(":", "") + "00";

            oracom.Parameters["p_msg_date"].Value = txtarepldate.Text;
            if (txtRepTime.Text == "")
                oracom.Parameters["p_msg_time"].Value = "000000";
            else
                oracom.Parameters["p_msg_time"].Value = txtRepTime.Text.Substring(0, 5).Replace(":", "") + "00";

            da = new OracleDataAdapter(oracom);
            ds = new DataSet();
            da.Fill(ds);
            //txtDebitDrop.Text = oracom.Parameters["p_Credit"].Value.ToString();
            ////txtCreditDrop.Text = oracom.Parameters["p_Credit"].Value.ToString();
            //// txtNonDrop.Text = oracom.Parameters["p_nonDrop"].Value.ToString();
            grDropDetails.DataSource = null;
            grFinacleReplDet.DataSource = null;

            grDropDetails.DataSource = null;
            grDropDetails.DataBind();
            grFinacleReplDet.DataSource = null;
            grFinacleReplDet.DataBind();



            //   txtGlDifference.Text = (double.Parse(txtGlDifference.Text) + (double.Parse(txtDebitDrop.Text) - double.Parse(txtCreditDrop.Text))).ToString();
            //txtOverAllDiffer.Text = (double.Parse(TextBox11.Text) - (double.Parse(TextBox3.Text) - double.Parse(TextBox12.Text))).ToString("#,##0");


        }
    }

    protected void btnDropGet_Click(object sender, EventArgs e)
    {

        getDropDetails(Helper.gridSize(), 1);
        Page.RegisterStartupScript("showgrid3", "<script language = JavaScript> showgrid3();</script>");
    }

    private void getDropDetails(int pageSize, int pageNumber)
    {
        /*30-6-2012
             IHJ 
             Added to get the details of the deopped transaction*/
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.getFinacleDroppedDetails";

        oracom.Parameters.Clear();
        oracom.Parameters.Add("p_current_uid", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_pre_clear_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_pre_clear_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_msg_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_msg_time", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters.Add("p_type", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters["p_page_size"].Value = pageSize;

        /*if (ddlDropDetails.Items.Count != 0)
            oracom.Parameters["p_page_num"].Value = 1;
        else
            oracom.Parameters["p_page_num"].Value = pageNumber;*/
        oracom.Parameters["p_page_num"].Value = pageNumber;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();


        oracom.Parameters["p_atm_id"].Value = txtATMNumberAdd.Text;
        oracom.Parameters["p_pre_clear_date"].Value = txtaprevrepldate.Text;


        if (txtPreTime.Text == "")
            oracom.Parameters["p_pre_clear_time"].Value = "000000";
        else
            oracom.Parameters["p_pre_clear_time"].Value = txtPreTime.Text.Substring(0, 5).Replace(":", "") + "00";

        oracom.Parameters["p_msg_date"].Value = txtarepldate.Text;

        if (txtRepTime.Text == "")
            oracom.Parameters["p_msg_time"].Value = "000000";
        else
            oracom.Parameters["p_msg_time"].Value = txtRepTime.Text.Substring(0, 5).Replace(":", "") + "00";


        oracom.Parameters["p_type"].Value = ddlDropSelection.SelectedValue;


        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da = new OracleDataAdapter(oracom);
        ds = new DataSet();
        da.Fill(ds);
        grDropDetails.DataSource = ds;
        grDropDetails.DataBind();

        int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
        if (pageNumber == 1)
        {
            if (nop > 0)
            {
                ddlDropDetails.Items.Clear();
                for (int i = 0; i < nop; i++)
                {
                    ddlDropDetails.Items.Add((i + 1).ToString());
                }
            }
        }
        //ddlDropDetails_SelectedIndexChanged
    }

    //protected void btnCancel_Click(object sender, EventArgs e)
    //{
    //    if (Request.QueryString["status"] == null)
    //    {
    //        pnlControls.Visible = false;
    //        pnlResult.Enabled = true;
    //    }
    //    else
    //    {
    //        Page.ClientScript.RegisterStartupScript(this.GetType(), "ATM Replenishment", "window.close()", true);
    //    }
    //}

    protected void btnSave_Click(object sender, EventArgs e)
    {
        Notifications.showModal("confirmation_recon-modal-xl", this);

        txtPreTime.Text = pickpretime.Text;
        txtRepTime.Text = pickreptime.Text;

        //pnl_confirmation_recon.Visible = true;
        //pnlResult.Enabled = false;
        //pnlControls.Visible = false;

        //try
        //{
        //    if (txtPrevB24Time.Text.Length != 0 && txtPrevB24Time.Text.Length != 8)
        //        lblError.Text = "time fields must be entered correctly";
        //    else if (txtB24Time.Text.Length != 0 && txtB24Time.Text.Length != 8)
        //        lblError.Text = "time fields must be entered correctly";
        //    else if (txtPreTime.Text.Length != 0 && txtPreTime.Text.Length != 8)
        //        lblError.Text = "time fields must be entered correctly";
        //    else if (txtRepTime.Text.Length != 0 && txtRepTime.Text.Length != 8)
        //        lblError.Text = "time fields must be entered correctly";
        //    else
        //    {
        //        string mode = ViewState["mode"].ToString();
        //        string error = "";
        //        if (mode.Equals("a"))
        //        {
        //            bool saved = addRepl(ref error);
        //            if (saved)
        //            {
        //                lblError.Text = "Replenishment data Saved";
        //            }
        //            else
        //            {
        //                lblError.Text = error;
        //            }
        //        }
        //        else if (mode.Equals("u"))
        //        {
        //            string Uid = ViewState["rowid"].ToString();
        //            if (TextBox11.Text.Length > 0)
        //            {
        //                bool saved = updateRepl(Uid, ref error);
        //                if (saved)
        //                {
        //                    lblError.Text = "Replenishment data Saved";
        //                }
        //                else
        //                {
        //                    lblError.Text = error;
        //                }
        //            }
        //            else
        //            {
        //                lblError.Text = "Please enter opening balance";
        //            }
        //        }
        //        //getrepS();
        //        ViewState["mode"] = null;
        //        ViewState["rowid"] = null;
        //        pnlControls.Visible = false;
        //        pnlResult.Enabled = true;
        //        loadResult(Helper.gridSize(), 1);
        //    }
        //}
        //catch (Exception ex)
        //{
        //    lblError.Text = ex.Message;
        //}
    }

    private bool addRepl(ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.add_atm_replenishment";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rid", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_branch_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_b24_prepl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_prepl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_repl_cur", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_amt_disp", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_amt_frm_vault", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_amt_to_vault", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_record_status", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        if (ViewState["rowid"] != null)
            oracom.Parameters["p_rid"].Value = ViewState["rowid"];
        else
            oracom.Parameters["p_rid"].Value = "0";
        oracom.Parameters["p_branch_code"].Value = DropDownList1.SelectedValue;
        oracom.Parameters["p_atm_num"].Value = txtATMNumberAdd.Text;

        oracom.Parameters["p_prev_repl_date"].Value = txtaprevrepldate.Text;
        oracom.Parameters["p_prev_repl_time"].Value = txtPreTime.Text.Replace(":", "");
        oracom.Parameters["p_repl_date"].Value = txtarepldate.Text;
        oracom.Parameters["p_repl_time"].Value = txtRepTime.Text.Replace(":", "");

        if (txtdateB24PrevDate.Text.Length > 0)
            oracom.Parameters["p_b24_prepl_date"].Value = txtdateB24PrevDate.Text;
        else
            oracom.Parameters["p_b24_prepl_date"].Value = OracleString.Null;

        oracom.Parameters["p_b24_prepl_time"].Value = txtPrevB24Time.Text.Replace(":", "");
        if (txtdateB24Date.Text.Length > 0)
            oracom.Parameters["p_b24_repl_date"].Value = txtdateB24Date.Text;
        else
            oracom.Parameters["p_b24_repl_date"].Value = OracleString.Null;
        oracom.Parameters["p_b24_repl_time"].Value = txtB24Time.Text.Replace(":", "");


        oracom.Parameters["p_repl_cur"].Value = ddlCurrency.SelectedValue;

        if (getNumber(TextBox6.Text).Length > 0)
            oracom.Parameters["p_amt_disp"].Value = getNumber(TextBox6.Text);
        else
            oracom.Parameters["p_amt_disp"].Value = OracleNumber.Null;

        if (getNumber(TextBox7.Text).Length > 0)
            oracom.Parameters["p_amt_frm_vault"].Value = getNumber(TextBox7.Text);
        else
            oracom.Parameters["p_amt_frm_vault"].Value = OracleNumber.Null;

        if (getNumber(TextBox8.Text).Length > 0)
            oracom.Parameters["p_amt_to_vault"].Value = getNumber(TextBox8.Text);
        else
            oracom.Parameters["p_amt_to_vault"].Value = OracleNumber.Null;

        oracom.Parameters["p_record_status"].Value = ddlStatus.SelectedValue;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    private bool updateRepl(string rowID, ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_replenishment_editor.update_atm_replenishment";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rid", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_prev_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_b24_prepl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_prepl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_b24_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_amt_disp", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_record_status", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_open_bal", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_close_bal", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_error_desc", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_reason", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_rid"].Value = rowID;

        if (txtdateB24PrevDate.Text.Length > 0)
            oracom.Parameters["p_b24_prepl_date"].Value = txtdateB24PrevDate.Text;
        else
            oracom.Parameters["p_b24_prepl_date"].Value = OracleString.Null;
        oracom.Parameters["p_b24_prepl_time"].Value = txtPrevB24Time.Text.Replace(":", "");
        if (txtdateB24Date.Text.Length > 0)
            oracom.Parameters["p_b24_repl_date"].Value = txtdateB24Date.Text;
        else
            oracom.Parameters["p_b24_repl_date"].Value = OracleString.Null;

        oracom.Parameters["p_b24_repl_time"].Value = txtB24Time.Text.Replace(":", "");

        oracom.Parameters["p_prev_repl_date"].Value = txtaprevrepldate.Text;
        oracom.Parameters["p_repl_date"].Value = txtarepldate.Text;
        oracom.Parameters["p_prev_repl_time"].Value = txtPreTime.Text.Replace(":", "");
        oracom.Parameters["p_repl_time"].Value = txtRepTime.Text.Replace(":", "");

        if (getNumber(TextBox6.Text).Length > 0)
            oracom.Parameters["p_amt_disp"].Value = getNumber(TextBox6.Text);
        else
            oracom.Parameters["p_amt_disp"].Value = OracleNumber.Null;

        oracom.Parameters["p_record_status"].Value = ddlStatus.SelectedValue;
        oracom.Parameters["p_open_bal"].Value = getNumber(TextBox11.Text);
        oracom.Parameters["p_close_bal"].Value = getNumber(TextBox12.Text);
        oracom.Parameters["p_error_desc"].Value = TextBox1.Text;
        if (ddlModifyReason.SelectedIndex > 0)
            oracom.Parameters["p_reason"].Value = ddlModifyReason.SelectedValue;
        else
            oracom.Parameters["p_reason"].Value = OracleString.Null;

        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    for (int i = 7; i <= 43;i++ )
        //        e.Row.Cells[i].Visible = false;
        //}
    }

    private string getNumber(string amount)
    {
        return amount.Replace(",", "");
    }

    private void clear()
    {
        txtaprevrepldate.Text = "";
        //txtaprevrepldate.Text = "";
        txtPreTime.Text = "";
        txtarepldate.Text = "";
        //txtarepldate.Text = "";
        txtRepTime.Text = "";
        TextBox5.Text = "";
        TextBox6.Text = "";
        TextBox7.Text = "";
        TextBox8.Text = "";
        ddlStatus.SelectedIndex = 0;
        txtrecdate.Text = "";
        TextBox11.Text = "";
        TextBox12.Text = "";
        txtGlDifference.Text = "";
        TextBox14.Text = "";
        txtOverAllDiffer.Text = "";
        TextBox16.Text = "";
        TextBox17.Text = "";
        TextBox18.Text = "";
        TextBox19.Text = "";
        TextBox1.Text = "";
        TextBox3.Text = "";
        ddlModifyReason.SelectedIndex = 0;
        chkFromBase24.Checked = false;
        txtClAdd.Text = "";
        txtBANCS.Text = "";
        TextBox20.Text = "";
        TextBox21.Text = "";
        TextBox22.Text = "";
        txtATMNumberAdd.Text = "";
        txtUser.Text = "";
        txtUserDate.Text = "";
        txtdateB24PrevDate.Text = "";
        txtdateB24Date.Text = "";
        txtB24Time.Text = "";
        txtPrevB24Time.Text = "";
    }

    protected void TextBox11_TextChanged(object sender, EventArgs e)
    {
        double openingBalance = double.Parse(TextBox11.Text);
        double closingBalance = double.Parse(TextBox12.Text);
        double dispAmount = double.Parse(TextBox3.Text);
        double overAllDiff = openingBalance - closingBalance - dispAmount;
        txtOverAllDiffer.Text = overAllDiff.ToString("#,##0");
        //txtOverAllDiffer.Text = (decimal.Parse(TextBox11.Text) - (decimal.Parse(TextBox3.Text) - decimal.Parse(TextBox12.Text))).ToString("#,##0");
    }
    protected void TextBox12_TextChanged(object sender, EventArgs e)
    {
        double openingBalance = double.Parse(TextBox11.Text);
        double closingBalance = double.Parse(TextBox12.Text);
        double dispAmount = double.Parse(TextBox3.Text);
        double overAllDiff = openingBalance - closingBalance - dispAmount;
        txtOverAllDiffer.Text = overAllDiff.ToString("#,##0");
        //txtOverAllDiffer.Text = (decimal.Parse(TextBox11.Text) - (decimal.Parse(TextBox3.Text) - decimal.Parse(TextBox12.Text))).ToString("#,##0");
    }
    protected void btnApprove_Click(object sender, EventArgs e)
    {

    }
    protected void btnReject_Click(object sender, EventArgs e)
    {

    }
    protected void btnManualGLEntry_Click(object sender, EventArgs e)
    {
        //Notifications.hideModal("modal-xl", this);
        //Notifications.showModal("confirmation-glentry-modal-xl", this);

        Notifications.showModal("confirmation-glentry-modal-xl", this);

        //pnl_confirmation_glentry.Visible = true;
        //pnlSearch.Enabled = false;
        //pnl_confirmation_recon.Visible = false;
        //pnlControls.Visible = false;
        //pnlResult.Enabled = false;
        /*
        StringBuilder sb = new StringBuilder();
        string atmNo = txtATMNumberAdd.Text.Trim();
        string branchNo = DropDownList1.SelectedValue;
        string replDate = txtarepldate.Text;
        string replTime = txtRepTime.Text.Trim();
        string atmType ="Dispense";
        string replCurrency = TextBox5.Text;
        string glAcctNo = ViewState["acctNo"].ToString();
        string openingBalance = TextBox11.Text.Trim();
        string closingBalance = TextBox12.Text.Trim();

        if (!atmNo.Equals("&nbsp;"))
            sb.Append("atmno=" + atmNo + "&");

        if (!replDate.Equals("&nbsp;"))
            sb.Append("replDate=" + replDate + "&");

        if (!replTime.Equals("&nbsp;"))
            sb.Append("replTime=" + replTime + "&");

        if (!atmType.Equals("&nbsp;"))
            sb.Append("atmType=" + atmType + "&");

        if (!replCurrency.Equals("&nbsp;"))
            sb.Append("replCurrency=" + replCurrency + "&");

        if (!glAcctNo.Equals("&nbsp;"))
            sb.Append("glAcctNo=" + glAcctNo + "&");

        if (!openingBalance.Equals("&nbsp;"))
            sb.Append("openingBalance=" + openingBalance + "&");

        if (!closingBalance.Equals("&nbsp;"))
            sb.Append("closingBalance=" + closingBalance + "&");

        string queryString = sb.ToString();
        queryString = queryString.TrimEnd('&');
        //ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                           // "window.open('ManualGLEntry.aspx?" + queryString + "','ManualGLEntry')", true);

        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                 "window.open('ManualGLEntry.aspx?" + queryString + "','popWindow','toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=700,height=350,left=300,top=50')", true);*/
    }
    [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
    public static List<string> GetCompletionList(string prefixText, int count)
    {
        return AutoFillAtmNo(prefixText);

    }
    private static List<string> AutoFillAtmNo(string prefixText)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.Text;
        oracom.CommandText = "select distinct substr(terminal_id,-4) as atm_number from atm_repl_details where record_type='009' and substr(terminal_id,-4) like '" + prefixText + "%' ";

        //oracom.Parameters.Add("p_value",OracleType.VarChar).Direction=ParameterDirection.Input;


        //oracom.Parameters["p_value"].Value = prefixText;

        List<string> atmList = new List<string>();
        OracleDataReader odr = oracom.ExecuteReader();

        while (odr.Read())
        {
            atmList.Add(odr["atm_number"].ToString());
        }

        oracon.Close();
        return atmList;

    }
    protected void btn_conf_ok_Click(object sender, EventArgs e)
    {
        //pnl_confirmation_recon.Visible = false;
        //pnlControls.Visible = false;
        //pnlSearch.Enabled = true;
        try
        {

            if (txtPrevB24Time.Text.Length != 0 && txtPrevB24Time.Text.Length != 8)
            {
                //lblError.Text = "time fields must be entered correctly";
                Notifications.showMessage("Time Fields must be entered Correctly", this, Notifications.errorMessage, false);
                //pnlControls.Visible = true;
                return;
            }
            else if (txtB24Time.Text.Length != 0 && txtB24Time.Text.Length != 8)
            {
                //lblError.Text = "time fields must be entered correctly";
                Notifications.showMessage("Time Fields must be entered Correctly", this, Notifications.errorMessage, false);
                //pnlControls.Visible = true;
                return;
            }
            else if (txtPreTime.Text.Length != 0 && txtPreTime.Text.Length != 8)
            {
                //lblError.Text = "time fields must be entered correctly";
                Notifications.showMessage("Time Fields must be entered Correctly", this, Notifications.errorMessage, false);
                //pnlControls.Visible = true;
                return;
            }
            else if (txtRepTime.Text.Length != 0 && txtRepTime.Text.Length != 8)
            {
                //lblError.Text = "time fields must be entered correctly";
                Notifications.showMessage("Time Fields must be entered Correctly", this, Notifications.errorMessage, false);
                //pnlControls.Visible = true;
                return;
            }
            else if (txtaprevrepldate.Text.Length > 0 && txtarepldate.Text.Length > 0)
            {
                if (int.Parse(txtaprevrepldate.Text) > int.Parse(txtarepldate.Text))
                {
                    //lblError.Text = "Previos Replenishment Date should be less than Replenishment Date";
                    Notifications.showMessage("Previos Replenishment Date should be less than Replenishment Date", this, Notifications.errorMessage, false);
                    //pnlControls.Visible = true;
                    return;
                }
                else
                {
                    string mode = ViewState["mode"].ToString();
                    string error = "";
                    if (mode.Equals("a"))
                    {
                        bool saved = addRepl(ref error);
                        if (saved)
                        {
                            //lblError.Text = "Replenishment data Saved";
                            Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                            //pnlControls.Visible = true;
                            btnSave.Visible = false;
                            return;
                        }
                        else
                        {
                            //lblError.Text = error;
                            Notifications.showMessage(error, this, Notifications.errorMessage, false);
                            return;
                        }
                    }
                    else if (mode.Equals("u"))
                    {
                        string Uid = ViewState["rowid"].ToString();
                        if (Uid.Length > 0)
                        {
                            if (TextBox11.Text.Length > 0)
                            {
                                bool saved = updateRepl(Uid, ref error);
                                if (saved)
                                {
                                    //lblError.Text = "Replenishment data Saved";
                                    Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                                    //pnlControls.Visible = true;
                                    btnSave.Visible = false;
                                    return;
                                }
                                else
                                {
                                    //lblError.Text = error;
                                    Notifications.showMessage(error, this, Notifications.errorMessage, false);
                                    //pnlControls.Visible = true;
                                    return;
                                }
                            }
                            else
                            {
                                //lblError.Text = "Please enter opening balance";
                                Notifications.showMessage("Please enter opening balance", this, Notifications.errorMessage, false);
                                //pnlControls.Visible = true;
                                return;
                            }
                        }
                        else
                        {
                            bool saved = addRepl(ref error);
                            if (saved)
                            {
                                //lblError.Text = "Replenishment data Saved";
                                Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                                //pnlControls.Visible = true;
                                btnSave.Visible = false;
                                return;
                            }
                            else
                            {
                                //lblError.Text = error;
                                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                                //pnlControls.Visible = true;
                                return;
                            }
                        }
                    }
                }
            }

            else
            {
                string mode = ViewState["mode"].ToString();
                string error = "";
                if (mode.Equals("a"))
                {
                    bool saved = addRepl(ref error);
                    if (saved)
                    {
                        //lblError.Text = "Replenishment data Saved";
                        Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                        //pnlControls.Visible = true;
                        btnSave.Visible = false;
                        return;
                    }
                    else
                    {
                        //lblError.Text = error;
                        Notifications.showMessage(error, this, Notifications.errorMessage, false);
                        //pnlControls.Visible = true;
                        return;
                    }
                }
                else if (mode.Equals("u"))
                {
                    string Uid = ViewState["rowid"].ToString();
                    if (Uid.Length > 0)
                    {
                        if (TextBox11.Text.Length > 0)
                        {
                            bool saved = updateRepl(Uid, ref error);
                            if (saved)
                            {
                                //lblError.Text = "Replenishment data Saved";
                                Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                                //pnlControls.Visible = true;
                                btnSave.Visible = false;
                                return;
                            }
                            else
                            {
                                //lblError.Text = error;
                                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                                //pnlControls.Visible = true;
                                return;
                            }
                        }
                        else
                        {
                            //lblError.Text = "Please enter opening balance";
                            Notifications.showMessage("Please enter opening balance", this, Notifications.errorMessage, false);
                            //pnlControls.Visible = true;
                            return;
                        }
                    }
                    else
                    {
                        bool saved = addRepl(ref error);
                        if (saved)
                        {
                            //lblError.Text = "Replenishment data Saved";
                            Notifications.showMessage("Replenishment data Saved", this, Notifications.errorMessage, false);
                            //pnlControls.Visible = true;
                            btnSave.Visible = false;
                            return;
                        }
                        else
                        {
                            //lblError.Text = error;
                            Notifications.showMessage(error, this, Notifications.errorMessage, false);
                            //pnlControls.Visible = true;
                            return;
                        }
                    }
                }
                //getrepS();
                ViewState["mode"] = null;
                ViewState["rowid"] = null;
                if (Request.QueryString["status"] == null)
                {
                    //pnlControls.Visible = false;
                    //pnlResult.Enabled = true;
                }
                else
                {
                    //pnlControls.Visible = true;
                    btnSave.Enabled = false;
                }

                loadResult(Helper.gridSize(), 1);
            }
        }
        catch (Exception ex)
        {
            //lblError.Text = ex.Message;
            Notifications.showMessage(ex.Message, this, Notifications.errorMessage, false);
            return;
        }
    }
    protected void btn_conf_cancel_Click(object sender, EventArgs e)
    {
        Notifications.hideModal("modal-xl", this);

        //pnl_confirmation_recon.Visible = false;
        //pnlControls.Visible = false;
        //pnlResult.Enabled = true;
    }
    protected void btn_confirm_ok_glentry_Click(object sender, EventArgs e)
    {
        Notifications.showModal("ManualGlEntry-modal-xl", this);
        TextBox4.Text = pickmrepltime.Text;

        //pnlManualGlEntry.Visible = true;
        //pnl_confirmation_glentry.Visible = false;
        //pnlResult.Visible = true;
        //pnlControls.Visible = false;
        ////StringBuilder sb = new StringBuilder();
        txtTerminalID.Text = "";
        txtrepldate.Text = "";
        txtrepltime.Text = "";


        txtGLAccountNo.Text = "";
        txtOpeningBalance.Text = "";
        txtClosingBalance.Text = "";


        string glAcctNo = "";
        string atmNo = txtATMNumberAdd.Text.Trim();
        string branchNo = DropDownList1.SelectedValue;
        string replDate = txtarepldate.Text;
        string replTime = txtRepTime.Text.Trim();


        if (ViewState["acctNo"] != null)
            glAcctNo = ViewState["acctNo"].ToString();
        string openingBalance = TextBox11.Text.Trim();
        string closingBalance = TextBox12.Text.Trim();


        if (!atmNo.Equals("&nbsp;"))
            txtTerminalID.Text = atmNo;
        //sb.Append("atmno=" + atmNo + "&");

        if (!replDate.Equals("&nbsp;"))
        {
            if (replDate.Length > 0)
            {
                txtrepldate.Visible = false;
                txtrepltime.Visible = true;
                //txtReplDate.Text = Request.QueryString["replDate"];

                string d, m, y;
                d = replDate.Substring(4, 2);
                m = replDate.Substring(2, 2);
                y = replDate.Substring(0, 2);
                txtrepldate.Text = d + "-" + m + "-" + "20" + y;
            }
        }
        //sb.Append("replDate=" + replDate + "&");

        if (!replTime.Equals("&nbsp;"))
            txtrepltime.Text = replTime;
        //sb.Append("replTime=" + replTime + "&");

        ddlReplType.SelectedValue = "009";
        //sb.Append("atmType=" + atmType + "&");



        if (!glAcctNo.Equals("&nbsp;"))
            txtGLAccountNo.Text = glAcctNo;
        //sb.Append("glAcctNo=" + glAcctNo + "&");

        if (!openingBalance.Equals("&nbsp;"))
            txtOpeningBalance.Text = openingBalance;
        //sb.Append("openingBalance=" + openingBalance + "&");

        if (!closingBalance.Equals("&nbsp;"))
            txtClosingBalance.Text = closingBalance;
        //sb.Append("closingBalance=" + closingBalance + "&");

        //string queryString = sb.ToString();
        //queryString = queryString.TrimEnd('&');

        // ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        // "window.open('ManualGLEntry.aspx?" + queryString + "','ManualGLEntry')", true);

        //ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //                         "window.open('ManualGLEntry.aspx?" + queryString + "','popWindow','toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=700,height=350,left=300,top=50')", true);

    }
    protected void btn_confirm_cancel_glentry_Click(object sender, EventArgs e)
    {
        Notifications.showModal("modal-xl", this);

        //pnl_confirmation_glentry.Visible = false;
        //pnl_confirmation_recon.Visible = false;
        //pnlControls.Visible = true;
        //pnlResult.Visible = true;
        //pnlSearch.Enabled = true;

        //pnlResult.Visible = true;
    }
    protected void btnSaveManualGlEntry_Click(object sender, EventArgs e)
    {
        string error = "";
        string openingBalance;
        string closingBalance;
        double retractAmount = 0;

        if (txtOpeningBalance.Text.Length == 0)
            openingBalance = "0";
        else
            openingBalance = txtOpeningBalance.Text;

        if (txtClosingBalance.Text.Length == 0)
            closingBalance = "0";
        else
            closingBalance = txtClosingBalance.Text;

        // IRFAN_MOD 
        if (txtRetract.Text.Length == 0)
            txtRetract.Text = "0";
        if (!double.TryParse(getNumber(txtRetract.Text), out retractAmount))
        {
            //lblError1.Visible = true;
            //lblError1.Text = "Please Enter correct Retract Amount";
            Notifications.showMessage("Please Enter correct Retract Amount", this, Notifications.errorMessage, false);

            //pnlManualGlEntry.Visible = true;
            //pnlControls.Visible = false;
            return;
        }
        //

        if (double.Parse(getNumber(openingBalance)) > 0 || double.Parse(getNumber(closingBalance)) > 0)
        {
            if (txtrepldate.Text.Length > 0)
            {
                if (txtrepltime.Text.Length > 0)
                {
                    if (txtGLAccountNo.Text.Length > 0)
                    {
                        //btnSave.Enabled = false;
                        bool saved = addBancsRepl(ref error);
                        if (saved)
                        {
                            //lblError1.Visible = true;
                            //lblError1.Text = "Manual GL Entry Saved!!";

                            btnEdit.Visible = false;
                            btnSave.Visible = false;
                            btnManualGLEntry.Visible = false;
                            //Session["Msg"] = lblError1.Text;
                            //Label lbl = ((Label)PreviousPage.FindControl("lblError1"));
                            //lbl.Text = lblError1.Text;
                            //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);

                            Notifications.showMessage("Manual GL Entry Saved", this, Notifications.errorMessage, false);
                            return;
                        }
                        else
                        {
                            //lblError1.Visible = true;
                            //lblError1.Text = error;
                            Notifications.showMessage(error, this, Notifications.errorMessage, false);
                            //pnlManualGlEntry.Visible = true;
                            //pnlControls.Visible = false;
                            return;
                        }
                    }
                    else
                    {
                        //lblError1.Visible = true;
                        //lblError1.Text = "Please enter Account No.";
                        Notifications.showMessage("Please enter Account No", this, Notifications.errorMessage, false);
                        //pnlManualGlEntry.Visible = true;
                        //pnlControls.Visible = false;
                        return;
                    }
                }
                else
                {
                    //lblError1.Visible = true;
                    //lblError1.Text = "Please enter Replenishment Time";
                    Notifications.showMessage("Please enter Replenishment Time", this, Notifications.errorMessage, false);

                    //pnlManualGlEntry.Visible = true;
                    //pnlControls.Visible = false;
                    return;
                }
            }
            else
            {
                //lblError1.Visible = true;
                //lblError1.Text = "Please enter Replenishment Date";
                Notifications.showMessage("Please enter Replenishment Date", this, Notifications.errorMessage, false);

                //pnlManualGlEntry.Visible = true;
                //pnlControls.Visible = false;
                return;
            }
        }
        else
        {
            //lblError1.Visible = true;
            //lblError1.Text = "Either Opening Balance or Closing Balance greater than zero";
            Notifications.showMessage("Either Opening Balance or Closing Balance greater than zero", this, Notifications.errorMessage, false);
            //pnlManualGlEntry.Visible = true;
            //pnlControls.Visible = false;
            return;
        }
        //pnlManualGlEntry.Visible = false;
        //pnlControls.Visible = true;
    }
    protected void btnCancelManualGlEntry_Click(object sender, EventArgs e)
    {
        //pnlManualGlEntry.Visible = false;
        //pnlSearch.Enabled = true;
        //pnlResult.Enabled = true;
    }

    private bool addBancsRepl(ref string error)
    {
        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_summary_viewer.add_manual_gl_entry";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rid", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_time", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_type", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_repl_cur", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_gl_account", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_opening_balance", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_closing_balance", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_retractAmt", OracleType.Number).Direction = ParameterDirection.Input; // irfan_mod

        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;


        oracom.Parameters["p_rid"].Value = ViewState["rowid"];
        oracom.Parameters["p_atm_num"].Value = txtTerminalID.Text.Substring(txtTerminalID.Text.Length - 4);
        oracom.Parameters["p_repl_date"].Value = txtrepldate.Text;
        // oracom.Parameters["p_repl_date"].Value = txtReplDate.Text;
        oracom.Parameters["p_repl_time"].Value = txtrepltime.Text.Replace(":", "");
        oracom.Parameters["p_atm_type"].Value = ddlReplType.SelectedValue;
        oracom.Parameters["p_repl_cur"].Value = DropDownList2.SelectedValue;
        oracom.Parameters["p_gl_account"].Value = txtGLAccountNo.Text;

        if (getNumber(txtOpeningBalance.Text).Length > 0)
            oracom.Parameters["p_opening_balance"].Value = getNumber(txtOpeningBalance.Text);
        else
            oracom.Parameters["p_opening_balance"].Value = OracleNumber.Null;

        if (getNumber(txtClosingBalance.Text).Length > 0)
            oracom.Parameters["p_closing_balance"].Value = getNumber(txtClosingBalance.Text);
        else
            oracom.Parameters["p_closing_balance"].Value = OracleNumber.Null;

        // Irfan_Mod
        if (getNumber(txtRetract.Text).Length > 0)
            oracom.Parameters["p_retractAmt"].Value = getNumber(txtRetract.Text);
        else
            oracom.Parameters["p_retractAmt"].Value = OracleNumber.Null;

        //Ends


        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();
        error = oracom.Parameters["p_res_msg"].Value.ToString();
        if (a == "0")
            return true;
        else
            return false;
    }

    protected void btnEdit_Click(object sender, EventArgs e)
    {
        ddlModifyReason.SelectedValue = "4";
        ddlStatus.SelectedValue = "020";
        ViewState["mode"] = "a";
        ddlModifyReason.Enabled = false;
        ddlStatus.Enabled = false;
        TextBox6.Enabled = true;
        TextBox7.Enabled = true;
        TextBox8.Enabled = true;
        btnEdit.Visible = false;
    }
    protected void btn_DifferenceGlEntry_Click(object sender, EventArgs e)
    {
        //PanelGlEntrySave.Visible = true;
        ////pnl_confirmation_glentry.Visible = false;
        ////pnlSearch.Enabled = false;
        ////pnl_confirmation_recon.Visible = false;
        //pnlControls.Enabled = false;
        ////pnlResult.Enabled = false;
        //lblError_PanelGlEntrySave.Text = "";

        GetGlEntry();


    }
    protected void btn_GlEntrySave_Click(object sender, EventArgs e)
    {

        SaveGlEntry();
        btn_GlEntrySave.Enabled = false;
    }
    protected void btn_GlEntryCancel_Click(object sender, EventArgs e)
    {
        //PanelGlEntrySave.Visible = false;
        //pnlControls.Enabled = true;
        //lblError_PanelGlEntrySave.Text = "";
        btn_GlEntryDelete.Enabled = true;
        btn_GlEntrySave.Enabled = true;

    }
    protected void ddlShortageType_SelectedIndexChanged(object sender, EventArgs e)
    {
        //lblError_PanelGlEntrySave.Text = "";

        GetGlEntry();


    }
    private void SaveGlEntry()
    {


        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_summary_viewer.GenerateGL_ReplEntry";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_RID", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("Posting_for_ReplDate", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("Acct_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("settle_account", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("gl_tran_amt", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("GL_Desc", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_Res", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();
        oracom.Parameters["p_RID"].Value = ViewState["rowid"];
        oracom.Parameters["Posting_for_ReplDate"].Value = lbl_Posting_for_ReplDate.Text.Substring(8, 2) + lbl_Posting_for_ReplDate.Text.Substring(3, 2) + lbl_Posting_for_ReplDate.Text.Substring(0, 2);
        oracom.Parameters["p_atm_number"].Value = lbl_ATM_NO.Text;
        oracom.Parameters["Acct_number"].Value = lbl_Acct_number.Text;
        oracom.Parameters["settle_account"].Value = lbl_settle_account.Text;

        oracom.Parameters["gl_tran_amt"].Value = Convert.ToDecimal(lbl_gl_tran_amt.Text);
        oracom.Parameters["GL_Desc"].Value = txt_GL_Desc.Text;

        oracom.ExecuteNonQuery();
        oracon.Close();

        string error = oracom.Parameters["p_Res"].Value.ToString();
        if (error == "Sucessful")
        {
            //lblError_PanelGlEntrySave.Text = "Successfully Created Entry";
            Notifications.showMessage("Successfully Created Entry", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError_PanelGlEntrySave.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    private void GetGlEntry()
    {
        if (txtBANCS.Text == "Shortage" && ddlShortageType.SelectedIndex < 1)
        {
            //lblError_PanelGlEntrySave.Text = "Please Select Shortage Type";
            Notifications.showMessage("Please Select Shortage Type", this, Notifications.errorMessage, false);
            return;
        }

        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_summary_viewer.GetATMRepl_GL";

        oracom.Parameters.Add("p_RID", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_AcctType", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_SubAcctTYpe", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_Res", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;

        oracom.Parameters["p_RID"].Value = ViewState["rowid"];

        if (txtBANCS.Text == "Overage")
        {
            oracom.Parameters["p_AcctType"].Value = 1;
            oracom.Parameters["p_SubAcctTYpe"].Value = 0;
        }
        else if (txtBANCS.Text == "Shortage")
        {
            oracom.Parameters["p_AcctType"].Value = 2;
            oracom.Parameters["p_SubAcctTYpe"].Value = Convert.ToInt32(ddlShortageType.SelectedValue);
        }
        // oracom.Parameters["p_atm_num"].Value = txtTerminalID.Text.Substring(txtTerminalID.Text.Length - 4);
        // oracom.Parameters["p_repl_date"].Value = dtReplDate.date;
        // oracom.Parameters["p_repl_date"].Value = txtReplDate.Text;


        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da = new OracleDataAdapter(oracom);
        ds = new DataSet();
        da.Fill(ds);

        string error = oracom.Parameters["p_Res"].Value.ToString();
        if (error != "Successful")
        {
            //lblError_PanelGlEntrySave.Text = error;
            btn_GlEntrySave.Enabled = false;
            ddlShortageType.Enabled = false;
            txt_GL_Desc.Enabled = false;

            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;

        }
        else // Enable Save
        {
            btn_GlEntrySave.Enabled = true;
            ddlShortageType.Enabled = true;
            txt_GL_Desc.Enabled = true;
        }
        lbl_CreatedDate.Text = ds.Tables[0].Rows[0]["GL_Created_Date"].ToString();
        lbl_Posting_for_ReplDate.Text = ds.Tables[0].Rows[0]["Posting_for_ReplDate"].ToString();
        lbl_Acct_number.Text = ds.Tables[0].Rows[0]["Acct_number"].ToString();
        lbl_settle_account.Text = ds.Tables[0].Rows[0]["settle_account"].ToString();
        lbl_txn_type.Text = ds.Tables[0].Rows[0]["txn_type"].ToString();
        lbl_approved_by.Text = ds.Tables[0].Rows[0]["approved"].ToString();
        lbl_approve_date.Text = ds.Tables[0].Rows[0]["approve_date"].ToString();
        lbl_gl_tran_amt.Text = ds.Tables[0].Rows[0]["gl_tran_amt"].ToString();
        txt_GL_Desc.Text = ds.Tables[0].Rows[0]["GL_Desc"].ToString();

        lbl_POSTED.Text = ds.Tables[0].Rows[0]["POSTED"].ToString();
        lbl_GPE_CODE.Text = ds.Tables[0].Rows[0]["GPE_CODE"].ToString();
        lbl_ATM_NO.Text = ds.Tables[0].Rows[0]["atm_no"].ToString();


    }

    private void DeleteGlEntry()
    {


        string DBConnection = Helper.dbConnection();

        OracleConnection oracon = new OracleConnection(DBConnection);
        oracon.Open();

        OracleCommand oracom = new OracleCommand();
        oracom.Connection = oracon;

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "atm_summary_viewer.DEL_ATMREPLGL";

        oracom.Parameters.Add("p_gpe_code", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_Res", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_gpe_code"].Value = Convert.ToInt32(lbl_GPE_CODE.Text);
        oracom.ExecuteNonQuery();
        oracon.Close();

        string error = oracom.Parameters["p_Res"].Value.ToString();
        if (error == "Successful")
        {
            //lblError_PanelGlEntrySave.Text = "Successfully Deleted Entry";
            btn_GlEntryDelete.Enabled = false;
            //PanelGlEntrySave.Visible = true;
            Notifications.showMessage("Successfully Deleted Entry", this, Notifications.errorMessage, false);
            return;
        }
        else
        {
            //lblError_PanelGlEntrySave.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    protected void btn_GlEntryDelete_Click(object sender, EventArgs e)
    {
        DeleteGlEntry();
    }
}