protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["NewsID"] != null) { Label1.Text = "Update News"; int NewsID = Convert.ToInt32(Request.QueryString["NewsID"]); Project.Entity.News news = Project.Entity.NewList.GetNews(NewsID); FileUpload1.Attributes.Add("onchange", "return checkFileExtension(this);"); StartDate.Text = news.StartDate.ToString(); TextBox1.Text = news.Imglink; filename.Text = news.NewsDocx; TitleNews.Text = news.NewTitle; btnAddNews.Text = "Save"; listType.DataTextField = "TypeName"; listType.DataValueField = "TypeID"; listType.SelectedIndex = news.TypeID - 1; listType.DataSource = Project.Data.TypeNewsDAO.GetAllType(); listType.DataBind(); } else { Label1.Text = "Add News"; FileUpload1.Attributes.Add("onchange", "return checkFileExtension(this);"); StartDate.Text = DateTime.Now.ToString(); listType.DataTextField = "TypeName"; listType.DataValueField = "TypeID"; listType.DataSource = Project.Data.TypeNewsDAO.GetAllType(); listType.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { int id = 1; if (Request.QueryString["id"] != null) { id = Convert.ToInt32(Request.QueryString["id"]); } Project.Entity.News news = Project.Entity.NewList.GetNews(id); contentNews.Src = @"~/HtmlNews/" + news.NewsDocx + ".html"; string text = news.NewTitle; if (news.NewTitle == null) { Response.Redirect("ErrorPage.aspx"); } List <Project.Entity.Banner> bannerList = Project.Entity.BannerList.GetAllBanner(); Random r = new Random(); int bannerid = r.Next(1, bannerList.Count - 1); Label2.Text = news.StartDate.ToString(); banner.ImageUrl = @"~\Banner Vertical\" + bannerList[bannerid].AdvertisementImage; dlNews.DataSource = Project.Data.NewDAO.GetRandomTop3(id); dlNews.DataBind(); rpComment.DataSource = Project.Data.CommentDAO.GetCommentByNewsID(id); rpComment.DataBind(); } else { if (Request.QueryString["cmtID"] != null) { int cmtID = Convert.ToInt32(Request.QueryString["cmtID"]); } } } catch (Exception) { Response.Redirect("ErrorPage.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { newsSpec = Project.Entity.NewList.GetTop1News(); if (!IsPostBack) { NewsSpecs.ImageUrl = @"~\logo\" + newsSpec.Imglink; btnNewsSpecs.Text = newsSpec.NewTitle; dlNews.DataSource = Project.Data.NewDAO.GetTop10News(); dlNews.DataBind(); rpRandomNews.DataSource = Project.Data.NewDAO.GetLittleNewsHome(); rpRandomNews.DataBind(); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { int ID = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString()); if (dataGridView1.Columns[e.ColumnIndex].Name == "DeleteNews" && !Status) { DialogResult result = MessageBox.Show("Do you want to delete this News?", "Confirm!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Project.Data.NewDAO.DeleteNews(ID); LoadDataNews(); } } else { if (!Status) { Project.Entity.News GetNews = Project.Entity.NewList.GetNews(ID); DetailForm detail = new DetailForm(GetNews, this); detail.Show(); } } if (dataGridView1.Columns[e.ColumnIndex].Name == "DeleteUser") { DialogResult result = MessageBox.Show("Do you want to delete this Member?", "Confirm!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Project.Data.UserInfoDAO.DeleteUser(Convert.ToInt32(ID)); LoadDataMember(); } } else { if (Status) { Project.Entity.UserInfo User = Project.Entity.UserInfoList.GetUserByID(ID); DetailUser detail = new DetailUser(User, this); detail.Show(); } } } catch (Exception) {} }