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

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);
            
            loadChannels();
            //loadChannelEvents();
            loadChannels18();
            loadStatus18();
            loadStatus();
            btnSearch.Enabled = false;
            loadEvents();
            loadSpanEvents();
            loadJobNames();
            loadEventsActive();
            loadATMTypes();
            loadVendorList();
            loadSpanEvents();
            loadClaimType18();
            loadClaimStatus();
            loadClaimTypes();           
            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();
        }
        lblError.Text = "";
        hide();
    }

    private void loadPremittedReports(int reportGroupId, int groupId)
    {
        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 ------");
        }
    }
    
    private void loadChannels()
    {
        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_rpt";

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

         private DataSet loadChannelEvents_IncludeCommerce(string selectedChannelId)
        {
        //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_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;
            //ddlEvents.DataSource = ds;
            //ddlEvents.DataBind();
        //}
        //ddlEvents.Items.Insert(0, "------ Events ------");

    }
    private DataSet loadChannelEvents(string selectedChannelId)
    {
        //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;
            //ddlEvents.DataSource = ds;
            //ddlEvents.DataBind();
        //}
        //ddlEvents.Items.Insert(0, "------ Events ------");

    }

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

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "LOOKUP_GETTER.Get_Recon_Events_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();
    }

    

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

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

          // For 81
           ddlEvent_tranDetailRpt.DataSource = ds;
           ddlEvent_tranDetailRpt.DataBind();

    }

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

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

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

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

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


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

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

        ddlRecordStatus.Items.Insert(0, "------ All Status ------");
        oracon.Close();
    }

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

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

    private void loadClaimTypes()
    {
        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();
    }
    
    private void loadClaimStatus()
    {
        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();
    }

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

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

        oracon.Close();
    }

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

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

    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
        if (ddlChannels.SelectedIndex != 0)
        {
            int selectedChannelId = int.Parse(this.ddlChannels.SelectedValue.ToString());

            ddlEvents.Items.Clear();
            if (ddlChannels.SelectedIndex > 0)
            {
                this.ddlEvents.DataSource = this.loadChannelEvents_IncludeCommerce(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 (ddlChannels.SelectedValue == "6")
        {
            Channel_6.Visible = true;

            if (ddlEvents.SelectedValue == "44")
            {
                rdRecon.ToolTip = "Exist in A12 Not in Switch C6E 002";
                rdTxn.ToolTip = "Exist in Switch C6E 002 Not in A12";
            }
            else if (ddlEvents.SelectedValue == "45")
            {
                rdRecon.ToolTip = "Exist in A12 Not in Virgin Txn 003";
                rdTxn.ToolTip = "Exist in Virgin Txn 003 Not in A12";
            }
        } 
        else
        {
            Channel_6.Visible = false;

            rdRecon.ToolTip = "Exist in Master Not in Switch";
            rdTxn.ToolTip = "Exist in Switch Not in Master";
        } 

        if (ddlEvents.SelectedIndex > 0)
            btnSearch.Enabled = true;
        else
            btnSearch.Enabled = false;
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        // first & second report
        if (ddlReports.SelectedValue == "1")
        {
            if (ddlChannels.SelectedIndex != 0 && ddlEvents.SelectedIndex != 0)
            {
                if (dtpFromDateReconResult.date.Length == 0 || dtpToDateReconResult.date.Length == 0)
                {
                    lblError.Text = "please enter a date";
                }
                else
                {
                    DateTime fromdate = Convert.ToDateTime(DateTime.ParseExact(Helper.convertDate(dtpFromDateReconResult.date), "dd-MM-yyyy", CultureInfo.InvariantCulture));
                    DateTime todate = Convert.ToDateTime(DateTime.ParseExact(Helper.convertDate(dtpToDateReconResult.date), "dd-MM-yyyy", CultureInfo.InvariantCulture));

                    TimeSpan datediff = todate - fromdate;
                    double TotalDays = datediff.TotalDays;

                    if(TotalDays < 3)
                    {
                        string p1 = ddlChannels.SelectedValue;
                        string p2 = ddlEvents.SelectedValue;
                        string p3 = dtpFromDateReconResult.date;
                        string p7 = dtpToDateReconResult.date;
                        string p4 = this.ddl_reconTranType.SelectedValue.ToString();
                        string p5 = ddlChannels.SelectedItem.Text;
                        string p6 = ddlEvents.SelectedItem.Text;

                        if (rdRecon.Checked)
                        {
                            int p8 = 2;
                            if (p1 == "6")
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1015&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);
                            }
                            else
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);
                            }
                        }
                        else if (rdTxn.Checked)
                        {
                            if (p1 == "6")
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1016&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "','Report')", true);
                            }
                            else
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=2&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "','Report')", true);
                            }
                        }
                        else if (rdMTxn.Checked)
                        {
                            int p8 = 1;
                            if (p1 == "6")
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1015&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);
                            }
                            else
                            {
                                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                "window.open('../Reports/Default.aspx?rpt=1&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "&p5=" + p5 + "&p6=" + p6 + "&p7=" + p7 + "&p8=" + p8 + "','Report')", true);
                            }
                        }
                    }
                    else
                    {
                        lblError.Text = "Date range should not exceed more than 2 days";
                    }
                }
            }
            else
                lblError.Text = "Select Channel and Event";
        }

        //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;
                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;
                string p9 = ddlChannels18.SelectedItem.Text;
                string p10 = ddlStatus18.SelectedItem.Text;
                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 + "&p9=" + p9 + "&p10=" + p10 + "','Report')", true);
            }
        }

        // 19
        if (ddlReports.SelectedValue == "18")
        {
            string p1="",p2="",p3="",p4="";
           
            if(rdATMCPS.Checked)
                p3="1";
            else //POS
                p3="2"; 
            p4= ddlCPSClaimType.SelectedValue;
            
            if (dtFromCPS.date.Length >1 && dtToCPS.date.Length>1 )
            {
                p1 = "20" + dtFromCPS.date;
                p2 = "20" + dtToCPS.date;
            }
            else
            {
                lblError.Text = "Please select the Date";
                return;
            }

            if ( ddlReprotType.SelectedValue == "18")
            {

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

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

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=221&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','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 .ddl_reconSummary_channels.SelectedValue.Equals("7"))
            {
                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 if (p1.Equals("12"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=10432&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "&p4=" + p4 + "','Report')", true);
                }
                else if (p1.Equals("7"))
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=10433&p1=" + p1 + "&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.";
            }
        }



        if (ddlReports.SelectedValue == "54")
        {
            if (dtpDeposit.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 = dtpDeposit.date;
                string p3 = "";
                if(txtATMID_Deposit.Text.Length ==0)
                    p3 = "";
                else
                    p3 = txtATMID_Deposit.Text;    
          
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                    "window.open('../Reports/Default.aspx?rpt=504&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','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.";
            }
        }
        if (ddlReports.SelectedValue == "62")
        {
            string settlDate = this.dtSettlDate.date;
            

            if (settlDate .Length  != 0)
            {
                string p1 = settlDate ;    
                string p2 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1053&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }           
            else 
            {
                this.lblError.Text = "Please select a Date.";
            }
        }
        if (ddlReports.SelectedValue == "63")
        {
            string EJDate = this.EJDate.date;


            if (EJDate.Length != 0)
            {
                string p1 = EJDate;
                string p2 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1055&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
        }
        if (ddlReports.SelectedValue == "64")
        {
            string LoadDate = this.LoadDate.date;


            if (LoadDate.Length != 0)
            {
                string p1 = LoadDate;
                string p2 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1056&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
        }
        if (ddlReports.SelectedValue == "65")
        {
       
            string FromDate = this.dt_GLPosting_From.date;
            string ToDate = this.dt_GLPosting_To.date;
       

            if (FromDate.Length != 0 || ToDate.Length != 0)
            {
                   string p1 = Session["uid"].ToString();
                   string p2 = FromDate;
                   string p3 = ToDate;

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

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

        if (ddlReports.SelectedValue == "66")
        {
            string TransactionDate = this.dtpDailyClaimAdvancePayment.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1058&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
        }
        if (ddlReports.SelectedValue == "67")
        {
            string TransactionDate = this.dtpClaimWithStatus.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

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

        if (ddlReports.SelectedValue == "68")
        {
            string TransactionDate = this.dtpDailyATMSchemewise.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

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

        if (ddlReports.SelectedValue == "69")
        {
            string TransactionDate = this.dtpatmreplenishment.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1061&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
        }
        if (ddlReports.SelectedValue == "70")
        {
            string SettlementDate = this.dtpSpanSettl.date;
            string channel = this.ddlChannelSettl.SelectedItem.Text;

            if (SettlementDate.Length != 0)
            {
                string p2 = SettlementDate;
                string p1 = Session["uid"].ToString();
                string p3 = channel;
                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1062&p1=" + p1 + "&p2=" + p2 + "&p3=" + p3 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
        }

        if (ddlReports.SelectedValue == "72")
        {
            string TransactionDate = this.dtpMDSRecon.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

                ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                            "window.open('../Reports/Default.aspx?rpt=1064&p1=" + p1 + "&p2=" + p2 + "','Report')", true);
            }
            else
            {
                this.lblError.Text = "Please select a Date.";
            }
           
        }
        if (ddlReports.SelectedValue == "73")
        {
            //string TransactionDate = this.dtpMDSReconNet.date;


            //if (TransactionDate.Length != 0)
            //{
            //    string p2 = TransactionDate;
            //    string p1 = Session["uid"].ToString();

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

        }
        if (ddlReports.SelectedValue == "74")
        {
            //string TransactionDate = this.dtpAMEX.date;


            //if (TransactionDate.Length != 0)
            //{
            //    string p2 = TransactionDate;
            //    string p1 = Session["uid"].ToString();

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

        }
        if (ddlReports.SelectedValue == "75")
        {
            //string TransactionDate = this.dtpGCC.date;


            //if (TransactionDate.Length != 0)
            //{
            //    string p2 = TransactionDate;
            //    string p1 = Session["uid"].ToString();

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

        }
        if (ddlReports.SelectedValue == "76")
        {
            string TransactionDate = this.dtpATMRecon.date;


            if (TransactionDate.Length != 0)
            {
                string p2 = TransactionDate;
                string p1 = Session["uid"].ToString();

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

        }
        if (ddlReports.SelectedValue == "77")
        {
            string fromDate = this.dtpFromFalseReversal.date;
            string toDate = this.dtptoFalseReversal.date;

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

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

        }
        if (ddlReports.SelectedValue == "78")
        {
            string fromDate = this.dtpFromBTLTLFSummary.date;
            string toDate = this.dtpToBTLTLFSummary.date;

            if (fromDate.Length != 0 || toDate.Length != 0)
            {

                string p1 = Session["uid"].ToString();
                string p2 = fromDate;
                string p3 = toDate;
                int p4 = 0;
                if (rdbATMBTLTLFSummary.Checked)
                    p4 = 1;
                else if (rdbPOSBTLTLFSummary.Checked)
                    p4 = 2;
                else
                    p4 = 3;

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

        }
        if (ddlReports.SelectedValue == "79")
        {
            string fromDate = this.dtpFrombtltlfdetail.date;
            string toDate = this.dtpTobtltlfdetail.date; 


            if (fromDate.Length != 0 || toDate.Length !=0)
            {

                string p1 = Session["uid"].ToString();
                string p2 = fromDate;
                string p3=toDate;
                int p4= 0;
                if (rdbatmacqbtl.Checked)
                    p4 = 1;
                else if (rdbatmacqtlf.Checked)
                    p4 = 2;
                if (rdbatmissbtl.Checked)
                    p4 = 3;
                else if (rdbatmisstlf.Checked)
                    p4 = 4;
                if (rdbposacqbtal.Checked)
                    p4 = 5;
                else if (rdbposacqtlf.Checked)
                    p4 = 6;
                if (rdbposissbtal.Checked)
                    p4 = 7;
                else if (rdbposisstlf.Checked)
                    p4 = 8;
                //Ecom
                if (rdbEcomacqbtal.Checked)
                    p4 = 9;
                else if (rdbEcomacqtlf.Checked)
                    p4 = 10;
                if (rdbEcomissbtal.Checked)
                    p4 = 11;
                else if (rdbEcomisstlf.Checked)
                    p4 = 12;
                //

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

        }
        if (ddlReports.SelectedValue == "80")
        {
            string replFromDate = this.dtpReplFromDate.date;
            string replToDate = this.dtpReplToDate.date;


            if (replFromDate.Length != 0 || replToDate.Length !=0)
            {

                string p1 = Session["uid"].ToString();
                string p2 = replFromDate;
                string p3 = replToDate;
               

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

        }

        if (ddlReports.SelectedValue == "81")
        {
            string FromDate = this.dt_tranDetailRpt_from.date;
            string ToDate = this.dt_tranDetailRpt_to.date;
            string Switch_Channel_FLAG = "M";
            if (rd_Channel_tranDetailRpt.Checked)
                Switch_Channel_FLAG = "C";
        
            string ReCode= this.ddlEvent_tranDetailRpt.SelectedValue;
            string CardNo = this.txt_CardNo_tranDetailRpt.Text;
            string TerminalID = this.txt_TerminalID_tranDetailRpt.Text;
            string RRN = this.txt_RRN_tranDetailRpt.Text;

            if (CardNo.Length == 0 && TerminalID.Length == 0 && RRN.Length == 0)
            {
                this.lblError.Text = "Enter at least one of the field. Card No. or RRN or Terminal ID";
            }
            else if (FromDate.Length != 0 || ToDate.Length != 0)
            {

                string p1 = Session["uid"].ToString();
                string p2 = Switch_Channel_FLAG;
                string p3 = ReCode;
                string p4 = CardNo;
                string p5 = TerminalID;
                string p6 = RRN;
                string p7 = FromDate;
                string p8 = ToDate;



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

        }

        if (ddlReports.SelectedValue == "95")
        {
            //pnlType.Visible = false;

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

            }
            else
            {
                lblError.Text = "Please select date & Enter complete Terminal Number";
            }
        }
    }




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

    }


    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.tblDailySettl.Visible = false;
        this.tblMissingEJ.Visible = false;
        this.tblSamaBankLoad.Visible = false;
        this.tblGLPostingRejected.Visible = false;
        this.tblDailyClaimAdvancePayment.Visible = false;
        this.tblClaimWithStatus.Visible = false;
        this.tblDailyATMSchemewise.Visible = false;
        this.tblatmreplenishment.Visible = false;
        this.tblSpanSettl.Visible = false;
        this.tblMDSRecon.Visible = false;
        this.tblMDSReconNet.Visible = false;
        this.tblAMEX.Visible = false;
        this.tblGCC.Visible = false;
        this.tblATMRecon.Visible = false;
        this.tblFalseReversal.Visible = false;
        this.tblBTLTLFSummary.Visible = false;
        this.TBLBTLTLFDETAIL.Visible = false;
        this.tblReplenishment.Visible = false;
        this.tbl_tranDetailRpt.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 "62":
                this.tblDailySettl.Visible = true;
                break;
            case "63":
                this.tblMissingEJ.Visible = true;
                break;

            case "64":
                this.tblSamaBankLoad.Visible = true;
                break;

            case "65":
                this.tblGLPostingRejected.Visible = true;
                break;

            case "66":
                this.tblDailyClaimAdvancePayment.Visible = true;
                break;

            case "67":
                this.tblClaimWithStatus.Visible = true;
                break;

            case "68":
                this.tblDailyATMSchemewise.Visible = true;
                break;

            case "69":
                this.tblatmreplenishment.Visible = true;
                break;

            case "70":
                this.tblSpanSettl.Visible = true;
                break;

            case "72":
                this.tblMDSRecon.Visible = true;
                break;
            case "73":
                this.tblMDSReconNet.Visible = true;
                break;
            case "74":
                this.tblAMEX.Visible = true;
                break;
            case "75":
                this.tblGCC.Visible = true;
                break;
            case "76":
                this.tblATMRecon.Visible = true;
                break;
            case "77":
                this.tblFalseReversal.Visible = true;
                break;
            case "78":
                this.tblBTLTLFSummary.Visible = true;
                break;
            case "79":
                this.TBLBTLTLFDETAIL.Visible = true;
                break;
            case "80":
                this.tblReplenishment.Visible = true;
                break;
            case "81":
                this.tbl_tranDetailRpt.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();
    }


    private void CreateRptForDepExcepTxn(string date, string atmNo)
    {

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


    }

    
    //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_IncludeCommerce(selectedChannelId);// 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();
        }
        if (this.ddl_reconSummary_channels.SelectedValue.Equals("7"))
        {
            this.ddl_reconSummary_events.Enabled = false;
            this.btnSearch.Enabled = true;
        }

    }

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