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


当前文件路径:Votes/App_Code/Items.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 12/// <summary> 13/// Items 的摘要说明 14/// </summary> 15public interface IItems 16{ 17 SqlDataReader GetItemBySubject(int sid); 18 SqlDataReader GetSumItemsBySubject(int sid); 19 int DeleteItem(int iid); 20 int AddItem(string iname, int isid); 21 int UpdateItem(string iname, int iid); 22 SqlDataReader GetSingleItem(int iid); 23 int AddItemCount(int iid); 24 SqlDataReader GetIsRepeat(); 25 int UpdateIsRepeat(string isRepeat); 26} 27 28public class Items : IItems 29{ 30 public int UpdateIsRepeat(string isRepeat) 31 { 32 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 33 string cmd = "update Profiles set p_IsRepeat='" + isRepeat + "'"; 34 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 35 int nResult; 36 try 37 { 38 myConnection.Open(); 39 nResult = myCommand.ExecuteNonQuery(); 40 } 41 catch (SqlException ex) 42 { 43 throw new Exception(ex.Message, ex); 44 } 45 finally 46 { 47 myConnection.Close(); 48 } 49 return nResult; 50 } 51 52 public SqlDataReader GetIsRepeat() 53 { 54 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 55 string cmd = "select * from Profiles"; 56 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 57 SqlDataReader dr = null; 58 try 59 { 60 myConnection.Open(); 61 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 62 } 63 catch (SqlException ex) 64 { 65 throw new Exception(ex.Message, ex); 66 } 67 return dr; 68 } 69 70 public int AddItemCount(int iid) 71 { 72 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 73 string cmd = "update Items set i_count=i_count+1 where i_id='"+iid.ToString()+"'"; 74 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 75 int nResult; 76 try 77 { 78 myConnection.Open(); 79 nResult = myCommand.ExecuteNonQuery(); 80 } 81 catch (SqlException ex) 82 { 83 throw new Exception(ex.Message, ex); 84 } 85 finally 86 { 87 myConnection.Close(); 88 } 89 return nResult; 90 } 91 92 public SqlDataReader GetSingleItem(int iid) 93 { 94 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 95 string cmd = "select * from Items where i_id='" + iid.ToString() + "'"; 96 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 97 SqlDataReader dr = null; 98 try 99 { 100 myConnection.Open(); 101 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 102 } 103 catch (SqlException ex) 104 { 105 throw new Exception(ex.Message, ex); 106 } 107 return dr; 108 } 109 110 public int UpdateItem(string iname, int iid) 111 { 112 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 113 string cmd = "update Items set i_name='" + iname.ToString() + "' where i_id='" + iid.ToString() + "'"; 114 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 115 int nResult; 116 try 117 { 118 myConnection.Open(); 119 nResult = myCommand.ExecuteNonQuery(); 120 } 121 catch (SqlException ex) 122 { 123 throw new Exception(ex.Message, ex); 124 } 125 finally 126 { 127 myConnection.Close(); 128 } 129 return nResult; 130 } 131 132 public int AddItem(string iname, int isid) 133 { 134 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 135 string cmd = "insert into Items(i_name,i_sid) values('" + iname.ToString() + "','" + isid.ToString() + "')"; 136 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 137 int nResult; 138 try 139 { 140 myConnection.Open(); 141 nResult = myCommand.ExecuteNonQuery(); 142 } 143 catch (SqlException ex) 144 { 145 throw new Exception(ex.Message, ex); 146 } 147 finally 148 { 149 myConnection.Close(); 150 } 151 return nResult; 152 } 153 154 public int DeleteItem(int iid) 155 { 156 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 157 string cmd = "delete from Items where i_id='" + iid.ToString() + "'"; 158 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 159 int nResult; 160 try 161 { 162 myConnection.Open(); 163 nResult = myCommand.ExecuteNonQuery(); 164 } 165 catch (SqlException ex) 166 { 167 throw new Exception(ex.Message, ex); 168 } 169 finally 170 { 171 myConnection.Close(); 172 } 173 return nResult; 174 } 175 176 public SqlDataReader GetSumItemsBySubject(int sid) 177 { 178 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 179 string cmd = "select sum(i_count) as SumVoteCount from Items where i_sid='" + sid.ToString() + "'"; 180 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 181 SqlDataReader dr = null; 182 try 183 { 184 myConnection.Open(); 185 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 186 } 187 catch (SqlException ex) 188 { 189 throw new Exception(ex.Message, ex); 190 } 191 return dr; 192 } 193 194 public SqlDataReader GetItemBySubject(int sid) 195 { 196 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 197 string cmd = "select * from Items where i_sid='"+sid.ToString()+"'"; 198 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 199 SqlDataReader dr = null; 200 try 201 { 202 myConnection.Open(); 203 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 204 } 205 catch (SqlException ex) 206 { 207 throw new Exception(ex.Message, ex); 208 } 209 return dr; 210 } 211} 212
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:简单多功能投票/调查系统源码

- ASP.NET通用权限管理系统1.0..

- TreeGrid控件及Demo源码

- 多功能在线考试系统改进版源码

- 基于NBear的简易AJAX留言板案..

- Ajax之用户注册实例源码

- HuGo版文章发布系统(三层MVC..

- Asp.net2.0中GridView、Upda..

- Asp.net2.0用户注册控件使用实例

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