protected void Page_Load(object sender, EventArgs e) { new BasePage(); Session["bodyid"] = "coupon"; if (Session["AdminLogin"] == null) { divLogin.Visible = true; } else { divLogin.Visible = false; if (!IsPostBack) { if (authenticateAndPopulateInformation()) { HLfbconnect1.Enabled = false; HLfbconnect2.Enabled = false; try { HLfbLocalize1.Text = Resources.Resource.AuthenticatedWithFacebook + adminName; HLfbLocalize2.Text = Resources.Resource.AuthenticatedWithFacebook + adminName; } catch { HLfbLocalize1.Text = "Connected as " + adminName; HLfbLocalize2.Text = "Connected as " + adminName; } divFBAuthenticate.Style.Add("width", "374px"); RemoveBtn.Visible = true; ConnectionToFacebook.ImageUrl = "~/Images/socialmedia/clean.png"; divPageMapping.Visible = true; using (Database db = new MySqlDatabase()) { FBPagesList.DataSource = db.getAdminFBPages(); FBPagesList.DataTextField = "Value"; FBPagesList.DataValueField = "Key"; FBPagesList.DataBind(); FBPagesList.Items.Insert(0, new ListItem("--Select--", "Select")); GenreList.DataSource = db.getGenreList(); GenreList.DataTextField = "Value"; GenreList.DataValueField = "Key"; GenreList.DataBind(); GenreList.Items.Insert(0, new ListItem("--Select--", "Select")); GenreList.Items.Insert(1, new ListItem("--Add New Genre--", "Add")); MappingGrid.DataSource = db.getPageGenreMapping(); MappingGrid.DataBind(); } } else { divFBAuthenticate.Style.Add("width", "230px"); HLfbconnect1.Enabled = true; HLfbconnect2.Enabled = true; HLfbLocalize1.Text = Resources.Resource.AuthenticateWithFacebook; HLfbLocalize2.Text = Resources.Resource.AuthenticateWithFacebook; RemoveBtn.Visible = false; ConnectionToFacebook.ImageUrl = "~/Images/socialmedia/Redcross.png"; divPageMapping.Visible = false; try { using (Database db = new MySqlDatabase()) { db.deleteAdminFBCred(); } } catch { } } } } if (Convert.ToString(Session["culture"]).Contains("nl")) { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageNL" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageUS" + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "HighLightLangBtn", "HighLightLangBtn('" + "ctl00_LanguageUS" + "');", true); ClientScript.RegisterStartupScript(this.GetType(), "UnHighLightLangBtn", "UnHighLightLangBtn('" + "ctl00_LanguageNL" + "');", true); } }
protected void BtnMap_Click(object sender, EventArgs e) { if (Session["AdminLogin"] != null) { MappingGrid.DataSource = null; MappingGrid.DataBind(); if (ViewState["PageId"] == null) { ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Please select a facebook page from list." + "');", true); } if (Convert.ToString(ViewState["PageId"]).Contains("Select")) { ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Please select a facebook page from list." + "');", true); } else if (ViewState["GenreID"] == null) { ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Please select a genre from list to map facebook page and genre. And select a sub genre from list to map facebook page and sub genre." + "');", true); } else if (Convert.ToString(ViewState["GenreID"]).Contains("Select") || Convert.ToString(ViewState["GenreID"]).Contains("Add")) { ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Please select a genre from list to map facebook page and genre. And select a sub genre from list to map facebook page and sub genre." + "');", true); } else { using (Database db = new MySqlDatabase()) { int genreid = 0; string genretype = string.Empty; if (ViewState["SubGenreID"] != null) { if (Convert.ToString(ViewState["SubGenreID"]).Contains("Select") || Convert.ToString(ViewState["SubGenreID"]).Contains("Add")) { genreid = Convert.ToInt32(ViewState["GenreID"]); genretype = "genre"; } else { genreid = Convert.ToInt32(ViewState["SubGenreID"]); genretype = "subgenre"; } } else { genreid = Convert.ToInt32(ViewState["GenreID"]); genretype = "genre"; } if (db.AddGenreMapping(Convert.ToInt32(ViewState["PageId"]), genreid, genretype) == false) { switch (genretype) { case "genre": ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Mapping done between genre and facebook page." + "');", true); break; case "subgenre": ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Mapping done between sub-genre and facebook page." + "');", true); break; } } else { switch (genretype) { //case "genre": // ClientScript.RegisterStartupScript // (this.GetType(), "alert", "alert('" + "Mapping already exist between this genre and facebook page." + "');", true); // break; //case "subgenre": // ClientScript.RegisterStartupScript // (this.GetType(), "alert", "alert('" + "Mapping already exist between this sub-genre and facebook page." + "');", true); // break; case "genre": ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Mapping done between genre and facebook page." + "');", true); break; case "subgenre": ClientScript.RegisterStartupScript (this.GetType(), "alert", "alert('" + "Mapping done between sub-genre and facebook page." + "');", true); break; } } MappingGrid.DataSource = db.getPageGenreMapping(); MappingGrid.DataBind(); } } } }
protected void DeleteSubgenre_Click(object sender, EventArgs e) { using (Database db = new MySqlDatabase()) { SubGenreList.DataSource = null; SubGenreList.DataBind(); MappingGrid.DataSource = null; MappingGrid.DataBind(); db.DeleteSubGenre(Convert.ToInt32(ViewState["SubGenreID"])); SubGenreList.DataSource = db.getSubGenreList(Convert.ToInt32(ViewState["GenreID"])); SubGenreList.DataTextField = "Value"; SubGenreList.DataValueField = "Key"; SubGenreList.DataBind(); SubGenreList.Items.Insert(0, new ListItem("--Select--", "Select")); SubGenreList.Items.Insert(1, new ListItem("--Add New Sub Genre--", "Add")); MappingGrid.DataSource = db.getPageGenreMapping(); MappingGrid.DataBind(); } EditSubGenre.Visible = false; divAddSubGenre.Visible = false; divDeleteSubGenre.Visible = false; }