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


当前文件路径:Votes/App_Code/Subjects.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/// Subjects 的摘要说明 14/// </summary> 15public interface ISubjects 16{ 17 SqlDataReader GetSubjectByTopic(int tid); 18 int DeleteSubject(int sid); 19 int AddSubject(string sname,int stid); 20 int UpdateSubject(string sname, int sid); 21 SqlDataReader GetSingleSubject(int sid); 22 int UpdateSubjectMode(int sid); 23} 24 25public class Subjects : ISubjects 26{ 27 public int UpdateSubjectMode(int sid) 28 { 29 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 30 string cmd = "update Subjects set s_mode=1 where s_id='" + sid.ToString() + "'"; 31 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 32 int nResult; 33 try 34 { 35 myConnection.Open(); 36 nResult = myCommand.ExecuteNonQuery(); 37 } 38 catch (SqlException ex) 39 { 40 throw new Exception(ex.Message, ex); 41 } 42 finally 43 { 44 myConnection.Close(); 45 } 46 return nResult; 47 } 48 49 public SqlDataReader GetSingleSubject(int sid) 50 { 51 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 52 string cmd = "select * from Subjects where s_id='" + sid.ToString() + "'"; 53 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 54 SqlDataReader dr = null; 55 try 56 { 57 myConnection.Open(); 58 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 59 } 60 catch (SqlException ex) 61 { 62 throw new Exception(ex.Message, ex); 63 } 64 return dr; 65 } 66 67 public int UpdateSubject(string sname, int sid) 68 { 69 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 70 string cmd = "update Subjects set s_name='"+sname.ToString()+"' where s_id='"+sid.ToString()+"'"; 71 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 72 int nResult; 73 try 74 { 75 myConnection.Open(); 76 nResult = myCommand.ExecuteNonQuery(); 77 } 78 catch (SqlException ex) 79 { 80 throw new Exception(ex.Message, ex); 81 } 82 finally 83 { 84 myConnection.Close(); 85 } 86 return nResult; 87 } 88 89 public int AddSubject(string sname, int stid) 90 { 91 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 92 string cmd = "insert into Subjects(s_name,s_tid) values('"+sname.ToString()+"','"+stid.ToString()+"')"; 93 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 94 int nResult; 95 try 96 { 97 myConnection.Open(); 98 nResult = myCommand.ExecuteNonQuery(); 99 } 100 catch (SqlException ex) 101 { 102 throw new Exception(ex.Message, ex); 103 } 104 finally 105 { 106 myConnection.Close(); 107 } 108 return nResult; 109 } 110 111 public int DeleteSubject(int sid) 112 { 113 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 114 string cmd = "delete from Subjects where s_id='" + sid.ToString() + "'"; 115 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 116 int nResult; 117 try 118 { 119 myConnection.Open(); 120 nResult = myCommand.ExecuteNonQuery(); 121 } 122 catch (SqlException ex) 123 { 124 throw new Exception(ex.Message, ex); 125 } 126 finally 127 { 128 myConnection.Close(); 129 } 130 return nResult; 131 } 132 133 public SqlDataReader GetSubjectByTopic(int tid) 134 { 135 SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONNECTIONSTRING"].ConnectionString); 136 string cmd = "select * from Subjects where s_tid='" + tid.ToString() + "'"; 137 SqlCommand myCommand = new SqlCommand(cmd, myConnection); 138 SqlDataReader dr = null; 139 try 140 { 141 myConnection.Open(); 142 dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection); 143 } 144 catch (SqlException ex) 145 { 146 throw new Exception(ex.Message, ex); 147 } 148 return dr; 149 } 150 151}
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:简单多功能投票/调查系统源码

- Ajax入门的三个实用小例子

- 简单数据查询与报表打印系统源码

- DotNetTextBox网页编辑器 V3..

- 明日Asp.net在线论坛源码

- 坏孩子无限级树型菜单(JS+Sql)

- Openlab开源综合社区系统

- 苹果投票系统源码及毕业论文

- B2C电子商务网站系统源码

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