您目前尚未登陆,请选择【登陆】或【注册
首页->投票调查->简单多功能投票/调查系统源码>>App-Code/Topics.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:简单多功能投票/调查系统源码


当前文件路径:Votes/App_Code/Topics.cs 文件类型
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Web; 5using System.Web.Security; 6using System.Web.UI; 7using System.Web.UI.WebControls; 8using System.Web.UI.WebControls.WebParts; 9using System.Web.UI.HtmlControls; 10using System.Data.SqlClient; 11//5-1-aspx 12/// <summary> 13/// Topics 的摘要说明 14/// </summary> 15public interface ITopics 16{ 17 SqlDataReader GetCurrentTopic(); 18 SqlDataReader GetAllTopic(); 19 int AddTopic(string tname, string tcontent); 20 int UpdateTopic(string tname,string tcontent,int tid); 21 int DeleteTopic(int tid); 22 SqlDataReader GetTopic(int tid); 23 int UpdateCurrentTopicByProc(int tid); 24} 25 26public class Topics : ITopics 27{ 28 public int UpdateCurrentTopicByProc(int tid) 29 { 30 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 31 32 SqlCommand myCommand = new SqlCommand("Pro_UpdateCurrentTopic", myConnection); 33 myCommand.CommandType = CommandType.StoredProcedure; 34 SqlParameter pCurrent = new SqlParameter("@t_id", SqlDbType.Int, 4); 35 pCurrent.Value=tid; 36 myCommand.Parameters.Add(pCurrent); 37 int nResult; 38 try 39 { 40 myConnection.Open(); 41 nResult = myCommand.ExecuteNonQuery(); 42 } 43 catch (SqlException ex) 44 { 45 throw new Exception(ex.Message, ex); 46 } 47 finally 48 { 49 myConnection.Close(); 50 } 51 return nResult; 52 } 53 54 public SqlDataReader GetTopic(int tid) 55 { 56 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 57 string cmd = "select * from Topics where t_id='"+tid.ToString()+"'"; 58 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 59 SqlDataReader dr = null; 60 try 61 { 62 myConnection.Open(); 63 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 64 } 65 catch (SqlException ex) 66 { 67 throw new Exception(ex.Message, ex); 68 } 69 return dr; 70 } 71 72 public int DeleteTopic(int tid) 73 { 74 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 75 string cmd = "delete from Topics where t_id='"+tid.ToString()+"'"; 76 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 77 int nResult; 78 try 79 { 80 myConnection.Open(); 81 nResult = myCommand.ExecuteNonQuery(); 82 } 83 catch (SqlException ex) 84 { 85 throw new Exception(ex.Message, ex); 86 } 87 finally 88 { 89 myConnection.Close(); 90 } 91 return nResult; 92 } 93 94 public int UpdateTopic(string tname, string tcontent,int tid) 95 { 96 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 97 string cmd = "update Topics set t_name='"+tname.ToString()+"',t_content='"+tcontent.ToString()+"' where t_id='"+tid.ToString()+"'"; 98 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 99 int nResult; 100 try 101 { 102 myConnection.Open(); 103 nResult = myCommand.ExecuteNonQuery(); 104 } 105 catch (SqlException ex) 106 { 107 throw new Exception(ex.Message, ex); 108 } 109 finally 110 { 111 myConnection.Close(); 112 } 113 return nResult; 114 } 115 116 public int AddTopic(string tname,string tcontent) 117 { 118 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 119 string cmd = "insert into Topics(t_name,t_content) values('"+tname.ToString()+"','"+tcontent.ToString()+"')"; 120 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 121 int nResult; 122 try 123 { 124 myConnection.Open(); 125 nResult = myCommand.ExecuteNonQuery(); 126 } 127 catch (SqlException ex) 128 { 129 throw new Exception(ex.Message, ex); 130 } 131 finally 132 { 133 myConnection.Close(); 134 } 135 return nResult; 136 } 137 138 public SqlDataReader GetAllTopic() 139 { 140 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 141 string cmd = "select * from Topics"; 142 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 143 SqlDataReader dr = null; 144 try 145 { 146 myConnection.Open(); 147 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 148 } 149 catch (SqlException ex) 150 { 151 throw new Exception(ex.Message, ex); 152 } 153 return dr; 154 } 155 156 public SqlDataReader GetCurrentTopic() 157 { 158 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 159 string cmd = "select * from Topics where t_IsCurrent=1"; 160 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 161 SqlDataReader dr = null; 162 try 163 { 164 myConnection.Open(); 165 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 166 } 167 catch (SqlException ex) 168 { 169 throw new Exception(ex.Message, ex); 170 } 171 return dr; 172 } 173} 174
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:简单多功能投票/调查系统源码

- BugTrack免安装英文原版2.4.8

- SCO在线售卡系统(.Net开源版..

- Asp.Net许愿墙系统源码

- Pizza在线订购系统源码

- Asp.net购物车示例源码(VS2005)

- ASP.NET仓库管理系统源码

- 洪病毒单用户Blog系统源码

- Yetanotherforum论坛1.9.1多..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号