public bool Login(string name, string pass) // 判断用户名和密码是否正确
{
string sqlString = \"select count(*) from Users where name='\"+name+\"' and pass='\"+pass+\"'\";
object obj = SqlHelper.ExecuteScalar(SqlString,CommandType.Text, sqlString);
if(obj!=null && obj.ToString()!=\"0\") return true; else
return false;
}
// 判断登录类型,为学生,为老师,为管理员 public int LoginType(string name) {
string sqlString = \"select type from Users where name='\"+name+\"'\"; object obj = SqlHelper.ExecuteScalar(SqlString,CommandType.Text, sqlString);
if(obj!=null && obj.ToString()!=\"0\") return int.Parse(obj.ToString()); else
return -1; }
// 取得登录的ID
public int LoginID(string name) {
string sqlString = \"select id from Users where name='\"+name+\"'\"; object obj = SqlHelper.ExecuteScalar(SqlString,CommandType.Text, sqlString);
if(obj!=null && obj.ToString()!=\"0\") return int.Parse(obj.ToString()); else
return -1;
}
protected void btnOK_Click(object sender, System.EventArgs e) {
CourseBiz.Auth auth = new CourseBiz.Auth(); if(auth.Login(txtName.Text, txtPass.Text)) {
FormsAuthentication.SetAuthCookie(txtName.Text, false); Response.Redirect(\"Common/Main.aspx\"); } else {
Response.Write(\"\"); }
}
其中左侧功能栏的JS代码如下:
document.writeln('
document.writeln('
'); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln('
'); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln(''); document.writeln(' |
'); document.writeln(' href=\"../Admin/Student.aspx\" class=\"left\" target=\"ifmContent\">学生管理 ');document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' href=\"../Admin/Teacher.aspx\" class=\"left\" target=\"ifmContent\">教师管理 ');document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' '); document.writeln(' | '); document.writeln(' '); document.writeln(' |
'); document.writeln(' |
后台代码如下:
Response.Cache.SetCacheability(HttpCacheability.NoCache);//去掉页面缓存 if(!IsPostBack) {
DgBind(); } }
///
public void DgBind() {
CourseBiz.Dept dept = new CourseBiz.Dept(); DataSet ds = dept.GetAllDeptInfo();
if(ds!=null && ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0) {
dgBulletin.DataSource = ds; dgBulletin.DataBind(); } }
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e) {
//
// CODEGEN: 该调用是ASP.NET Web 窗体设计器所必需的。 //
InitializeComponent(); base.OnInit(e); }
/// /// 设计器支持所需的方法- 不要使用代码编辑器修改 /// 此方法的内容。 ///
private void InitializeComponent() {
this.dgBulletin.ItemDataBound += new
System.Web.UI.WebControls.DataGridItemEventHandler(this.dgBulletin_ItemDataBound);
}
#endregion //5-1-as-px
public void dgItem(object sender, DataGridCommandEventArgs e) {
CourseBiz.Dept dept = new CourseBiz.Dept(); int deptID = int.Parse(e.Item.Cells[0].Text);
if(e.CommandName==\"edit\") {
//编辑院系信息
string str = \"\";
Response.Write(str);
}
if(e.CommandName==\"delete\") {
//删除院系信息
dept.DeleteDeptInfo(deptID); }
DgBind(); }
protected void btnAdd_ServerClick(object sender, System.EventArgs e) {
//转向到添加院系页面
string str = \"\";
Response.Write(str); }
private void dgBulletin_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {
//添加客户端删除事件
e.Item.Cells[3].Attributes.Add(\"onclick\confirm('确实要删除吗?');\"); }
因篇幅问题不能全部显示,请点此查看更多更全内容