protected void ddlAction_SelectedIndexChanged(object sender, EventArgs e) { string str = ((Label)((DropDownList)sender).Parent.FindControl("lblddlActionNewsID")).Text; string ddlSelectedValue = ((DropDownList)sender).SelectedValue; if (ddlSelectedValue == "Edit") { funClearData(); FillSport(); FillCountry(); FillEvent(); FillSeason(); FillCompetition(); FillClub(); FillClubOwner(); FillClubMember(); FillTeam(); FillTeamMember(); FillPlayer(); FillSponsor(); int NewsID = 0; int.TryParse(str, out NewsID); LinkButton btn = sender as LinkButton; clsNews cs = new clsNews(); clsNewsController csc = new clsNewsController(); DataTable dt = new DataTable(); dt = csc.GetNewsDataByNewsID(NewsID); if (dt.Rows.Count > 0) { hidRegID.Value = dt.Rows[0]["NewsId"].ToString(); ddlSports.SelectedValue = dt.Rows[0]["SportId"].ToString(); ddlSeason.SelectedValue = dt.Rows[0]["SeasonId"].ToString(); ddlCompetition.SelectedValue = dt.Rows[0]["CompetitionId"].ToString(); ddlClub.SelectedValue = dt.Rows[0]["ClubId"].ToString(); ddlClubOwner.SelectedValue = dt.Rows[0]["ClubOwnersId"].ToString(); ddlClubMember.SelectedValue = dt.Rows[0]["ClubMemberId"].ToString(); ddlTeam.SelectedValue = dt.Rows[0]["TeamId"].ToString(); ddlTeamMember.SelectedValue = dt.Rows[0]["TeamMemberId"].ToString(); ddlPlayer.SelectedValue = dt.Rows[0]["PlayerId"].ToString(); ddlEvent.SelectedValue = dt.Rows[0]["EventId"].ToString(); ddlSponsor.SelectedValue = dt.Rows[0]["SponsorId"].ToString(); ddlCountry.SelectedValue = dt.Rows[0]["CountryID"].ToString(); ddlNewsPriority.SelectedValue = dt.Rows[0]["NewsLevelId"].ToString(); txtNewsTitle.Text = dt.Rows[0]["NewsTitle"].ToString(); txtNewsDesc.Text = dt.Rows[0]["NewsDesc"].ToString(); txtNewText.Text = dt.Rows[0]["NewsText"].ToString(); txtNewsDate.Text = dt.Rows[0]["NewsDate"].ToString(); NewsLogoImage.ImageUrl = dt.Rows[0]["NewsPicture"].ToString(); string ufname = dt.Rows[0]["NewsPicture"].ToString().Replace(" ", ""); NewsLogoFile.ResolveUrl("ufname"); txtVideoPath.Text = dt.Rows[0]["NewsVideo"].ToString(); HtmlGenericControl contentPanel1 = (HtmlGenericControl)this.FindControl("ifmOtherVideoPath"); contentPanel1.Attributes["src"] = "DesktopModules\\ThSportSite\\" + dt.Rows[0]["NewsOtherVideoPath"].ToString(); if (dt.Rows[0]["VideoType"].ToString() == "1") { ddlvideotype.SelectedValue = "YouTube"; divvideopath.Visible = true; divOtherVideoPath.Visible = false; ifmOtherVideoPath.Visible = false; } else { ddlvideotype.SelectedValue = "Other"; divvideopath.Visible = false; divOtherVideoPath.Visible = true; ifmOtherVideoPath.Visible = true; } if (dt.Rows[0]["ActiveFlagId"].ToString() == "1") { ChkIsActive.Checked = true; } else { ChkIsActive.Checked = false; } if (dt.Rows[0]["ShowFlagId"].ToString() == "1") { ChkIsShow.Checked = true; } else { ChkIsShow.Checked = false; } pnlEntryNews.Visible = true; PnlGridNews.Visible = false; btnUpdateNews.Visible = true; btnSaveNews.Visible = false; } } else if (ddlSelectedValue == "Delete") { //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "javascript:confirm('Are You Sure? Want To Delete.');", true); //Page.ClientScript.RegisterStartupScript(this.GetType(), "confirm", "javascript:Confirmation();", true); //int competition_Id = 0; //int.TryParse(str, out competition_Id); //CompRegInfo.DeleteCompetitionReg(competition_Id); //FillGridView(); } }
protected void btnUpdateNews_Click(object sender, EventArgs e) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "UpdateSuccessfully()", true); Boolean FileOK = false; Boolean FileSaved = false; cs.NewsId = Convert.ToInt32(hidRegID.Value); if (ddlSports.SelectedValue == "") { cs.SportsId = 0; } else { cs.SportsId = Convert.ToInt32(ddlSports.SelectedValue); } if (ddlCountry.SelectedValue == "") { cs.CountryId = 0; } else { cs.CountryId = Convert.ToInt32(ddlCountry.SelectedValue); } if (ddlEvent.SelectedValue == "") { cs.EventId = 0; } else { cs.EventId = Convert.ToInt32(ddlEvent.SelectedValue); } if (ddlSeason.SelectedValue == "") { cs.SeasonId = 0; } else { cs.SeasonId = Convert.ToInt32(ddlSeason.SelectedValue); } if (ddlCompetition.SelectedValue == "") { cs.CompetitionId = 0; } else { cs.CompetitionId = Convert.ToInt32(ddlCompetition.SelectedValue); } if (ddlClub.SelectedValue == "") { cs.ClubId = 0; } else { cs.ClubId = Convert.ToInt32(ddlClub.SelectedValue); } if (ddlClubOwner.SelectedValue == "") { cs.ClubOwnersId = 0; } else { cs.ClubOwnersId = Convert.ToInt32(ddlClubOwner.SelectedValue); } if (ddlClubMember.SelectedValue == "") { cs.ClubMemberId = 0; } else { cs.ClubMemberId = Convert.ToInt32(ddlClubMember.SelectedValue); } if (ddlTeam.SelectedValue == "") { cs.TeamId = 0; } else { cs.TeamId = Convert.ToInt32(ddlTeam.SelectedValue); } if (ddlTeamMember.SelectedValue == "") { cs.TeamMemberId = 0; } else { cs.TeamMemberId = Convert.ToInt32(ddlTeamMember.SelectedValue); } if (ddlPlayer.SelectedValue == "") { cs.PlayerId = 0; } else { cs.PlayerId = Convert.ToInt32(ddlPlayer.SelectedValue); } if (ddlSponsor.SelectedValue == "") { cs.SponsorId = 0; } else { cs.SponsorId = Convert.ToInt32(ddlSponsor.SelectedValue); } cs.NewsTitle = txtNewsTitle.Text.Trim(); cs.NewsDesc = txtNewsDesc.Text.Trim(); cs.NewsText = txtNewText.Text.Trim(); cs.NewsDate = txtNewsDate.Text.Trim(); if (NewsLogoFile.PostedFile.FileName == "") { DataTable dt1 = new DataTable(); cs.NewsId = Convert.ToInt32(hidRegID.Value); dt1 = csc.GetNewsLogoByNewsID(cs); NewsLogoImage.ImageUrl = dt1.Rows[0]["NewsPicture"].ToString(); string ufname = dt1.Rows[0]["NewsPicture"].ToString().Replace(" ", ""); NewsLogoFile.ResolveUrl("ufname"); cs.NewsPicture = ufname.Replace(" ", ""); FileOKForUpdate = true; } else { cs.NewsPicture = imhpathDB + NewsLogoFile.PostedFile.FileName.Replace(" ", ""); if (NewsLogoFile.PostedFile != null) { String FileExtension = Path.GetExtension(NewsLogoFile.PostedFile.FileName.Replace(" ", "")).ToLower(); String[] allowedExtensions = { ".png", ".jpg", ".gif", ".jpeg" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (FileExtension == allowedExtensions[i]) { FileOK = true; break; } } } if (!string.IsNullOrEmpty(NewsLogoFile.PostedFile.FileName)) { if (!FileOK) { //Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please choose only .jpg, .png and .gif images For Competition !')", true); return; } } if (FileOK) { if (NewsLogoFile.PostedFile.ContentLength > 10485760) { //dvMsg.Attributes.Add("style", "display:block;"); //return; } else { //dvMsg.Attributes.Add("style", "display:none;"); } try { NewsLogoFile.PostedFile.SaveAs(physicalpath + ImageUploadFolder + NewsLogoFile.PostedFile.FileName.Replace(" ", "")); FileSaved = true; } catch (Exception ex) { FileSaved = false; } } } if (ddlvideotype.SelectedValue == "YouTube") { cs.VideoType = 1; // string youtubelink = "http://www.youtube.com/embed/"; string videopath = txtVideoPath.Text; //youtubelink cs.NewsVideo = videopath; } else { cs.VideoType = 2; if (NewsVideoLogoFile.PostedFile.FileName == "") { DataTable dt = new DataTable(); cs.NewsId = Convert.ToInt32(hidRegID.Value); dt = csc.GetOtherVideoPathByNewsID(cs); string ufname = dt.Rows[0]["NewsOtherVideoPath"].ToString().Replace(" ", ""); cs.NewsOtherVideoPath = ufname; } else { if (NewsVideoLogoFile.PostedFile != null) { cs.NewsOtherVideoPath = videohpathDB + NewsVideoLogoFile.PostedFile.FileName.Replace(" ", ""); String FileExtension = Path.GetExtension(NewsVideoLogoFile.PostedFile.FileName.Replace(" ", "")).ToLower(); String[] allowedExtensions = { ".flv", ".webm", ".mkv", ".vob", ".ogv", ".ogg", ".avi", ".mov", ".wmv", ".rm", ".mp4", ".m4p", ".m4v", ".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v", ".svi", ".3gp", ".3g2", ".nsv", ".asf", ".asx", ".srt", ".swf" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (FileExtension == allowedExtensions[i]) { FileOK = true; break; } } } if (FileOK) { try { NewsVideoLogoFile.PostedFile.SaveAs(physicalpath + VideoUploadFolder + NewsVideoLogoFile.PostedFile.FileName.Replace(" ", "")); FileSaved = true; } catch (Exception ex) { FileSaved = false; } } } } if (ChkIsActive.Checked == true) { cs.ActiveFlagId = 1; } else { cs.ActiveFlagId = 0; } if (ChkIsShow.Checked == true) { cs.ShowFlagId = 1; } else { cs.ShowFlagId = 0; } cs.NewsLevelId = ddlNewsPriority.SelectedValue; cs.PortalID = PortalId; cs.CreatedById = currentUser.Username; cs.ModifiedById = currentUser.Username; int eventid = csc.UpdateNews(cs); int evid = csc.UpdateNewsLinks(cs); pnlEntryNews.Visible = false; PnlGridNews.Visible = true; FillGridView(); funClearData(); }