protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["pid"] != null)
            {
                long productId;
                if (!long.TryParse(Request.Params["pid"], out productId))
                    productId = 0;
                Session["quotation.pid"] = productId;
            }

            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);
                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>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, protectedTracks);
                string userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
                decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
                CompletedLiteral.Text = string.Empty;
                if (percentComplete < 100)
                    CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m);
                ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);
            }
        }
        protected void AddCoArtist(object sender, CommandEventArgs e)
        {
            bool found = false;
            if (CoArtistDropDown.SelectedIndex < 0)
                return;

            using (Database db = new MySqlDatabase())
            {
                long userId = Convert.ToInt64(CoArtistDropDown.SelectedValue);
                if (userId > 0)
                {
                    UserInfo ui = db.GetUser(userId);
                    ClientInfo ci = db.GetClientInfo(userId);

                    Session["user.userid"] = userId;
                    AddCoArtistRow(CoArtistsTable, ci.GetFullName(), CoArtistRole.Text, ci.ClientId);

                    DataView dataView = new DataView(CoArtistsTable);
                    CoArtistsList.DataSource = dataView;
                    CoArtistsList.DataBind();

                    found = true;
                }
            }
            if (!found)
                ErrorMessage.Text = Resources.Resource.ClientNotFound;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludePage(HowItWorksInc, Resources.Resource.incHowItWorks);
            IncludePage(ProtectInc, Resources.Resource.incProtect);
            IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement);

            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);
                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>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, 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);
                ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);
            }

            if (!IsPostBack)
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "relationships";
            IncludePage(ProtectInc, Resources.Resource.incProtect);
            IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

            string fullname = string.Empty;
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

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

                fullname = ci.FirstName; //ci.GetFullName();
                LoggedOnTitle.Text = Resources.Resource.LoggedOnTitle;
                LoggedOnUserName.Text = string.Format("<span><b>{0}</b></span>", fullname);
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            string email = Request.Params["email"] ?? "???";
            string format = Resources.Resource.fmtInviteSuccess;
            if (Request.Params["mode"] != null)
            {
                if (Request.Params["mode"] == "1")
                    format = Resources.Resource.fmtInviteExists;
            }
            InviteSuccessLiteral.Text = string.Format(format, email);

            if (!IsPostBack)
            {
            }

            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);
            }
        }
        protected void TpIdSearch(object sender, CommandEventArgs e)
        {
            string email = TpIdText.Text;
            using (Database db = new MySqlDatabase())
            {
                long userId = db.GetUserIdByEmail(email);
                UserInfo ui = db.GetUser(userId);
                ClientInfo ci = db.GetClientInfo(userId);

                Session["mgmt.userid"] = userId;
                ManagerNameLabel.Text = ci.GetFullName();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                IncludePage(AccountOverviewInc, Resources.Resource.incMemberHome);
                IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

                using (Database db = new MySqlDatabase())
                {

                    UserInfo ui = db.GetUser(Util.UserId);
                    ClientInfo ci = db.GetClientInfo(Util.UserId);

                    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>", ci.FirstName); //ci.GetFullName());
                    CreditsLiteral.Text = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                    ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, protectedTracks);

                    string userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
                    decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
                    Session["percentComplete"] = percentComplete;
                    CompletedLiteral.Text = string.Empty;
                    if (percentComplete < 100)
                        CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m);
                    ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);
                }

                FillAccountInformation();

                int couponEntry = 0;
                if (Session["coupon.entry"] != null)
                    couponEntry = (int)Session["coupon.entry"];

                if (!IsPostBack)
                {
                    using (Database db = new MySqlDatabase())
                    {
                        int violationState = db.GetUserWhmcsClientId(Util.UserId);
                        if (violationState == 1)
                            couponEntry = 3;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(LogLevel.Error, ex, "AccountOverView<Exception>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "relationships";
            Session["loggedinUserEmail"] = string.Empty;
            Util.GetUserClearanceLevels(Util.UserId, out _vcl, out _ecl);
            if (_vcl < 100 && _ecl < 100)
            {
                divManaccChk.Visible = false;
            }
            else
            {
                divManaccChk.Visible = true;
            }
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                DataSet ds = db.GetRegister(Util.UserId);
                int protectedTracks = ds.Tables[0].Rows.Count;
                Session["loggedinUserEmail"] = ui.Email;
                LoggedOnTitle.Text = Resources.Resource.LoggedOnTitle;
                LoggedOnUserName.Text = string.Format("<span><b>{0}</b></span>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

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

                ddl_Language.SelectedValue = "nl";
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_HeadLoginView_LanguageUS" + "');", true);
                ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_HeadLoginView_LanguageNL" + "');", true);

                ddl_Language.SelectedValue = "en";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "tracks";
            IncludePage(SelectProductInc, Resources.Resource.incSelectProduct);
            IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

            long userId = Util.UserId;

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

                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>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            getProductList(userId);

            SetProductItemLinks();

            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);
            }
        }
        protected void ArtistsTable_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument);
            // Retrieve the row that contains the button
            // from the Rows collection.
            GridViewRow row = ArtistsTable.Rows[rowIndex];
            HiddenField hfd = row.FindControl("HiddenFieldUserId") as HiddenField;

            switch (e.CommandName)
            {
                case "DeleteUser":
                    if (hfd != null)
                    {
                        long targetId = 0;
                        if (!long.TryParse(hfd.Value, out targetId))
                            targetId = 0;
                        if (targetId > 0)
                        {
                            long sourceId = Util.UserId;
                            using (Database db = new MySqlDatabase())
                            {
                                db.DeleteRelation(sourceId, targetId, 1);
                            }
                        }
                    }
                    break;

                case "RelateUser":
                    if (hfd != null)
                    {
                        long targetId = 0;
                        if (!long.TryParse(hfd.Value, out targetId))
                            targetId = 0;
                        if (targetId > 0)
                        {
                            long sourceId = Util.UserId;
                            using (Database db = new MySqlDatabase())
                            {
                                UserInfo targetUi = db.GetUser(targetId);
                                RequestConfirmation(targetUi.Email, 1);
                            }
                        }
                    }
                    break;
            }
            FillManagedRelationsTable();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludePage(FAQInc, Resources.Resource.incFAQ);
            //IncludePage(ProtectInc, Resources.Resource.incProtect);
            //IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement);
            UserInformation();
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                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>", ci.FirstName);// ci.GetFullName());
                //CreditsLiteral.Text     = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId));
                //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);
            }

            //------- 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('" + "Menu4" + "');", true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string retUrl = Request.Params["url"].Trim('#');

            string accessToken = string.Empty;

            using (Database db = new MySqlDatabase())
            {
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                string[] kvps = retUrl.Split('&');
                foreach (string kvp in kvps)
                {
                    string[] parts = kvp.Split('=');
                    if (parts.Length == 2)
                    {
                        string key = parts[0];
                        string val = parts[1];

                        if (val.EndsWith(",/social/soundcloud.aspx"))
                            val = val.Substring(0, val.Length - ",/social/soundcloud.aspx".Length);

                        if (string.Compare(key, "access_token", true) == 0)
                            accessToken = val;
                        db.UpdateSocialCredential(ci.ClientId, SocialConnector.SoundCloud, key, val);
                    }
                }
            }

            if (!string.IsNullOrEmpty(accessToken))
            {
                string userName = GetUserData(accessToken);

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

                    ClientInfo ci = db.GetClientInfo(ui.UserId);

                    db.UpdateSoundCloudId(ci.ClientId, userName);

                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string scope = Request.QueryString["scope"];

            string access_token = Request.QueryString["access_token"];

            if (!string.IsNullOrEmpty(access_token))
            {
                using (Database db = new MySqlDatabase())
                {
                    UserInfo ui = db.GetUser(Util.UserId);

                    ClientInfo ci = db.GetClientInfo(ui.UserId);

                    db.UpdateSocialCredential(ci.ClientId, SocialConnector.SoundCloud, "access_token", access_token);

                    db.UpdateSocialCredential(ci.ClientId, SocialConnector.SoundCloud, "scope", scope);

                    db.UpdateSoundCloudId(ci.ClientId, GetUserData(access_token));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "tracks";
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                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>", ci.FirstName);// ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["id"]))
                {
                    long managedUserId = Convert.ToInt64(Request["id"]);
                    Session["managed.userid"] = managedUserId;
                    FillRegistrationGrid(Util.UserId, managedUserId);
                }
            }

            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);
            }
        }
        private void ModifyClientInfo()
        {
            try
            {
                using (Database db = new MySqlDatabase())
                {
                    ClientInfo ci = db.GetClientInfo(Util.UserId);

                    string lastName = ci.LastName;
                    string firstName = ci.FirstName;
                    string addressLine1 = ci.AddressLine1;
                    string addressLine2 = ci.AddressLine2;
                    string zipcode = ci.ZipCode;
                    string city = ci.City;
                    string state = ci.State;
                    string country = ci.Country;
                    string language = ci.Language;
                    string telephone = ci.Telephone;
                    string cellular = ci.Cellular; // Cellular.Text;
                    string accountOwner = ci.AccountOwner;
                    string bumaCode = BumaNo.Text.Trim();
                    string senaCode = SenaNo.Text.Trim();
                    string isrcCode = ISRC.Text.Trim();
                    string twitterId = ci.TwitterId.Trim();
                    string facebookId = ci.FacebookId.Trim();
                    string soundcloudId = ci.SoundCloudId.Trim();
                    string soniallId = ci.SoniallId.Trim();
                    string ownerKind = ci.OwnerKind;
                    string referer = ci.Referer;
                    char gender = ci.Gender;
                    string stagename = ci.stagename;
                    string companyname = ci.CompanyName;
                    DateTime birthday = Convert.ToDateTime(ci.Birthdate);

                    if (ci != null)
                        referer = ci.Referer;
                    db.RegisterClientInfo(lastName,
                                          firstName,
                                          addressLine1,
                                          addressLine2,
                                          zipcode,
                                          state,
                                          city,
                                          country,
                                          language,
                                          telephone,
                                          cellular,
                                          companyname,
                                          Util.UserId,
                                          accountOwner,
                                          bumaCode,
                                          senaCode,
                                          isrcCode,
                                          twitterId,
                                          facebookId,
                                          soundcloudId,
                                          soniallId,
                                          ownerKind,
                                          string.Empty,
                                          string.Empty,
                                          string.Empty,
                                          referer,
                                          gender,
                                          birthday,
                                          stagename);

                    // Remove the user's identification certificate so a new one
                    // can be registered.
                    UserInfo ui = db.GetUser(Util.UserId);
                    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(identDocPath))
                    {
                        string filePattern = string.Format("ID{0:D10}.*.cer", ui.UserId);
                        string[] files = Directory.GetFiles(userDocPath, filePattern);
                        int highIndex = -1;
                        foreach (string file in files)
                        {
                            string filename = Path.GetFileName(file);
                            if (filename != null)
                            {
                                string[] parts = filename.Split('.');
                                if (parts.Length == 3)
                                {
                                    int index;
                                    if (int.TryParse(parts[1], out index))
                                    {
                                        if (index > highIndex)
                                            highIndex = index;
                                    }
                                }
                            }
                        }
                        if (highIndex > -1)
                        {
                            ++highIndex;
                            while (highIndex > 0)
                            {
                                string srcFilename = Path.Combine(userDocPath,
                                                                  string.Format("ID{0:D10}.{1}.cer",
                                                                                ui.UserId, highIndex - 1));
                                string tgtFilename = Path.Combine(userDocPath,
                                                                  string.Format("ID{0:D10}.{1}.cer",
                                                                                ui.UserId, highIndex));
                                File.Move(srcFilename, tgtFilename);
                                --highIndex;
                            }
                        }

                        string newDocName = string.Format("ID{0:D10}.0.cer", ui.UserId);
                        string newDocPath = Path.Combine(userDocPath, newDocName);
                        if (File.Exists(newDocPath))
                            File.Delete(newDocPath);
                        string newPdfPath = Path.ChangeExtension(newDocPath, ".pdf");
                        if (File.Exists(newPdfPath))
                            File.Delete(newPdfPath);
                        string identPdfPath = Path.ChangeExtension(identDocPath, ".pdf");

                        File.Move(identDocPath, newDocPath);
                        if (File.Exists(identPdfPath))
                            File.Move(identPdfPath, newPdfPath);

                        //File.Delete(identDocPath);

                        //Added by Nagesh

                        decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
                        if (percentComplete < 100)
                        {
                            Response.Redirect("Profile.aspx");
                        }
                        else
                        {
                            Response.Redirect("Thankyou.aspx");
                        }
                        //Added by Nagesh
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(LogLevel.Error, ex, "MemberEdit<Exception> on ModifyUserButtonClick");
            }

            Response.Redirect("~/Member/ProfilePrint.aspx", false);
        }
        private void UserInformation()
        {
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);
                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>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId));
                ProtectedLiteral.Text = Convert.ToString(protectedTracks);

                MemberSince.Text = Convert.ToString(ui.MemberSince);

                string userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
                decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
                Session["percentComplete"] = 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);
            }
        }
        /// <summary>
        /// Fill the control with account information
        /// </summary>
        private void FillAccountInformation()
        {
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                Name.Text = ci.FirstName + " " + ci.LastName;
                StageName.Text = ci.stagename;
                CompanyName.Text = ci.CompanyName;
                if (ci.Gender == 'm' || ci.Gender == 'M')
                    Gender.Text = "Male";
                else if (ci.Gender == 'f' || ci.Gender == 'F')
                    Gender.Text = "Female";
                DOB.Text = Convert.ToString(ci.Birthdate).Split(' ')[0];
                Address.Text = ci.AddressLine1 + System.Environment.NewLine + ci.AddressLine2;
                Pincode.Text = ci.ZipCode;
                City.Text = ci.City;
                State.Text = ci.State;
                Country.Text = ci.Country;
                Number.Text = ci.Telephone;
                BumaNo.Text = ci.BumaCode;
                SenaNo.Text = ci.SenaCode;
                ISRC.Text = ci.IsrcCode;

                if (!string.IsNullOrEmpty(ci.TwitterId))
                {
                    lblTwitter.Text = "CONNECTED AS";
                    TwitterIdLabel.Text = ci.TwitterId;
                    TwitterIdLabel.Visible = true;
                    twitterdiv.Visible = true;
                    RemoveTwitter.Visible = true;
                    linkTwitter.Enabled = false;
                }
                else
                {
                    lblTwitter.Text = "CONNECT";
                    TwitterIdLabel.Visible = false;
                    RemoveTwitter.Visible = false;
                    twitterdiv.Visible = false;
                    linkTwitter.Enabled = true;
                }

                if (!string.IsNullOrEmpty(ci.FacebookId))
                {
                    lblFacebook.Text = "CONNECTED AS";
                    FacebookIdLabel.Text = ci.FacebookId;
                    FacebookIdLabel.Visible = true;
                    facebookdiv.Visible = true;
                    RemoveFacebook.Visible = true;
                    linkFacebook.Enabled = false;
                }
                else
                {
                    lblFacebook.Text = "CONNECT";
                    facebookdiv.Visible = false;
                    FacebookIdLabel.Visible = false;
                    RemoveFacebook.Visible = false;
                    linkFacebook.Enabled = true;
                }

                if (!string.IsNullOrEmpty(ci.SoundCloudId))
                {
                    lblsoundcloud.Text = "CONNECTED AS";
                    SoundCloudLabel.Text = ci.SoundCloudId;
                    SoundCloudLabel.Visible = true;
                    soundclouddiv.Visible = true;
                    RemoveSoundCloud.Visible = true;
                    linkSoundCloud.Enabled = false;
                }
                else
                {
                    lblsoundcloud.Text = "CONNECT";
                    soundclouddiv.Visible = false;
                    SoundCloudLabel.Visible = false;
                    RemoveSoundCloud.Visible = false;
                    linkSoundCloud.Enabled = true;
                }

                OwnerKind.Text = ci.OwnerKind;
                Email.Text = ui.Email;

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

                // Assume the button will need to be visible, if not so we will discover afterwards
                if (File.Exists(identDocPath))
                {
                    IdentityCertificate.Text = Path.GetFileName(identDocPath);
                    DownloadIdent.Visible = true;
                    //DownloadIdent.NavigateUrl = string.Format("~/DownloadHandler.ashx?file='{0}'", Server.MapPath(identDocPath));
                    DownloadIdent.Attributes.Add("onclick", "InitializeRequest('" + identDocPath.Replace("\\", "/") + "');");
                }
                else
                {
                    // credential document has been marked as 'old' due to changed information
                    // of the client and no new credential file has been uploaded
                    identDocName = string.Format("ID{0:D10}.0.cer", ui.UserId);
                    identDocPath = Path.Combine(userDocPath, identDocName);
                    if (File.Exists(identDocPath))
                    {
                        IdentityCertificate.Text = Path.GetFileName(identDocPath);
                        DownloadIdent.Visible = true;
                        //DownloadIdent.NavigateUrl = string.Format("~/DownloadHandler.ashx?file='{0}'", Server.MapPath(identDocPath));
                        DownloadIdent.Attributes.Add("onclick", "InitializeRequest('" + identDocPath.Replace("\\", "/") + "');");
                    }
                }
            }
        }
        protected void AccountOverview_Click(object sender, EventArgs e)
        {
            using (Database db = new MySqlDatabase())
            {
                UserInfo ui = db.GetUser(Util.UserId);
                ClientInfo ci = db.GetClientInfo(Util.UserId);

                string password = Session["access"] as string;
                string uploadPath = db.GetUserDocumentPath(Util.UserId, password);

                //GenerateAccountOverView(
                //    Server.MapPath(Path.Combine(uploadPath, "/Temporaryfiles/AccInfo_" + ui.UserId + "_" + ci.FirstName + "_" + ci.LastName + ".pdf")),
                //    HttpContext.Current.Server.MapPath(Resources.Resource.AccountOverViewTemplate),
                //    ci, ui);

                using (StreamReader reader = new StreamReader(Server.MapPath("~") + "/HtmlTemplates/accountoverview_template_en_form.html"))
                {
                    String htmlText = reader.ReadToEnd();

                    HtmlToPdf(Server.MapPath(Path.Combine(uploadPath, "/Temporaryfiles/AccInfo_" + ui.UserId + "_" + ci.FirstName + "_" + ci.LastName + ".pdf")),
                        htmlText,
                        ci, ui);
                }
            }
        }
        protected void SubmitButton_Command(object sender, CommandEventArgs e)
        {
            InitializeWithDefaultValues();

            Page.Validate("TrackProtectValidation");

            bool atleastOneTaggingSelected = false;

            if (ViewState["Genre1"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["Genre2"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["Genre3"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SubGenre1"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SubGenre2"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SubGenre3"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SoundTag1"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SoundTag2"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;
            else if (ViewState["SoundTag3"] != null && atleastOneTaggingSelected == false)
                atleastOneTaggingSelected = true;

            if (!FileUpload1.HasFile)
            {
                CustomValidationShow(Resources.Resource.SelectMp3File);
            }
            else if (FileUpload1.FileContent.Length > 12582912)
            {
                CustomValidationShow(Resources.Resource.FileSizeExceed);
            }
            else if (atleastOneTaggingSelected == false)
            {
                CustomValidationShow(Resources.Resource.SelectOneTag);
            }
            else if (Session["soundCloudAccessToken"] == null && (cbxSendToFacebook.Checked == true || cbxSendToTwitter.Checked == true))
            {
                CustomValidationShow(Resources.Resource.SoundCloudCredRequired);
            }
            else if (cbxSendToSoundCloud.Checked == false && (cbxSendToFacebook.Checked == true || cbxSendToTwitter.Checked == true))
            {
                CustomValidationShow(Resources.Resource.SelectSoundcloud);
            }

            if (Page.IsValid)
            {
                bool failed = false;
                long managedUserId = 0;
                if (Session["managed.userid"] != null)
                    managedUserId = Convert.ToInt64(Session["managed.userid"]);

                if (!FileUpload1.HasFile)
                {
                    // No file for the first option, need one to proceed or need a check to indicate
                    // only songtext and sheet music will be registered.
                    Response.Redirect(string.Format("~/Member/ErrorPage.aspx?title={0}&message={1}&returnurl={2}",
                        Resources.Resource.FirstFileRequiredTitle,
                        Resources.Resource.FirstFileRequiredMessage,
                        Uri.EscapeDataString(Request.RawUrl)), false);
                }

                long registerId = 0;

                string trackName = TrackNameText.Text;
                string doc1 = string.Empty, doc2 = string.Empty, doc3 = string.Empty;
                string uploadPath = string.Empty;
                using (Database db = new MySqlDatabase())
                {
                    UserInfo ui = db.GetUser(Util.UserId);

                    uploadPath = db.GetUserDocumentPath(managedUserId);

                    string isrcCode = string.Empty;
                    if (!string.IsNullOrEmpty(IsrcHandle.Text) && !string.IsNullOrEmpty(IsrcPostfix.Text))
                        isrcCode = IsrcHandle.Text + "-" + IsrcPostfix.Text;

                    if (!failed && FileUpload1.HasFile)
                    {
                        doc1 = FileUpload1.FileName;
                        try
                        {
                            FileUpload1.SaveAs(Path.Combine(uploadPath, Path.GetFileName(doc1)));
                            StatusInfo1.Text = string.Format(Resources.Resource.FileStoreSuccess, Path.GetFileName(doc1));
                        }
                        catch (Exception)
                        {
                            StatusInfo1.Text = string.Format(Resources.Resource.FileStoreFailed, Path.GetFileName(doc1));
                            failed = true;
                        }
                    }
                    if (!failed && FileUpload2.HasFile)
                    {
                        doc2 = FileUpload2.FileName;
                        try
                        {
                            FileUpload2.SaveAs(Path.Combine(uploadPath, Path.GetFileName(doc2)));
                            StatusInfo2.Text = string.Format(Resources.Resource.FileStoreSuccess, Path.GetFileName(doc2));
                        }
                        catch (Exception)
                        {
                            StatusInfo2.Text = string.Format(Resources.Resource.FileStoreFailed, Path.GetFileName(doc2));
                            failed = true;
                        }
                    }
                    if (!failed && FileUpload3.HasFile)
                    {
                        doc3 = FileUpload3.FileName;
                        try
                        {
                            FileUpload3.SaveAs(Path.Combine(uploadPath, Path.GetFileName(doc3)));
                            StatusInfo3.Text = string.Format(Resources.Resource.FileStoreSuccess, Path.GetFileName(doc3));
                        }
                        catch (Exception)
                        {
                            StatusInfo3.Text = string.Format(Resources.Resource.FileStoreFailed, Path.GetFileName(doc3));
                            failed = true;
                        }
                    }
                    if (!failed)
                    {
                        // Continue registration
                        string f1 = string.Empty, f2 = string.Empty, f3 = string.Empty;
                        if (!string.IsNullOrEmpty(doc1))
                            f1 = Path.Combine(uploadPath, Path.GetFileName(doc1));
                        if (!string.IsNullOrEmpty(doc2))
                            f2 = Path.Combine(uploadPath, Path.GetFileName(doc2));
                        if (!string.IsNullOrEmpty(doc3))
                            f3 = Path.Combine(uploadPath, Path.GetFileName(doc3));

                        // Get the cooperating artists to add to the certificate
                        CoopArtistList coopArtists = new CoopArtistList();
                        foreach (DataRow row in CoArtistsTable.Rows)
                        {
                            string name = Convert.ToString(row[0]);
                            string role = Convert.ToString(row[1]);
                            coopArtists.Add(new CoopArtist(name, role));
                        }

                        string certfilename = CreateCertificate(managedUserId, f1, f2, f3, isrcCode, trackName, coopArtists);
                        //long registerId = db.CreateRegistry(managedUserId, certfilename, f1);
                        registerId = db.CreateRegistry(Util.UserId, managedUserId, certfilename, f1, trackName.Trim(), isrcCode,
                            (Genre1.SelectedItem.Text == "--Select--" ? "" : Genre1.SelectedItem.Text),
                            (Genre2.SelectedItem.Text == "--Select--" ? "" : Genre2.SelectedItem.Text),
                            (Genre3.SelectedItem.Text == "--Select--" ? "" : Genre3.SelectedItem.Text),
                            (SubGenre1.SelectedItem.Text == "--Select--" ? "" : SubGenre1.SelectedItem.Text),
                            (SubGenre2.SelectedItem.Text == "--Select--" ? "" : SubGenre2.SelectedItem.Text),
                            (SubGenre3.SelectedItem.Text == "--Select--" ? "" : SubGenre3.SelectedItem.Text),
                            (Tag1.SelectedItem.Text == "--Select--" ? "" : Tag1.SelectedItem.Text),
                            (Tag2.SelectedItem.Text == "--Select--" ? "" : Tag2.SelectedItem.Text),
                            (Tag3.SelectedItem.Text == "--Select--" ? "" : Tag3.SelectedItem.Text), StageNameText.Text.Trim());

                        if (registerId > 0)
                        {
                            if (!failed && !string.IsNullOrEmpty(f1))
                                failed = (RegisterDoc(registerId, f1) == 0);

                            if (!failed && !string.IsNullOrEmpty(f2))
                                failed = (RegisterDoc(registerId, f2) == 0);

                            if (!failed && !string.IsNullOrEmpty(f3))
                                failed = (RegisterDoc(registerId, f3) == 0);
                            if (!failed && CoArtistsTable.Rows.Count > 0)
                            {
                                foreach (DataRow row in CoArtistsTable.Rows)
                                {
                                    string name = Convert.ToString(row[0]);
                                    string role = Convert.ToString(row[1]);
                                    long clientId = Convert.ToInt64(row[2]);
                                    string id = clientId.ToString();
                                    RegisterCoArtist(registerId, name, id, role);
                                }
                            }
                            if (!failed)
                            {
                                StatusInfo4.Text = Resources.Resource.RegistrationSuccessful;
                                db.DecrementCredits(Util.UserId);
                                db.AddCreditHistory(Util.UserId, 0L, 1, 0);

                                string certdocfile = Path.ChangeExtension(certfilename, ".pdf");
                                Util.SendRegistration(Convert.ToInt64(Session["managed.userid"]), uploadPath, trackName, certfilename, certdocfile);
                            }
                            else
                            {
                                StatusInfo4.Text = Resources.Resource.RegistrationFailed;
                            }
                        }
                        else
                        {
                            // Registration failed
                            StatusInfo4.Text = Resources.Resource.RegistrationFailed;
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(doc1))
                            DeleteFile(Path.Combine(uploadPath, Path.GetFileName(doc1)));
                        if (!string.IsNullOrEmpty(doc2))
                            DeleteFile(Path.Combine(uploadPath, Path.GetFileName(doc2)));
                        if (!string.IsNullOrEmpty(doc3))
                            DeleteFile(Path.Combine(uploadPath, Path.GetFileName(doc3)));
                    }
                }

                if (failed == false)
                {
                    Session["TrackProtected"] = true;

                    if (cbxSendToSoundCloud.Checked == false)
                        Session["SoundCloud.Response"] = "Deactive";
                    else if (cbxSendToSoundCloud.Checked && !File.Exists(Path.Combine(uploadPath, doc1)))
                        Session["SoundCloud.Response"] = "Error";
                    else if (cbxSendToSoundCloud.Checked && File.Exists(Path.Combine(uploadPath, doc1)))
                        Session["SoundCloud.Response"] = Publish.SoundCloudPublish(Convert.ToString(Session["soundCloudAccessToken"]), Path.Combine(uploadPath, doc1), trackName + System.Environment.NewLine + SoundCloudMsg.Text.Trim());

                    if (Session["SoundCloud.Response"] != null)
                    {
                        if (!Convert.ToString(Session["SoundCloud.Response"]).Contains("Deactive") && !Convert.ToString(Session["SoundCloud.Response"]).Contains("Error"))
                        {
                            string shortUrl =
                                BitlyApi.GetShortUrl(ConfigurationManager.AppSettings["SiteNavigationLink"] + "/idlookup.aspx?TrackID="
                                + EncryptionClass.Encrypt(Convert.ToString(registerId)));

                            string stream_url = string.Empty;

                            try
                            {
                                var obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(Convert.ToString(Session["SoundCloud.Response"]));

                                stream_url = Convert.ToString(obj["permalink_url"]) + "/" + Convert.ToString(obj["secret_token"]);
                            }
                            catch { }

                            #region Facebook

                            if (cbxSendToFacebook.Checked == false)
                                Session["Facebook.Response"] = "Deactive";
                            else if (cbxSendToFacebook.Checked)
                            {
                                String messageToPost = string.Empty;
                                messageToPost += FacebookMsg.Text.Trim() + System.Environment.NewLine + System.Environment.NewLine;
                                messageToPost += "Trackname : " + TrackNameText.Text.Trim() + System.Environment.NewLine;
                                messageToPost += "Trackprotect ID : " + shortUrl + System.Environment.NewLine;
                                //messageToPost += "Protected by: " + ConfigurationManager.AppSettings["SiteNavigationLink"] + System.Environment.NewLine;

                                if (cbxSendToGenreCommunityPage.Checked == false)
                                    Session["FacebookGenre.Response"] = "Deactive";
                                else if (cbxSendToGenreCommunityPage.Checked)
                                    Session["FacebookGenre.Response"] = postToFacebook(messageToPost, stream_url, Convert.ToString(ViewState["GenrePageToken"]), Convert.ToString(ViewState["GenrePageID"]));

                                if (cbxSendToSubGenreCommunityPage.Checked == false)
                                    Session["FacebookSubGenre.Response"] = "Deactive";
                                else if (cbxSendToSubGenreCommunityPage.Checked)
                                    Session["FacebookSubGenre.Response"] = postToFacebook(messageToPost, stream_url, Convert.ToString(ViewState["SubGenrePageToken"]), Convert.ToString(ViewState["SubGenrePageID"]));

                                if (cbxShareToUserWall.Checked == false)
                                    Session["Facebook.Response"] = "Deactive";
                                else if (cbxShareToUserWall.Checked)
                                    Session["Facebook.Response"] = postToFacebook(messageToPost, stream_url, Convert.ToString(Session["FBACC"]), Convert.ToString(Session["FBID"]));

                                if (cbxShareToFriends.Checked == false)
                                    Session["ShareToFriends"] = "Deactive";
                                else if (cbxShareToFriends.Checked)
                                {
                                    IList<string> friendList = getFriendIDs();

                                    foreach (var friendId in friendList)
                                        Session["ShareToFriends"] =
                                            postToFacebook(messageToPost, stream_url, Convert.ToString(Session["FBACC"]), friendId);
                                }

                                if (cbxShareToPages.Checked == false)
                                    Session["ShareToPages"] = "Deactive";
                                else if (cbxShareToPages.Checked)
                                {
                                    Dictionary<string, string> pageList = getPageIDs();

                                    foreach (var pageId in pageList)
                                        Session["ShareToPages"] = postToFacebook(messageToPost, stream_url, pageId.Value, pageId.Key);
                                }

                                if (cbxShareToMyWall.Checked == false)
                                    Session["FacebookOwnPage.Response"] = "Deactive";
                                else if (cbxShareToMyWall.Checked)
                                    Session["FacebookOwnPage.Response"] = postToFacebook(messageToPost, stream_url, Convert.ToString(Session["FBOwnACC"]), Convert.ToString(Session["FBOwnID"]));

                                if (cbxShareToOwnFriends.Checked == false)
                                    Session["ShareToOwnFriends"] = "Deactive";
                                else if (cbxShareToOwnFriends.Checked)
                                {
                                    IList<string> friendList = getOwnFriendIDs();

                                    foreach (var friendId in friendList)
                                        Session["ShareToOwnFriends"] = postToFacebook(messageToPost, stream_url, Convert.ToString(Session["FBOwnACC"]), friendId);
                                }

                                if (cbxShareToOwnPages.Checked == false)
                                    Session["ShareToOwnPages"] = "Deactive";
                                else if (cbxShareToOwnPages.Checked)
                                {
                                    Dictionary<string, string> pageList = getOwnPageIDs();

                                    foreach (var pageId in pageList)
                                        Session["ShareToOwnPages"] = postToFacebook(messageToPost, stream_url, pageId.Value, pageId.Key);
                                }
                            }

                            #endregion

                            #region Twitter

                            if (cbxSendToTwitter.Checked == false)
                                Session["Twitter.Response"] = "Deactive";
                            else if (cbxSendToTwitter.Checked)
                                Session["Twitter.Response"] = tweetToTwitter(shortUrl, stream_url);

                            #endregion
                        }
                    }
                }
                else
                    Session["TrackProtected"] = false;

                string continueUrl = "~/Member/UploadConfirmation.aspx?id=" + Convert.ToInt64(Session["managed.userid"]);

                if (HttpContext.Current.Session["ReturnUrl"] != null)
                    continueUrl = HttpContext.Current.Session["ReturnUrl"] as string;

                Response.Redirect(continueUrl, false);
            }

            if (cbxSendToFacebook.Checked)
                divFBSharing.Attributes.Add("style", "display:block");
            else
                divFBSharing.Attributes.Add("style", "display:none");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "user-home";

            bool couponEntryState = true;
            UserInfo ui = null;
            ClientInfo ci = null;
            string userDocPath = null;
            using (Database db = new MySqlDatabase())
            {
                db.ResetUserWhmcsClientd(Util.UserId);

                ui = db.GetUser(Util.UserId);
                ci = db.GetClientInfo(Util.UserId);

                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>", ci.FirstName); //ci.GetFullName());
                //CreditsLiteral.Text     = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                CreditsLiteral.Text = Convert.ToString(Util.GetUserCredits(Util.UserId));
                //ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, protectedTracks);
                ProtectedLiteral.Text = Convert.ToString(protectedTracks);

                couponEntryState = (db.GetUserWhmcsClientId(Util.UserId) == 0);
                userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
            }

            int vcl = 0, ecl = 0;
            Util.GetUserClearanceLevels(Util.UserId, out vcl, out ecl);
            //divManagedArtists.Visible = (vcl >= 100 || ecl >= 100);
            // managedArtist.Visible = (vcl >= 100 || ecl >= 100);
            fieldsMissing = false;
            decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
            ////Added by Nagesh to redirect user to complete profile page.
            //if (ui.IsActive == 0)
            //    Response.Redirect("~/FirstLogon.aspx?userId=" + ui.UserId);

            StringBuilder sb = new StringBuilder();
            if (string.IsNullOrEmpty(ci.GetFullName()))
                AddLine(sb, Resources.Resource.NoName);

            if (string.IsNullOrEmpty(ci.AddressLine1))
                AddLine(sb, Resources.Resource.NoAddress);

            if (string.IsNullOrEmpty(ci.City))
                AddLine(sb, Resources.Resource.NoResidence);

            if (string.IsNullOrEmpty(ci.OwnerKind))
                AddLine(sb, Resources.Resource.NoOwnerKind);

            if (string.IsNullOrEmpty(ci.TwitterId))
                AddLine(sb, Resources.Resource.NoTwitterId);

            if (string.IsNullOrEmpty(ci.FacebookId))
                AddLine(sb, Resources.Resource.NoFacebookId);

            if (string.IsNullOrEmpty(ci.SenaCode))
                AddLine(sb, Resources.Resource.NoSenaCode);

            if (string.IsNullOrEmpty(ci.IsrcCode))
                AddLine(sb, Resources.Resource.NoIsrcCode);

            string identDocName = string.Format("ID{0:D10}.cer", ui.UserId);
            string identDocPath = Path.Combine(userDocPath, identDocName);
            //if (!File.Exists(Server.MapPath(Request.ApplicationPath + identDocPath)))
            if (!File.Exists(identDocPath))
                AddLine(sb, Resources.Resource.NoCredentials);

            if (fieldsMissing)
                AddLine(sb, Resources.Resource.ClickToEdit);

            //MissingInfoPanel.Text = sb.ToString();
            //MissingInfoDiv.Visible = fieldsMissing;

            Session["percentComplete"] = 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);

            //CouponCodeEdit.Enabled = couponEntryState;
            //CouponCodeGo.Enabled = couponEntryState;

            //------- 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('" + "Menu1" + "');", true);
        }
        private void FillInvitationsTable()
        {
            StringBuilder sb = new StringBuilder();
            Invitations.Clear();
            using (Database db = new MySqlDatabase())
            {
                DataTable dt = db.GetInvitations(Util.UserId);
                pendingInvitationsHeader.Visible = (dt.Rows.Count > 0);
                foreach (DataRow row in dt.Rows)
                {
                    long confId = Convert.ToInt64(row["confirmation_id"]);
                    long userId = Convert.ToInt64(row["requesting_user_id"]);
                    int relType = Convert.ToInt32(row["relationtype"]);

                    UserInfo ui = db.GetUser(userId);
                    ClientInfo ci = db.GetClientInfo(userId);

                    AddInvitationsRow(Invitations, ci.GetFullName(), ui.Email, confId, relType);
                }
                Invitations.DefaultView.Sort = "name ASC";
                pendingInvitations.DataSource = Invitations;
                pendingInvitations.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "coupon";
            UserInfo ui = null;
            ClientInfo ci = null;

            new BasePage();

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

                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>", ci.FirstName); // ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);

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

                divTrackProtected.Visible = true;

                if (Convert.ToBoolean(Session["TrackProtected"]) == true)
                {
                    TrackProtected.Text = Resources.Resource.TrackProtectedSuccessNotify;

                    #region SoundCloud

                    divSoundCloudPost.Visible = true;

                    if (Convert.ToString(Session["SoundCloud.Response"]).Contains("Deactive"))
                        divSoundCloudPost.Visible = false;
                    else if (Convert.ToString(Session["SoundCloud.Response"]).Contains("Error"))
                        SoundCloudPost.Text = Resources.Resource.SoundCloudPostFailureNotify;
                    else if (!string.IsNullOrEmpty(Convert.ToString(Session["SoundCloud.Response"])))
                        SoundCloudPost.Text = Resources.Resource.SoundCloudPostSuccessNotify;

                    #endregion

                    #region Facebook My/User wall

                    if (Request.QueryString["type"] == "own")
                    {
                        divFacebookPost.Visible = true;

                        if (Convert.ToString(Session["Facebook.Response"]).Contains("Deactive"))
                            divFacebookPost.Visible = false;
                        else if (Convert.ToString(Session["Facebook.Response"]).Contains("Error"))
                            FacebookPost.Text = string.Format(Resources.Resource.FacebookPostOnOwnWallFailureNotify, Convert.ToString(Session["TPForUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["Facebook.Response"])))
                            FacebookPost.Text = string.Format(Resources.Resource.FacebookPostOnOwnWallSuccessNotify, Convert.ToString(Session["TPForUser"]));
                    }
                    else
                    {
                        divFacebookPost.Visible = true;

                        if (Convert.ToString(Session["Facebook.Response"]).Contains("Deactive"))
                            divFacebookPost.Visible = false;
                        else if (Convert.ToString(Session["Facebook.Response"]).Contains("Error"))
                            FacebookPost.Text = string.Format(Resources.Resource.FacebookPostOnUserWallFailureNotify, Convert.ToString(Session["ManagedUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["Facebook.Response"])))
                            FacebookPost.Text = string.Format(Resources.Resource.FacebookPostOnUserWallSuccessNotify, Convert.ToString(Session["ManagedUser"]));
                    }

                    #endregion

                    #region Facebook Genre

                    divFacebookGenreCommunityPost.Visible = true;

                    if (Convert.ToString(Session["FacebookGenre.Response"]).Contains("Deactive"))
                        divFacebookGenreCommunityPost.Visible = false;
                    else if (Convert.ToString(Session["FacebookGenre.Response"]).Contains("Error"))
                        FacebookGenreCommunityPost.Text = string.Format(Resources.Resource.FacebookGenreCommunityPostFailureNotify, Convert.ToString(Session["GenrePageName"]));
                    else if (!string.IsNullOrEmpty(Convert.ToString(Session["FacebookGenre.Response"])))
                        FacebookGenreCommunityPost.Text = string.Format(Resources.Resource.FacebookGenreCommunityPostSuccessNotify, Convert.ToString(Session["GenrePageName"]));

                    #endregion

                    #region Facebook SubGenre

                    divFacebookSubGenreCommunityPost.Visible = true;

                    if (Convert.ToString(Session["FacebookSubGenre.Response"]).Contains("Deactive"))
                        divFacebookSubGenreCommunityPost.Visible = false;
                    else if (Convert.ToString(Session["FacebookSubGenre.Response"]).Contains("Error"))
                        FacebookSubGenreCommunityPost.Text = string.Format(Resources.Resource.FacebookGenreCommunityPostFailureNotify, Convert.ToString(Session["SubGenrePageName"]));
                    else if (!string.IsNullOrEmpty(Convert.ToString(Session["FacebookSubGenre.Response"])))
                        FacebookSubGenreCommunityPost.Text = string.Format(Resources.Resource.FacebookGenreCommunityPostSuccessNotify, Convert.ToString(Session["SubGenrePageName"]));

                    #endregion

                    #region Facebook to Friends

                    if (Request.QueryString["type"] == "own")
                    {
                        divPostOnFriendWall.Visible = true;

                        if (Convert.ToString(Session["ShareToFriends"]).Contains("Deactive"))
                            divPostOnFriendWall.Visible = false;
                        else if (Convert.ToString(Session["ShareToFriends"]).Contains("Error"))
                            PostOnFriendWall.Text = string.Format(Resources.Resource.PostOnMyFriendWallFailureNotify, Convert.ToString(Session["TPForUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToFriends"])))
                            PostOnFriendWall.Text = string.Format(Resources.Resource.PostOnMyFriendWallSuccessNotify, Convert.ToString(Session["TPForUser"]));
                    }
                    else
                    {
                        divPostOnFriendWall.Visible = true;

                        if (Convert.ToString(Session["ShareToFriends"]).Contains("Deactive"))
                            divPostOnFriendWall.Visible = false;
                        else if (Convert.ToString(Session["ShareToFriends"]).Contains("Error"))
                            PostOnFriendWall.Text = string.Format(Resources.Resource.PostOnFriendWallFailureNotify, Convert.ToString(Session["ManagedUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToFriends"])))
                            PostOnFriendWall.Text = string.Format(Resources.Resource.PostOnFriendWallSuccessNotify, Convert.ToString(Session["ManagedUser"]));
                    }

                    #endregion

                    #region Facebook to Pages

                    if (Request.QueryString["type"] == "own")
                    {
                        divPostOnPages.Visible = true;

                        if (Convert.ToString(Session["ShareToPages"]).Contains("Deactive"))
                            divPostOnPages.Visible = false;
                        else if (Convert.ToString(Session["ShareToPages"]).Contains("Error"))
                            PostOnPages.Text = string.Format(Resources.Resource.PostOnMyPagesFailureNotify, Convert.ToString(Session["TPForUser"]), "");
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToPages"])))
                            PostOnPages.Text = string.Format(Resources.Resource.PostOnMyPagesSuccessNotify, Convert.ToString(Session["TPForUser"]), "");
                    }
                    else
                    {
                        divPostOnPages.Visible = true;

                        if (Convert.ToString(Session["ShareToPages"]).Contains("Deactive"))
                            divPostOnPages.Visible = false;
                        else if (Convert.ToString(Session["ShareToPages"]).Contains("Error"))
                            PostOnPages.Text = string.Format(Resources.Resource.PostOnPagesFailureNotify, Convert.ToString(Session["ManagedUser"]), "");
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToPages"])))
                            PostOnPages.Text = string.Format(Resources.Resource.PostOnPagesSuccessNotify, Convert.ToString(Session["ManagedUser"]), "");
                    }

                    #endregion

                    if (Request.QueryString["type"] != "own")
                    {
                        divPostToOwnWall.Visible = true;

                        if (Convert.ToString(Session["FacebookOwnPage.Response"]).Contains("Deactive"))
                            divPostOnPages.Visible = false;
                        else if (Convert.ToString(Session["FacebookOwnPage.Response"]).Contains("Error"))
                            PostToOwnWall.Text =
                              string.Format(Resources.Resource.FacebookPostOnOwnWallFailureNotify, Convert.ToString(Session["TPForUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["FacebookOwnPage.Response"])))
                            PostToOwnWall.Text =
                                string.Format(Resources.Resource.FacebookPostOnOwnWallSuccessNotify, Convert.ToString(Session["TPForUser"]));

                        divPostOnMyFriendWall.Visible = true;

                        if (Convert.ToString(Session["ShareToOwnFriends"]).Contains("Deactive"))
                            divPostOnMyFriendWall.Visible = false;
                        else if (Convert.ToString(Session["ShareToOwnFriends"]).Contains("Error"))
                            PostOnMyFriendWall.Text = string.Format(Resources.Resource.PostOnMyFriendWallFailureNotify, Convert.ToString(Session["TPForUser"]));
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToOwnFriends"])))
                            PostOnMyFriendWall.Text = string.Format(Resources.Resource.PostOnMyFriendWallSuccessNotify, Convert.ToString(Session["TPForUser"]));

                        divPostOnMyPages.Visible = true;

                        if (Convert.ToString(Session["ShareToOwnPages"]).Contains("Deactive"))
                            divPostOnMyPages.Visible = false;
                        else if (Convert.ToString(Session["ShareToOwnPages"]).Contains("Error"))
                            PostOnMyPages.Text = string.Format(Resources.Resource.PostOnMyPagesFailureNotify, Convert.ToString(Session["TPForUser"]), "");
                        else if (!string.IsNullOrEmpty(Convert.ToString(Session["ShareToOwnPages"])))
                            PostOnMyPages.Text = string.Format(Resources.Resource.PostOnMyPagesSuccessNotify, Convert.ToString(Session["TPForUser"]), "");
                    }

                    #region Twitter

                    divTwitterpost.Visible = true;

                    if (Convert.ToString(Session["Twitter.Response"]).Contains("Deactive"))
                        divTwitterpost.Visible = false;
                    else if (Convert.ToString(Session["Twitter.Response"]).Contains("Error"))
                        Twitterpost.Text = Resources.Resource.TwitterpostFailureNotify;
                    else if (!string.IsNullOrEmpty(Convert.ToString(Session["Twitter.Response"])))
                        Twitterpost.Text = Resources.Resource.TwitterpostSuccessNotify;

                    #endregion
                }
                else
                {
                    TrackProtected.Text = Resources.Resource.TrackProtectedFailureNotify;
                }
            }
        }
        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 SendQuotation(object sender, CommandEventArgs e)
        {
            long productId = 0;
            int credits = 0;
            if (QuotationAmount.Text.Length > 0)
            {
                int tmp = 0;
                if (int.TryParse(QuotationAmount.Text, out tmp))
                    credits = tmp;
            }

            if (Session["quotation.pid"] != null)
                productId = (long)Session["quotation.pid"];

            if (credits > 0)
            {
                // Send e-mail with quotation request
                Config cfg = new Config();
                cfg.Load(Server.MapPath("~/Config/trackprotect.config"));

                string emailTo = cfg["email.sales"];
                StringBuilder body = new StringBuilder();

                // Get user/client information
                using (Database db = new MySqlDatabase())
                {
                    long userId = Util.UserId;
                    UserInfo ui = db.GetUser(userId);
                    ClientInfo ci = db.GetClientInfo(userId);
                    body.Append("<html><head></head><body><p><div style=\"background-color:#E6E6E6;\"><table><tr><td>");
                    body.Append("<img src=\"" + ConfigurationManager.AppSettings["EmailHeaderLogo"] + "\" alt=\"logo\"/></td><td><span>");
                    body.Append("<a style=\"color:#E4510A; margin-left:450px;\" href=\"" + ConfigurationManager.AppSettings["EmailmailToLink"] + "\" >" + ConfigurationManager.AppSettings["EmailmailToLink"] + "</a>");
                    body.Append("<br><a style=\"color:#E4510A; margin-left:450px;\" href=\"" + ConfigurationManager.AppSettings["SiteNavigationLink"] + "\">" + ConfigurationManager.AppSettings["SiteNavigationLink"] + "</a>");
                    body.Append("</span></td></tr></table></div><br><br>");

                    body.Append(ci.GetFullName());
                    body.AppendFormat("heeft een offerte aangevraagd voor {0} credits.\r\n", QuotationAmount.Text);
                    body.AppendFormat("e-mail         : {0}\r\n", ui.Email);
                    body.AppendFormat("e-mail receipt : {0}\r\n", ci.EmailReceipt);
                    body.AppendFormat("user-id        : {0}\r\n", ui.UserId);
                    body.AppendFormat("client-id      : {0}\r\n", ci.ClientId);

                    body.Append("<br><br><img src=\"" + ConfigurationManager.AppSettings["EmailFooterLogo"] + "\" alt=\"logo\"/>");
                    body.Append("<a href=\"" + ConfigurationManager.AppSettings["EmailFBlink"] + "\"><img src=\"" + ConfigurationManager.AppSettings["EmailFBLogo"] + "\" alt=\"facebook\"></img></a>");
                    body.Append("<a href=\"" + ConfigurationManager.AppSettings["EmailTwitterLink"] + "\"><img src=\"" + ConfigurationManager.AppSettings["EmailTwitterLogo"] + "\" alt=\"twitter\"></img></a>");
                    body.Append("<a href=\"" + ConfigurationManager.AppSettings["EmailSoundCloudLink"] + "\"><img src=\"" + ConfigurationManager.AppSettings["EmailSoundCloudLogo"] + "\" alt=\"soundcloud\"></img></a>");
                    body.Append("<br><br>Trackprotect is “a RHOS Initiative” – Robin Hood of Sound – A Sound Revolution.<br>");

                    if (productId == 0)
                        productId = 4;

                    db.CreateQuotation(ui.UserId, credits, productId, string.Format("Quotation for {0} credits", QuotationAmount.Text));
                }

                Util.SendEmail(new string[] { emailTo }, "*****@*****.**", Resources.Resource.Quotation, body.ToString(), new string[] { }, 0);
                Response.Redirect("~/Member/QuotationSuccess.aspx", false);
            }
            else
            {
                ErrorMessage.Text = Resources.Resource.InvalidAmount;
            }
        }
        private void UpdateUserStatusPanel()
        {
            UserInfo ui = null;
            ClientInfo ci = null;
            string userDocPath = null;
            using (Database db = new MySqlDatabase())
            {
                db.ResetUserWhmcsClientd(Util.UserId);

                ui = db.GetUser(Util.UserId);
                ci = db.GetClientInfo(Util.UserId);
                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>", ci.GetFullName());
                CreditsLiteral.Text = string.Format(Resources.Resource.spnCredits, Util.GetUserCredits(Util.UserId));
                ProtectedLiteral.Text = string.Format(Resources.Resource.spnProtected, protectedTracks);

                userDocPath = db.GetUserDocumentPath(ui.UserId, Session["access"] as string);
            }

            int vcl = 0, ecl = 0;
            Util.GetUserClearanceLevels(Util.UserId, out vcl, out ecl);

            decimal percentComplete = DetermineCompletion(userDocPath, ui, ci);
            CompletedLiteral.Text = string.Empty;
            if (percentComplete < 100)
                CompletedLiteral.Text = string.Format(Resources.Resource.PercentComplete, percentComplete / 100m);
            ClickToLinkLiteral.Visible = (CompletedLiteral.Text != string.Empty);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "relationships";
            //IncludePage(ProtectInc, Resources.Resource.incProtect);
            //IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

            Util.GetUserClearanceLevels(Util.UserId, out _vcl, out _ecl);

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

                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>", ci.FirstName);// ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            if (!IsPostBack)
            {
                TpIdButton.Height = TpIdText.Height;

                if (ManagedRelations == null)
                {
                    DataTable dt = new DataTable("artists");
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("userid", typeof(long));
                    dt.Columns.Add("reltype", typeof(int));
                    dt.Columns.Add("manage", typeof(bool));
                    ManagedRelations = dt;
                }
                FillManagedRelationsTable();
                if (Invitations == null)
                {
                    DataTable dt = new DataTable("confirmations");
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("email", typeof(string));
                    dt.Columns.Add("confirmation_id", typeof(long));
                    dt.Columns.Add("relation_type", typeof(int));
                    Invitations = dt;
                }
                FillInvitationsTable();
            }

            //------- 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);
            }
        }
        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"] = "relationships";
            IncludePage(ProtectInc, Resources.Resource.incProtect);
            IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

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

                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>", ci.FirstName);// ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            string email = Request.Params["email"] ?? "???";
            int error = Convert.ToInt32(Request.Params["err"] ?? "0");
            string errorText = string.Empty;
            switch (error)
            {
                case 0:
                    break;
                case 1: // bad email address
                    errorText = string.Format(Resources.Resource.errEmailBadFormat);
                    break;
                case 2: // can't send email
                    errorText = string.Format(Resources.Resource.errEmailCantSend);
                    InviteFailureLiteral.Text = string.Format(Resources.Resource.fmtInviteFailure, email, errorText);
                    break;
                case 3:
                    InviteFailureLiteral.Text = string.Format(Resources.Resource.fmtInviteSent, email);
                    break;
                case 4:
                    InviteFailureLiteral.Text = Resources.Resource.fmtInviteSelf;
                    break;
            }

            if (!IsPostBack)
            {
            }

            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);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "user-home";

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

                    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>", ci.FirstName); // ci.GetFullName());
                    CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                    ProtectedLiteral.Text = protectedTracks.ToString();
                    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);
                }

                //using (Database db = new MySqlDatabase())
                //{
                //    ClientInfo ci = db.GetClientInfo(Util.UserId);
                //    string accessToken = db.GetSocialCredential(ci.ClientId, SocialConnector.Facebook, "accesstoken");

                //    FriendService fbFriendService = new FriendService(accessToken);

                //    //GetFacebookFriendList(accessToken);

                //    List<Friend> friendList = fbFriendService.Get();
                //}
            }

            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);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "coupon";
            // IncludePage(ProtectInc, Resources.Resource.incProtect);
            //IncludePage(RhosMovementInc, Resources.Resource.incRhosMovement2);

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

                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>", ci.FirstName);// ci.GetFullName());
                CreditsLiteral.Text = Util.GetUserCredits(Util.UserId).ToString();
                ProtectedLiteral.Text = protectedTracks.ToString();
                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);
            }

            if (!IsPostBack)
            {
                Config cfg = new Config();
                cfg.Load(Server.MapPath("~/Config/trackprotect.config"));

                int couponCodeCount = 0;
                if (Session["coupon.entry"] != null)
                    couponCodeCount = (int)Session["coupon.entry"];
                if (couponCodeCount < 3)
                    ++couponCodeCount;
                Session["coupon.entry"] = couponCodeCount;

                if (couponCodeCount < 3)
                {
                    ErrorCode.Text = string.Format("<span style=\"color: orange;\">{0}</span>", Resources.Resource.CouponIncorrect);
                }
                else
                {
                    string couponCode = Request.Params["couponcode"];
                    using (Database db = new MySqlDatabase())
                    {
                        ClientInfo ci = db.GetClientInfo(Util.UserId);
                        ErrorCode.Text = string.Format("<span style=\"color: red;\">{0}</span>",
                                                       Resources.Resource.CouponError);
                        StringBuilder body = new StringBuilder();
                        body.AppendFormat("The user with id {0} ({1}) entered too many invalid coupon codes.",
                                          Util.UserId, ci.GetFullName());
                        body.Append(Environment.NewLine);
                        body.AppendFormat("The last coupon code entered was {0}.", couponCode);
                        body.Append(Environment.NewLine);
                        body.Append("Coupon code entry was disabled");

                        Util.SendEmail(new string[] { cfg["email.admin"] }, "*****@*****.**", "Invalid coupon entry", body.ToString(), null,0);

                        // Register entry violation in the database
                        // Alright. Some abuse here, we're going to use the whmcsclient_id here to store the violation.
                        // The id isn't used anymore since whmcs has been abandoned and thus it remains simply an integer.
                        db.UpdateUserWhmcsClientId(Util.UserId, 1);
                    }
                }
            }

            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);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["bodyid"] = "user-home";

            if (!IsPostBack)
            {
                int ecl, vcl;
                Util.GetUserClearanceLevels(Util.UserId, out vcl, out ecl);

                int tmp = 0;
                int pid = -1;
                decimal tmpDec = 0m;
                decimal unitprice = 0m;

                if (Request.Params["pid"] != null)
                {
                    if (int.TryParse(Request.Params["pid"], out tmp))
                        pid = tmp;
                    Session["subscription.productid"] = pid;
                    Session["pid"] = pid;
                }

                string desc = string.Empty;
                using (Database db = new MySqlDatabase())
                {
                    UserInfo ui = db.GetUser(Util.UserId);
                    ClientInfo ci = db.GetClientInfo(Util.UserId);

                    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>", ci.FirstName); // ci.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);

                    string unitpriceStr = db.GetSetting("unitprice");
                    if (decimal.TryParse(unitpriceStr, out tmpDec))
                        unitprice = tmpDec;
                    Session["subscription.unitprice"] = unitprice;
                    Session["amt"] = unitprice;

                    CultureInfo culture = null;

                    if (Convert.ToString(Session["culture"]).Contains("nl"))
                    {
                        culture = new CultureInfo("nl-NL");
                    }
                    else if (Convert.ToString(Session["culture"]).Contains("en"))
                    {
                        culture = new CultureInfo("en-US");
                    }
                    else
                    {
                        culture = new CultureInfo("nl-NL");
                    }

                    desc = db.GetProductDescription(pid, culture);
                    if (vcl >= 100 || ecl >= 100)
                        desc = Resources.Resource.SubscriptionPurchase;
                }

                SubscriptionLiteral.Text = desc;
            }

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

            this.Page.Form.DefaultButton = SubscriptionSubmit.UniqueID;
        }