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.Globalization;

public partial class POS_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(3, userGroupID);
            loadChannels();
            loadEvents();
            loadStatus5();
            loadStatus6();
            loadChType();
            loadStatus8();
            loadStatus9();
            loadChannels11();
            loadServices();
            //loadChannelEvents11();
            loadClaimType5();
            Textproduct.Visible = false;
            ddlChannels5_SelectedIndexChanged(sender, e);
            ddlType20_SelectedIndexChanged(sender, e);


            lblDtRange.Text = "[Max Date Range - " + Helper.getParamByID("606") + " days]";

            this.ddl_contraMatched_events.Enabled = false;
            dtMerchantFrom.date = dtMerchantTo.date = DateTime.Now.Date.ToString("dd-MM-yyyy");
            ExceptionUtility.LogException(0, "", "64", "Page_Load", "");
        }
        lblError.Text = "";
        hide();
    }

    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 ------");
            }
            //ExceptionUtility.LogException("Success", "REPORTS_PERMISSIONS_OPS.GET_ACTIVE_PERMITTED_REPORTS", "loadPremittedReports", "reportGroupId: " + reportGroupId + ", groupId: " + groupId);
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "REPORTS_PERMISSIONS_OPS.GET_ACTIVE_PERMITTED_REPORTS", "loadPremittedReports", "", "reportGroupId: " + reportGroupId + ", groupId: " + groupId);
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }


    /*IJR Load Services*/
    private void loadServices()
    {
        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_merservices_DailyReport";

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


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

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

            oracon.Close();
            //ExceptionUtility.LogException("Success", "poslookup_getter.get_merservices_DailyReport", "loadServices", "");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_merservices_DailyReport", "", "loadServices", "");
            //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 = "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);

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

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

    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 = "poslookup_getter.get_pos_recon_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();
            //ExceptionUtility.LogException("Success", "poslookup_getter.get_pos_recon_events", "loadEvents", "");
            // ddlEvents5.DataSource = ds;
            // ddlEvents5.DataBind();
            // ddlEvents6.DataSource = ds;
            //  ddlEvents6.DataBind();
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_pos_recon_events", "", "loadEvents", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadStatus5()
    {
        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();
            ddlStatus5.DataSource = ds;
            ddlStatus5.DataBind();
            //ExceptionUtility.LogException("Success", "poslookup_getter.rprt_grpclaimstatus", "loadStatus5", "");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.rprt_grpclaimstatus", "", "loadStatus5", "");
            //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";

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

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

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

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

            OracleDataAdapter da = new OracleDataAdapter(oracom);
            DataSet ds = new DataSet();
            da.Fill(ds);
            oracon.Close();
            //ddlStatus5.Items.Clear()
            ddlStatus5.DataSource = ds;
            ddlStatus5.DataBind();
            //ExceptionUtility.LogException("Success", "poslookup_getter.get_claim_SAMAStatus", "loadStatus5_SAMA", "");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claim_SAMAStatus", "", "loadStatus5_SAMA", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }
    private void loadChType()
    {
        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_rpt_channel_types ";

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

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

    private void loadStatus8()
    {
        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_posmerchant_status";

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

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

    private void loadStatus9()
    {
        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_terminal_status";

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

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

    private void loadChannels11()
    {
        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);

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

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

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

    private DataSet loadChannelEvents11(string selectedChannelId)
    {
        try
        {
            //ddlEvents11.Items.Clear();
            //if (ddlChannels11.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;
            // ExceptionUtility.LogException("Success", "LOOKUP_GETTER.Get_Recon_Job_Channel_Events", "loadChannelEvents11", "");
            //ddlEvents11.DataSource = ds;
            //ddlEvents11.DataBind();
            //}
            //ddlEvents11.Items.Insert(0, "------ Events ------");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Recon_Job_Channel_Events", "", "loadChannelEvents11", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
            return null;
        }
    }

    private void loadClaimType5()
    {
        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 = "2";

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

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

            ddlClaimType5.Items.Insert(0, "------ All ------");
            oracon.Close();
            //ExceptionUtility.LogException("Success", "poslookup_getter.get_claimtype", "loadClaimType5", "");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "poslookup_getter.get_claimtype", "", "loadClaimType5", "");
            //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 ddlChannels11_SelectedIndexChanged(object sender, EventArgs e)
    {
        //loadChannelEvents11();

        //Updated By Ibrahim Al-Ashqar

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

        ddlEvents11.Items.Clear();
        if (ddlChannels11.SelectedIndex > 0)
        {
            this.ddlEvents11.DataSource = loadChannelEvents11(selectedChannelId.ToString());
            this.ddlEvents11.DataBind();

            this.ddlEvents11.Items.Insert(0, "------Event-----");
        }
        ExceptionUtility.LogException(0, "", "", "ddlChannels11_SelectedIndexChanged", "");
        //btnSearch.Enabled = false;
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        ExceptionUtility.LogException(0, "", "64.347", "btnSearch_Click", ddlReports.SelectedItem.Text);
        // 1 
        if (ddlReports.SelectedValue == "21")
        {
            if (fromDate1.date.Length == 0 || toDate1.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = fromDate1.date;
                string p3 = toDate1.date;
                string p2 = txtTerminalID1.Text;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=201&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        // 2 
        if (ddlReports.SelectedValue == "22")
        {
            if (DatePicker2.date.Length == 0)//|| txtTime2.Text.Length == 0)
            {
                lblError.Text = "please enter a date and time";
            }
            else
            {
                string p1 = DatePicker2.date;
                string p2 = txtTerminalID2.Text;
                string p3 = txtTime2.Text;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=202&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        // 3 
        if (ddlReports.SelectedValue == "23")
        {
            if (fromDate3.date.Length == 0 || toDate3.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = fromDate3.date;
                string p3 = toDate3.date;
                string p2 = txtTerminalID3.Text;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=203&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        // 4 
        if (ddlReports.SelectedValue == "24")
        {
            if (DatePicker4.date.Length == 0 || txtTime4.Text.Length == 0)
            {
                lblError.Text = "please enter a date and time";
            }
            else
            {
                string p1 = DatePicker4.date;
                string p2 = txtTerminalID4.Text;
                string p3 = "235959";
                if (txtTime4.Text.Length > 0)
                    p3 = txtTime4.Text;

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

        // 5 
        if (ddlReports.SelectedValue == "25")
        {
            if (fromDate5.date.Length == 0 || toDate5.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                //  string p1 = ddlEvents5.SelectedValue;
                string p2, p3 = "";
                if (ddlChannels5.SelectedValue == "003" && ddlStatus5.SelectedValue == "1")
                {
                    p2 = ddlChannels5.SelectedValue;
                    p3 = "301"; // SAMA Pending Status
                }
                else
                {
                    p2 = ddlChannels5.SelectedValue;
                    p3 = ddlStatus5.SelectedValue;
                }
                string p4 = fromDate5.date;
                string p5 = toDate5.date;
                string p6 = Textproduct.Text;
                string p7 = ddlOrigin.SelectedValue;
                string p8 = "";
                if (ddlClaimType5.SelectedIndex > 0)
                    p8 = ddlClaimType5.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);
            }
        }

        //// 6 
        //if (ddlReports.SelectedValue == "6")
        //{
        //    if (fromDate6.date.Length == 0 || toDate6.date.Length == 0)
        //    {
        //        lblError.Text = "please enter a date";
        //    }
        //    else
        //    {
        //        string p1 = ddlEvents6.SelectedValue;
        //        string p2 = ddlStatus6.SelectedValue;
        //        string p3 = fromDate6.date;
        //        string p4 = toDate6.date;
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //            "window.open('../Reports/Default.aspx?rpt=206&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
        //    }
        //}

        // 7 
        if (ddlReports.SelectedValue == "26")
        {
            if (procDate7.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = ddlChType7.SelectedValue;
                string p2 = procDate7.date;
                string p3 = txtuserid.Text; ;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=207&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        // 8 
        //if (ddlReports.SelectedValue == "8")
        //{
        //    if (fromDate8.date.Length == 0 || toDate8.date.Length == 0)
        //    {
        //        lblError.Text = "please enter a date";
        //    }
        //    else
        //    {
        //        string p3 = ddlStatus8.SelectedValue;
        //        string p1 = fromDate8.date;
        //        string p2 = toDate8.date;
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //            "window.open('../Reports/Default.aspx?rpt=208&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
        //    }
        //}


        //// 9 
        //if (ddlReports.SelectedValue == "9")
        //{
        //    if (fromDate9.date.Length == 0 || toDate9.date.Length == 0)
        //    {
        //        lblError.Text = "please enter a date";
        //    }
        //    else
        //    {
        //        string p3 = ddlStatus9.SelectedValue;
        //        string p1 = fromDate9.date;
        //        string p2 = toDate9.date;
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //            "window.open('../Reports/Default.aspx?rpt=209&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
        //    }
        //}

        //// 10 
        //if (ddlReports.SelectedValue == "10")
        //{
        //    //if (fromDate10.date.Length == 0 || toDate10.date.Length == 0)
        //    //{
        //    //    lblError.Text = "please enter a date";
        //    //}
        //    //else
        //    //{
        //        string p2 = txtClientNo10.Text;
        //        string p1 = txtTermID10.Text;
        //        string p3 = fromDate10.date;
        //        string p4 = toDate10.date;
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
        //            "window.open('../Reports/Default.aspx?rpt=210&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
        //    //}
        //}

        // 11
        if (ddlReports.SelectedValue == "27")
        {
            if (settlDate11.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else if (ddlChannels11.SelectedIndex == 0)
            {
                lblError.Text = "please select the channel & Event";
            }
            else if (ddlEvents11.SelectedIndex == 0)
            {
                lblError.Text = "please select an Event";
            }
            else
            {
                string p1 = ddlEvents11.SelectedValue;
                string p2 = settlDate11.date;
                string p3 = ddlFinancial.SelectedValue;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=211&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        // 12
        if (ddlReports.SelectedValue == "28")
        {
            if (settlDate12.date.Length == 0)
            {
                lblError.Text = "please enter a date";
            }
            else
            {
                string p1 = txtClientNo12.Text;
                string p2 = settlDate12.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=212&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
        }

        // 13
        //if (ddlReports.SelectedValue == "13")
        //{
        //    string p1 = txtClientNo13.Text;
        //    string p2 = DatePicker13.date;


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

        // 14
        if (ddlReports.SelectedValue == "29")
        {
            if (txtAccNo14.Text.Length == 0 || dateFrom14.date.Length == 0 || dateTo14.date.Length == 0)
            {
                lblError.Text = "please enter all fields";
            }
            else
            {
                string p1 = txtAccNo14.Text;
                string p2 = dateFrom14.date;
                string p3 = dateTo14.date;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=214&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
        }

        //15th report
        if (ddlReports.SelectedValue == "30")
        {
            if (DatePicker15.date.Length == 0 || txtClientNo15.Text.Length == 0)
            {
                lblError.Text = "please enter All fields";
            }
            else
            {
                string p1 = DatePicker15.date;
                string p2 = txtClientNo15.Text;


                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=215&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
        }
        //16th report
        if (ddlReports.SelectedValue == "31")
        {
            if (FromDate16.date.Length == 0 || Todate16.date.Length == 0 || User_ID.Text.Length == 0)
            {
                lblError.Text = "please enter All fields";
            }
            else
            {
                string p1 = User_ID.Text;
                string p2 = FromDate16.date;
                string p3 = Todate16.date;
                string p4 = fromtime.Text;
                string p5 = totime.Text;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=216&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "','Report')", true);
            }
        }
        // 17
        //if (ddlReports.SelectedValue == "17")
        //{
        //    string p1 = txtClientNo17.Text;
        //    string p2 = DatePicker17.date;


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

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


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

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


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

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


            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 == "42")
        {
            if (this.dtp_contraMatched_date.date != null && this.dtp_contraMatched_date.date.Length != 0)
            {

                if (ddl_contraMatched_channels.SelectedIndex > 0
                    && ddl_contraMatched_events.SelectedIndex > 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 Channel and Event.";
                }
            }
            else
            {
                this.lblError.Text = "Please select a date.";
            }
        }

        //IJR 25-02-2012
        //POS Daily Tranasctions
        /*  if (ddlReports.SelectedValue == "54")
          {
              if (dtpSettelemetDate.date != null)
              {
                  string p1 = this.dtpSettelemetDate.date;
                  string p2 = this.ddlServices.SelectedValue;
                  string p3 = Session["uid"].ToString();

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



        //POS Claims With No Action Taken
        if (ddlReports.SelectedValue == "46")
        {
            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=1046&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a period.";
            }
        }

        //POS Debited Claims 
        if (ddlReports.SelectedValue == "48")
        {
            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=1048&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.";
            }
        }



        if (ddlReports.SelectedValue == "58")
        {
            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=510&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }




        if (ddlReports.SelectedValue == "61")
        {
            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=513&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 +
                   "&p5=" + p5 + "&p6=" + p6 + "','Report')", true);
            }
        }

        if (ddlReports.SelectedValue == "62")
        {
            if (DatePicker1.date.Length == 0)
                lblError.Text = " Please enter date";

            else
            {
                string p1 = DatePicker1.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=514&p1=" + p1 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "69")
        {
            string p1 = Session["username"].ToString();
            string p4 = txtRetailerID.Text;
            string p5 = txtTermID.Text;
            if (dtMerchantFrom.date.Length == 0 || dtMerchantTo.date.Length == 0)
                lblError.Text = " Please enter From and To date";

            else
            {
                string p2 = dtMerchantFrom.date;
                string p3 = dtMerchantTo.date;

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                   "window.open('../Reports/Default.aspx?rpt=516&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "70")
        {
            string p1 = Session["username"].ToString();
            string p3 = txtRetailerIDMonthly.Text;
            string p4 = txtTerminalIDMonthly.Text;
            if (dtMerchantMonthly.date.Length == 0)
                lblError.Text = " Please enter date";

            else
            {
                string p2 = dtMerchantMonthly.date.Substring(0, 4);

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

        if (ddlReports.SelectedValue == "74")
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
               "window.open('../Reports/Default.aspx?rpt=604','Report')", true);
        }

        if (ddlReports.SelectedValue == "75")
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
               "window.open('../Reports/Default.aspx?rpt=606','Report')", true);
        }
        if (ddlReports.SelectedValue == "84")
        {
            string p1 = Session["username"].ToString();
            string p2 = DropDownListTranType.SelectedValue;

            if (FromDt__Contactless_Offline.date.Length == 0 || ToDt__Contactless_Offline.date.Length == 0)
                lblError.Text = " Please enter From and To date";

            else
            {
                string p3 = FromDt__Contactless_Offline.date;
                string p4 = ToDt__Contactless_Offline.date;


                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=840&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "85")
        {
            string p1 = Session["uid"].ToString();
            string p2 = dt_Span_out_of_balance.date;

            if (dt_Span_out_of_balance.date.Length == 0)
                lblError.Text = " Please enter the date";

            else
            {


                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=850&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "86")
        {
            string p1 = Session["uid"].ToString();
            string p2 = dt_span_merchant_debit.date;

            if (dt_span_merchant_debit.date.Length == 0)
                lblError.Text = " Please enter the date";

            else
            {


                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=860&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "88")
        {
            string p1 = DatePicker88.date;

            if (DatePicker88.date.Length == 0)
                lblError.Text = " Please enter the date";

            else
            {


                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                        "window.open('../Reports/Default.aspx?rpt=871&p1=" + p1 + "','Report')", true);
            }
        }
        if (ddlReports.SelectedValue == "102")
        {
            if (dtpProofECOM.date.Length == 0)
                lblError.Text = " Please enter a date";
            else
            {
                string p1 = dtpProofECOM.date;
                string p2 = ddlProofAccountReportECOM.SelectedValue;
                string p3 = dtpProofECOM.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=520&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }

        if (ddlReports.SelectedValue == "103")
        {
            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=519&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);

            }
        }

        if (ddlReports.SelectedValue == "104")
        {
            if (dtTerminalCharges.date.Length < 6 )
                lblError.Text = " Please enter a date";
            else
            {
                string p1 = dtTerminalCharges.date;

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

            }
        }
        //Settlment Report by Merchant
        if (ddlReports.SelectedValue == "105")
        {
    CultureInfo provider = CultureInfo.InvariantCulture;  
        // It throws Argument null exception  

    if (dt_MerhSettRpt_From.date.Length == 0 || dt_MerhSettRpt_To.date.Length == 0 || txtAcctNo_MerhSettRpt.Text.Length == 0)
            {
                lblError.Text = "please Enter All the fields";
            }

          DateTime FromDate = DateTime.ParseExact(dt_MerhSettRpt_From.date, "yyMMdd", provider);
          DateTime ToDate = DateTime.ParseExact(dt_MerhSettRpt_To.date, "yyMMdd", provider);

            

           string dt_DiffinDays= Helper.getParamByID("600");
           if (String.IsNullOrEmpty(dt_DiffinDays))
               dt_DiffinDays = "7";// Backup


           if (ToDate < FromDate || (ToDate - FromDate).Days > Convert.ToInt32(dt_DiffinDays))
            {
                lblError.Text = "Difference Between To Date and From Date can be maximum "+dt_DiffinDays+" days";
            }
            else
            {
                string p1 = dt_MerhSettRpt_From.date;

                string p2 = txtAcctNo_MerhSettRpt.Text;
                string p3 = dt_MerhSettRpt_To.date;



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

            }
        }


        if (ddlReports.SelectedValue == "106") // PreAuth Txn Report
        {
            CultureInfo provider = CultureInfo.InvariantCulture;
            // It throws Argument null exception  

            if (dt_from_PreAuth.date.Length == 0 || dt_To_PreAuth.date.Length == 0 )
            {
                lblError.Text = "please Enter All the fields";
            }
            DateTime FromDate = DateTime.ParseExact(dt_from_PreAuth.date, "yyMMdd", provider);
            DateTime ToDate = DateTime.ParseExact(dt_To_PreAuth.date, "yyMMdd", provider);

            string dt_DiffinDays = "15";
            //if (String.IsNullOrEmpty(dt_DiffinDays))
            //    dt_DiffinDays = "7";// Backup


            if (ToDate < FromDate || (ToDate - FromDate).Days > Convert.ToInt32(dt_DiffinDays))
            {
                lblError.Text = "Difference Between To Date and From Date can be maximum " + dt_DiffinDays + " days";
            }
            else
            {
                string p1 = dt_from_PreAuth.date;
                string p2 = dt_To_PreAuth.date;
           

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

            }
        }

        if (ddlReports.SelectedValue == "107") // PreAuth Settled Summary Txn Report
        {
            CultureInfo provider = CultureInfo.InvariantCulture;
            // It throws Argument null exception  

            if (dt_from_PreAuthSumm.date.Length == 0 || dt_To_PreAuthSumm.date.Length == 0)
            {
                lblError.Text = "please Select the Date fields ";
            }
            DateTime FromDate = DateTime.ParseExact(dt_from_PreAuthSumm.date, "yymmdd", provider);
            DateTime ToDate   = DateTime.ParseExact(dt_To_PreAuthSumm.date, "yymmdd", provider);

            //if (String.IsNullOrEmpty(dt_DiffinDays))
            //    dt_DiffinDays = "7";// Backup


            if (ToDate < FromDate || (ToDate - FromDate).Days > Convert.ToInt32(Helper.getParamByID("606")))
            {
                lblError.Text = "Difference Between To Date and From Date can be maximan " + Helper.getParamByID("606") + " days";
            }
            else
            {
                string p1 = dt_from_PreAuthSumm.date;
                string p2 = dt_To_PreAuthSumm.date;


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

            }
        }

    }

    protected void ddlReports_SelectedIndexChanged(object sender, EventArgs e)
    {
        hide();
    }

    private void hide()
    {
        tblLowUsageTerminalCharges.Visible = false;
        row1.Visible = false;
        row2.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;
        row12.Visible = false;
        row13.Visible = false;
        row14.Visible = false;
        row15.Visible = false;
        row16.Visible = false;
        row17.Visible = false;
        row19.Visible = false;
        row20.Visible = false;
        row21.Visible = false;
        row30.Visible = false;
        row62.Visible = false;
        row63.Visible = false;
        row64.Visible = false;
        row74.Visible = false;
        row88.Visible = false;

        tblMerchantSettlmentRpt.Visible = false;
        tblPreAuthTxn.Visible = false;
        tblPreAuthSummTxn.Visible = false;
        tbl_rpt_contactless_offline.Visible = false;
        //by Ibrahim Al-Ashqar
        tbl_rpt_contraMatched.Visible = false;
        this.tbl_rpt_claimsNoAction.Visible = false;
        this.tbl_rpt_debitedClaims.Visible = false;

        //IHJ
        this.tblProofAccountReport.Visible = false;
        this.tblProofAccountReportECOM.Visible = false;
        this.tblClaimsProofPeriod.Visible = false;

        this.tbl_Span_out_of_balance.Visible = false;
        this.tbl_span_merchant_debit.Visible = false;
        this.tbl_Gcc_ProofAccountReport.Visible = false;


        switch (ddlReports.SelectedValue)
        {
            case "21":
                row1.Visible = true;
                break;
            case "22":
                row2.Visible = true;
                break;
            case "23":
                row3.Visible = true;
                break;
            case "24":
                row4.Visible = true;
                break;
            case "25":
                row5.Visible = true;
                break;
            case "26":
                row7.Visible = true;
                break;
            case "27":
                row11.Visible = true;
                break;
            case "28":
                row12.Visible = true;
                break;
            case "29":
                row14.Visible = true;
                break;
            case "30":
                row15.Visible = true;
                break;
            case "31":
                row16.Visible = true;
                break;
            case "32":
                row19.Visible = true;
                break;
            case "33":
                row20.Visible = true;
                break;
            case "34":
                row21.Visible = true;
                break;
            case "42":
                tbl_rpt_contraMatched.Visible = true;
                break;
            case "46":
                this.tbl_rpt_claimsNoAction.Visible = true;
                break;
            case "48":
                this.tbl_rpt_debitedClaims.Visible = true;
                break;

            case "58":
                this.tblProofAccountReport.Visible = true;
                break;

            case "61":
                this.tblClaimsProofPeriod.Visible = true;
                break;

            case "62":
                this.row62.Visible = true;
                break;
            case "69":
                this.row63.Visible = true;
                break;
            case "70":
                this.row64.Visible = true;
                break;
            case "74":
                this.row74.Visible = true;
                break;
            case "84":
                this.tbl_rpt_contactless_offline.Visible = true;
                break;
            case "85":
                this.tbl_Span_out_of_balance.Visible = true;
                break;
            case "86":
                this.tbl_span_merchant_debit.Visible = true;
                break;
            case "88":
                this.row88.Visible = true;
                break;
            case "102":
                this.tblProofAccountReportECOM.Visible = true;
                break;
            case "103":
                this.tbl_Gcc_ProofAccountReport.Visible = true;
                break;
            case "104":
                this.tblLowUsageTerminalCharges.Visible = true;
                break;
            case "105":
                this.tblMerchantSettlmentRpt.Visible = true;
                break;
            case "106":
                this.tblPreAuthTxn.Visible = true;
                break;
            case "107":
                this.tblPreAuthSummTxn.Visible = true;
                break;   
                
            /* case "54":
                 row30.Visible = true;
                 break;*/
        }
    }

    protected void ddlChannels5_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlChannels5.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.loadChannelEvents11(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 (ddl_contraMatched_events.SelectedIndex > 0)
        {
            this.btnSearch.Enabled = true;
        }
        else
        {
            this.btnSearch.Enabled = false;
        }
    }
}
