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

public partial class ReconSummary : System.Web.UI.Page
{
    public string channel_name, event_name, recon_date;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //HttpContext.Current.Session["mode"] = "l";
            //Session["uid"] = "1";
            ExceptionUtility.LogException(0, "", "55", "Page_Load", "");
            //getGroups();
            //loadResult(10, 1);
            loadChannels();
            loadEvents();

            loadCFJobMonitor();
        }
    }

    public void loadCFJobMonitor()
    {
        if (Request.QueryString["CName"] != "" && Request.QueryString["EName"] != "" && Request.QueryString["RDate"] != "")
        {
            channel_name = Request.QueryString["CName"] as string;
            event_name = Request.QueryString["EName"] as string;
            recon_date = Request.QueryString["RDate"] as string;

            this.loadJMChannels();
            ExceptionUtility.LogException(0, "", "", "ddlChannels_SelectedIndexChanged", ddlChannels.SelectedItem.Text);
            loadEvents();

            this.loadJMEvents();

            ddlEventTypes.SelectedIndex = 1;
            txtDate.Text = recon_date;

            this.Search();
        }
    }

    public void loadJMChannels()
    {
        DataTable dtRes = new DataTable();
        try
        {
            string DBConnection = Helper.dbConnection();

            OracleConnection oracon = new OracleConnection(DBConnection);

            OracleCommand oraCom = new OracleCommand();
            oraCom.CommandText = "select RC_CODE from recon_channel where CHANNEL_NAME = '" + channel_name + "'";
            oraCom.Connection = oracon;
            OracleDataAdapter da = new OracleDataAdapter(oraCom);

            da.Fill(dtRes);
            if (dtRes.Rows.Count > 0)
            {
                ddlChannels.SelectedValue = dtRes.Rows[0]["RC_CODE"].ToString();
            }
        }
        catch (Exception ex)
        {
            Notifications.showMessage(ex.Message, this, Notifications.errorMessage, false);
        }
    }

    public void loadJMEvents()
    {
        DataTable dtRes = new DataTable();
        try
        {
            string DBConnection = Helper.dbConnection();

            OracleConnection oracon = new OracleConnection(DBConnection);

            OracleCommand oraCom = new OracleCommand();
            oraCom.CommandText = "select RE_CODE from recon_event where EVANT_NAME = '" + event_name + "'";
            oraCom.Connection = oracon;
            OracleDataAdapter da = new OracleDataAdapter(oraCom);

            da.Fill(dtRes);
            if (dtRes.Rows.Count > 0)
            {
                ddlEvents.SelectedValue = dtRes.Rows[0]["RE_CODE"].ToString();
            }
        }
        catch (Exception ex)
        {
            Notifications.showMessage(ex.Message, this, Notifications.errorMessage, false);
        }
    }

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

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

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

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

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

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

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

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

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

                oracom.Parameters["p_rc_code"].Value = ddlChannels.SelectedValue; ;

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

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

                oracon.Close();
            }
            ddlEvents.Items.Insert(0, "------ Events ------");
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "LOOKUP_GETTER.Get_Recon_Channel_Events", "1.2", "loadEvents", "");
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadResult(string channelID, string eventID, string eventType, string date, int pageSize, int pageNumber)
    {
        string parameters = "";
        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 = "RECON_SUMMARY_INQUIRER.Search_Recon_Summary";

            oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_channel", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_re_code", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_re_type", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_settle_date", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_page_size", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_page_num", OracleType.Number).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
            oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_output", OracleType.Cursor).Direction = ParameterDirection.Output;
            oracom.Parameters.Add("p_total_pages", OracleType.Number).Direction = ParameterDirection.Output;

            oracom.Parameters["p_re_code"].IsNullable = true;


            if (channelID.Length != 0)
            {
                oracom.Parameters["p_channel"].Value = channelID;
                parameters = "p_channel-" + channelID;
            }
            else
                oracom.Parameters["p_channel"].Value = OracleNumber.Null;
            if (eventID.Length != 0)
            {
                parameters = parameters + ":p_re_code-" + eventID;
                oracom.Parameters["p_re_code"].Value = eventID;
            }
            else
                oracom.Parameters["p_re_code"].Value = OracleNumber.Null;
            if (eventType.Length != 0)
            {
                parameters = parameters + ":p_re_type-" + eventType;
                oracom.Parameters["p_re_type"].Value = eventType;
            }
            else
                oracom.Parameters["p_re_type"].Value = OracleString.Null;
            oracom.Parameters["p_settle_date"].Value = date;
            parameters = parameters + ":p_settle_date-" + date;
            oracom.Parameters["p_page_size"].Value = pageSize;
            oracom.Parameters["p_page_num"].Value = pageNumber;
            oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();
            oracom.Parameters["p_lang"].Value = "EN";

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

            int nop = int.Parse(oracom.Parameters["p_total_pages"].Value.ToString());
            oracon.Close();

            GridView1.DataSource = ds;
            GridView1.DataBind();
            if (pageNumber == 1)
            {
                ddlPages.Items.Clear();
                for (int i = 1; i <= nop; i++)
                {
                    ddlPages.Items.Add(i.ToString());
                }
            }
            
            ExceptionUtility.LogException(0, "RECON_SUMMARY_INQUIRER.Search_Recon_Summary", "21.1", "loadResult", parameters);
        }
        catch (Exception ex)
        {
            ExceptionUtility.LogException(ex, "RECON_SUMMARY_INQUIRER.Search_Recon_Summary", "21.1", "loadResult", parameters);
            GridView1.DataSource = null;
            GridView1.DataBind();
            //Response.Redirect("../ErrorPages/ErrorPage.aspx");
        }
    }

    private void loadFinacleFileDetails(string fileNumber, int eventId)
    {
        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 = "recon_summary_inquirer.GET_FINACLE_FILE_DETAILS";

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

        oracom.Parameters.Add("p_FILE_NO", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_RECON_TYPE", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_CHANNEL", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_EVENT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NUMBER_OF_MATCH", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_RECON", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRANSACTION", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_MATCHED_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCHED_RECON_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRAN_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_NUMBER", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

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

        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 == 0)
        {
            this.lbl_fileName.Text = oracom.Parameters["p_file_id"].Value.ToString();
            this.lbl_fileNumber_finacle.Text = oracom.Parameters["p_FILE_NO"].Value.ToString();
            this.lbl_reconType_finacle.Text = oracom.Parameters["p_RECON_TYPE"].Value.ToString();
            this.lbl_channel_finacle.Text = oracom.Parameters["p_CHANNEL"].Value.ToString();
            this.lbl_event_finacle.Text = oracom.Parameters["p_EVENT"].Value.ToString();
            this.lbl_matchCount_finacle.Text = oracom.Parameters["p_NUMBER_OF_MATCH"].Value.ToString();
            this.lbl_matchAmount_finacle.Text = oracom.Parameters["p_MATCHED_AMOUNT"].Value.ToString();
            this.lbl_nonMatchReconCount_finacle.Text = oracom.Parameters["p_NON_MATCH_RECON"].Value.ToString();
            this.lbl_nonMatchReconAmount_finacle.Text = oracom.Parameters["p_NON_MATCHED_RECON_AMOUNT"].Value.ToString();
            this.lbl_nonMatchTrxnCount_finacle.Text = oracom.Parameters["p_NON_MATCH_TRANSACTION"].Value.ToString();
            this.lbl_nonMatchTrxnAmount_finacle.Text = oracom.Parameters["p_NON_MATCH_TRAN_AMOUNT"].Value.ToString();
            this.lbl_duplicateNumber_finacle.Text = oracom.Parameters["p_DUPLICATE_NUMBER"].Value.ToString();
            this.lbl_duplicateAmount_finacle.Text = oracom.Parameters["p_DUPLICATE_AMOUNT"].Value.ToString();

        }

    }

    private void loadGeneralsFilesDetails(string fileNumber, int eventId)
    {
        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 = "recon_summary_inquirer.GET_GENERAL_FILES_DETAILS";

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

        oracom.Parameters.Add("p_FILE_NO", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_RECON_TYPE", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_rc_code", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_CHANNEL", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_re_code", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_EVENT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NUMBER_OF_MATCH", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_RECON", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRANSACTION", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_MATCHED_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCHED_RECON_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRAN_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_NUMBER", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_AMOUNT", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_RECON_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRANSACTION_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_NUMBER_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCHED_RECON_AMOUNT_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRAN_AMOUNT_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_AMOUNT_CR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_RECON_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRANSACTION_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_NUMBER_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCHED_RECON_AMOUNT_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_NON_MATCH_TRAN_AMOUNT_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_DUPLICATE_AMOUNT_DR", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

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

        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 == 0)
        {
            this.lbl_fileName.Text = oracom.Parameters["p_file_id"].Value.ToString();
            this.lbl_fileNumber.Text = oracom.Parameters["p_FILE_NO"].Value.ToString();
            this.lbl_reconType.Text = oracom.Parameters["p_RECON_TYPE"].Value.ToString();
            ViewState["channel"] = oracom.Parameters["p_rc_code"].Value.ToString();
            this.lbl_channel.Text = oracom.Parameters["p_CHANNEL"].Value.ToString();
            ViewState["event"] = oracom.Parameters["p_re_code"].Value.ToString();
            this.lbl_event.Text = oracom.Parameters["p_EVENT"].Value.ToString();
            this.lbl_matchCount.Text = oracom.Parameters["p_NUMBER_OF_MATCH"].Value.ToString();
            this.lbl_matchAmount.Text = oracom.Parameters["p_MATCHED_AMOUNT"].Value.ToString();
            //this.lbl_nonMatchReconCount.Text = oracom.Parameters["p_NON_MATCH_RECON"].Value.ToString();
            this.link_nonMatchReconCount.Text = oracom.Parameters["p_NON_MATCH_RECON"].Value.ToString();
            if (int.Parse(oracom.Parameters["p_NON_MATCH_RECON"].Value.ToString()) > 0)
                link_nonMatchReconCount.Font.Underline = true;
            else
                link_nonMatchReconCount.Font.Underline = false;
            this.lbl_nonMatchReconAmount.Text = oracom.Parameters["p_NON_MATCHED_RECON_AMOUNT"].Value.ToString();
            //this.lbl_nonMatchTrxnCount.Text = oracom.Parameters["p_NON_MATCH_TRANSACTION"].Value.ToString();
            this.lnk_nonMatchTrxnCount.Text = oracom.Parameters["p_NON_MATCH_TRANSACTION"].Value.ToString();
            if (int.Parse(oracom.Parameters["p_NON_MATCH_TRANSACTION"].Value.ToString()) > 0)
                lnk_nonMatchTrxnCount.Font.Underline = true;
            else
                lnk_nonMatchTrxnCount.Font.Underline = false;
            this.lbl_nonMatchTrxnAmount.Text = oracom.Parameters["p_NON_MATCH_TRAN_AMOUNT"].Value.ToString();
            this.lbl_duplicateNumber.Text = oracom.Parameters["p_DUPLICATE_NUMBER"].Value.ToString();
            this.lbl_duplicateAmount.Text = oracom.Parameters["p_DUPLICATE_AMOUNT"].Value.ToString();

            this.lbl_nonMatchReconCountCr.Text = oracom.Parameters["p_NON_MATCH_RECON_CR"].Value.ToString();
            this.lbl_nonMatchReconAmountCr.Text = oracom.Parameters["p_NON_MATCHED_RECON_AMOUNT_CR"].Value.ToString();
            this.lbl_nonMatchReconCountDr.Text = oracom.Parameters["p_NON_MATCH_RECON_DR"].Value.ToString();
            this.lbl_nonMatchReconAmountDr.Text = oracom.Parameters["p_NON_MATCHED_RECON_AMOUNT_DR"].Value.ToString();
            this.lbl_nonMatchTrxnCountCr.Text = oracom.Parameters["p_NON_MATCH_TRANSACTION_CR"].Value.ToString();
            this.lbl_nonMatchTrxnAmountCr.Text = oracom.Parameters["p_NON_MATCH_TRAN_AMOUNT_CR"].Value.ToString();
            this.lbl_nonMatchTrxnCountDr.Text = oracom.Parameters["p_NON_MATCH_TRANSACTION_DR"].Value.ToString();
            this.lbl_nonMatchTrxnAmountDr.Text = oracom.Parameters["p_NON_MATCH_TRAN_AMOUNT_DR"].Value.ToString();
            this.lbl_duplicateNumberCr.Text = oracom.Parameters["p_DUPLICATE_NUMBER_CR"].Value.ToString();
            this.lbl_duplicateAmounCr.Text = oracom.Parameters["p_DUPLICATE_AMOUNT_CR"].Value.ToString();
            this.lbl_duplicateNumberDr.Text = oracom.Parameters["p_DUPLICATE_NUMBER_DR"].Value.ToString();
            this.lbl_duplicateAmounDr.Text = oracom.Parameters["p_DUPLICATE_AMOUNT_DR"].Value.ToString();
        }

    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        this.Search();
    }

    public void Search()
    {
        string channelID = "", EventID = "", EventType = "";

        //this.pnl_finacleDetails.Visible = false;
        //this.pnl_generalDetails.Visible = false;

        if (ddlChannels.SelectedIndex > 0)
            channelID = ddlChannels.SelectedValue;
        else
        {
            Notifications.showMessage("Please Select a channel", this, Notifications.errorMessage, false);
            return;
        }
        if (ddlEvents.SelectedIndex > 0)
            EventID = ddlEvents.SelectedValue;
        if (ddlEventTypes.SelectedIndex > 0)
            EventType = ddlEventTypes.SelectedValue;
        //pnlResult.Visible = true;
        GridView1.Columns[0].Visible = true;
        ExceptionUtility.LogException(0, "", "20.21", "Button1_Click", "");
        string date = Helper.getDate(txtDate.Text);
        loadResult(channelID, EventID, EventType, Helper.getDate(txtDate.Text), Helper.gridSize(), 1);
        GridView1.Columns[0].Visible = false;
    }

    protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        string channelID = "", EventID = "", EventType = "";

        if (ddlChannels.SelectedIndex > 0)
            channelID = ddlChannels.SelectedValue;
        if (ddlEvents.SelectedIndex > 0)
            EventID = ddlEvents.SelectedValue;
        if (ddlEventTypes.SelectedIndex > 0)
            EventType = ddlEventTypes.SelectedValue;
        //GridView1.Columns[0].Visible = true;
        loadResult(channelID, EventID, EventType, Helper.getDate(txtDate.Text), Helper.gridSize(), int.Parse(ddlPages.SelectedValue));
        //GridView1.Columns[0].Visible = false;
    }

    protected void ddlChannels_SelectedIndexChanged(object sender, EventArgs e)
    {
        //this.pnlResult.Visible = false;
        //this.pnl_finacleDetails.Visible = false;
        //this.pnl_generalDetails.Visible = false;
        //this.Button1.Enabled = false;
        ExceptionUtility.LogException(0, "", "", "ddlChannels_SelectedIndexChanged", ddlChannels.SelectedItem.Text);
        loadEvents();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string command = e.CommandName.ToString();

        int selectedIndex = int.Parse(e.CommandArgument.ToString());
        int selectedChannelId = int.Parse(this.ddlChannels.SelectedValue.ToString());
        string selectedFileNumber = this.GridView1.DataKeys[selectedIndex].Value.ToString();
        // int selectedEventId = int.Parse(this.ddlEvents.SelectedValue.ToString());
        GridView1.Columns[0].Visible = true;
        int selectedEventId = int.Parse(this.GridView1.Rows[selectedIndex].Cells[0].Text.ToString());
        GridView1.Columns[0].Visible = false;
        ViewState["SettlDate"] = txtDate.Text;
        if (command.Equals("v"))
        {
            ExceptionUtility.LogException(0, "", "20.418", "GridView1_RowCommand.View_Summary", "");
            if (selectedChannelId == 6)
            {
                //this.pnl_finacleDetails.Visible = true;
                this.loadFinacleFileDetails(selectedFileNumber, selectedEventId);
                Notifications.showModal("modal-xl", this);
            }
            else
            {
                //this.pnl_generalDetails.Visible = true;
                this.loadGeneralsFilesDetails(selectedFileNumber, selectedEventId);
                Notifications.showModal("modal-xl2", this);
            }
        }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    e.Row.Cells[7].ToolTip = DataBinder.Eval(e.Row.DataItem, "Present In Channel not in Switch", string.Empty);
        //    e.Row.Cells[9].ToolTip = DataBinder.Eval(e.Row.DataItem, "Present In Switch not in Channel", string.Empty);
        //}

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            for (int i = 0; i < e.Row.Cells.Count; i++)
            {
                e.Row.Cells[7].ToolTip = "Present In Channel not in Switch";
                e.Row.Cells[9].ToolTip = "Present In Switch not in Channel";
            }
        }
    }

    protected void ddlEvents_SelectedIndexChanged(object sender, EventArgs e)
    {
        //this.pnlResult.Visible = false;
        //this.pnl_finacleDetails.Visible = false;
        //this.pnl_generalDetails.Visible = false;
        ExceptionUtility.LogException(0, "", "", "ddlEvents_SelectedIndexChanged", ddlEvents.SelectedItem.Text);
        //if (this.ddlEvents.SelectedIndex > 0)
        //{
        //    this.Button1.Enabled = true;
        //}
        //else
        //{
        //    this.Button1.Enabled = false;
        //}
    }
    protected void ddlEventTypes_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

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

    protected void LB_nonMatchReconCount_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                 "window.open('ReconResults.aspx?channel=" + ViewState["channel"] + "&event=" + ViewState["event"] + "&filedate=" + ViewState["SettlDate"] + "&Type=1&eventType=" + ddlEventTypes.SelectedIndex + " ','popWindow','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=810,height=1000,left=300,top=75')", true);
    }
    protected void LB_nonMatchTrxnCount_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                             "window.open('ReconResults.aspx?channel=" + ViewState["channel"] + "&event=" + ViewState["event"] + "&filedate=" + ViewState["SettlDate"] + "&Type=2&eventType=" + ddlEventTypes.SelectedIndex + "  ','popWindow','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=1000,height=1000,left=350,top=75')", true);
    }

    protected void link_nonMatchReconCount_Click(object sender, EventArgs e)
    {
        if (int.Parse(link_nonMatchReconCount.Text) > 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                                 "window.open('ReconResults.aspx?channel=" + ViewState["channel"] + "&event=" + ViewState["event"] + "&filedate=" + ViewState["SettlDate"] + "&Type=1&eventType=" + ddlEventTypes.SelectedIndex + " ','popWindow','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=810,height=1000,left=300,top=75')", true);
        }
    }
    protected void lnk_nonMatchTrxnCount_Click(object sender, EventArgs e)
    {
        if (int.Parse(lnk_nonMatchTrxnCount.Text) > 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(string), "new window",
                             "window.open('ReconResults.aspx?channel=" + ViewState["channel"] + "&event=" + ViewState["event"] + "&filedate=" + ViewState["SettlDate"] + "&Type=2&eventType=" + ddlEventTypes.SelectedIndex + "  ','popWindow','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=1000,height=1000,left=350,top=75')", true);
        }
    }
    
}