asp net课程设计-教师信息管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

a s p n e t课程设计-教
师信息管理系统
work Information Technology Company.2020YEAR
图2 用户登录界面
系统登录的主要代码如下:
public partial class MyControl_UserLogin : erControl
{
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
}
#region 登录函数
protected void btnLogin_Click(object sender, EventArgs e)
{
//先连接
if (txtPwd .Text == "" ||txtName .Text == "")
{
Response.Write(bc.MessageBox("用户名和密码不能为空"));
return;
}
if (rdoBtnAdmin.Checked ) //管理员登录
{
DataSet ds = bc.GetDataSet("select count(*) from sy_sysUser where userName='" + txtName.Text + "'and userPwd='" + txtPwd.Text + "'and system=1","sy_sysUser");
}
}
#endregion
protected void btnCancel_Click(object sender, EventArgs e)
{
this.txtName.Text = "";
this.txtPwd.Text = "";
}
}
3.2主界面
这里是用户登录后看到的第一个界面,在主界面中可以进行查看公告,查看教师信息,修改教师信息和查看教师通信录。

主界面如图3 所示
图3主界面
主界面程序代码如下:
<asp:TreeView ID="tree_SysUser" runat="server" ImageSet="Simple" NodeIndent="10"
ShowLines="True">
<ParentNodeStyle Font-Bold="False" />
<HoverNodeStyle Font-Underline="True" ForeColor="#DD5555" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#DD5555" HorizontalPadding="0px"
VerticalPadding="0px" />
<Nodes>
</asp:TreeView>
3.3公告模块
公告模块主要功能可以进行查看学校发布的公告,查看之后对公告进行删除操作。

公告功能功能模块如图4所示。

图 4公告功能模块界面
公告模块主要代码如下:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["LoginName"]==null)
{
Response.Write("<script> this.parent.location.href='../Default.aspx'</script>");
}
if (!IsPostBack)
{
DataSet ds = bc.GetDataSet("select * from sy_notice", "sy_notice");
this.DataList1.DataKeyField = "noticeID";
DataList1.DataSource = ds;
DataList1.DataBind();
}
}
protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
{
int id = (int)DataList1.DataKeys[e.Item.ItemIndex];
bc.SqlExecute("delete from sy_notice where noticeID ='" + id + "'");
DataList1.DataSource = bc.GetDataSet("select * from sy_notice", "sy_notice");
DataList1.DataKeyField = "noticeID";
DataList1.DataBind();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) {
string strTitle;
int id = (int)DataList1.DataKeys[e.Item.ItemIndex];
DataSet ds = bc.GetDataSet("select * from sy_notice where noticeID='"+id+"'", "sy_notice");
if (ds.Tables[0].Rows.Count>0)
{
strTitle = ds.Tables[0].Rows[0]["noticeTitle"].ToString();
((Button)e.Item.Controls[1]).Attributes.Add("onclick", "javascript:return confirm('公告 "+strTitle+" 确认删除吗');");
}
}
3.4 教师信息界面
教师信息模块主要功能是输入教师自己的姓名、密码、重新确认密码、电话就可以进入教师自己的信息界面。

教师界面如5 所示
图 5教师信息界面
教师信息界面的主要代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
if (TPwd.Text == rpwd.Text)
{
bool bl = bc.SqlExecute("UPDATE sy_sysuser SET username = '" +
this.TName.Text + "', userpwd = '" + this.TPwd.Text + "',tel='" + this.TTel.Text + "' WHERE (username ='" + Session["LoginName"] + "')");
if (bl)
{
Response.Write(bc.MessageBox("信息更改成功!"));
Response.Write("<script language='javascript'>
this.parent.MainFrame.location.href='update.aspx'</script>");
}
else
{
Response.Write(bc.MessageBox("信息更改失败!"));
}
}
else
{
Response.Write(bc.MessageBox("密码不一样!"));
}
}
3.5教师个人信息界面
教师个人信息界面,其主要记录每一位教师的信息,包括姓名、电话等,教师个人信息如图6所示。

图6学生成绩管理
教师个人信息界面的主要代码:
#region 按照某列进行排序
private void SortGridView(string sortExpresion, string direction)
{
DataSet ds = bc.GetDataSet("select * from sy_sysuser", "employee");
DataTable dt = ds.Tables[0];
DataView dv = new DataView(dt);
dv.Sort = sortExpresion + direction;
GridView1.DataSource = dv;
GridView1.DataBind();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
if (GetViewSortDirection == SortDirection.Ascending)
{
GetViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, " DESC");
}
else
{
GetViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, " ASC");
}
}
#endregion
3.6 用户管理界面
用户管理界面中可以对公告进行查看,删除。

对教师可以添加等操作。

用户管理界面如图7 所示
图7用户管理界面
用户管理界面的主要代码如下:
private void AdminData()
{
string cn = "Data Source=.;Initial Catalog=xjgl1;Integrated Security=True";
SqlConnection cnn = new SqlConnection(cn);
string sel = "select User_id as 用户ID,User_name as 姓名,User_password as 密码 from Users";
SqlCommand com = new SqlCommand(sel, cnn);
da = new SqlDataAdapter();
dt = new DataTable();
da.SelectCommand = com;
da.Fill(dt);
dataGridView1.DataSource = dt;
}
3.7添加教师界面
添加教师界面的功能就是对教师进行添加。

添加教师界面如图 8 所示
图8 添加教师界面
添加教师界面主要代码如下:
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
string paths = Directory.GetCurrentDirectory() + "\\log.txt";
StreamWriter sw = new StreamWriter(paths, false, Encoding.Default);。

相关文档
最新文档