温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:商务维基网源码
当前文件:
MerchantViki/ArticleList.aspx.cs,打开代码结构图
MerchantViki/ArticleList.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Data.SqlClient; 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
13
public partial class ArticleList : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
this.Header.Title = Application.Get("siteName") + "---" + this.Header.Title; 18
19
if (Request.Params["EditionID"] != null) 20
{ 21
int editionID = int.Parse(Request.Params["EditionID"]); 22
//info.Text = editionID.ToString(); 23
if (AddClick(editionID)) 24
{ 25
26
info.Text = "操纵成功"; 27
} 28
else 29
{ 30
info.Text = "操纵错误"; 31
} 32
} 33
else 34
{ 35
info.Text = "版块未选定!"; 36
} 37
} 38
39
private bool AddClick(int id) 40
{ 41
try 42
{ 43
string conStr = Application.Get("conStr").ToString(); 44
SqlConnection sqlCon = new SqlConnection(conStr); 45
sqlCon.Open(); 46
SqlCommand sqlCmd = new SqlCommand(); 47
48
string cmdStr = "select click,name from edition where id = "+ id +" "; 49
sqlCmd.CommandText = cmdStr; 50
sqlCmd.Connection = sqlCon; 51
SqlDataReader sqlDR = sqlCmd.ExecuteReader(); 52
53
if (sqlDR.Read()) 54
{ 55
int click = int.Parse(sqlDR.GetValue(0).ToString()) + 1; 56
Edition.Text = sqlDR.GetValue(1).ToString().Trim() + Edition.Text; 57
sqlDR.Close(); 58
cmdStr = "update edition set click = "+ click +" where id = "+ id +""; 59
sqlCmd.CommandText = cmdStr; 60
sqlCmd.ExecuteNonQuery(); 61
62
sqlCon.Close(); 63
return true; 64
} 65
else 66
{ 67
sqlDR.Close(); 68
sqlCon.Close(); 69
return false; 70
} 71
} 72
catch (Exception ex) 73
{ 74
//info.Text = ex.Message; 75
throw new Exception(ex.Message, ex); 76
return false; 77
} 78
} 79
80
} 81





}
}