using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;

public partial class AddClaim : System.Web.UI.Page
{
    string claim_id_CheckTranasctions;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadEvents();
            loadBankBins();
            //pnlControls.Visible = false;
            //DatePicker2.date = DateTime.Today.AddDays(-1).ToString("dd-MM-yyyy");
            //DatePicker1.date = DateTime.Today.AddDays(-1).ToString("dd-MM-yyyy");
            trAcct.Visible = false;
        }

        //this.lbl_error.Text = "";
    }

    private void loadEvents()
    {
        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_Recon_Events";

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

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

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

        ddlEvents.Items.Insert(0, "------ Events ------");
        oracon.Close();
    }

    private void loadBankBins()
    {
        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_Bank_Bin";

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

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

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

        ddlIssuer.Items.Insert(0, "------ Issuer ------");

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

        ddlAcquirer.Items.Insert(0, "------ Acquirer ------");

        oracon.Close();

    }

    private void loadResult(string terminalID, string eventID, string Card, string reference, string datefrom, string dateto, 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 = "TRANSACTIONS_SEARCHER.Search_Master_Tran";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_re_code", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_card_no", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_date_from", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_date_to", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_time_from", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_time_to", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("p_rrn", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_source", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_dest", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_atm_num", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_acct_num", 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;

        if (eventID.Length != 0)
            oracom.Parameters["p_re_code"].Value = eventID;
        else
            oracom.Parameters["p_re_code"].Value = OracleNumber.Null;
        oracom.Parameters["p_card_no"].Value = Card;
        oracom.Parameters["p_tran_date_from"].Value = datefrom;
        oracom.Parameters["p_tran_date_to"].Value = dateto;
        oracom.Parameters["p_tran_time_from"].Value = TextBoxFrom.Text.Replace(":", "");
        oracom.Parameters["p_tran_time_to"].Value = TextBoxTo.Text.Replace(":", "");

        oracom.Parameters["p_rrn"].Value = reference;
        oracom.Parameters["p_atm_num"].Value = terminalID;

        if (txtAccount.Text.Trim().Length > 0)
            oracom.Parameters["p_acct_num"].Value = txtAccount.Text.Trim();
        else
            oracom.Parameters["p_acct_num"].Value = OracleString.Null;

        if (ddlIssuer.SelectedIndex > 0)
            oracom.Parameters["p_dest"].Value = ddlIssuer.SelectedValue;
        else
            oracom.Parameters["p_dest"].Value = OracleNumber.Null;
        if (ddlAcquirer.SelectedIndex > 0)
            oracom.Parameters["p_source"].Value = ddlAcquirer.SelectedValue;
        else
            oracom.Parameters["p_source"].Value = OracleNumber.Null;

        //if (ddlIssuer.SelectedIndex > 0)
        //    oracom.Parameters["p_source"].Value = ddlIssuer.SelectedValue;
        //else
        //    oracom.Parameters["p_source"].Value = OracleNumber.Null;
        //if (ddlAcquirer.SelectedIndex > 0)
        //    oracom.Parameters["p_dest"].Value = ddlAcquirer.SelectedValue;
        //else
        //    oracom.Parameters["p_dest"].Value = OracleNumber.Null;

        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());
            }
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string selectedCardNumber = txtCardNo.Text;
        double cardNumber;


        ////if ((selectedCardNumber.Length != 0 && double.TryParse(selectedCardNumber, out cardNumber)) || txtTerminal.Text.Trim().Length>0)
        //{
        if (txtDate.Text.Length > 0)
        {
            string EventID = "";
            if (ddlEvents.SelectedIndex > 0)
                EventID = ddlEvents.SelectedValue;
            //pnlResult.Visible = true;

            //loadResult(this.txtTerminal.Text.Trim(), EventID, this.lov_cardNumbers.getSelectedCardNumber(), txtReferenceNumber.Text.Trim(), DatePicker1.date, DatePicker2.date, Helper.gridSize(), 1);
            loadResult(this.txtTerminal.Text, EventID, txtCardNo.Text, txtReferenceNumber.Text, txtDate.Text.Substring(8, 2) + txtDate.Text.Substring(3, 2) + txtDate.Text.Substring(0, 2), txtDate.Text.Substring(21, 2) + txtDate.Text.Substring(16, 2) + txtDate.Text.Substring(13, 2), Helper.gridSize(), 1);
            //pnlControls.Visible = false;
        }
        else
        {
            Notifications.showMessage("Please enter From Date and To Date", this, Notifications.errorMessage, true);
            return;
        }
        //}
        //else if (selectedCardNumber.Length == 0)
        //{
        //    this.lbl_error.Text = "Please enter Card Number or ATM Number";
        //}
        //else
        //{
        //    this.lbl_error.Text = "Please enter a valid Card Number";
        //}
    }

    protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        string EventID = "";
        if (ddlEvents.SelectedIndex > 0)
            EventID = ddlEvents.SelectedValue;
        loadResult(this.txtTerminal.Text, EventID, txtCardNo.Text, txtReferenceNumber.Text, txtDate.Text.Substring(8, 2) + txtDate.Text.Substring(3, 2) + txtDate.Text.Substring(0, 2), txtDate.Text.Substring(21, 2) + txtDate.Text.Substring(16, 2) + txtDate.Text.Substring(13, 2), Helper.gridSize(), int.Parse(ddlPages.SelectedValue));
        //pnlControls.Visible = false;
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("v"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string tID = GridView1.DataKeys[index].Value.ToString();
            loadTranDetails(tID);

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

    private void loadTranDetails(string tID)
    {
        //pnlControls.Visible = true;
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "TRANSACTIONS_SEARCHER.Get_Master_Tran";

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

        oracom.Parameters["p_mt_code"].Value = tID;

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

        oracon.Close();

        //set the data in the controls
        Label1.Text = ds.Tables[0].Rows[0]["RECORD_DATE"].ToString();
        Label2.Text = ds.Tables[0].Rows[0]["SETTL_DATE"].ToString();

        Label3.Text = ds.Tables[0].Rows[0]["TRAN_DATE"].ToString();
        txtInputTransactionDate.Text = ds.Tables[0].Rows[0]["TRAN_DATE"].ToString();
        Label4.Text = ds.Tables[0].Rows[0]["TRAN_TIME"].ToString();
        Label5.Text = ds.Tables[0].Rows[0]["CARD_NUMBER"].ToString();
        txtInputCard.Text = ds.Tables[0].Rows[0]["CARD_NUMBER"].ToString();
        Label6.Text = ds.Tables[0].Rows[0]["PCODE"].ToString();
        Label7.Text = ds.Tables[0].Rows[0]["FINANCIAL_FLAG"].ToString();
        Label8.Text = ds.Tables[0].Rows[0]["B24_RSP"].ToString();
        Label9.Text = ds.Tables[0].Rows[0]["ISO_RSP"].ToString();
        Label10.Text = ds.Tables[0].Rows[0]["TERM_ID"].ToString();
        txtInputTerminalID.Text = ds.Tables[0].Rows[0]["TERM_ID"].ToString();
        Label11.Text = ds.Tables[0].Rows[0]["TRAN_AMOUNT"].ToString();
        txtInputAmount.Text = ds.Tables[0].Rows[0]["TRAN_AMOUNT"].ToString();
        Label12.Text = ds.Tables[0].Rows[0]["TRAN_SOURCE"].ToString();
        Label13.Text = ds.Tables[0].Rows[0]["TRAN_DEST"].ToString();
        Label14.Text = ds.Tables[0].Rows[0]["MSG_TYPE"].ToString();
        Label15.Text = ds.Tables[0].Rows[0]["TRACE_ID"].ToString();
        Label16.Text = ds.Tables[0].Rows[0]["FILE_NUMBER"].ToString();
        Label17.Text = ds.Tables[0].Rows[0]["CARD_BRAND"].ToString();
        Label18.Text = ds.Tables[0].Rows[0]["RRN"].ToString();
        txtInputReference.Text = ds.Tables[0].Rows[0]["RRN"].ToString();
        Label19.Text = ds.Tables[0].Rows[0]["CARD_EXP_DATE"].ToString();
        Label20.Text = ds.Tables[0].Rows[0]["ACCT_NUMBER"].ToString();
        Label21.Text = ds.Tables[0].Rows[0]["AUTH_CODE"].ToString();
        Label22.Text = ds.Tables[0].Rows[0]["BUSS_CLASS"].ToString();
        Label23.Text = ds.Tables[0].Rows[0]["TRAN_STATUS"].ToString();
        Label24.Text = ds.Tables[0].Rows[0]["TRAN_CURR"].ToString();
        Label25.Text = ds.Tables[0].Rows[0]["SETTL_CURR"].ToString();
        Label26.Text = ds.Tables[0].Rows[0]["SETTL_AMOUNT"].ToString();
        Label27.Text = ds.Tables[0].Rows[0]["TRAN_CHG"].ToString();
        Label28.Text = ds.Tables[0].Rows[0]["RECON_REQ_FLAG"].ToString();
        Label29.Text = ds.Tables[0].Rows[0]["RECON_PERFORMED_FLAG"].ToString();
        Label30.Text = ds.Tables[0].Rows[0]["MATCH_CRIERIA"].ToString();
        Label31.Text = ds.Tables[0].Rows[0]["MATCH_REF1"].ToString();
        Label32.Text = ds.Tables[0].Rows[0]["MATCH_REF2"].ToString();
        Label33.Text = ds.Tables[0].Rows[0]["MATCH_REF3"].ToString();
        Label34.Text = ds.Tables[0].Rows[0]["MATCH_REF4"].ToString();
        Label35.Text = ds.Tables[0].Rows[0]["MATCH_DATE1"].ToString();
        Label36.Text = ds.Tables[0].Rows[0]["MATCH_DATE2"].ToString();
        Label37.Text = ds.Tables[0].Rows[0]["MATCH_DATE3"].ToString();
        Label38.Text = ds.Tables[0].Rows[0]["MATCH_DATE4"].ToString();
        Label39.Text = ds.Tables[0].Rows[0]["CHIP_DATA"].ToString();
        Label40.Text = ds.Tables[0].Rows[0]["NEXT_MATCH"].ToString();
        Label41.Text = ds.Tables[0].Rows[0]["re_code"].ToString();
        Label42.Text = ds.Tables[0].Rows[0]["PRODUCT"].ToString();
        Label43.Text = ds.Tables[0].Rows[0]["ORIG_OSEQ_NUM"].ToString();
        Label44.Text = ds.Tables[0].Rows[0]["ORIG_DATE"].ToString();
        Label45.Text = ds.Tables[0].Rows[0]["ORIG_TIME"].ToString();
        Label46.Text = ds.Tables[0].Rows[0]["AMT_2"].ToString();
        Label47.Text = ds.Tables[0].Rows[0]["AMT_3"].ToString();
        Label48.Text = ds.Tables[0].Rows[0]["AUTH_AMT"].ToString();
        Label49.Text = ds.Tables[0].Rows[0]["merch_settle_desc"].ToString();
        lblClaimId.Text = ds.Tables[0].Rows[0]["claim_id"].ToString();
        GridView2.DataSource = ds.Tables[1];
        GridView2.DataBind();

    }

    protected void ddlEvents_SelectedIndexChanged(object sender, EventArgs e)
    {
        //pnlControls.Visible = false;
        //pnlResult.Visible = false;
        if (ddlEvents.SelectedIndex != 0)
        {
            int selectedEventId = int.Parse(this.ddlEvents.SelectedValue.ToString());

            string eventType = Helper.getEventType(selectedEventId);

            if (eventType.Equals("OUS"))
            {
                this.ddlAcquirer.SelectedValue = Constants.BANK_ID;
                this.ddlIssuer.SelectedValue = Constants.BANK_ID;

                this.ddlIssuer.Enabled = false;
                this.ddlAcquirer.Enabled = false;
            }
            else if (eventType.Equals("ACQ"))
            {
                this.ddlAcquirer.SelectedValue = Constants.BANK_ID;
                this.ddlAcquirer.Enabled = false;

                this.ddlIssuer.SelectedIndex = 0;
                this.ddlIssuer.Enabled = true;
            }
            else if (eventType.Equals("ISS"))
            {
                this.ddlIssuer.SelectedValue = Constants.BANK_ID;
                this.ddlIssuer.Enabled = false;

                this.ddlAcquirer.SelectedIndex = 0;
                this.ddlAcquirer.Enabled = true;
            }
            else
            {
                this.ddlAcquirer.SelectedIndex = 0;
                this.ddlAcquirer.Enabled = true;

                this.ddlIssuer.SelectedIndex = 0;
                this.ddlIssuer.Enabled = true;
            }
        }
    }
    protected void ddlAcquirer_SelectedIndexChanged(object sender, EventArgs e)
    {
        txtAccount.Text = "";
        if (ddlAcquirer.SelectedValue.Equals("589206"))
            trAcct.Visible = true;
        else
            trAcct.Visible = false;
    }
  

    protected void GridView1_PreRender(object sender, EventArgs e)
    {
        if (GridView1.Rows.Count > 0)
        {
            GridView1.UseAccessibleHeader = true;
            GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Lbl_URC_Message.Text = "Are you sure you want to add a New Claim ?";
        //Notifications.showModal("UR-confirmation-modal-xl", this);

        if (lblClaimId.Text.Length > 0)
        {
            checkTransactionClaims();
            if (claim_id_CheckTranasctions != "0")
            {
                Notifications.showMessage("Claim " + claim_id_CheckTranasctions + " Is Already opened for this transaction. Please close the claim before open a new one", this, Notifications.errorMessage, false);
            }
            else
            {
                if (checkClaimStatus())
                {
                    Lbl_URC_Message.Text = "Are you sure you want to add New Claim, This transaction already has a claim ?";
                    Notifications.showModal("UR-confirmation-modal-xl", this);
                }
                else
                {
                    Notifications.showMessage("This claim is still opened in SAMA. Please make sure to close this claim before re-open it", this, Notifications.errorMessage, false);
                }
            }
        }
        else
        {
            if (pnlControls.Visible)
            {
                string ID = "", error = "";
                bool saved = addClaim(ref ID, ref error);
                if (saved)
                {
                    Notifications.showMessage("claim saved. (Claim ID: " + ID + " )", this, Notifications.successMessage, false);
                    pnlControls.Visible = false;
                    //pnlControls2.Visible = false;
                    //pnlTxn.Visible = false;
                }
                else
                {
                    Notifications.showMessage(error + " " + ID, this, Notifications.errorMessage, false);
                }
            }
            else
            {
                string ID = "", error = "";
                bool saved = addClaim(ref ID, ref error);
                if (saved)
                {
                    Notifications.showMessage("claim saved. (Claim ID: " + ID + " )", this, Notifications.successMessage, false);
                }
                else
                {
                    Notifications.showMessage(error + " " + ID, this, Notifications.errorMessage, false);
                }
            }
        }
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        pnlControls.Visible = false;
    }

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

    private bool addClaim(ref string ID, 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 = "CLAIM_BY_CH_PROCESS.add_claim_info";

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

        oracom.Parameters.Add("p_card_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_term_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_amount", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rrn", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_mt_code", OracleType.Number).Direction = ParameterDirection.Input;

        //IHJ 12-07-2012
        oracom.Parameters.Add("p_new_rrn", 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.Add("p_claim_id", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

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

        oracom.Parameters["p_card_number"].Value = txtInputCard.Text;
        oracom.Parameters["p_tran_date"].Value = txtHDATE.Text;
        oracom.Parameters["p_term_id"].Value = txtInputTerminalID.Text;
        oracom.Parameters["p_tran_amount"].Value = txtInputAmount.Text.Replace(",", "");
        oracom.Parameters["p_rrn"].Value = txtInputReference.Text;
        if (txtHMTCODE.Text.Length == 0)
            oracom.Parameters["p_mt_code"].Value = OracleNumber.Null;
        else
            oracom.Parameters["p_mt_code"].Value = txtHMTCODE.Text;


        if (txtNewRRN.Text.Length == 0)
            oracom.Parameters["p_new_rrn"].Value = OracleString.Null;
        else
            oracom.Parameters["p_new_rrn"].Value = txtNewRRN.Text;

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

    private bool checkClaimStatus()
    {
        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_BY_CH_PROCESS.CHECK_CLAIM_STATUS";
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_result", OracleType.Number).Direction = ParameterDirection.Output;


        oracom.Parameters["p_claim_id"].Value = lblClaimId.Text;
        oracom.ExecuteNonQuery();
        oracon.Close();

        if (int.Parse(oracom.Parameters["p_result"].Value.ToString()) == 1)
            return true; // Can be re-opened
        else
            return false;
    }

    private void checkTransactionClaims()
    {
        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_BY_CH_PROCESS.GET_TRANSACTION_CLAIMS";

        oracom.Parameters.Add("p_card_number", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_tran_date", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rrn", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_out", OracleType.VarChar, 250).Direction = ParameterDirection.Output;


        oracom.Parameters["p_card_number"].Value = txtInputCard.Text;
        string date = txtInputTransactionDate.Text.Replace("-", "");
        oracom.Parameters["p_tran_date"].Value = date.Substring(6, 2) + date.Substring(2, 2) + date.Substring(0, 2);
        oracom.Parameters["p_rrn"].Value = txtInputReference.Text;

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

        if (oracom.Parameters["p_claim_out"].Value.ToString() != "0")
            claim_id_CheckTranasctions = oracom.Parameters["p_claim_out"].Value.ToString();
        else
            claim_id_CheckTranasctions = "0";
    }

}