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;
using System.Web.Services;

public partial class InvestigateClaim : System.Web.UI.Page
{
    // static string prevPage = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //if(Request.UrlReferrer !=null )
            //    prevPage = Request.UrlReferrer.ToString();
            loadClaimByID(Request.QueryString["clID"]);
            loadB24(Request.QueryString["clID"]);
            loadChannel(Request.QueryString["clID"]);
            loadEJ(Request.QueryString["clID"]);
            loadNotes(Request.QueryString["clID"]);
            //pnlControls.Visible = false;
            //pnlControls1.Visible = false;
            //pnlControls2.Visible = false;
            loadCPSTypes(Request.QueryString["clID"]);
            loadPrepaidAccountTypes();

            //if (lbl_Re_Code.Text == "5" || lbl_Re_Code.Text == "17")
            //    btnsenttoCPS.Enabled = false;

        }

        //if ( (lbl_Re_Code.Text == "5" || lbl_Re_Code.Text == "17") && (lblFromAcctDesc.Text.Length < 5 || lblToAcctDesc.Text.Length <5) )
        if (lblFromAcctDesc.Text.Length < 5 || lblToAcctDesc.Text.Length < 5)
            btnsenttoCPS.Enabled = false;
        else
            btnsenttoCPS.Enabled = true;

        btnPaySlip.OnClientClick = "javascript:return popUp('" + Request.QueryString["clID"] + "')";
    }



    [WebMethod(enableSession: true)]
    public static string Update_Ext_Ref_No(string claim_id, string Ext_Ref_No)
    {

        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_INVESTIGATOR.Update_Ext_RRN";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_ext_RRN", 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_claim_id"].Value = claim_id;
        oracom.Parameters["p_ext_RRN"].Value = Ext_Ref_No;
        oracom.Parameters["p_current_uid"].Value = HttpContext.Current.Session["uid"].ToString();

        oracom.ExecuteNonQuery();
        oracon.Close();
        string a = oracom.Parameters["p_res_code"].Value.ToString();

        if (a == "0")
            return "Sucessfully Updated";
        else
            return oracom.Parameters["p_res_msg"].Value.ToString();
    }


    //ddlPrepaidAcctType

    private void loadPrepaidAccountTypes()
    {

        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "poslookup_getter.GET_EXT_ACCT_TYPE";

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



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

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

        oracon.Close();

        ddlPrepaidAcctType.Items.Insert(0, "------ Account Type ------");



    }
    private void loadCPSTypes(string claimID)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "poslookup_getter.Get_CPS_Claim_Type";

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

        oracom.Parameters["p_claim_id"].Value = claimID;

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

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

        oracon.Close();

        ddlCPSType.Items.Insert(0, "------ Claim Type ------");


        //if (lblClaimType.Text != "100")
        //    ddlCPSType.SelectedValue = lblClaimType.Text;
    }

    private void loadClaimByID(string claimID)
    {
        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_INVESTIGATOR.get_claim_data_by_id";

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

        oracom.Parameters["p_claim_id"].Value = claimID;

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

        da.Fill(ds);

        oracon.Close();

        //set the data in the controls
        lblClaimID.Text = claimID;
        lblClaimID.NavigateUrl = "ClaimHistory.aspx?clID=" + claimID;
        lblCardNo.Text = ds.Tables[0].Rows[0]["card_number"].ToString();
        lblTxnDate.Text = ds.Tables[0].Rows[0]["tran_date"].ToString();
        lblTermID.Text = ds.Tables[0].Rows[0]["term_id"].ToString();
        lblAmount.Text = ds.Tables[0].Rows[0]["tran_amount"].ToString();

        lblSettlementAmt.Text = ds.Tables[0].Rows[0]["settl_amount"].ToString(); // IRFAN_MOD 190908

        lblReference.Text = ds.Tables[0].Rows[0]["rrn"].ToString();
        lblStatus.Text = ds.Tables[0].Rows[0]["claim_status"].ToString();
        lblProduct.Text = ds.Tables[0].Rows[0]["product_desc"].ToString();
        lblDuration.Text = ds.Tables[0].Rows[0]["duration_days"].ToString();
        txtNote.Text = ds.Tables[0].Rows[0]["note_text"].ToString();
        lblSamaStatus.Text = ds.Tables[0].Rows[0]["SAMA_status"].ToString();
        lblCPSType.Text = ds.Tables[0].Rows[0]["claim_type"].ToString();
        lblSugAmt.Text = ds.Tables[0].Rows[0]["claim_amount"].ToString();
        lblClMessage.Text = ds.Tables[0].Rows[0]["message_text"].ToString();
        lblCPSFile.Text = ds.Tables[0].Rows[0]["sama_file_name"].ToString();
        lblModifiedBy.Text = ds.Tables[0].Rows[0]["last_Modified_by"].ToString();
        string claimStatusCD = ds.Tables[0].Rows[0]["claim_status_cd"].ToString();
        string samaStatusCD = ds.Tables[0].Rows[0]["sama_status_cd"].ToString();
        string transSrc = ds.Tables[0].Rows[0]["tran_src"].ToString();
        string samaClaim = ds.Tables[0].Rows[0]["sama_claim"].ToString();
        lbl_sama_claim_id.Text = ds.Tables[0].Rows[0]["ORG_CLAIM_ID"].ToString();

        lblfromAccount.Text = ds.Tables[0].Rows[0]["FROM_ACCT"].ToString();
        lbltoAccount.Text = ds.Tables[0].Rows[0]["TO_ACCT"].ToString();
        lblClaimType.Text = ds.Tables[0].Rows[0]["CLAIM_TYPE_VAL"].ToString();

        LblOriginator.Text = ds.Tables[0].Rows[0]["Originator_Id"].ToString(); //irfan_mod 170216

        string err = "";
        string cpsID = Request.QueryString["clID"];
        //samaActions.Visible = cansenttoCPS(Request.QueryString["clID"], ref err);
        cpsInfo.Visible = samaActions.Visible;
        //txtSugAmt.Text = lblAmount.Text;
        txtSugAmt.Text = lblSugAmt.Text;

        this.lbl_acquirerBank.Text = ds.Tables[0].Rows[0]["ACQUIRER_BANK_CODE"].ToString();
        this.lbl_issuerBank.Text = ds.Tables[0].Rows[0]["ISSUER_BANK_CODE"].ToString();

        //irfan_mod
        txtExtRefNo.Text = ds.Tables[0].Rows[0]["ext_ref_no"].ToString();
        lblExtOutwardFileID.Text = ds.Tables[0].Rows[0]["ext_outward_file_id"].ToString();
        if (lblExtOutwardFileID.Text.Trim().Length > 1)
        {
            txtExtRefNo.Enabled = false;
            btnSavePPPMS.Visible = false;
        }
        //


        this.lblNEW_RRN.Text = ds.Tables[0].Rows[0]["NEW_RRN"].ToString();
        this.lblDEBIT_ISSUER.Text = ds.Tables[0].Rows[0]["DEBIT_ISSUER"].ToString();
        this.lblDEBIT_ACQUIRER.Text = ds.Tables[0].Rows[0]["DEBIT_ACQUIRER"].ToString();
        this.lblCREDIT_ACQUIRER.Text = ds.Tables[0].Rows[0]["CREDIT_ACQUIRER"].ToString();
        this.lblCREDIT_ISSUER.Text = ds.Tables[0].Rows[0]["CREDIT_ISSUER"].ToString();
        this.lblFromAcctDesc.Text = ds.Tables[0].Rows[0]["FROM_ACCT_DESC"].ToString();
        this.lblToAcctDesc.Text = ds.Tables[0].Rows[0]["TO_ACCT_DESC"].ToString();
        // IRFAN_MOD 170322 SAIB CR
        this.lblValFromAcct_2.Text = ds.Tables[0].Rows[0]["FROM_ACCT_2"].ToString();
        this.lblValToAcct_2.Text = ds.Tables[0].Rows[0]["To_Acct_2"].ToString();

        this.lblValFromAcct_3.Text = ds.Tables[0].Rows[0]["From_Acct_3"].ToString();
        this.lblValToAcct_3.Text = ds.Tables[0].Rows[0]["To_Acct_3"].ToString();
        //IRFAN_MOD 170322 SAIB CR


        hideButtons();


        string product = ds.Tables[0].Rows[0]["product"].ToString();
        string Re_Code = ds.Tables[0].Rows[0]["RE_CODE"].ToString();
        ViewState["product"] = product;
        ViewState["Re_Code"] = Re_Code;

        lbl_Re_Code.Text = Re_Code;

        //if (ViewState["product"]=="2")
        //{
        lblNarrrFromAcct.Text = lblFrom.Text = "From Account";
        lblNarrrToAcct.Text = lblTo.Text = "To Account";
        lblNarrrFromAcct_2.Text = lblFrom_2.Text = "From Account 2nd GL";
        lblNarrrToAcct_2.Text = lblTo_2.Text = "To Account 2nd GL";
        lblNarrrFromAcct_3.Text = lblFrom_3.Text = "From Account 3rd Gl";
        lblNarrrToAcct_3.Text = lblTo_3.Text = "To Account 3rd GL";
        //    //this.Pos_Claim.Visible = true;
        //}
        //else
        //{
        //    lblNarrrFromAcct.Text = lblFrom.Text = "From Account";
        //    lblNarrrToAcct.Text = lblTo.Text = "To Account";
        //   // this.Pos_Claim.Visible = false;
        //  //  lblCommissionFee.Visible = false;
        //   // txtCommissionFee.Visible = false;
        //}
        if (product.Equals("1"))
        {
            //atm
            pnlEJ.Visible = true;
            pnlPOS.Visible = false;
            gvAcc.Visible = false;
            gvAccATM.Visible = true;



            //btnPaySlip.Visible = false;


        }
        else
        {
            //pos
            loadRelatedClaims(claimID);
            pnlEJ.Visible = false;
            pnlPOS.Visible = true;
            gvAcc.Visible = true;
            gvAccATM.Visible = false;

            //btnPaySlip.Visible = true;

            // not for saib  lblAtmOvShort.Visible = false;
            //not for saib TxtRefNo.Visible = false;

        }

    }

    public void SetAccountsFor2nd3rdGl()
    {
        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_INVESTIGATOR.CLAIMS_CONTRA_GL";

        oracom.Parameters.Add("P_RE_CODE", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_FROM_ACCT_1", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_TO_ACCT_1", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_FROM_ACCT_2", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_TO_ACCT_2", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_FROM_ACCT_2DESC", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_TO_ACCT_2DESC", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_FROM_ACCT_3", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_TO_ACCT_3", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_Res", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_FROM_ACCT_3DESC", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_TO_ACCT_3DESC", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("P_FLAG_C_M", OracleType.VarChar).Direction = ParameterDirection.Input;

        if ((lbl_Re_Code.Text == "8" || lbl_Re_Code.Text == "33") && rdCard.Checked == true)
            oracom.Parameters["P_FLAG_C_M"].Value = "C";
        else if ((lbl_Re_Code.Text == "8" || lbl_Re_Code.Text == "33") && reMer.Checked == true)
            oracom.Parameters["P_FLAG_C_M"].Value = "M";
        else
            oracom.Parameters["P_FLAG_C_M"].Value = OracleString.Null;




        oracom.Parameters["P_RE_CODE"].Value = lbl_Re_Code.Text;

        oracom.Parameters["P_FROM_ACCT_1"].Value = ddlFromAcct.SelectedValue;
        oracom.Parameters["P_TO_ACCT_1"].Value = ddlToAcct.SelectedValue;

        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);
        string resp = oracom.Parameters["P_Res"].Value.ToString();



        lblFrom_2.Text = oracom.Parameters["P_FROM_ACCT_2DESC"].Value.ToString();
        lblTo_2.Text = oracom.Parameters["P_TO_ACCT_2DESC"].Value.ToString();

        if (lblFrom_2.Text.ToUpper().Contains("MERCH") || lblFrom_2.Text.ToUpper().Contains("CARD"))
            lbl_FromAcct2.Enabled = true;
        else
            lbl_FromAcct2.Enabled = false;

        if (lblTo_2.Text.ToUpper().Contains("MERCH") || lblTo_2.Text.ToUpper().Contains("CARD"))
            txtToManualMerAccount.Enabled = true;
        else
            txtToManualMerAccount.Enabled = false;

        lbl_FromAcct2.Text = oracom.Parameters["P_FROM_ACCT_2"].Value.ToString();
        txtToManualMerAccount.Text = oracom.Parameters["P_TO_ACCT_2"].Value.ToString();



        lblFrom_3.Text = oracom.Parameters["P_FROM_ACCT_3DESC"].Value.ToString();
        lblTo_3.Text = oracom.Parameters["P_TO_ACCT_3DESC"].Value.ToString();

        lbl_FromAcct3.Text = oracom.Parameters["P_FROM_ACCT_3"].Value.ToString();
        lbl_ToAcct3.Text = oracom.Parameters["P_TO_ACCT_3"].Value.ToString();

        //VAT

        lblVatRate.Text = Convert.ToString(Helper.Get_VAT_Rate() * 100);
        //
        oracon.Close();

    }



    private void loadRelatedClaims(string claimID)
    {
        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_merchant_recon_proces.get_merch_groupclaim";

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

        oracom.Parameters["p_claim_id"].Value = claimID;

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

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

        oracon.Close();
    }
    //public string PopulateAcct()
    //{
    //    string result="";
    //    try
    //    {
    //        string sQMgrName = "", sSendQName = "", sRecQName = "",sTimeout="";
    //        sQMgrName = ConfigurationManager.AppSettings["QMgrName"];
    //        sSendQName = ConfigurationManager.AppSettings["CardInqReq"];
    //        sRecQName = ConfigurationManager.AppSettings["CardInqResp"];
    //        sTimeout = ConfigurationManager.AppSettings["TimeOut"];
    //        CardDtlsInqGenerator.CardDtlsInqGen CardDtlsGenObj = new CardDtlsInqGenerator.CardDtlsInqGen();
    //        //string strReqMsg = CardDtlsGenObj.GenReqMsg(Label36 .Text.Trim ());
    //        //string strReqMsg = CardDtlsGenObj.GenReqMsg("4323282970109050");this.lblCardNo.Text

    //        string strReqMsg = CardDtlsGenObj.GenReqMsg(this.lblCardNo.Text);

    //        Helper.writeMWLog("Message Request : " + strReqMsg);

    //        //call mq processor


    //        //EjadaMQProcessorCls EjadaMQProcessorObj = new EjadaMQProcessorCls(sQMgrName, sSendQName, sRecQName, Label36 .Text);
    //        EjadaMQProcessorCls EjadaMQProcessorObj = new EjadaMQProcessorCls(sQMgrName , sSendQName , sRecQName , this.lblCardNo.Text);
    //        string[] resultantAccounts;

    //        //string result = CardDtlsGenObj.ParseResMsgXMLBased(EjadaMQProcessorObj.ProcessMessage(strReqMsg, "90000"), out resultantAccounts);
    //        string RecvMsg = EjadaMQProcessorObj.ProcessMessage(strReqMsg, sTimeout);
    //        Helper.writeMWLog("RecvMsg : " + RecvMsg);
    //        result = CardDtlsGenObj.ParseResMsgXMLBased(RecvMsg, out resultantAccounts);

    //        for (int i = 0; i < resultantAccounts.Length; i++)
    //        {
    //            ddlFromAcct.Items.Add(resultantAccounts[i]);
    //            ddlToAcct.Items.Add(resultantAccounts[i]);

    //        }
    //        return result;

    //    }
    //    catch (Exception ex)
    //    {
    //        Helper.writeMWLog(ex.Message);

    //        return  ex.Message;

    //    }

    //    //}
    //}


    private void loadB24(string claimID)
    {
        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_INVESTIGATOR.search_invstb24_claim";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", 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_outputclaimdet", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_gl_info", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_atm_gl_info", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = claimID;

        oracom.Parameters["p_page_size"].Value = 100;
        oracom.Parameters["p_page_num"].Value = 1;
        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);

        gvB24.DataSource = ds.Tables[0];
        gvB24.DataBind();

        gvAcc.DataSource = ds.Tables[1];
        gvAcc.DataBind();

        gvAccATM.DataSource = ds.Tables[2];
        gvAccATM.DataBind();

        oracon.Close();
    }

    private void loadChannel(string claimID)
    {
        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_INVESTIGATOR.search_invstchl_claim";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", 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_outputchlinvst", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = claimID;

        oracom.Parameters["p_page_size"].Value = 100;
        oracom.Parameters["p_page_num"].Value = 1;
        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);

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

        oracon.Close();
    }

    private void loadEJ(string claimID)
    {
        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_INVESTIGATOR.search_invstej_claim";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", 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_outputejlinvst", OracleType.Cursor).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters["p_claim_id"].Value = claimID;
        oracom.Parameters["p_page_size"].Value = 100;
        oracom.Parameters["p_page_num"].Value = 1;
        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);

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

        oracon.Close();
    }

    private void loadNotes(string claimID)
    {
        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_COMMENTATOR.Get_Claim_Comments";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", 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_output", OracleType.Cursor).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = claimID;

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

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

        oracon.Close();

        //if (gvNotes.Rows.Count > 0)
        //{
        //    lblClaimNote.Text = "Claim Notes (*)";
        //    lblClaimNote.ForeColor = System.Drawing.Color.Red;
        //}
        //else
        //{
        //    lblClaimNote.Text = "Claim Notes";
        //    lblClaimNote.ForeColor = System.Drawing.Color.Empty;
        //}
    }

    protected void btnApprove_Click(object sender, EventArgs e)
    {
        lbl_FromAcct2.Text = "";
        txtToManualMerAccount.Text = "";
        lbl_FromAcct3.Text = "";
        lbl_ToAcct3.Text = "";


        OtherFromMerAccountNo.Text = "";
        OtherToMerAccount.Text = "";

        string product = ViewState["product"].ToString();

        //this.pnlApprove.Visible = true;
        Notifications.showModal("pnlApprove-modal-xl", this);

        //this.OtherFromMerAccountNo.Visible = true;
        //this.OtherToMerAccount.Visible = true;
        if (product.Equals("1"))
        {

            loadFromAcct(Request.QueryString["clID"]);
            loadToAcct(Request.QueryString["clID"]);
            //if (!GetCustomerAccountNo())
            //{

            //    string res = PopulateAcct();
            //    if (!res.Equals("I000000"))
            //        lblError.Text = "Error Occured while populating Account Numbers";
            //}
        }
        //else if (product.Equals("2")) // ECOM CR Code merging 
        else
        {

            this.loadClaimAcct(Request.QueryString["clID"]);
        }

        this.lblGlAmt1.Text = this.txt_approve_suggestedAmount.Text = this.getSuggestedAmount();

        try
        {
            if (lblfromAccount.Text != "")
            {
                ddlFromAcct.SelectedValue = lblfromAccount.Text.Trim();
            }

            if (lbltoAccount.Text != "")
            {
                ddlToAcct.SelectedValue = lbltoAccount.Text.Trim();
            }
        }
        catch (Exception ex)
        {
            lbltoAccount.Text = "";
            lblfromAccount.Text = "";
        }
    }

    protected void btnDecline_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = Decline(clID, ref error);
        if (saved)
        {
            loadClaimByID(Request.QueryString["clID"]);
            //lblError.Text = "Claim Rejected";
            Notifications.showMessage("Claim Rejected", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    private bool Approve(string index, 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_INVESTIGATOR.submit_claim_info";

        // string OVER_SHORT_REF_NO = ;

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_sugg_amt", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_account", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_to_account_desc", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_account", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_from_account_desc", OracleType.VarChar).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_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_RRN", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_OVER_SHORT_REF_NO", 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_claim_id"].Value = index;
        oracom.Parameters["p_sugg_amt"].Value = this.txt_approve_suggestedAmount.Text;
        oracom.Parameters["p_to_account"].Value = ddlToAcct.SelectedValue;
        oracom.Parameters["p_from_account"].Value = ddlFromAcct.SelectedValue;

        oracom.Parameters["P_CARD_NUMBER"].Value = this.lblCardNo.Text;
        oracom.Parameters["P_TRAN_DATE"].Value = Helper.formatDate_ToDBFormat(lblTxnDate.Text);
        oracom.Parameters["P_RRN"].Value = lblReference.Text;


        // IRFAN_MOD 170322 SAIB_CR Starts
        oracom.Parameters.Add("P_TXN_CHG", OracleType.Number).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("P_FROM_ACCT_2", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_TO_ACCT_2", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_FROM_ACCT_3", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("P_TO_ACCT_3", OracleType.VarChar).Direction = ParameterDirection.Input;

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


        if (ddlPrepaidAcctType.SelectedIndex > 0)
        {
            oracom.Parameters["P_Ext_Acct_Type"].Value = ddlPrepaidAcctType.SelectedValue;
        }
        else
            oracom.Parameters["P_Ext_Acct_Type"].Value = OracleString.Null;


        if (OtherToMerAccount.Text.Trim().Length == 0)
        {
            oracom.Parameters["p_to_account_desc"].Value = ddlToAcct.SelectedItem.Text;
            oracom.Parameters["p_to_account"].Value = ddlToAcct.SelectedValue;
        }
        else
        {
            oracom.Parameters["p_to_account_desc"].Value = OtherToMerAccount.Text;
            oracom.Parameters["p_to_account"].Value = OtherToMerAccount.Text;
        }

        if (OtherFromMerAccountNo.Text.Trim().Length == 0)
        {
            oracom.Parameters["p_from_account_desc"].Value = ddlFromAcct.SelectedItem.Text;
            oracom.Parameters["p_from_account"].Value = ddlFromAcct.SelectedValue;
        }
        else
        {
            oracom.Parameters["p_from_account_desc"].Value = OtherFromMerAccountNo.Text;
            oracom.Parameters["p_from_account"].Value = OtherFromMerAccountNo.Text;
        }



        //if (ViewState["product"].ToString().Equals("1"))
        //    oracom.Parameters["P_OVER_SHORT_REF_NO"].Value = this.TxtRefNo.Text;
        //else // IRFAN_MOD not used for saib
        oracom.Parameters["P_OVER_SHORT_REF_NO"].Value = OracleString.Null;

        if (this.txtCommissionFee.Text.Trim().Length >= 1)
            oracom.Parameters["P_TXN_CHG"].Value = Convert.ToDecimal(this.txtCommissionFee.Text.Trim());
        else
            oracom.Parameters["P_TXN_CHG"].Value = OracleNumber.Null;


        if (lbl_FromAcct2.Text.Length > 1)
        {


            oracom.Parameters["P_FROM_ACCT_2"].Value = lbl_FromAcct2.Text;
            oracom.Parameters["P_TO_ACCT_2"].Value = txtToManualMerAccount.Text;

        }
        else
        {

            oracom.Parameters["P_FROM_ACCT_2"].Value = OracleString.Null;
            oracom.Parameters["P_TO_ACCT_2"].Value = OracleString.Null;

        }

        if (lbl_FromAcct3.Text.Length > 1 && lbl_ToAcct3.Text.Length > 1)
        {
            oracom.Parameters["P_FROM_ACCT_3"].Value = lbl_FromAcct3.Text;
            oracom.Parameters["P_TO_ACCT_3"].Value = lbl_ToAcct3.Text;
        }
        else
        {
            oracom.Parameters["P_FROM_ACCT_3"].Value = OracleString.Null;
            oracom.Parameters["P_TO_ACCT_3"].Value = OracleString.Null;



        }//
        // IRFAN_MOD 170322 SAIB_CR 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;
    }

    private bool Decline(string index, 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_INVESTIGATOR.reject_claim_info";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", 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_claim_id"].Value = index;

        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 gvClaims_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("i"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = gvClaims.DataKeys[index].Value.ToString();
            Response.Redirect("InvestigateClaim.aspx?clID=" + rowID);
        }
    }

    protected void gvB24_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            if (ViewState["product"].ToString().Equals("1"))
                e.Row.Cells[9].Visible = false;
        }
    }

    protected void btnPaySlip_Click(object sender, EventArgs e)
    {
        //string p1 = Session["uid"].ToString();
        //string p2 = Request.QueryString["clID"];
        //ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //"window.open('../Reports/Default.aspx?rpt=102&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
        // Response.Redirect("Slip.aspx");
        //ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        // "window.open('slip.aspx?clID=" + lblClaimID.Text .Trim() + "','Redirect')", true);
    }

    protected void gvEJ_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            for (int i = 10; i <= 19; i++)
                e.Row.Cells[i].Visible = false;

            e.Row.Cells[22].Visible = false;
        }
    }

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

    protected void btnSaveResponse_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = SamaResponse(clID, ref error);
        if (saved)
        {
            loadClaimByID(Request.QueryString["clID"]);
            //lblError.Text = "Informatino Response Saved";
            Notifications.showMessage("Information Response Saved", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    //**************************************** Sama Operations ******************************************\\

    protected void btnsenttoCPS_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        if (ddlCPSType.SelectedIndex == 0)
        {
            //lblError.Text = "Please select Claim Type";
            Notifications.showMessage("Please select Claim Type", this, Notifications.errorMessage, false);
            return;
        }
        else
        {
            bool saved = SamasenttoCPS(clID, ref error);
            if (saved)
            {
                loadClaimByID(Request.QueryString["clID"]);
                //lblError.Text = "Sent To CPS succesfully";
                Notifications.showMessage("Sent To CPS succesfully", this, Notifications.successMessage, false);
                return;
            }
            else
            {
                //lblError.Text = error;
                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                return;
            }
        }
    }

    protected void btnSamaAccept_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = SamaApprove(clID, ref error);
        if (saved)
        {
            loadClaimByID(Request.QueryString["clID"]);
            //lblError.Text = "Claim is Approved";
            Notifications.showMessage("Claim is Approved", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    protected void btnSamaReject_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = SamaReject(clID, ref error);
        if (saved)
        {
            loadClaimByID(Request.QueryString["clID"]);
            //lblError.Text = "Claims is Rejected";
            Notifications.showMessage("Claims is Rejected", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    protected void btnRequest_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = SamaRequest(clID, ref error);
        if (saved)
        {
            loadClaimByID(Request.QueryString["clID"]);
            //lblError.Text = "Information Request saved";
            Notifications.showMessage("Information Request saved", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    protected void btnResponse_Click(object sender, EventArgs e)
    {
        Panel2.Visible = true;
    }

    private bool SamasenttoCPS(string index, ref string error)
    {
        double sugAmt;
        try
        {
            sugAmt = Double.Parse(txtSugAmt.Text);

            if (sugAmt > Double.Parse(lblAmount.Text) && sugAmt > Double.Parse(lblSettlementAmt.Text)) // IRFAN_MOD 190908
            {
                error = "Suggested Amount cannot be larger than Claim Amount";
                return false;
            }

        }
        catch (Exception)
        {
            error = "Wrong Amount Entered";
            return false;
        }

        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_INVESTIGATOR.send_to_CPS";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_type", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_sug_amt", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_notes", 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_claim_id"].Value = index;
        oracom.Parameters["p_claim_type"].Value = ddlCPSType.SelectedValue;
        oracom.Parameters["p_sug_amt"].Value = Double.Parse(txtSugAmt.Text);
        oracom.Parameters["p_notes"].Value = txtNote.Text;

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

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

    private bool SamaApprove(string index, 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_INVESTIGATOR.samaclaim_closedaccpt";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_note_text", 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_claim_id"].Value = index;
        oracom.Parameters["p_note_text"].Value = txtNote.Text;

        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 SamaReject(string index, 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_INVESTIGATOR.samaclaim_closedreject";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_note_text", 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_claim_id"].Value = index;
        oracom.Parameters["p_note_text"].Value = txtNote.Text;

        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 SamaRequest(string index, 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_INVESTIGATOR.samaclaim_acqinfo_request";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_note_text", 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_claim_id"].Value = index;
        oracom.Parameters["p_note_text"].Value = txtNote.Text;

        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 SamaResponse(string index, 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_INVESTIGATOR.samaclaim_inforesp";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_note_text", 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_claim_id"].Value = index;
        oracom.Parameters["p_note_text"].Value = txtNote.Text;

        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 cansenttoCPS(string index, 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_INVESTIGATOR.Can_Send_To_CPS";

    //    oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
    //    oracom.Parameters.Add("p_claim_id", 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_claim_id"].Value = index;

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

    //    oracom.ExecuteNonQuery();
    //    oracon.Close();
    //    string p = oracom.Parameters["p_res_code"].Value.ToString();
    //    error = oracom.Parameters["p_res_msg"].Value.ToString();
    //    if (p == "0")
    //    {
    //        //samaActions.Visible = true;
    //        loadCPSTypes(Request.QueryString["clID"]);
    //        txtSugAmt.Text = lblSugAmt.Text;

    //        return true;
    //    }

    //    else if (p == "999")
    //        //samaActions.Visible = false;
    //        return false;

    //    return false;
    //}

    //protected void btnBack_Click(object sender, EventArgs e)
    //{
    //    //Response.Redirect("POSClaimsATM.aspx");
    //    //Response.Redirect(prevPage);
    //    Response.Redirect(Request.QueryString["URL"].ToString());
    //}

    protected void gvClaims_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void btnAddNote_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        bool saved = addNote(clID, ref error);
        if (saved)
        {
            loadNotes(Request.QueryString["clID"]);
            //lblError.Text = "Note Saved";
            Notifications.showMessage("Note Saved", this, Notifications.successMessage, false);
            return;
        }
        else
        {
            //lblError.Text = error;
            Notifications.showMessage(error, this, Notifications.errorMessage, false);
            return;
        }
    }

    private bool addNote(string index, 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_COMMENTATOR.Add_Claim_Comment";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_claim_id", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_note", 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_claim_id"].Value = index;
        oracom.Parameters["p_note"].Value = txtAddNote.Text;

        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 void hideButtons()
    {
        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_INVESTIGATOR.View_screen_buttons";

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

        oracom.Parameters.Add("p_Req_Pay_Slip", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Sub_Approv", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Reject", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Send_CPS", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Sama_accept", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Sama_reject", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Req_info", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_Info_resp", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_claim_id"].Value = Request.QueryString["clID"];

        oracom.ExecuteNonQuery();

        string paySlip = oracom.Parameters["p_Req_Pay_Slip"].Value.ToString();
        string approve = oracom.Parameters["p_Sub_Approv"].Value.ToString();
        string reject = oracom.Parameters["p_Reject"].Value.ToString();
        string CPS = oracom.Parameters["p_Send_CPS"].Value.ToString();
        string samaAccept = oracom.Parameters["p_Sama_accept"].Value.ToString();
        string samReject = oracom.Parameters["p_Sama_reject"].Value.ToString();
        string reqInfo = oracom.Parameters["p_Req_info"].Value.ToString();
        string infoResp = oracom.Parameters["p_Info_resp"].Value.ToString();

        if (paySlip.Equals("N"))
            btnPaySlip.Visible = false;

        if (approve.Equals("N"))
        {
            btnApprove.Visible = false;
        }

        if (reject.Equals("N"))
            btnDecline.Visible = false;

        if (CPS.Equals("N"))
        {

            btnsenttoCPS.Visible = false;
            cpsInfo.Visible = false;
        }

        if (CPS.Equals("N") && approve.Equals("N"))
            rowSugAmt.Visible = false;

        if (samaAccept.Equals("N"))
            btnSamaAccept.Visible = false;

        if (samReject.Equals("N"))
            btnSamaReject.Visible = false;

        if (reqInfo.Equals("N"))
            btnRequest.Visible = false;

        if (infoResp.Equals("N"))
        {
            btnResponse.Visible = false;
            Panel2.Visible = false;
        }

        oracon.Close();
    }

    private bool GetCustomerAccountNo()
    {
        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_APPROVER.Get_CT_Acct";


        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_Acc_Number", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters["p_Card_Number"].Value = this.lblCardNo.Text;
        oracom.Parameters["p_Tran_Date"].Value = Helper.formatDate_ToDBFormat(lblTxnDate.Text);
        oracom.Parameters["P_RRN"].Value = this.lblReference.Text;

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

        string Account = oracom.Parameters["p_Acc_Number"].Value.ToString();

        if (String.IsNullOrWhiteSpace(Account))
            return false;

        ddlToAcct.Items.Add(Account);
        ddlFromAcct.Items.Add(Account);

        return true;
    }

    private void loadFromAcct(string claimID)
    {
        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_APPROVER.Get_ATM_frm_Acct";

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

        oracom.Parameters["p_claim_id"].Value = claimID;
        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);
        oracon.Close();

        ddlFromAcct.DataSource = ds;
        ddlFromAcct.DataBind();
        this.ddlFromAcct.Items.Insert(0, "Other");
        if (ds.Tables[0].Rows.Count > 1)
        {
            ddlFromAcct.SelectedIndex = 1;

        }
        else
        {
            OFMAccNo.Visible = true;
        }

        if (lblfromAccount.Text != "")
        {
            ddlFromAcct.SelectedValue = lblfromAccount.Text.Trim();
        }
    }

    private void loadToAcct(string claimID)
    {
        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_APPROVER.Get_ATM_to_Acct";

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

        oracom.Parameters["p_claim_id"].Value = claimID;
        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);
        oracon.Close();

        ddlToAcct.DataSource = ds;
        ddlToAcct.DataBind();
        this.ddlToAcct.Items.Insert(0, "Other");
        if (ds.Tables[0].Rows.Count > 1)
        {
            ddlToAcct.SelectedIndex = 1;

        }
        else
            OtherToMerAccount.Visible = true;


        if (lbltoAccount.Text != "")
        {
            ddlToAcct.SelectedValue = lbltoAccount.Text.Trim();
        }

    }

    protected void btnCancelPost_Click(object sender, EventArgs e)
    {
        //pnlApprove.Visible = false;
    }

    protected void btnSavePost_Click(object sender, EventArgs e)
    {
        Lbl_URC_Message.Text = "Are you sure you want to continue with changes ?";
        Notifications.showModal("UR-confirmation-modal-xl", this);
    }

    protected void btn_URConfirm_OK_Click(object sender, EventArgs e)
    {
        string error = "";
        string clID = Request.QueryString["clID"];
        decimal amount, sugAmount;

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

        amount = decimal.Parse(lblAmount.Text);
        sugAmount = decimal.Parse(txt_approve_suggestedAmount.Text);

        if ((lbl_FromAcct2.Text.Trim().Length > 1 && txtToManualMerAccount.Text.Trim().Length == 0)
            || (lbl_FromAcct2.Text.Trim().Length == 0 && txtToManualMerAccount.Text.Trim().Length > 1))
        {
            //lblError.Text = "Account should not be blank";
            Notifications.showMessage("Account should not be blank", this, Notifications.errorMessage, false);
            return;

        }
        else if (lblCardNo.Text.Trim().Substring(0, 6) == Helper.getParamByID("302") && ddlPrepaidAcctType.SelectedIndex == 0)
        {
            //lblError.Text = "Select Prepaid Account Type";
            Notifications.showMessage("Select Prepaid Account Type", this, Notifications.errorMessage, false);
            return;
        }
        else if (OtherFromMerAccountNo.Text.Trim().Length == 0 || OtherToMerAccount.Text.Trim().Length == 0)
        {
            if (ddlToAcct.SelectedValue.Equals(ddlFromAcct.SelectedValue))
            {
                //lblError.Text = "From Account must be different than To Account";
                Notifications.showMessage("From Account must be different than To Account", this, Notifications.errorMessage, false);
                return;
            }
            else
            {
                bool saved = Approve(clID, ref error);
                if (saved)
                {
                    loadClaimByID(Request.QueryString["clID"]);
                    btnsenttoCPS.Enabled = true; // Enable after accounts r saved
                    //lblError.Text = "Claim Submitted for approval";
                    Notifications.showMessage("Claim Submitted for Approval", this, Notifications.successMessage, false);
                    return;
                }
                else
                {
                    //lblError.Text = error;
                    Notifications.showMessage(error, this, Notifications.errorMessage, false);
                    return;
                }

                //this.pnlApprove.Visible = false;
            }
        }
        else
        {
            bool saved = Approve(clID, ref error);
            if (saved)
            {
                loadClaimByID(Request.QueryString["clID"]);
                //lblError.Text = "Claim Submitted for approval";
                Notifications.showMessage("Claim Submitted for Approval", this, Notifications.successMessage, false);
                return;
            }
            else
            {
                //lblError.Text = error;
                Notifications.showMessage(error, this, Notifications.errorMessage, false);
                return;
            }

            //this.pnlApprove.Visible = false;
        }

    }

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

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "POSLOOKUP_GETTER.Get_Claim_Accounts_List";

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

        oracom.Parameters["p_claim_id"].Value = claimID;
        OracleDataAdapter da = new OracleDataAdapter(oracom);
        DataSet ds = new DataSet();
        da.Fill(ds);
        oracon.Close();

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


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



        this.ddlFromAcct.Items.Insert(0, "Other");
        this.ddlToAcct.Items.Insert(0, "Other");


    }

    private string getSuggestedAmount()
    {
        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_APPROVER.GET_SUGGESTED_AMOUNT";

        oracom.Parameters.Add("P_CLAIM_ID", OracleType.VarChar).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_RRN", OracleType.VarChar).Direction = ParameterDirection.Input;

        oracom.Parameters.Add("P_SUGGESTED_AMOUNT", OracleType.Number).Direction = ParameterDirection.Output;

        oracom.Parameters["P_CLAIM_ID"].Value = this.lblClaimID.Text;
        oracom.Parameters["P_CARD_NUMBER"].Value = this.lblCardNo.Text;
        oracom.Parameters["P_TRAN_DATE"].Value = Helper.formatDate_ToDBFormat(this.lblTxnDate.Text);
        oracom.Parameters["P_RRN"].Value = this.lblReference.Text;

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

        return oracom.Parameters["P_SUGGESTED_AMOUNT"].Value.ToString();
    }
    protected void ddlFromAcct_SelectedIndexChanged(object sender, EventArgs e)
    {
        Notifications.showModal("pnlApprove-modal-xl", this);

        if (ddlFromAcct.SelectedIndex == 0)
        {
            OFMAccNo.Visible = true;
        } 
        else
        {
            OFMAccNo.Visible = false;
            //OtherFromMerAccountNo.Visible = false;
        }
        if (ViewState["product"].ToString().Equals("2") || ViewState["product"].ToString().Equals("3"))
        {
            SetAccountsFor2nd3rdGl();

        }


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

        if (ddlToAcct.SelectedIndex == 0)
            OtherToMerAccount.Visible = true;
        else
        {
            OtherToMerAccount.Visible = false;


        }
        if (ViewState["product"].ToString().Equals("2") || ViewState["product"].ToString().Equals("3"))
        {
            SetAccountsFor2nd3rdGl();
        }

    }

    // Only POS Aread Starts//
    protected void ddlFromAcct2_SelectedIndexChanged(object sender, EventArgs e) { }

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


    protected void ddlToAcct2_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlToAcct.SelectedIndex == 0)
            txtToManualMerAccount.Visible = true;
        else
            txtToManualMerAccount.Visible = false;

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

    }
    // Only POS Aread Ends//
    protected void reMer_CheckedChanged(object sender, EventArgs e)
    {
        if (lbl_Re_Code.Text == "8" || lbl_Re_Code.Text == "33")
            SetAccountsFor2nd3rdGl();


    }
    protected void rdCard_CheckedChanged(object sender, EventArgs e)
    {
        if (lbl_Re_Code.Text == "8" || lbl_Re_Code.Text == "33")
            SetAccountsFor2nd3rdGl();


    }

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