SqlConnection conn = new SqlConnection(\Catalog=studentInfo;Integrated Security=SSPI;\); //取出连接字符串 string SqlStr = \; DataSet ds = new DataSet();
if (conn.State.ToString() == \) //如果连接关闭,打开
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
da.Fill(ds);
if (conn.State.ToString() == \)
conn.Close(); } }
protected void Button1_Click(object sender, EventArgs e)
{
GridViewBind(); }
private void GridViewBind()
{
string connStr = \
Security=SSPI;\;
string SqlStr = \* from users where userName='\ + TextBox1.Text.ToString().Trim() + \;
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(connStr); try
{
if (conn.State.ToString() == \)
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SqlStr, conn);
da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView; GridView1.DataBind(); }
catch (Exception ex)
{
Response.Write(\数据库错误,错误原因:\ + ex.Message);
Response.End(); }
finally
{
if (conn.State.ToString() == \)
conn.Close();
} }}
10
3.2.3 管理员登录管理界面
11
3.2.4添加功能模块
主要代码:
protected void Button1_Click1(object sender, EventArgs e)
{
string sex;
string userid = this.txtName.Text; string userpwd = this.txtPwd.Text; string username = this.userName.Text; string minzu = this.minzu.Text; string birthday = this.bd.Text; string intime = this.intime.Text; string uclass = this.uclass.Text; string comefrom = this.dr.Text; string beizhu = this.beizhu.Text;
if (this.RadioButton1.Checked == true)
{
sex = \男\;
}
else
{
sex = \女\;
}
12
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings[\].ToString()); string sql1 = string.Format(\
(userid,username,sex,minzu,birthday,intime,uclass,comefrom,beizhu) values('\ + userid + \ +
username + \ + sex + \ + minzu + \ + birthday + \ + intime + \ + uclass + \ + comefrom + \ + beizhu + \); string sql = string.Format(%users (userid,userpwd,username) values('\ + userid + \ + userpwd + \ + username + \); SqlCommand cmd1 = new SqlCommand(sql1, conn); SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
if (cmd1.ExecuteNonQuery() > 0)
{
if (cmd.ExecuteNonQuery() > 0)
{
conn.Close();
Response.Write(\添加成功!');window.location =
window.location;\); }
else
{
Response.Write(\添加失败!');window.location = window.location;\);
} }
}
13
3.2.5编辑和删除功能模块
删除主要代码:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString(); SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrings[\].ToString());//创建连接对象号
string SqlStr = \+id +\;
try
{
if (conn.State.ToString() == \)
conn.Open();
SqlCommand comm = new SqlCommand(SqlStr, conn); comm.ExecuteNonQuery(); //执行删除
comm.Dispose();
if (conn.State.ToString() == \)
conn.Close();
GridView1.EditIndex = -1; GridViewBind(); }
14
catch (Exception ex)
{
Response.Write(\数据库错误,错误原因:\ + ex.Message);
Response.End(); }
总结
经过一段时间的学生信息管理系统的设计,我在这次设计网页中锻炼了自我动手能力,增强了操作能力和分析逻辑能力。可能该网站还存在着许多不尽如人意的地方,我会进一步改善,正所谓任何设计都需要较长的一段时间来维护和管理。
在本次的课程设计中,在学习管理信息系统分析与设计的基础上对系统设计有了更深刻的了解,也有了更强的巩固和加深了ASP.NET动态网页设计、SQL Server 2005和Visual Studio 2008的应用能力。经过多次调试后,该系统能够完成学生、课程、成绩的相关管理,还对添加学生中进行了AJAX学号认证,防止输入相同的学号所带来的很多无效操作。
我知道在此次的学生信息管理系统网站设计中有许多的欠缺,在以后的日子中,我一定得更加严格要求自己,改正缺点,不断努力,不断进步,争取做到更好。
参考资料
1.《管理信息系统分析与设计》,邝孔武 编著,西安电子科技大学出版社 2006年12月 2.《ASP.NET 基础与案例开发详解》编著:易巍 张新颖 清华大学出版社 2009年8月 3.《ASP.NET 程序设计与软件项目实训》编著:郑伟 清华大学出版社 2009年3月
4.《数据库技术与应用——SQL Sever 2005》编著:张建伟 人民邮政出版社 2009年2月 5.《Visual C# 2008 入门经典》编著:James Foxall 人民邮政出版社 2009年6月
15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库net学生信息系统项目设计报告(3)在线全文阅读。
相关推荐: