温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:小范企业管理源码
当前文件路径:XiaoFanWeb/admin/news_Add.aspx.cs

1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.IO; 12
using System.Data.OleDb; 13
public partial class admin_news_Add : System.Web.UI.Page 14
{ 15
16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
if (!IsPostBack) 19
{ 20
if (Request.QueryString["id"] !=null) 21
{ 22
string ID = Request.QueryString["ID"]; 23
OleDbConnection oledbcon = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + HttpContext.Current.Server.MapPath(@"~/App_Data/dbs.mdb")); 24
string SelString = "select * from FZ_News where id="+ID; 25
oledbcon.Open(); 26
//OleDbCommand cmd = new OleDbCommand(SelString, oledbcon); 27
OleDbDataAdapter oda = new OleDbDataAdapter(SelString, oledbcon); 28
DataSet ds = new DataSet(); 29
oda.Fill(ds, "temp"); 30
NTitle.Text = ds.Tables["temp"].Rows[0]["Title"].ToString(); 31
Nfrom.Text = ds.Tables["temp"].Rows[0]["Fr"].ToString(); 32
//Nhit.Text = ds.Tables["temp"].Rows[0]["Hit"].ToString(); 33
Ninfo.Text = ds.Tables["temp"].Rows[0]["Info"].ToString(); 34
if (ds.Tables["temp"].Rows[0]["Top"].ToString() == "False") 35
{ 36
Ntop.Checked = false; 37
Label1.Text = "当前状态不置顶!"; 38
} 39
else 40
{ 41
Ntop.Checked = true; 42
Label1.Text = "当前状态置顶!"; 43
} 44
45
oledbcon.Close(); 46
47
} 48
49
} 50
} 51
protected void btn_ok_Click(object sender, EventArgs e) 52
{ 53
try 54
{ 55
string UpString; 56
UpString = ""; 57
string Title, Nfr, Info, Img, Tid ,Addtime; 58
bool Top; 59
Title = NTitle.Text.ToString(); 60
Nfr = Nfrom.Text.ToString(); 61
Info = Ninfo.Text.ToString(); 62
Tid = Ntype.SelectedValue.ToString(); 63
Img = Nimg.Text.ToString(); 64
//if (Ntop.Checked.ToString() == "True") 65
//{ 66
// Top = true; 67
//} 68
//else 69
//{ 70
// Top = false; 71
//} 72
if (Request.QueryString["id"] == null) 73
{//,Top 74
//"+Top+", 75
UpString = "insert into FZ_News(Title,Fr,Info,Img,Tid)values('" + Title + "','" + Nfr + "','" + Info + "','" + Img + "','" + Tid + "')"; 76
} 77
OleDbConnection oledbcon = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + HttpContext.Current.Server.MapPath(@"~/App_Data/dbs.mdb")); 78
oledbcon.Open(); 79
OleDbCommand cmd = new OleDbCommand(UpString, oledbcon); 80
cmd.ExecuteNonQuery(); 81
oledbcon.Close(); 82
83
} 84
catch (Exception M) 85
{ 86
Response.Write(M.Message); 87
} 88
} 89
} 90





}
}