温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:jimmyNews(Asp.net新闻系统)1.0源码
当前文件:
jimmyNews/Admin/class/Add.aspx.cs[3K,2009-6-12 11:45:38],打开代码结构图
jimmyNews/Admin/class/Add.aspx.cs[3K,2009-6-12 11:45:38],打开代码结构图1using System; 2
using System.Data; 3
using System.Data.OleDb; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
using Wuqi.Webdiyer; 13
using CFCHINA.TOOLS.ACCESS; 14
using CFCHINA.TOOLS.EnDecode; 15
using CFCHINA.TOOLS.COMM; 16
17
public partial class Admin_Class_Add : System.Web.UI.Page 18
{ 19
private DataBase db = new DataBase(); 20
private Tools tl = new Tools(); 21
private OleDbConnection conn = null; 22
private string strSql = ""; 23
24
protected void Page_Load(object sender, EventArgs e) 25
{ 26
InitPage(); 27
28
if (!IsPostBack) 29
{ 30
hdPage.Value = tl.GetPageIndex(); 31
txtOrder.Text = getMaxOrder(); 32
} 33
} 34
35
protected void InitPage() 36
{ 37
this.Page.Title = ConfigurationManager.AppSettings["webtitle"].ToString() + "_增加分类"; 38
((Label)(this.Master.FindControl("lblTitle"))).Text = "分类列表_增加分类"; 39
40
41
} 42
43
/// <summary> 44
/// 添加用户 45
/// </summary> 46
protected void AddData(string goUrl) 47
{ 48
try 49
{ 50
strSql = "select * from cf_Class where ucase(trim(cf_Name))='" + tl.GetSafeStr(this.txtClassName.Text.ToUpper().Trim()) + "'"; 51
if (db.ExistDate(strSql)) 52
{ 53
tl.Alert("该分类已经存在,请检查!", "javascript:window.history.back();"); 54
} 55
else 56
{ 57
conn = db.GetConn(); 58
Guid GID = tl.NewComb(); 59
60
string[] f = {"cf_id", "cf_Name", "cf_ReadMe","cf_Sort"}; 61
string[] v = { GID.ToString(), this.txtClassName.Text, this.txtReadme.Text,this.txtOrder.Text}; 62
63
if (db.InsertData("cf_Class", f, v)) 64
{ 65
tl.Alert("增加记录成功!", goUrl); 66
} 67
else 68
{ 69
tl.Alert("增加记录失败!", "javascript:window.history.back()"); 70
} 71
72
} 73
74
} 75
catch (Exception ex) 76
{ 77
tl.Alert(ex.Message.ToString().Replace("'", ""), "javascript:window.history.back()"); 78
} 79
80
} 81
82
protected void btnAdd_Click(object sender, EventArgs e) 83
{ 84
AddData("default.aspx?page=" + hdPage.Value); 85
} 86
87
protected void btnAddNew_Click(object sender, EventArgs e) 88
{ 89
AddData("Add.aspx?page=" + hdPage.Value); 90
} 91
92
/// <summary> 93
/// 得到最大排序号 94
/// </summary> 95
/// <returns></returns> 96
protected string getMaxOrder() { 97
strSql = "select Max(cf_Sort) from cf_Class"; 98
string result = "0"; 99
conn = db.GetConn(); 100
OleDbDataReader dr = db.RunSql(strSql,conn); 101
if (dr.HasRows) { 102
if (dr.Read()) { 103
result = dr[0].ToString(); 104
} 105
} 106
dr.Close(); 107
db.Dispose(conn); 108
return result; 109
} 110
} 111






}
}