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;

public partial class Business_GLSetup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SecurityAgent.AuthenticateArchive();
            loadChannels();
            loadEvents();
            loadChannelTypes();
            loadMatchResult();
            channelsRow.Visible = false;
            channelsRow1.Visible = false;
        }
        lblError.Text = "";
    }

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

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

        oracom.Parameters["p_ch_type"].Value = ddlType2.SelectedValue;

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

        ddlMatchResult.DataSource = ds;
        ddlMatchResult.DataBind();
        oracon.Close();
    }

    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_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();
        DropDownList2.DataSource = ds;
        DropDownList2.DataBind();


        ddlChannels.Items.Insert(0, "------ Channels ------");
        DropDownList2.Items.Insert(0, "------ Channels ------");
        oracon.Close();
    }

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

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

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

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

        ddlEvents.Items.Insert(0, "------ Events ------");
        DropDownList1.Items.Insert(0, "------ Events ------");
        oracon.Close();
    }

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

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

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

        ddlType.DataSource = ds;
        ddlType.DataBind();
        ddlType2.DataSource = ds;
        ddlType2.DataBind();
        oracon.Close();
    }

    private void loadResult(string ChannelID, string EventID, int pageSize, int pageNumber)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "GL_SETUP_EDITOR.Get_GL_Setup_Info";

        
        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_re_code", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rc_code", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_ch_type", OracleType.Number).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;

        if (rdChannel.Checked)
        {
            oracom.Parameters["p_rc_code"].Value = ChannelID;
            oracom.Parameters["p_ch_type"].Value = "3";
            oracom.Parameters["p_re_code"].Value = OracleNumber.Null;
        }

        if (rdEvent.Checked)
        {
            oracom.Parameters["p_re_code"].Value = EventID;
            oracom.Parameters["p_ch_type"].Value = ddlType.SelectedValue;
            oracom.Parameters["p_rc_code"].Value = OracleNumber.Null;
        }

        if (rdPOS1.Checked)
        {
            oracom.Parameters["p_rc_code"].Value = ChannelID;
            oracom.Parameters["p_ch_type"].Value = "6";
            oracom.Parameters["p_re_code"].Value = OracleNumber.Null;
        }

        //if (rdPOS2.Checked)
        //{
        //    oracom.Parameters["p_rc_code"].Value = OracleNumber.Null;
        //    oracom.Parameters["p_ch_type"].Value = "7";
        //    oracom.Parameters["p_re_code"].Value = OracleNumber.Null;
        //}
        
        
        oracom.Parameters["p_page_size"].Value = pageSize;
        oracom.Parameters["p_page_num"].Value = pageNumber;
        oracom.Parameters["p_lang"].Value = "EN";
        oracom.Parameters["p_current_uid"].Value = Session["uid"].ToString();

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

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

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (ddlChannels.SelectedIndex ==0 && rdChannel.Checked)
            lblError.Text = "You must choose a Channel";
        else if (ddlEvents.SelectedIndex == 0 && rdEvent.Checked)
            lblError.Text = "You must choose an Event";
        else if (ddlChannels.SelectedIndex == 0 && rdPOS1.Checked)
            lblError.Text = "You must choose an Channel";
        else
        {
            pnlResult.Visible = true;
            getSetup();
        }
    }

    private void getSetup()
    {
        string channelID = "", EventID = "";
        if (rdChannel.Checked || rdPOS1.Checked)
            channelID = ddlChannels.SelectedValue;
        else
            EventID = ddlEvents.SelectedValue;
        pnlResult.Visible = true;
        pnlControls.Visible = false;
        pnlResult.Enabled = true;
        loadResult(channelID, EventID, Helper.gridSize(), 1);
    }

    protected void ddlPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        string channelID = "", EventID = "";
        if (rdChannel.Checked)
            channelID = ddlChannels.SelectedValue;
        else
            EventID = ddlEvents.SelectedValue;
        pnlResult.Visible = true;
        pnlControls.Visible = false;
        pnlResult.Enabled = true;
        loadResult(channelID, EventID, Helper.gridSize(), int.Parse(ddlPages.SelectedValue));
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        txtAccount.Enabled = true;

        pnlControls.Visible = true;
        pnlResult.Enabled = false;
        ViewState["mode"] = "a";

        row1.Visible = false;
        rdChannels1.Checked = rdChannel.Checked;
        rdEvents1.Checked = rdEvent.Checked;
        rdPOS11.Checked = rdPOS1.Checked;
        //rdPOS22.Checked = rdPOS2.Checked;

        DropDownList1.SelectedIndex = ddlEvents.SelectedIndex;
        DropDownList2.SelectedIndex = ddlChannels.SelectedIndex;
        ddlType2.SelectedIndex = ddlType.SelectedIndex;
        loadMatchResult();
        if (rdChannels1.Checked || rdPOS11.Checked)
        {
            eventsRow1.Visible = false;
            channelsRow1.Visible = true;
        }
        else if (rdEvents1.Checked)
        {
            eventsRow1.Visible = true;
            channelsRow1.Visible = false;
        }
        else
        {
            eventsRow1.Visible = false;
            channelsRow1.Visible = false;
        }
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        pnlControls.Visible = true;
        if (e.CommandName.Equals("a"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string error = "";
            bool saved = GLPostingRequired("1", index, ref error);
            if (saved)
            {
                lblError.Text = "Record Updated";
            }
            else
            {
                lblError.Text = error;
            }
        }
        else if (e.CommandName.Equals("r"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string error = "";
            bool saved = GLPostingRequired("0", index, ref error);
            if (saved)
            {
                lblError.Text = "Record Updated";
            }
            else
            {
                lblError.Text = error;
            }
        }
        else if (e.CommandName.Equals("e"))
        {
            pnlControls.Visible = true;
            pnlResult.Enabled = false;
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            string eventID = GridView1.Rows[index].Cells[1].Text.ToString();
            string channelID = GridView1.Rows[index].Cells[0].Text.ToString();
            string account = GridView1.Rows[index].Cells[6].Text.ToString();
            string match = GridView1.Rows[index].Cells[7].Text.ToString();
            string AccName = GridView1.Rows[index].Cells[3].Text.ToString();
            string chType = GridView1.Rows[index].Cells[15].Text.ToString();

            if(!eventID.Equals("&nbsp;"))
                DropDownList1.SelectedValue = eventID;
            if (!channelID.Equals("&nbsp;"))
            DropDownList2.SelectedValue = channelID;

            if (rdEvent.Checked)
            {
                if (!chType.Equals("&nbsp;"))
                    ddlType2.SelectedValue = chType;
                loadMatchResult();
                ddlMatchResult.SelectedValue = match;
            }
            txtAccount.Text = account;
            //txtAccount.Enabled = false;
            
            txtAccountName.Text = AccName;

            ViewState["mode"] = "u";
            ViewState["rowid"] = rowID;

            row1.Visible = false;
            eventsRow1.Visible = false;
            channelsRow1.Visible = false;
            return;
        }
        else if (e.CommandName.Equals("d"))
        {
            int index = int.Parse(e.CommandArgument.ToString());
            string rowID = GridView1.DataKeys[index].Value.ToString();
            string error = "";
            bool saved = deleteGL(rowID, ref error);
            if (saved)
            {
                lblError.Text = "Record Deleted";
            }
            else
            {
                lblError.Text = error;
            }
        }

        getSetup();
    }

    protected void btnCancel_Click(object sender, EventArgs e)
    {
        pnlControls.Visible = false;
        pnlResult.Enabled = true;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
                string mode = ViewState["mode"].ToString();
                string error = "";
                if (mode.Equals("a"))
                {
                    bool saved = addGL(ref error);
                    if (saved)
                    {
                        lblError.Text = "GL data Saved";
                    }
                    else
                    {
                        lblError.Text = error;
                    }
                }
                else if (mode.Equals("u"))
                {
                    string Uid = ViewState["rowid"].ToString();
                    bool saved = updateGL(Uid, ref error);
                    if (saved)
                    {
                        lblError.Text = "GL data Saved";
                    }
                    else
                    {
                        lblError.Text = error;
                    }
                }
                getSetup();
                ViewState["mode"] = null;
                ViewState["rowid"] = null;
                pnlControls.Visible = false;
                pnlResult.Enabled = true;
        }
        catch (Exception ex)
        {
        }
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header || e.Row.RowType == DataControlRowType.DataRow)
        {
            for (int i = 0; i <= 2; i++)
                e.Row.Cells[i].Visible = false;
            e.Row.Cells[4].Visible = false;
            e.Row.Cells[5].Visible = false;
            e.Row.Cells[7].Visible = false;
            e.Row.Cells[8].Visible = false;
            e.Row.Cells[9].Visible = false;
            e.Row.Cells[15].Visible = false;
        }
        
    }

    private bool GLPostingRequired(string postingRequired,int index, ref string error)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "GL_SETUP_EDITOR.Update_GL_Posting";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_re_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rc_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_match_res", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_gl_posting_req", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_ch_type", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_lang", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_res_code", OracleType.Number).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_type", OracleType.VarChar, 250).Direction = ParameterDirection.Output;
        oracom.Parameters.Add("p_res_msg", OracleType.VarChar, 250).Direction = ParameterDirection.Output;

        if (GridView1.Rows[index].Cells[1].Text != "&nbsp;")
            oracom.Parameters["p_re_code"].Value = GridView1.Rows[index].Cells[1].Text;
        else
            oracom.Parameters["p_re_code"].Value = OracleString.Null;

        if (GridView1.Rows[index].Cells[0].Text != "&nbsp;")
            oracom.Parameters["p_rc_code"].Value = GridView1.Rows[index].Cells[0].Text;
        else
            oracom.Parameters["p_rc_code"].Value = OracleString.Null;

        oracom.Parameters["p_match_res"].Value = GridView1.Rows[index].Cells[7].Text;
        oracom.Parameters["p_gl_posting_req"].Value = postingRequired;
        oracom.Parameters["p_ch_type"].Value = GridView1.Rows[index].Cells[15].Text;

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

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

    private bool updateGL(string rowID, ref string error)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "GL_SETUP_EDITOR.Edit_GL_Setup_Info";

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

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

        oracom.Parameters["p_ga_code"].Value = rowID;

        oracom.Parameters["p_acct_name"].Value = txtAccountName.Text;
        oracom.Parameters["p_account_number"].Value = txtAccount.Text;

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

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

    private bool addGL(ref string error)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "GL_SETUP_EDITOR.Add_GL_Account";

        oracom.Parameters.Add("p_current_uid", OracleType.Number).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_acct_no", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_re_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_rc_code", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_acct_name", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_match_res", OracleType.VarChar).Direction = ParameterDirection.Input;
        oracom.Parameters.Add("p_ch_type", 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;

        if (rdEvents1.Checked)
        {
            oracom.Parameters["p_re_code"].Value = DropDownList1.SelectedValue;
            oracom.Parameters["p_ch_type"].Value = ddlType2.SelectedValue;
            oracom.Parameters["p_match_res"].Value = ddlMatchResult.SelectedValue;
            oracom.Parameters["p_rc_code"].Value = OracleString.Null;
        }
        if (rdChannels1.Checked)
        {
            oracom.Parameters["p_re_code"].Value = OracleString.Null;
            oracom.Parameters["p_ch_type"].Value = "3";
            oracom.Parameters["p_match_res"].Value = OracleString.Null;
            oracom.Parameters["p_rc_code"].Value = DropDownList2.SelectedValue;
        }
        if (rdPOS11.Checked)
        {
            oracom.Parameters["p_re_code"].Value = OracleString.Null;
            oracom.Parameters["p_ch_type"].Value = "6";
            oracom.Parameters["p_match_res"].Value = OracleString.Null;
            oracom.Parameters["p_rc_code"].Value = DropDownList2.SelectedValue;
        }
        if (rdPOS22.Checked)
        {
            oracom.Parameters["p_re_code"].Value = OracleString.Null;
            oracom.Parameters["p_ch_type"].Value = "7";
            oracom.Parameters["p_match_res"].Value = OracleString.Null;
            oracom.Parameters["p_rc_code"].Value = OracleString.Null;
        }

        
        oracom.Parameters["p_acct_no"].Value = txtAccount.Text;
        oracom.Parameters["p_acct_name"].Value = txtAccountName.Text;

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

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

    private bool deleteGL(string rowID, ref string error)
    {
        string DBConnection = Helper.dbConnection();

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

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

        oracom.CommandType = CommandType.StoredProcedure;
        oracom.CommandText = "GL_SETUP_EDITOR.Delete_GL_Account";

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

        oracom.Parameters["p_ga_code"].Value = rowID;

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

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

    protected void rdEvent_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow.Visible = true;
        channelsRow.Visible = false;
        pnlResult.Visible = false;
        pnlControls.Visible = false;
    }

    protected void rdChannel_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow.Visible = false;
        channelsRow.Visible = true;
        pnlResult.Visible = false;
        pnlControls.Visible = false;
    }

    protected void rdPOS1_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow.Visible = false;
        channelsRow.Visible = true;
        pnlResult.Visible = false;
        pnlControls.Visible = false;
    }

    protected void rdPOS2_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow.Visible = false;
        channelsRow.Visible = false;
        
    }

    protected void rdEvents1_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow1.Visible = true;
        channelsRow1.Visible = false;
        
    }

    protected void rdChannels1_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow1.Visible = false;
        channelsRow1.Visible = true;
    }

    protected void rdPOS11_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow1.Visible = false;
        channelsRow1.Visible = true;
    }

    protected void rdPOS22_CheckedChanged(object sender, EventArgs e)
    {
        eventsRow1.Visible = false;
        channelsRow1.Visible = false;
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void ddlType2_SelectedIndexChanged(object sender, EventArgs e)
    {
        loadMatchResult();
    }
}
