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

public partial class Business_ReconResult : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uid"] == null)
            Response.Redirect("../Security/LoginPage.aspx");
        
        int userGroupID = Helper.getCurrentUserGroup(int.Parse(Session["uid"].ToString()));      
        
        if (!IsPostBack)
        {
            
            this.loadPremittedReports(2, userGroupID);
            loadATMTypes1 ();
            loadStatus6();
            loadBank();
            loadChannels();
            //loadChannelEvents();
            loadChannels18();
            loadStatus18();
            loadStatus();
            btnSearch.Enabled = false;
            loadEvents();
            loadSpanEvents();
            loadJobNames();
            loadEventsActive();
            loadATMTypes();
            loadVendorList();
            loadSpanEvents();
            loadClaimType18();
            loadClaimStatus();
            loadClaimTypes();
            loadATMPOSClaimType();
            load_SAMA_FINC_SETL_Events();
            ddlChannels18_SelectedIndexChanged(sender, e);
            ddlType20_SelectedIndexChanged(sender, e);
            Textproduct.Visible = false;

            this.ddl_reconTranType.Enabled = false;

            this.ddl_contraMatched_events.Enabled = false;

            this.loadEvents_SamaCoreAmountRpt();
            ExceptionUtility.LogException(0,"","24","Page_Load","");
        }
        lblError.Text = "";
        hide();
    }

    private void loadBank()
    {
        try
        {
            
            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_bank_short";

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

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

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

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

            //this.ddlIssuerSAMAMonthlyClaim .DataSource = ds;
            //this.ddlIssuerSAMAMonthlyClaim.DataBind();

            //this.ddlAcquirerSAMAMonthlyClaim.DataSource = ds;
            //this.ddlAcquirerSAMAMonthlyClaim.DataBind();

            this.ddlIssuer.Items.Insert(0, "------ Issuer ------");
            this.ddlAcquirer.Items.Insert(0, "------ Acquirer ------");
            //this.ddlIssuerSAMAMonthlyClaim.Items.Insert(0, "------ Issuer ------");
            //this.ddlAcquirerSAMAMonthlyClaim.Items.Insert(0, "------ Acquirer ------");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_bank_short","", "loadBankDetails", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadPremittedReports(int reportGroupId, int groupId)
    {
        try
        {
            int resCode;

            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "REPORTS_PERMISSIONS_OPS.GET_ACTIVE_PERMITTED_REPORTS";

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

            oracom.Parameters.Add("p_group_id", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_reports_group_id", OracleType.Number).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_current_uid"].Value = Session["uid"].ToString(); ;
            oracom.Parameters["p_lang"].Value = "EN";
            oracom.Parameters["p_group_id"].Value = groupId;
            oracom.Parameters["p_reports_group_id"].Value = reportGroupId;

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

            oracon.Close();

            resCode = int.Parse(oracom.Parameters["p_res_code"].Value.ToString());

            if (resCode == 9)
            {
                Response.Redirect("../Business/default.aspx?err=1");
            }
            else
            {
                this.ddlReports.DataSource = ds;
                this.ddlReports.DataBind();

                this.ddlReports.Items.Insert(0, "------ Reports ------");
            }
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "REPORTS_PERMISSIONS_OPS.GET_ACTIVE_PERMITTED_REPORTS", "loadPremittedReports","", "reportGroupId: " + reportGroupId + ", groupId: " + groupId);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    
    private void loadChannels()
    {
        try
        {
            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_Job_Channels";

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


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

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

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

            DropDownList1.SelectedValue = "6";
            DropDownList1.Enabled = false;

            //by Ibrahim Al-Ashqar
            this.ddl_contraMatched_channels.DataSource = ds;
            this.ddl_contraMatched_channels.DataBind();
            this.ddl_contraMatched_channels.Items.Insert(0, "------ Channels ------");

            this.ddl_reconSummary_channels.DataSource = ds;
            this.ddl_reconSummary_channels.DataBind();
            this.ddl_reconSummary_channels.Items.Insert(0, "------ Channels ------");


            ddlChannels.Items.Insert(0, "------ Channels ------");
            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Recon_Job_Channels","", "loadChannels", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private DataSet loadChannelEvents(string selectedChannelId)
    {
        try
        {
            //Updated By Ibrahim Al-Ashqar

            //ddlEvents.Items.Clear();
            //if (ddlChannels.SelectedIndex > 0)
            //{
            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_Job_Channel_Events";

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

            oracom.Parameters["p_rc_code"].Value = selectedChannelId;

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

            return ds;
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Recon_Job_Channel_Events","", "loadChannelEvents", "selectedChannelId: " + selectedChannelId);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return null;
            
        }
            //ddlEvents.DataSource = ds;
            //ddlEvents.DataBind();
        //}
        //ddlEvents.Items.Insert(0, "------ Events ------");

    }

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

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            DropDownList2.DataSource = ds;
            DropDownList2.DataBind();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Recon_Events_NCB_ATM","", "loadEvents", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void load_SAMA_FINC_SETL_Events()
    {
        try
        {
            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_channel_events";
            oracom.Parameters.Add("p_rc_code", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_recon_events", OracleType.Cursor).Direction = ParameterDirection.Output;

            oracom.Parameters["p_rc_code"].Value = "4";

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            ddl_SAMA_FINC_EVENTS.DataSource = ds;
            ddl_SAMA_FINC_EVENTS.DataBind();
            //ddl_SAMA_FINC_EVENTS.Items.Insert(0, "------ All ------");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.get_recon_channel_events","", "load_SAMA_FINC_SETL_Events", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadSpanEvents()
    {
        try
        {
            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_Span_Events";

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            ddlEvents17.DataSource = ds;
            ddlEvents17.DataBind();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Span_Events","", "loadSpanEvents", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

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

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "non_match_tran_reports.Get_Recon_Events_Active";

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

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

            ddlEvents15.DataSource = ds;
            ddlEvents15.DataBind();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "non_match_tran_reports.Get_Recon_Events_Active","", "loadEventsActive", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

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

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

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

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

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


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

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

            ddlRecordStatus.Items.Insert(0, "------ All Status ------");
            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.get_repl_status","", "loadStatus", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadJobNames()
    {
        try
        {
            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_Job_Names";

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

            oracom.Parameters["p_job_type"].Value = "L";

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

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

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Job_Names", "","loadJobNames", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadATMTypes()
    {
        try
        {
            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_ATM_BAL_Types";

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

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

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

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

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_ATM_BAL_Types","", "loadATMTypes", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadATMTypes1()
    {
        try
        {
            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_ATM_Types";

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

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

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

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

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_ATM_BAL_Types","", "loadATMTypes", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadClaimTypes()
    {
        try
        {
            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_claimchannel";

            oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            ddlCLaimType.DataSource = ds;
            ddlCLaimType.DataBind();
            ddlCLaimType.Items.Insert(0, "------ All ------");
            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claimchannel","", "loadClaimTypes", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    private void CreateRptForDepExcepTxn(string date,string atmNo)
    {
        try
        {
            string DBConnection = Helper.dbConnection();

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "replinshiment_reports.Report_Dep_Txn_Exception";

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

            oracom.Parameters["p_date"].Value = date;
            oracom.Parameters["p_Terminal"].Value = atmNo;


            oracom.ExecuteNonQuery();
            oracon.Close();
           
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "replinshiment_reports.Report_Dep_Txn_Exception", "", "CreateRptForDepExcepTxn", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadClaimStatus()
    {
        try
        {
            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_status";

            oracom.Parameters.Add("p_claim_id", OracleType.Cursor).Direction = ParameterDirection.Output;
            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);

            ddlClaimStatus_1.DataSource = ds;
            ddlClaimStatus_1.DataBind();
            ddlClaimStatus_1.Items.Insert(0, "------ All ------");

          

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claim_status","", "loadClaimStatus", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadVendorList()
    {
        try
        {
            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_Vendors_List";

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

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



            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.Get_Vendors_List","", "loadVendorList", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadChannels18()
    {
        try
        {
            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_claimchanneltype";

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


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

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

            //ddlChannels18.Items.Insert(0, "------ All ------");

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claimchanneltype","", "loadChannels18", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadStatus18()
    {
        try
        {
            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.rprt_grpclaimstatus";

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            ddlStatus18.DataSource = ds;
            ddlStatus18.DataBind();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.rprt_grpclaimstatus","", "loadStatus18", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadClaimType18()
    {
        try
        {
            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_claimtype";

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

            oracom.Parameters["p_product"].Value = "1";

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

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

            ddlClaimType18.Items.Insert(0, "------ All ------");

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claimtype","", "loadClaimType18", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    private void loadATMPOSClaimType()
    {
        try
        {
            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_atmpos_claimtype";

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

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

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

            ddlClaimType19.Items.Insert(0, "------ All ------");

            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claimtype","", "loadClaimType18", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    private void loadStatus6()
    {
        try
        {
            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_SAMAStatus_all";

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            ddlClaimSamaStatus .DataSource = ds;
            ddlClaimSamaStatus.DataBind();
            ddlClaimSamaStatus.Items.Insert(0, "------ All ------");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "pposlookup_getter.get_claim_SAMAStatus","", "loadStatus6", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

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

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

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

        //oracom.CommandType = CommandType.StoredProcedure;
        //oracom.CommandText = "sama_cps_reports.get_file_id";

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

        //oracom.Parameters["p_type"].Value = ddlType20.SelectedValue;

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

        //ddlFileName20.DataSource = ds;
        //ddlFileName20.DataBind();

        //oracon.Close();
    }

    protected void ddlChannels_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Updated By Ibrahim Al-Ashqar

        int selectedChannelId = int.Parse(this.ddlChannels.SelectedValue.ToString());

        ddlEvents.Items.Clear();
        if (ddlChannels.SelectedIndex > 0)
        {
            this.ddlEvents.DataSource = loadChannelEvents(selectedChannelId.ToString());
            this.ddlEvents.DataBind();

            this.ddlEvents.Items.Insert(0, "-----Select Event-----");
        }

        btnSearch.Enabled = false;

        if (selectedChannelId == 6)
        {
            this.ddl_reconTranType.Enabled = false;
        }
        else
        {
            this.ddl_reconTranType.Enabled = true;
        }


    }

    protected void ddlEvents_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlEvents.SelectedIndex > 0)
            btnSearch.Enabled = true;
        else
            btnSearch.Enabled = false;
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        ExceptionUtility.LogException(0, "", "", "btnSearch_Click", ddlReports.SelectedItem.Text);
        // first & second report
        if (ddlReports.SelectedValue == "1")
        {
            if (DatePicker1.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = ddlChannels.SelectedValue;
                string p2 = ddlEvents.SelectedValue;
                string p3 = DatePicker1.date;
                string p4 = this.ddl_reconTranType.SelectedValue.ToString();

                if (rdRecon.Checked)
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=1&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
                    //Response.Redirect("../Reports/Default.aspx?rpt=1&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=2&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
                    //Response.Redirect("../Reports/Default.aspx?rpt=2&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3);
                }
            }
        }


        //third report
        if (ddlReports.SelectedValue == "2")
        {
            if (DatePicker2.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker2.date;
                string p2 = "";
                if (ddlRecordStatus.SelectedIndex > 0)
                    p2 = ddlRecordStatus.SelectedValue;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=3&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=3&p1=" + p1 + "&p2=" + p2);
            }
        }


        //forth report
        if (ddlReports.SelectedValue == "3")
        {
            if (DatePicker3.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker3.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=4&p1=" + p1 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=4&p1=" + p1);
            }
        }

        //// fifth report
        //if (ddlReports.SelectedValue == "5")
        //{
        //    lblError.Text = "";
        //    if (DatePicker4.date.Length == 0)
        //        lblError.Text += "please enter a from date<br>";
        //    if (DatePicker5.date.Length == 0)
        //        lblError.Text += "please enter a to date<br>";

        //    if (lblError.Text.Length == 0)
        //    {
        //        string p1 = txtATMNumber.Text;
        //        string p2 = DatePicker4.date;
        //        string p3 = DatePicker5.date;
        //        string p4 = "", p5 = "", p6 = "", p7 = "", p8 = "";
        //        if (rdOnUs.Checked)
        //            p4 = "0";
        //        else
        //            p4 = "1";
        //        if (chkAutoApp.Checked)
        //            p5 = "001";
        //        else
        //            p5 = "000";

        //        if (chkApproved.Checked)
        //            p6 = "1";
        //        else
        //            p6 = "0";
        //        if (chkPosted.Checked)
        //            p7 = "1";
        //        else
        //            p7 = "0";
        //        if (chkDeclined.Checked)
        //            p8 = "1";
        //        else
        //            p8 = "0";

        //        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //            "window.open('../Reports/Default.aspx?rpt=5&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);

        //        //Response.Redirect("../Reports/Default.aspx?rpt=5&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8);
        //    }
        //}

        //sixth report
        if (ddlReports.SelectedValue == "4")
        {
            if (DatePicker6.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker6.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=6&p1=" + p1 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=6&p1=" + p1);
            }
        }

        //seventh report
        if (ddlReports.SelectedValue == "5")
        {
            if (DatePicker7.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DropDownList1.SelectedValue;
                string p2 = DatePicker7.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=7&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=7&p1=" + p1 + "&p2=" + p2);
            }
        }

        //eight report
        if (ddlReports.SelectedValue == "6")
        {
            if (DatePicker8.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else if (txtATMNumber8.Text.Length == 0)
            {
                lblError.Text = "please enter the ATM number";
            }
            else
            {
                string p1 = DatePicker8.date;
                string p2 = txtATMNumber8.Text;
                string p3 = ddlDestination8.SelectedValue;
                string p4 = ddlRecordType8.SelectedValue;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=8&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

                //Response.Redirect("../Reports/Default.aspx?rpt=8&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4);
            }
        }

        //ninth report
        if (ddlReports.SelectedValue == "7")
        {
            if (DatePicker9.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else if (txtATMNumber9.Text.Length == 0)
            {
                lblError.Text = "please enter the ATM number";
            }
            else
            {
                string p1 = DatePicker9.date;
                string p2 = txtATMNumber9.Text;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                    "window.open('../Reports/Default.aspx?rpt=9&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

                //Response.Redirect("../Reports/Default.aspx?rpt=9&p1=" + p1 + "&p2=" + p2);
            }
        }

        //tenth report
        if (ddlReports.SelectedValue == "8")
        {
            if (DatePicker10.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker10.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=10&p1=" + p1 + "','Report')", true);

                //Response.Redirect("../Reports/Default.aspx?rpt=10&p1=" + p1);
            }
        }

        //eleventh report
        if (ddlReports.SelectedValue == "9")
        {
            if (DatePicker11.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker11.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=11&p1=" + p1 + "','Report')", true);
                //sponse.Redirect("../Reports/Default.aspx?rpt=11&p1=" + p1);
            }
        }

        //eleven eleventh report
        if (ddlReports.SelectedValue == "10")
        {
            if (DatePicker1111.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker1111.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=1111&p1=" + p1 + "','Report')", true);
                //sponse.Redirect("../Reports/Default.aspx?rpt=11&p1=" + p1);
            }
        }

        //12th report
        if (ddlReports.SelectedValue == "11")
        {
            if (DatePicker12.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker12.date;
                string p2 = ddljobName12.SelectedValue;
                string p3 = ddlResponse12.SelectedValue;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=12&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=12&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3);
            }
        }

        //13th report
        if (ddlReports.SelectedValue == "12")
        {
            if (DatePicker13.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = ddlATMType13.SelectedValue;
                string p2 = DatePicker13.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=13&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=13&p1=" + p1 + "&p2=" + p2);
            }
        }

        //14th report
        if (ddlReports.SelectedValue == "13")
        {
            if (DatePicker14.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker14.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=14&p1=" + p1 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=14&p1=" + p1);
            }
        }

        //15th report
        if (ddlReports.SelectedValue == "14")
        {
            if (DatePicker15.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else if (txtTime15.Text.Length == 0)
            {
                lblError.Text = "please enter time";
            }
            else
            {
                string p1 = ddlEvents15.SelectedValue;
                string p2 = DatePicker15.date;
                string p3 = txtTime15.Text;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=15&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
                //Response.Redirect("../Reports/Default.aspx?rpt=15&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3);
            }
        }

        //16th report
        if (ddlReports.SelectedValue == "15")
        {
            if (DatePicker16.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = DatePicker16.date;
                string p2 = ddlRecordType16.SelectedValue;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=16&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
        }

        //17th report
        if (ddlReports.SelectedValue == "16")
        {
            double temp;

            if (DatePicker17.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else if (Settl_amt17.Text.Length == 0)
            {
                lblError.Text = "please enter an amount";
            }
            else if (!double.TryParse(Settl_amt17.Text, out temp))
            {
                lblError.Text = "please enter a valid amount";
            }
            else
            {
                string p1 = ddlEvents17.SelectedValue;
                string p2 = DatePicker17.date;
                string p3 = Settl_amt17.Text;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=17&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }




        if (ddlReports.SelectedValue == "56")
        {
            if (dtpFromDateClaimStatus.date.Length == 0)
            {
                lblError.Text = "please enter From date";
            }
            else if (dtpToDateClaimStatus.date.Length == 0)
            {
                lblError.Text = "please enter To date";
            }
            else
            {
                string p1 = dtpFromDateClaimStatus.date;
                string p2 = dtpToDateClaimStatus.date;
                string p3 = "";
                string p4 = "";

                if (ddlClaimStatus_1.SelectedIndex > 0)
                {
                    p3 = ddlClaimStatus_1.SelectedValue;
                }
                else
                    p3 = "0";

                if (ddlCLaimType.SelectedIndex > 0)
                {
                    if (ddlCLaimType.SelectedValue == "001")
                        p4 = "C";
                    else if (ddlCLaimType.SelectedValue == "002")
                        p4 = "M";
                    else if (ddlCLaimType.SelectedValue == "003")
                        p4 = "A";
                    else if (ddlCLaimType.SelectedValue == "004")
                        p4 = "E";
                    else if (ddlCLaimType.SelectedValue == "005")
                        p4 = "S";
                }
                else p4 = "0";



                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=508&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }




        if (ddlReports.SelectedValue == "57")
        {
            if (dtpProof.date.Length == 0)
                lblError.Text = " Please enter a date";
            else
            {
                string p1 = dtpProof.date;
                string p2 = ddlProofAccountReport.SelectedValue;
                string p3 = dtpProof.FormatedDate;

                DateTime dt = new DateTime(int.Parse(p1.Substring(0, 2)), int.Parse(p1.Substring(2, 2)),
                    int.Parse(p1.Substring(4, 2)));
                dt = dt.AddDays(-1);
                string p4 = dt.ToString("dd-MM-yy");

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=509&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }


        if (ddlReports.SelectedValue == "59")
        {
            if (dtpGCC_ProofAccount.date.Length == 0)
                lblError.Text = " Please enter a date";
            else
            {
                string p1 = dtpGCC_ProofAccount.date;
                string p2 = ddlGCC_ProofAccount.SelectedValue;
                string p3 = dtpGCC_ProofAccount.FormatedDate;
                DateTime dt = new DateTime(int.Parse(p1.Substring(0, 2)), int.Parse(p1.Substring(2, 2)),
                    int.Parse(p1.Substring(4, 2)));
                dt = dt.AddDays(-1);
                string p4 = dt.ToString("dd-MM-yy");

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=511&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }

        if (ddlReports.SelectedValue == "60")
        {
            if (dtpClaimsProof_From.date.Length == 0)
                lblError.Text = " Please enter From date";
            else if (dtpClaimsProof_To.date.Length == 0)
                lblError.Text = " Please enter To date";
            else
            {
                string p1 = dtpClaimsProof_From.date;
                string p2 = dtpClaimsProof_To.date;

                string p3 = ddlClaimsProofPeriod.SelectedValue;

                string p4 = dtpClaimsProof_From.FormatedDate;
                string p5 = dtpClaimsProof_To.FormatedDate;

                string p6 = ddlReportType.SelectedValue;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=512&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 +
                   "&p5=" + p5 + "&p6=" + p6 + "','Report')", true);
            }
        }



        // 18 
        if (ddlReports.SelectedValue == "17")
        {
            if (fromDate5.date.Length == 0 || toDate5.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                //  string p1 = ddlEvents5.SelectedValue;
                string p2 = ddlChannels18.SelectedValue;
                if (p2 == "004")
                    p2 = "";
                string p3 = ddlStatus18.SelectedValue;
                string p4 = fromDate5.date;
                string p5 = toDate5.date;
                string p6 = Textproduct.Text;
                string p7 = ddlOrigin.SelectedValue;
                string p8 = "";
                if (ddlClaimType18.SelectedIndex > 0)
                    p8 = ddlClaimType18.SelectedValue;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=205&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);
            }
        }

        // 19
        if (ddlReports.SelectedValue == "18")
        {
            string p1 = ddlType19.SelectedValue;
            string p2 = "1";


            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                "window.open('../Reports/Default.aspx?rpt=219&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
        }

        // 20
        if (ddlReports.SelectedValue == "19")
        {
            string p1 = ddlClaimDate20.date;
            string p2 = "1";


            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                "window.open('../Reports/Default.aspx?rpt=220&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
        }

        // 21
        if (ddlReports.SelectedValue == "20")
        {
            string p1 = ddlType21.SelectedValue;
            string p2 = "1";


            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                "window.open('../Reports/Default.aspx?rpt=221&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
        }

        //By Ibrahim Al-Ashqar
        // Contra Matched Transactions Report
        if (ddlReports.SelectedValue == "41")
        {
            if (this.dtp_contraMatched_date.date != null && this.dtp_contraMatched_date.date.Length != 0)
            {
                string p1 = this.ddl_contraMatched_channels.SelectedValue;
                string p2 = this.ddl_contraMatched_events.SelectedValue;
                string p3 = this.dtp_contraMatched_date.date;
                string p4 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=1041&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a date.";
            }
        }

        // Recon Summary Report
        if (ddlReports.SelectedValue == "43")
        {
            string selectedChannelId = this.ddl_reconSummary_channels.SelectedValue;
            string selectedEventId = this.ddl_reconSummary_events.SelectedValue;
            string date = this.dtp_reconSummary_date.date;

            if (this.ddl_reconSummary_channels.SelectedIndex == 0)
            {
                this.lblError.Text = "Please Select a Channel";
            }
            else if (this.ddl_reconSummary_events.SelectedIndex == 0)
            {
                this.lblError.Text = "Please Select an Event";
            }
            else if (date.Length == 0)
            {
                this.lblError.Text = "Please select a date.";
            }
            else
            {

                string p1 = selectedChannelId;
                string p2 = selectedEventId;
                string p3 = date;
                string p4 = Session["uid"].ToString();

                if (p1.Equals("6"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=10431&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=10430&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
                }
            }

        }

        // Sama Core Amount
        if (ddlReports.SelectedValue == "44")
        {
            if (this.dtp_samaCoreAmount_date.date != null && this.dtp_samaCoreAmount_date.date.Length != 0)
            {
                string toTime = this.txt_samaCoreAmount_toTime.Text;
                string fromTime = this.txt_samaCoreAmount_fromTime.Text;

                Regex timeFormatValidator = new Regex(@"^(\d{1,2}):(\d{2}):(\d{2})");

                if (toTime.Trim() != "" && fromTime.Trim() != "")
                {
                    if (timeFormatValidator.IsMatch(fromTime) && timeFormatValidator.IsMatch(toTime))
                    {

                        string p1 = this.dtp_samaCoreAmount_date.date;
                        string p2 = Helper.formatTime_toDBFormat(fromTime);
                        string p3 = Helper.formatTime_toDBFormat(toTime);
                        string p4 = this.ddl_samaCoreAmount_events.SelectedValue;
                        string p5 = Session["uid"].ToString();

                        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1044&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "','Report')", true);
                    }
                    else
                    {
                        this.lblError.Text = "Please enter a valid time format eg.HH:MM:SS ...";
                    }
                }


            }
            else
            {
                this.lblError.Text = "Please select a date.";
            }
        }

        //ATM Claims With No Action Taken
        if (ddlReports.SelectedValue == "45")
        {
            string fromDate = this.dtp_claimsNoAction_fromDate.date;
            string toDate = this.dtp_claimsNoAction_toDate.date;

            if (fromDate.Length != 0 && toDate.Length != 0)
            {
                fromDate = DateTime.ParseExact(this.dtp_claimsNoAction_fromDate.date, "yyMMdd", null).ToString("yyyyMMdd");
                toDate = DateTime.ParseExact(this.dtp_claimsNoAction_toDate.date, "yyMMdd", null).ToString("yyyyMMdd");

                string p1 = fromDate;
                string p2 = toDate;
                string p3 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1045&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a period.";
            }
        }


        //IJR 13-03-2012 -- NEW REPORT FOR SAMA FINACLE SETTELEMENT
        if (ddlReports.SelectedValue == "53")
        {
            if (dtp_SAMA_FINACLE_DATE.date.Length == 0)//&& ddl_SAMA_FINC_EVENTS.SelectedIndex == 0)
            {
                lblError.Text = "please enter a date ";
            }
            else
            {

                //Run the procedure to prepare the settelement details
                string p1 = Session["uid"].ToString();
                string p2 = dtp_SAMA_FINACLE_DATE.date;
                string p3 = ddl_SAMA_FINC_EVENTS.SelectedValue;
                samaFinacle_Settelment();
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=502&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }


        //IJR 04-04-2012

        if (ddlReports.SelectedValue == "54")
        {
            if (dtpDeposit.date.Length == 0 || dtpDepositFrom.date.Length == 0)//&& ddl_SAMA_FINC_EVENTS.SelectedIndex == 0)
            {
                lblError.Text = "please enter a date ";
            }

            else
            {

                //Run the procedure to prepare the settelement details
                //string p1 = Session["uid"].ToString();
                string p1 = Session["username"].ToString();
                string p2 = dtpDeposit.date;
                string p3 = "";
                if (txtATMID_Deposit.Text.Length == 0)
                    p3 = "";
                else
                    p3 = txtATMID_Deposit.Text;
                string p4 = dtpDepositFrom.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=504&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
            }
        }



        if (ddlReports.SelectedValue == "55")
        {
            if (dtp_RetracrRep.date.Length == 0)//&& ddl_SAMA_FINC_EVENTS.SelectedIndex == 0)
            {
                lblError.Text = "please enter a date ";
            }
            else
            {

                //Run the procedure to prepare the settelement details
                string p1 = Session["uid"].ToString();
                string p2 = dtp_RetracrRep.date;
                string p3 = "";
                if (txtRetractRep.Text.Length == 0)
                    p3 = "";
                else
                    p3 = txtRetractRep.Text;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=505&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }



        //ATM Debited Claims 
        if (ddlReports.SelectedValue == "47")
        {
            string fromDate = this.dtp_debitedClaims_fromDate.date;
            string toDate = this.dtp_debitedClaims_toDate.date;
            string accountNumber = this.txt_debitedClaims_acctNumber.Text;

            if (accountNumber.Length != 0 && fromDate.Length != 0 && toDate.Length != 0)
            {
                string p1 = accountNumber;
                string p2 = fromDate;
                string p3 = toDate;
                string p4 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1047&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
            }
            else if (accountNumber.Length == 0)
            {
                this.lblError.Text = "Please enter an account number.";
            }
            else if (fromDate.Length == 0 || toDate.Length == 0)
            {
                this.lblError.Text = "Please select a period.";
            }
        }

        //Sama Claim Report
        if (ddlReports.SelectedValue == "64")
        {
            string p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p12, p13, p14, p15, p16, p17, p18;
            int p11;
            string terminalID = this.txtTerminalID.Text;
            string fromDate = this.DatePicker20.date;
            string toDate = this.DatePicker21.date;
            string SamaFromDate = this.DatePicker18.date;
            string SamaToDate = this.DatePicker19.date;

            if (fromDate.Length == 0 && toDate.Length == 0 && SamaFromDate.Length == 0 && SamaToDate.Length == 0)
            {
                lblError.Text = "Please enter date";
            }
            else
            {

                string claimStatus = "", claimStatusDesc = "";
                if (ddlClaimSamaStatus.SelectedIndex > 0)
                {
                    claimStatus = this.ddlClaimSamaStatus.SelectedValue;
                    claimStatusDesc = this.ddlClaimSamaStatus.SelectedItem.Text;
                }
                string claimType = "", claimTypeDesc = "";
                if (ddlClaimType19.SelectedIndex > 0)
                {
                    claimType = this.ddlClaimType19.SelectedValue;
                    claimTypeDesc = this.ddlClaimType19.SelectedItem.Text;
                }
                string Issuer = "", IssuerDesc = "";
                if (ddlIssuer.SelectedIndex > 0)
                {
                    Issuer = this.ddlIssuer.SelectedValue;
                    IssuerDesc = this.ddlIssuer.SelectedItem.Text;
                }
                string acquirer = "", acquirerDesc = "";
                if (ddlAcquirer.SelectedIndex > 0)
                {
                    acquirer = this.ddlAcquirer.SelectedValue;
                    acquirerDesc = this.ddlAcquirer.SelectedItem.Text;
                }
                string Entity = "", entityDesc = "";
                if (ddlClaimEntity.SelectedIndex > 0)
                {
                    Entity = ddlClaimEntity.SelectedValue;
                    entityDesc = ddlClaimEntity.SelectedItem.Text;
                }
                int Service = 0;
                string serviceDesc = "";
                if (rdATM.Checked)
                {
                    Service = 1;
                    serviceDesc = "ATM";
                }
                else if (rdPOS.Checked)
                {
                    Service = 2;
                    serviceDesc = "POS";
                }
                else
                {
                    Service = 0;
                    serviceDesc = "ALL";
                }
                p1 = terminalID;
                p2 = fromDate;
                p3 = toDate;
                p4 = SamaFromDate;
                p5 = SamaToDate;
                p6 = claimStatus;
                p7 = claimType;
                p8 = Issuer;
                p9 = acquirer;
                p10 = Entity;
                p11 = Service;
                p12 = Session["username"].ToString();

                p13 = claimStatusDesc;
                p14 = claimTypeDesc;
                p15 = IssuerDesc;
                p16 = acquirerDesc;
                p17 = entityDesc;
                p18 = serviceDesc;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1053&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "&p9=" + p9 + "&p10=" + p10 + "&p11=" + p11 + "&p12=" + p12 + "&p13=" + p13 + "&p14=" + p14 + "&p15=" + p15 + "&p16=" + p16 + "&p17=" + p17 + "&p18=" + p18 + "','Report')", true);
            }
        }

        if (ddlReports.SelectedValue == "66")
        {
            string p1 = Session["username"].ToString();
            string p2 = this.DatePicker22.date;
            string p3 = ddlAtmType14.SelectedValue;
            if (p1.Length == 0)
                this.lblError.Text = "Please enter a date.";

            else
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1054&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
        }

        if (ddlReports.SelectedValue == "65")
        {

            string p1 = Session["username"].ToString();



            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=1055&p1=" + p1 + "','Report')", true);
        }

        if (ddlReports.SelectedValue == "67")
        {
            //pnlType.Visible = false;
            if (dtpSAMAMonthlyClaim.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dtpSAMAMonthlyClaim.date.Substring(0, 4);
                if (rdbSeg.Checked)
                {

                    string p3;
                    //p2 = p2.Substring(0, 4);
                    //string p3 = ddlIssuerSAMAMonthlyClaim.SelectedValue;
                    //string p4 = ddlAcquirerSAMAMonthlyClaim.SelectedValue;
                    //if (rdbIsser.Checked)
                    p3 = ddlSeggregate.SelectedValue;
                    //else
                    //    p3 = 1;
                    int p5 = 0;
                    //if (rdbATM.Checked)
                    //    p5 = 1;
                    //else if (rdbPOS.Checked)
                    //    p5 = 2;
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1056&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p5=" + p5 + "','Report')", true);
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1057&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
                }
            }
            else
            {
                lblError.Text = "Please select Month";
            }
        }

        if (ddlReports.SelectedValue == "68")
        {
            //pnlType.Visible = false;
            if (dtpOnlineFrom.date.Length > 0 && dtpOnlineTo.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dtpOnlineFrom.date;
                string p3 = dtpOnlineTo.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1058&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }

        if (ddlReports.SelectedValue == "90")
        {
            //pnlType.Visible = false;
            if (dt_VisaMatch.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dt_VisaMatch.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=900&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }
        if (ddlReports.SelectedValue == "91")
        {

            if (dt_VisaNonMatchRecon.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dt_VisaNonMatchRecon.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=910&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }
        if (ddlReports.SelectedValue == "92")
        {

            if (dt_VisaNonMatchTran.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dt_VisaNonMatchTran.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=920&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }

        if (ddlReports.SelectedValue == "93")
        {

            if (dt_VisaRePresentment.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dt_VisaRePresentment.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=930&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }
        if (ddlReports.SelectedValue == "94")
        {
            //pnlType.Visible = false;

            if (dt_VisaMonthly_From.date.Length > 0 && dt_VisaMonthly_To.date.Length > 0)
            {
                string p1 = Session["username"].ToString();
                string p2 = dt_VisaMonthly_From.date;
                string p3 = dt_VisaMonthly_To.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=940&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date";
            }
        }
         if (ddlReports.SelectedValue == "95")
        {
            //pnlType.Visible = false;

            if (dtTranCoin.date.Length > 0 && txtAtmNoCoin.Text.Length==4 )
            {
                string p1 = Session["username"].ToString();
                string p2 = dtTranCoin.date;
                CreateRptForDepExcepTxn(dtTranCoin.date, txtAtmNoCoin.Text);
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=950&p1=" + p1 + "&p2=" + p2 + "','Report')", true);

            }
            else
            {
                lblError.Text = "Please select date & Enter 4 digit ATM";
            }
        }
      

    }
    

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

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

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

            oracom.CommandType = CommandType.StoredProcedure;
            oracom.CommandText = "operation_reports.REPORT_SAMA_Finacle_Settlement";

            oracom.Parameters.Add("p_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_settl_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_event", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_res", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

            oracom.Parameters["p_uid"].Value = Session["uid"].ToString();
            oracom.Parameters["p_settl_date"].Value = dtp_SAMA_FINACLE_DATE.date;
            oracom.Parameters["p_event"].Value = ddl_SAMA_FINC_EVENTS.SelectedValue;

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "operation_reports.REPORT_SAMA_Finacle_Settlement","", "samaFinacle_Settelment", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }


    protected void ddlReports_SelectedIndexChanged(object sender, EventArgs e)
    {
        hide();
        if (ddlReports.SelectedValue != "1")
            btnSearch.Enabled = true;
        else
        {
            btnSearch.Enabled = false;
            //ddlEvents.SelectedIndex = 0;
            //ddlChannels.SelectedIndex = 0;
        }
    }

    private void hide()
    {
        row1.Visible = false;
        row3.Visible = false;
        row4.Visible = false;
        row5.Visible = false;
        row6.Visible = false;
        row7.Visible = false;
        row8.Visible = false;
        row9.Visible = false;
        row10.Visible = false;
        row11.Visible = false;
        row1111.Visible = false;
        row12.Visible = false;
        row13.Visible = false;
        row14.Visible = false;
        row15.Visible = false;
        row16.Visible = false;
        row17.Visible = false;
        row18.Visible = false;
        row19.Visible = false;
        row20.Visible = false;
        row21.Visible = false;

        //by Ibrahim Al-Ashqar
        this.tbl_rpt_contraMatched.Visible = false;
        this.tbl_rpt_reconSummary.Visible = false;
        this.tbl_rpt_samaCoreAmount.Visible = false;
        this.tbl_rpt_claimsNoAction.Visible = false;
        this.tbl_rpt_debitedClaims.Visible = false;


        //by IJR 14-03-2012 --> 01-07-2012
        this.tbl_rpt_SAMA_FINC_SETL.Visible = false;
        this.tblDeposit.Visible = false;
        this.tblRetract_Dep.Visible = false;
        this.tblClaimByStatus.Visible = false;
        this.tblProofAccountReport.Visible = false;
        this.tbl_Gcc_ProofAccountReport.Visible = false;


        this.tblClaimsProofPeriod.Visible = false;
        this.tblSamaClaims.Visible = false;
        this.tblNonReplenishATMs.Visible = false;
        this.tblSAMAMonthlyClaim.Visible = false;
        this.tblOnlinePostingGL.Visible = false;

        // VISA CR
        tbl_VisaMatch.Visible = false;
        tbl_VisaNonMatchRecon.Visible = false;
        tbl_VisaNonMatchTran.Visible = false;
        tbl_VisaRePresentment.Visible = false;
        tbl_VisaMonthlyNonMatchTran.Visible = false;
        //
        //Coin CR
        this.tblCoinDep.Visible = false;
        //
        switch (ddlReports.SelectedValue)
        {
            case "1":
                row1.Visible = true;
                break;
            case "2":
                row3.Visible = true;
                break;
            case "3":
                row4.Visible = true;
                break;
            case "4":
                row6.Visible = true;
                break;
            case "5":
                row7.Visible = true;
                break;
            case "6":
                row8.Visible = true;
                break;
            case "7":
                row9.Visible = true;
                break;
            case "8":
                row10.Visible = true;
                break;
            case "9":
                row11.Visible = true;
                break;
            case "10":
                row1111.Visible = true;
                break;
            case "11":
                row12.Visible = true;
                break;
            case "12":
                row13.Visible = true;
                break;
            case "13":
                row14.Visible = true;
                break;
            case "14":
                row15.Visible = true;
                break;
            case "15":
                row16.Visible = true;
                break;
            case "16":
                row17.Visible = true;
                break;
            case "17":
                row18.Visible = true;
                break;
            case "18":
                row19.Visible = true;
                break;
            case "19":
                row20.Visible = true;
                break;
            case "20":
                row21.Visible = true;
                break;
            case "41":
                this.tbl_rpt_contraMatched.Visible = true;
                break;
            case "43":
                this.tbl_rpt_reconSummary.Visible = true;
                break;
            case "44":
                this.tbl_rpt_samaCoreAmount.Visible = true;
                break;
            case "45":
                this.tbl_rpt_claimsNoAction.Visible = true;
                break;
            case "47":
                this.tbl_rpt_debitedClaims.Visible = true;
                break;
            //by IJR 14-03-2012 -->  01-07-2012
            case "53":
                this.tbl_rpt_SAMA_FINC_SETL.Visible = true;
                break;
            case "54":
                this.tblDeposit.Visible = true;
                break;
            case "55":
                this.tblRetract_Dep.Visible = true;
                break;
            case "56":
                this.tblClaimByStatus.Visible = true;
                break;
            case "57":
                this.tblProofAccountReport.Visible = true;
                break;
            case "59":
                this.tbl_Gcc_ProofAccountReport.Visible = true;
                break;
            case "60":
                this.tblClaimsProofPeriod.Visible = true;
                break;
            case "64":
                this.tblSamaClaims.Visible = true;
                break;
            case "66":
                this.tblNonReplenishATMs.Visible = true;
                break;
            case "67":
                if (rdbComp.Checked)
                    this.ddlSeggregate.Visible = false;
                else
                    this.ddlSeggregate.Visible = true;
                this.tblSAMAMonthlyClaim .Visible = true;
                break;
            case "68":
                this.tblOnlinePostingGL.Visible = true;
                break;
            case "90":
                tbl_VisaMatch.Visible = true;
                break;
            case "91":
                tbl_VisaNonMatchRecon.Visible = true;
                break;
            case "92":
                tbl_VisaNonMatchTran.Visible = true;
                break;
            case "93":
                tbl_VisaRePresentment.Visible = true;
                break;
            case "94":
                tbl_VisaMonthlyNonMatchTran.Visible = true;
                break;
            case "95":
                tblCoinDep.Visible = true;
                break;
            //

        }
    }

    protected void ddlChannels18_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlChannels18.SelectedValue.Equals("003"))
            rowOrigin.Visible = true;
        else
            rowOrigin.Visible = false;
    }

    protected void ddlType20_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadFileNames();
    }
    
    //By Ibrahim Al-Ashqar
    protected void ddl_contraMatched_channels_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.btnSearch.Enabled = false;
        

        string selectedChannelId = this.ddl_contraMatched_channels.SelectedValue;

        if (this.ddl_contraMatched_channels.SelectedIndex > 0)
        {
            this.ddl_contraMatched_events.DataSource = this.loadChannelEvents(selectedChannelId);
            this.ddl_contraMatched_events.DataBind();

            this.ddl_contraMatched_events.Items.Insert(0, "----------- Select Event -----------");

            this.ddl_contraMatched_events.Enabled = true;
        }
        else
        {
            this.ddl_contraMatched_events.Enabled = false;
            this.ddl_contraMatched_events.Items.Clear();
        }
    }
    
    protected void ddl_contraMatched_events_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.ddl_contraMatched_events.SelectedIndex > 0)
        {
            this.btnSearch.Enabled = true;
        }
        else
        {
            this.btnSearch.Enabled = false;
        }
    }
    
    protected void ddl_reconSummary_channels_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.btnSearch.Enabled = false;

        string selectedChannelId = this.ddl_reconSummary_channels.SelectedValue;

        if (this.ddl_reconSummary_channels.SelectedIndex > 0)
        {
            this.ddl_reconSummary_events.DataSource = this.loadChannelEvents(selectedChannelId);
            this.ddl_reconSummary_events.DataBind();

            this.ddl_reconSummary_events.Items.Insert(0, "----------- Select Event -----------");

            this.ddl_reconSummary_events.Enabled = true;
        }
        else
        {
            this.ddl_reconSummary_events.Enabled = false;
            this.ddl_reconSummary_events.Items.Clear();
        }
    }

    protected void ddl_reconSummary_events_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.ddl_reconSummary_events.SelectedIndex > 0)
        {
            this.btnSearch.Enabled = true;
        }
        else
        {
            this.btnSearch.Enabled = false;
        }
    }

    private void loadEvents_SamaCoreAmountRpt()
    {
        this.ddl_samaCoreAmount_events.DataSource = this.loadChannelEvents("6");
        this.ddl_samaCoreAmount_events.DataBind();

        ListItem allEventsItem = new ListItem("All Events", "0");

        this.ddl_samaCoreAmount_events.Items.Insert(0, allEventsItem);
    }
    protected void ddl_SAMA_FINC_EVENTS_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.ddl_SAMA_FINC_EVENTS.SelectedIndex > 0)
        {
            this.btnSearch.Enabled = true;
        }
        else
        {
            this.btnSearch.Enabled = false;
        }
    }
    protected void rdbComp_CheckedChanged(object sender, EventArgs e)
    {
        ddlSeggregate .Visible = false;
    }
    protected void rdbSeg_CheckedChanged(object sender, EventArgs e)
    {
        ddlSeggregate.Visible = true;
    }
}