protected void EditCmd_Click(object sender, EventArgs e) { int NewsID = this.GetNewsID(); AdoSql SqlClass = new AdoSql(); SqlClass.UpdateNews(this.TitleStr.Text, this.ContentTxt.Text, this.GetNewsID()); this.MsgTxt.Text = "修改成功!"; }
private void LoadAllNews() { AdoSql ReadAllNews = new AdoSql(); DataTable NewsTable = ReadAllNews.ReadAllNews(); this.NewsGrid.DataSource = NewsTable; this.NewsGrid.DataBind(); }
protected void CmdAdd_Click(object sender, EventArgs e) { AdoSql AddSql = new AdoSql(); AddSql.AddNews(this.NewsType.SelectedItem.Value, this.TitleStr.Text, this.NameStr.Text, this.ContentTxt.Text); this.MsgTxt.Text = "新聞發布成功!"; this.CmdAdd.Enabled = false; }
protected void NewsGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DelCmd") { int NewsID = Convert.ToInt32(e.CommandArgument); AdoSql SqlDel = new AdoSql(); SqlDel.ExecuteSqlWrite("delete from NewsTxt where NewsID=" + NewsID); this.LoadAllNews(); } }
private void LoadAllType() { AdoSql ReadAllType = new AdoSql(); DataTable Type = ReadAllType.ReadAllType(); this.NewsType.DataSource = Type; this.NewsType.DataTextField = "NewsType"; this.NewsType.DataValueField = "NewsType"; this.NewsType.DataBind(); }
protected void LoginCmd_Click(object sender, EventArgs e) { if (AdoSql.LoginCheck(this.UserNameStr.Text, this.PassWordStr.Text) == true) { Session["UserSession"] = this.UserNameStr.Text; Response.Redirect("MNews.aspx"); } else { MsgTxt.Text = "用戶名或密碼有誤!"; } }
private void ReadNews() { int NewsID = this.GetNewsID(); if (NewsID > 0) { AdoSql SqlClass = new AdoSql(); DataTable NewsTab = SqlClass.ReadNewsByID(NewsID); if (NewsTab.Rows.Count == 1) { this.TitleStr.Text = NewsTab.Rows[0]["TitleStr"].ToString(); this.ContentTxt.Text = NewsTab.Rows[0]["ContentTxt"].ToString(); this.NameStr.Text = NewsTab.Rows[0]["NameStr"].ToString(); this.DateTimeTxt.Text = NewsTab.Rows[0]["DateTimeTxt"].ToString(); } } }