版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.系统源代码一、登录界面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public
2、 partial class login : System.Web.UI.Page protected void txtid_Click(object sender, EventArgs e) txtid.Text = ; txtpassword.Text = ; protected void Button1_Click(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); con
3、n.Open(); DataSet ds=new DataSet () ; SqlDataAdapter da = new SqlDataAdapter(select * from users where userid= + txtid.Text + and userpwd= + txtpassword.Text + , conn); da.Fill(ds); if (ds.Tables0.Rows.Count=0) Label3 .Text =账号或密码错误,请重新输入!; else Session userid=txtid .Text ; Sessionuserpwd = txtpassw
4、ord.Text; Sessionusername = ds.Tables0.Rows0username.ToString(); Sessionuserpower = ds.Tables0.Rows0userpower.ToString(); if (Sessionuserpower.ToString () = 0) Response.Redirect(admin/index.aspx); else if (Sessionuserpower.ToString() = 1) Response.Redirect(student/index.aspx); else Label3.Text = 对不起
5、,权限验证失败; conn.Close(); ds.Clear (); 二、添加课程页面代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;us
6、ing System.Data.SqlClient;public partial class addcourse : System.Web.UI.Page SqlCommand mycmd; SqlConnection conn; protected void Page_Load(object sender, EventArgs e) courseid.Attributes.Add(onblur, checkcourseid(); string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConnection
7、(strconn); protected void Button1_Click(object sender, EventArgs e) if (courseid.Text.ToString() = ) Label7.Text = 课程号不能为空; else string sqlstr = ; sqlstr = insert into course(courseid,coursename,coursetime,fen,type,teacher)values( + courseid.Text + , + coursename.Text + , + coursetime.Text + , + fen
8、.Text + , + type.Text + , + teacher.Text + ); conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); try mycmd.ExecuteNonQuery(); Response.Write(javascript:alert(添加成功!);); catch (SqlException) Response.Write(javascript:alert(添加失败!);); finally conn.Close(); sqlstr = ; protected void Butt
9、on2_Click(object sender, EventArgs e) courseid.Text = ; coursename.Text = ; coursetime.Text = ; fen.Text = ; type.Text = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(course.aspx); 三、添加成绩程序代码using System;using System.Data;using System.Configuration;using System.Collect
10、ions;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addscore : System.Web.UI.Page SqlCommand mycmd; SqlConnection conn; protected
11、 void Page_Load(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConnection(strconn); protected void Button1_Click(object sender, EventArgs e) if (userid.SelectedValue .ToString ()= ) Label11.Text = 学号不能为空; else string sqlstr = ; sqlstr = insert int
12、o score(userid,username,courseid,coursename,score,year)values( + userid.SelectedValue + , + username.Text + , + txtcourseid.SelectedValue + , + coursename.Text + , + score.Text + , + txtyear.SelectedValue + ); conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); try mycmd.ExecuteNonQu
13、ery(); Response.Write(javascript:alert(添加成功!);); catch (SqlException) Response.Write(javascript:alert(添加失败!);); finally conn.Close(); sqlstr = ; protected void Button2_Click(object sender, EventArgs e) username.Text = ; coursename.Text = ; score.Text = ; txtyear.Text = ; protected void Button3_Click
14、(object sender, EventArgs e) Response.Redirect(score.aspx); protected void userid_SelectedIndexChanged(object sender, EventArgs e) string sqlstr = ; sqlstr = select username from students where userid= + userid.SelectedValue + ; conn.Open(); mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); Sql
15、DataReader da; da = mycmd.ExecuteReader(); while (da.Read() username.Text = dausername.ToString(); protected void txtcourseid_SelectedIndexChanged(object sender, EventArgs e) string sqlstr = ; sqlstr = select coursename from course where courseid= + txtcourseid.SelectedValue + ; conn.Open(); mycmd =
16、 new SqlCommand(sqlstr, conn); mycmd.Dispose(); SqlDataReader da; da = mycmd.ExecuteReader(); while (da.Read() coursename.Text = dacoursename.ToString(); 四、添加学生程序代码using System;using System.IO;using System.Text;using System.Data;using System.Configuration;using System.Collections;using System.Web;us
17、ing System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class addstudent : System.Web.UI.Page SqlCommand mycmd; protected void Page_Load(object sender, EventArgs e
18、) userid.Attributes.Add(onblur, checkuserid(); string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); protected void Button1_Click(object sender, EventArgs e) if (userid.Text.ToString() = ) return; string strconn = ConfigurationManager.AppSettingsc
19、onnStr; SqlConnection conn = new SqlConnection(strconn); string sqlstr = ; string sql = ; sqlstr = insert into students(userid,username,sex,minzu,birthday,class,comefrom,beizhu,xuey,zhuany,tel,idc,zhengzmm,zhiw,huoj,weij)values( + userid.Text + , + txtusername.Text + , + txtsex.SelectedItem.Value +
20、, + txtminzu.Text + , + txtbirthday.Text + , + txtclass.Text + , + txtcomefrom.Text + , + txtbeizhu.Text + , + txtxuey.SelectedValue + , + txtzhuany.SelectedValue + , + txttel.Text + , + txtidc.Text + , + txtzzmm.SelectedValue + , + txtzhiw.Text + , + txthuoj.Text + , + txtweij.Text + ); conn.Open()
21、; mycmd = new SqlCommand(sqlstr, conn); mycmd.Dispose(); string name = this.获取上传文件的名称 string type = name.Substring(name.LastIndexOf() + 1);/获取上传文件的后缀 string ipath = Server.MapPath(images/) + DateTime.Now.ToString(yyyyMMddhhmmss) + name; string wpath = images + DateTime.Now.ToString(yyyyMMddhhmmss) +
22、 name; string query1 = insert into images(userid,path) values( + userid.Text + ,path); (ipath); /服务器保存路径 SqlCommand cm = new SqlCommand(query1); cm.Connection = conn; cm.Parameters.Add(path, SqlDbType.VarChar, 50); cm.Parameterspath.Value = wpath; cm.ExecuteNonQuery(); / this.lb_info.Text = 上传成功!; t
23、ry mycmd.ExecuteNonQuery(); string sqlstr1 = ; sqlstr1 = insert into users(userid,username)values( + userid.Text + , + txtusername.Text + ) ; SqlCommand mycmd1 = new SqlCommand(sqlstr1, conn); mycmd1.Dispose(); try mycmd1.ExecuteNonQuery(); Response.Write(javascript:alert(添加成功!);); catch (SqlExcepti
24、on) Response.Write(javascript:alert(添加失败!);); finally sqlstr1 = ; catch (SqlException) Response.Write(javascript:alert(添加失败!);); finally conn.Close(); sqlstr = ; protected void Button2_Click(object sender, EventArgs e) userid.Text = ; txtusername.Text = ; txtminzu.Text = ; txtbirthday.Text = ; txtcl
25、ass.Text = ; txtcomefrom.Text = ; txtbeizhu.Text = ; protected void Button3_Click(object sender, EventArgs e) Response.Redirect(student.aspx); 五、检查课程号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.
26、UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkcourseid : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) Response.Expires = 0; string strconn = ConfigurationMa
27、nager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); string nam = Request.QueryStringname.ToString(); string sql = select courseid from course where courseid= + nam + ; SqlCommand DBHelper; DBHelper = new SqlCommand(sql, conn); conn.Open(); SqlDataReader dr = DBHelper.ExecuteRe
28、ader(); if (dr.Read() Response.Write(该课程号已经存在,请换一个); else Response.Write(该课程号可以使用); dr.Close(); 六、检查学号唯一性程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.
29、Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class checkuser : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) Response.Expires = 0; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new S
30、qlConnection(strconn); string nam = Request.QueryStringname.ToString(); string sql = select userid from students where userid= + nam + ; SqlCommand DBHelper; DBHelper = new SqlCommand(sql, conn); conn.Open(); SqlDataReader dr = DBHelper.ExecuteReader(); if (dr.Read() Response.Write(该学号已经存在,请换一个); el
31、se Response.Write(该学号可以使用); dr.Close(); 七、课程信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControl
32、s;using System.Data.SqlClient;public partial class course : System.Web.UI.Page SqlConnection conn; SqlDataReader getdata; protected void Page_Load(object sender, EventArgs e) string strconn = ConfigurationManager.AppSettingsconnStr; conn = new SqlConnection(strconn); SqlDataReader getdata; SqlComman
33、d mycmd; DataSet ds = new DataSet(); string sql = ; sql = select * from course order by courseid; mycmd = new SqlCommand(sql, conn); conn.Open(); getdata = mycmd.ExecuteReader(); grdMain.DataSource = getdata; grdMain.DataBind(); mycmd.Connection.Close(); conn.Close(); mycmd.Dispose(); protected void
34、 Button1_Click(object sender, EventArgs e) DataSet ds; SqlDataReader da; string strsql = ; SqlCommand cmd; conn.Open(); strsql = select * from course where courseid= + courseid.Text + or coursename like + coursename.Text + ; cmd = new SqlCommand(strsql, conn); da = cmd.ExecuteReader(); Datagrid1.Dat
35、aSource = da; Datagrid1.DataBind(); conn.Close(); cmd.Dispose(); cmd.Connection.Close(); 八、编辑、删除学生信息程序代码using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.U
36、I.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;public partial class images_editstudent : System.Web.UI.Page SqlCommand cmd; SqlCommand cmd2; protected void Page_Load(object sender, EventArgs e) if (!this.IsPostBack) string sql = ; SqlDataReader reader; string uid
37、 = ; uid = Page.Requestid; string strconn = ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); sql = select * from students where userid= + uid + ; SqlCommand cmd; cmd = new SqlCommand(sql, conn); conn.Open(); reader = cmd.ExecuteReader(); while (reader.Read()
38、userid.Text = readeruserId.ToString(); txtusername.Text = readerusername.ToString(); txtsex.SelectedValue = readersex.ToString(); txtminzu.Text = readerminzu.ToString(); txtbirthday.Text = readerbirthday.ToString(); txtclass.Text = readerclass.ToString(); txtcomefrom.Text = readercomefrom.ToString()
39、; txtxuey.Text = readerxuey.ToString(); txtzhuany.Text = readerzhuany.ToString(); txttel.Text = readertel.ToString(); txtidc.Text = readeridc.ToString(); cmd.Dispose(); sql = ; conn.Close(); protected void Button1_Click(object sender, EventArgs e) string uid=; uid=Page .Request id; string strconn =
40、ConfigurationManager.AppSettingsconnStr; SqlConnection conn = new SqlConnection(strconn); string sql=; sql = update students set userid= + userid.Text + ,username= + txtusername.Text + ,minzu= + txtminzu.Text + ,sex= + txtsex.SelectedItem.Value + ,birthday= + txtbirthday.Text + ,class= + txtclass.Te
41、xt + ,comefrom= + txtcomefrom.Text + ,beizhu= + txtbeizhu.Text + ,xuey= + txtxuey.Text + ,zhuany= + txtzhuany.Text + ,tel= + txttel.Text + ,idc= + txtidc.Text + ,zhengzmm= + txtzzmm.SelectedValue + where userid= + uid + ; cmd=new SqlCommand (sql,conn ); conn.Open(); try cmd.ExecuteNonQuery(); Label1
42、1.Stylecolor = blue; Label11.Text = 编辑成功; Response.Write(javascript:alert(编辑成功!);); catch(SqlException ) Label11.Text = 编辑失败; Label11.Stylecolor = red; cmd.Dispose(); conn.Close(); protected void Button2_Click(object sender, EventArgs e) string sql = ; string uid = ; string sqlall = ; uid = Page.Requestid; string strconn = Configura
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 绿化施工劳务合同范例
- 番薯收购合同范例
- 《我国企业资产收购的所得税制度研究》
- 临沂购房合同范例
- 1994版劳动合同范例
- 地磅维保合同范例
- 全新养生会馆合作协议3篇
- 债权债务抵消协议书3篇
- 化肥买卖合同样本3篇
- 办公用品交易协议3篇
- 2024年秋季学期无机化学(药)期末综合试卷-国开(XJ)-参考资料
- 2025年1月浙江省高中学业水平考试政治试卷试题(含答案解析)
- 学校网络合同范例
- 2022-2023学年上海市浦东区高二(上)期末语文试卷
- 【MOOC】英文技术写作-东南大学 中国大学慕课MOOC答案
- 电气工程及其自动化职业规划课件
- 辐射与防护学习通超星期末考试答案章节答案2024年
- 2023年新高考(新课标)全国2卷数学试题真题(含答案解析)
- 建筑施工安全生产治本攻坚三年行动方案(2024-2026年)
- 大学生助农直播创业计划书
- 2-05SFG04 防空地下室室外出入口部钢结构装配式防倒塌棚架结构设计
评论
0/150
提交评论