protected void AddGenre_Click(object sender, EventArgs e)
        {
            GenreList.DataSource = null;
            GenreList.DataBind();

            using (Database db = new MySqlDatabase())
            {
                db.AddGenre(addGenreText.Text.Trim());

                GenreList.DataSource = db.getGenreList();
                GenreList.DataTextField = "Value";
                GenreList.DataValueField = "Key";
                GenreList.DataBind();
                GenreList.Items.Insert(0, new ListItem("--Select--", "Select"));
                GenreList.Items.Insert(1, new ListItem("--Add New Genre--", "Add"));
            }

            EditGenre.Visible = false;
            divAddGenre.Visible = false;
            divDeleteGenre.Visible = false;
            divSubGenre.Visible = false;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "trackprotect";

            if (!IsPostBack)
            {
                using (Database db = new MySqlDatabase())
                {
                    UserInfo ui = db.GetUser(Util.UserId);
                    _ManAccClientInfo = db.GetClientInfo(Util.UserId);

                    Session["TPForUser"] = _ManAccClientInfo.FirstName;

                    #region Fill Managed User Info

                    FillManagedArtistDropDown();

                    PopulateSocialMediaInfo(db);

                    #endregion

                    Genre1.DataSource = db.getGenreList();
                    Genre1.DataTextField = "Value";
                    Genre1.DataValueField = "Key";
                    Genre1.DataBind();
                    Genre1.Items.Insert(0, new ListItem("--Select--", null));

                    Genre2.DataSource = db.getGenreList();
                    Genre2.DataTextField = "Value";
                    Genre2.DataValueField = "Key";
                    Genre2.DataBind();
                    Genre2.Items.Insert(0, new ListItem("--Select--", null));

                    Genre3.DataSource = db.getGenreList();
                    Genre3.DataTextField = "Value";
                    Genre3.DataValueField = "Key";
                    Genre3.DataBind();
                    Genre3.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre1.DataSource = null;
                    SubGenre1.DataBind();
                    SubGenre1.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre2.DataSource = null;
                    SubGenre2.DataBind();
                    SubGenre2.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre3.DataSource = null;
                    SubGenre3.DataBind();
                    SubGenre3.Items.Insert(0, new ListItem("--Select--", null));

                    #region Control Panel information

                    DataSet ds = db.GetRegister(Util.UserId);
                    int protectedTracks = ds.Tables[0].Rows.Count;

                    LoggedOnTitle.Text = Resources.Resource.LoggedOnTitle;
                    LoggedOnUserName.Text = _ManAccClientInfo.FirstName;//_ManAccClientInfo.GetFullName();
                    CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId));
                    ProtectedLiteral.Text = Convert.ToString(protectedTracks);
                    decimal percentComplete = 0m;
                    if (Session["percentComplete"] != null)
                        percentComplete = Convert.ToDecimal(Session["percentComplete"]);
                    CompletedLiteral.Text = string.Empty;
                    if (percentComplete < 100)
                        CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m);
                    divAccPerCompleted.Visible = ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);

                    #endregion

                    #region Removed Code

                    //string userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
                    //string identDocName = string.Format("ID{0:D10}.cer", ui.UserId);
                    //string identDocPath = Path.Combine(userDocPath, identDocName);

                    //if (!File.Exists(Server.MapPath(identDocPath)))
                    //{
                    //    litDialogText.Text = Resources.Resource.InfoIncomplete;
                    //    Master.PrepareMessageBox("Message", Resources.Resource.InfoIncomplete);
                    //}

                    #endregion

                    ShareToMyWall.Text = string.Format(Resources.Resource.ShareToMyWall, _ManAccClientInfo.FirstName);
                    ShareToMyFriends.Text = string.Format(Resources.Resource.ShareToMyFriends, _ManAccClientInfo.FirstName);
                    ShareToMyPages.Text = string.Format(Resources.Resource.ShareToMyPages, _ManAccClientInfo.FirstName);
                }

                Session["CoArtistsTable"] = null;

                Session["ReturnUrl"] = Request.QueryString["ReturnUrl"];
                CoArtistsTable = CreateCoArtistsTable();

                long userId = Util.UserId;
                int credits = Util.GetUserCredits(userId);
                bool controlsEnabled = (credits > 0);
                FileUpload1.Enabled = controlsEnabled;
                FileUpload2.Enabled = controlsEnabled;
                FileUpload3.Enabled = controlsEnabled;
                RegisterDocumentButton.Enabled = controlsEnabled;

                FillCoArtistsDropDown();
            }

            //------- Highlight the selected lang button ------- !

            if (Convert.ToString(Session["culture"]).Contains("nl"))
            {
                ClientScript.RegisterStartupScript
                    (this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true);
                ClientScript.RegisterStartupScript
                    (this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true);
            }
            else
            {
                ClientScript.RegisterStartupScript
                    (this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true);
                ClientScript.RegisterStartupScript
                    (this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true);
            }

            ClientScript.RegisterStartupScript(this.GetType(), "HighLightMenu", "HighLightMenu('" + "Menu3" + "');", true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "trackprotect";

            if (!IsPostBack)
            {
                RedirectToManaccPage();

                using (Database db = new MySqlDatabase())
                {
                    UserInfo ui = db.GetUser(Util.UserId);
                    _clientInfo = db.GetClientInfo(Util.UserId);

                    Session["TPForUser"] = _clientInfo.FirstName;

                    ViewState["isSoundCloudActive"] = FillSoundCloudInfo();

                    if (Convert.ToBoolean(ViewState["isSoundCloudActive"]) == true)
                    {
                        ViewState["isFacebookActive"] = FillFacebookInfo();

                        if (Convert.ToBoolean(ViewState["isFacebookActive"]))
                        {
                            FillFBPageList(Convert.ToString(Session["FBACC"]));
                            FillFBFriendList(Convert.ToString(Session["FBACC"]));
                        }

                        FillTwitterInfo();
                    }
                    else
                    {
                        #region Deactivate Facebook

                        Session["FBACC"] = Session["FBID"] = Session["AppId"] = Session["AppSecret"] = null;

                        cbxSendToFacebook.Enabled = false;

                        FacebookMsg.Enabled = false;

                        cbxSendToFacebook.Visible = false;

                        #endregion

                        #region Deactivate Facebook Pages

                        divShareToPages.Visible = false;

                        cbxShareToPages.Enabled = false;

                        cbxShareToPages.Visible = false;

                        dlPageList.Enabled = false;

                        #endregion

                        #region Deactivate Facebook Friends

                        divShareToFriends.Visible = false;

                        cbxShareToFriends.Enabled = false;

                        cbxShareToFriends.Visible = false;

                        dlFriendList.Enabled = false;

                        #endregion

                        #region Deactivate Twitter

                        cbxSendToTwitter.Enabled = false;

                        TwitterMsg.Enabled = false;

                        cbxSendToTwitter.Visible = false;

                        #endregion
                    }

                    Genre1.DataSource = db.getGenreList();
                    Genre1.DataTextField = "Value";
                    Genre1.DataValueField = "Key";
                    Genre1.DataBind();
                    Genre1.Items.Insert(0, new ListItem("--Select--", null));

                    Genre2.DataSource = db.getGenreList();
                    Genre2.DataTextField = "Value";
                    Genre2.DataValueField = "Key";
                    Genre2.DataBind();
                    Genre2.Items.Insert(0, new ListItem("--Select--", null));

                    Genre3.DataSource = db.getGenreList();
                    Genre3.DataTextField = "Value";
                    Genre3.DataValueField = "Key";
                    Genre3.DataBind();
                    Genre3.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre1.DataSource = null;
                    SubGenre1.DataBind();
                    SubGenre1.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre2.DataSource = null;
                    SubGenre2.DataBind();
                    SubGenre2.Items.Insert(0, new ListItem("--Select--", null));

                    SubGenre3.DataSource = null;
                    SubGenre3.DataBind();
                    SubGenre3.Items.Insert(0, new ListItem("--Select--", null));

                    #region Control Panel information

                    DataSet ds = db.GetRegister(Util.UserId);
                    int protectedTracks = ds.Tables[0].Rows.Count;

                    LoggedOnTitle.Text = Resources.Resource.LoggedOnTitle;
                    LoggedOnUserName.Text = string.Format("<span><b>{0}</b></span>", _clientInfo.FirstName);// _clientInfo.GetFullName());
                    CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId));

                    if (string.IsNullOrEmpty(CreditsLiteral.Text.Trim()))
                        Response.Redirect("SelectProduct.aspx");
                    else if (Convert.ToInt32(CreditsLiteral.Text.Trim()) <= 0)
                        Response.Redirect("SelectProduct.aspx");

                    //ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, protectedTracks);
                    ProtectedLiteral.Text = Convert.ToString(protectedTracks);
                    decimal percentComplete = 0m;
                    if (Session["percentComplete"] != null)
                        percentComplete = Convert.ToDecimal(Session["percentComplete"]);
                    CompletedLiteral.Text = string.Empty;
                    if (percentComplete < 100)
                        CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m);
                    divAccPerCompleted.Visible = ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);

                    #endregion

                    #region Removed Code

                    //string userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
                    //string identDocName = string.Format("ID{0:D10}.cer", ui.UserId);
                    //string identDocPath = Path.Combine(userDocPath, identDocName);

                    //if (!File.Exists(Server.MapPath(identDocPath)))
                    //{
                    //    //litDialogText.Text = Resources.Resource.InfoIncomplete;
                    //    Master.PrepareMessageBox("Message", Resources.Resource.InfoIncomplete);
                    //}

                    #endregion

                    ShareToFriends.Text = string.Format(Resources.Resource.ShareToFriends, _clientInfo.FirstName);
                    ShareToPages.Text = string.Format(Resources.Resource.ShareToPages, _clientInfo.FirstName);
                }

                Session["CoArtistsTable"] = null;

                Session["ReturnUrl"] = Request.QueryString["ReturnUrl"];

                int credits = Util.GetUserCredits(Util.UserId);
                bool controlsEnabled = (credits > 0);
                FileUpload1.Enabled = controlsEnabled;
                FileUpload2.Enabled = controlsEnabled;
                FileUpload3.Enabled = controlsEnabled;
                IsrcPostfix.Enabled = controlsEnabled;
                RegisterDocumentButton.Enabled = controlsEnabled;

                using (Database db = new MySqlDatabase())
                {
                    ClientInfo ci = db.GetClientInfo(Util.UserId);
                    IsrcHandle.Text = string.Format("ISRC {0}-{1:D2}-", ci.IsrcCode, DateTime.Now.Year % 100);
                }

                FillCoArtistsDropDown();
            }

            if (CoArtistsTable == null)
            {
                DataTable table = new DataTable("coartists");
                table.Columns.Add("name", typeof(string));
                table.Columns.Add("role", typeof(string));
                table.Columns.Add("clientid", typeof(long));
                CoArtistsTable = table;
            }

            //------- Highlight the selected lang button ------- !

            if (Convert.ToString(Session["culture"]).Contains("nl"))
            {
                ClientScript.RegisterStartupScript
                    (this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true);
                ClientScript.RegisterStartupScript
                    (this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true);
            }
            else
            {
                ClientScript.RegisterStartupScript
                    (this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true);
                ClientScript.RegisterStartupScript
                    (this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true);
            }

            ClientScript.RegisterStartupScript(this.GetType(), "HighLightMenu", "HighLightMenu('" + "Menu3" + "');", true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            new BasePage();

            Session["bodyid"] = "coupon";

            if (Session["AdminLogin"] == null)
            {
                divLogin.Visible = true;
            }
            else
            {
                divLogin.Visible = false;

                if (!IsPostBack)
                {
                    if (authenticateAndPopulateInformation())
                    {
                        HLfbconnect1.Enabled = false;
                        HLfbconnect2.Enabled = false;

                        try
                        {
                            HLfbLocalize1.Text = Resources.Resource.AuthenticatedWithFacebook + adminName;
                            HLfbLocalize2.Text = Resources.Resource.AuthenticatedWithFacebook + adminName;
                        }
                        catch
                        {
                            HLfbLocalize1.Text = "Connected as " + adminName;
                            HLfbLocalize2.Text = "Connected as " + adminName;
                        }

                        divFBAuthenticate.Style.Add("width", "374px");

                        RemoveBtn.Visible = true;

                        ConnectionToFacebook.ImageUrl = "~/Images/socialmedia/clean.png";

                        divPageMapping.Visible = true;

                        using (Database db = new MySqlDatabase())
                        {
                            FBPagesList.DataSource = db.getAdminFBPages();
                            FBPagesList.DataTextField = "Value";
                            FBPagesList.DataValueField = "Key";
                            FBPagesList.DataBind();
                            FBPagesList.Items.Insert(0, new ListItem("--Select--", "Select"));

                            GenreList.DataSource = db.getGenreList();
                            GenreList.DataTextField = "Value";
                            GenreList.DataValueField = "Key";
                            GenreList.DataBind();
                            GenreList.Items.Insert(0, new ListItem("--Select--", "Select"));
                            GenreList.Items.Insert(1, new ListItem("--Add New Genre--", "Add"));

                            MappingGrid.DataSource = db.getPageGenreMapping();
                            MappingGrid.DataBind();
                        }
                    }
                    else
                    {
                        divFBAuthenticate.Style.Add("width", "230px");

                        HLfbconnect1.Enabled = true;
                        HLfbconnect2.Enabled = true;

                        HLfbLocalize1.Text = Resources.Resource.AuthenticateWithFacebook;
                        HLfbLocalize2.Text = Resources.Resource.AuthenticateWithFacebook;

                        RemoveBtn.Visible = false;

                        ConnectionToFacebook.ImageUrl = "~/Images/socialmedia/Redcross.png";

                        divPageMapping.Visible = false;

                        try
                        {
                            using (Database db = new MySqlDatabase())
                            {
                                db.deleteAdminFBCred();
                            }
                        }
                        catch { }
                    }
                }
            }

            if (Convert.ToString(Session["culture"]).Contains("nl"))
            {
                ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageNL" + "');", true);
                ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageUS" + "');", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageUS" + "');", true);
                ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageNL" + "');", true);
            }
        }
        protected void DeleteGenre_Click(object sender, EventArgs e)
        {
            GenreList.DataSource = null;
            GenreList.DataBind();

            MappingGrid.DataSource = null;
            MappingGrid.DataBind();

            using (Database db = new MySqlDatabase())
            {
                db.DeleteGenre(Convert.ToInt32(ViewState["GenreID"]));

                GenreList.DataSource = db.getGenreList();
                GenreList.DataTextField = "Value";
                GenreList.DataValueField = "Key";
                GenreList.DataBind();
                GenreList.Items.Insert(0, new ListItem("--Select--", "Select"));
                GenreList.Items.Insert(1, new ListItem("--Add New Genre--", "Add"));

                MappingGrid.DataSource = db.getPageGenreMapping();
                MappingGrid.DataBind();
            }

            EditGenre.Visible = false;
            divAddGenre.Visible = false;
            divDeleteGenre.Visible = false;
            divSubGenre.Visible = false;
        }