zoukankan      html  css  js  c++  java
  • ASP.NET学生成绩管理系统

    一、实现功能

    1.  用户注册登录
    2.  两种身份:教师和学生
    3.  学生能够查看自己的成绩
    4.  教师可以对班级,对学生的信息进行查看
    5.  教师可以增、减、查、改等学生信息
    

    二、简单代码

    1.登陆页面(内容判断不在内)

    //教师学生判断登陆
                    string user = this.txtUserName.Text;
                    string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPwd.Text, "MD5");
                    string sql = "select a.*,b.RoleName,b.PowerIds from tb_UserInfo a join tb_Role b on a.RoleId=b.Id where a.LoginName=@LoginName and a.LoginPwd=@LoginPwd";
                    SqlParameter[] parameters = 
                    {
                       new SqlParameter("@LoginName",user),
                       new SqlParameter("@LoginPwd",pwd)
                    };
                    SqlDataReader sdr = SqlHelper.ExecuteReader(connStr, CommandType.Text, sql, parameters);
                    if (sdr.Read())
                    {
                        Session["UserName"] = sdr["UserName"].ToString();
                        Session["UserId"] = sdr["Id"].ToString();
                        Session["RoleName"] = sdr["RoleName"].ToString();
                        sdr.Close();
                        Response.Redirect("Main.html");
                    }
                    else
                    {
                        sdr.Close();
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "loginError", "alert('用户或密码错误!');", true);
                    }
    

    2.班级添加(内容判断不在内)

     string sql = "insert into tb_ClassInfo values(@ClassName,@Remark)";
                    SqlParameter[] parameters = 
                    {
                       new SqlParameter("@ClassName",txtClassName.Text.Trim()),
                       new SqlParameter("@Remark",Server.HtmlEncode(txtRemark.Text.Trim()))
                    };
                    bool result = false;
                    result = SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, sql, parameters) > 0 ? true : false;
                    if (result)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addOk", "alert('添加成功!')", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addError", "alert('添加失败!')", true);
                    }
    

    3.删除学生页面(内容判断不在内)

    string chkSql = "select ClassId from tb_StuInfo where ClassId=" + id;
                    object obj = SqlHelper.ExecuteScalar(connStr, CommandType.Text, chkSql);
                    if (obj != null)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "havestu", "alert('存在该班级的学生,不能删除该班级!')", true);
                        return;
                    }
    
                    string sql = "delete from tb_ClassInfo where Id=" + id;
                    bool result = false;
                    result = SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, sql) > 0 ? true : false;
                    if (result)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "delOk", "alert('删除成功!')", true);
                        BindgvClass(gvClassManage.PageSize, gvClassManage.PageIndex);
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "delError", "alert('删除失败!')", true);
                    }
    

    4.添加学生页面(内容判断不在内)

    if (!CheckStuId("add"))
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addcheckerror", "alert('该学号已存在!')", true);
                        return;
                    }
    
    
                    string sql = "insert into tb_StuInfo values(@StuNum,@StuPwd,@StuName,@Birthday,@Sex,@ClassId,@StartTime)";
                    SqlParameter[] parameters = 
                    {
                       new SqlParameter("@StuNum",txtstuId.Text.Trim()),
                       new SqlParameter("@StuPwd",txtstuPwd.Text.Trim()),
                       new SqlParameter("@StuName",txtstuName.Text.Trim()),
                       new SqlParameter("@Birthday",txtBirth.Value),
                       new SqlParameter("@Sex",radMan.Checked),
                       new SqlParameter("@ClassId",Convert.ToInt32(ddlClass.SelectedValue)),
                       new SqlParameter("@StartTime",txtJionTime.Value)
                    };
                    bool result = false;
                    result = SqlHelper.ExecuteNonQuery(connStr, CommandType.Text, sql, parameters) > 0 ? true : false;
                    if (result)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addOk", "alert('添加成功!')", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "addError", "alert('添加失败!')", true);
                    }
    

    4.学生成绩查询页面(内容判断不在内)

      string sql0 = "select COUNT(a.Id) from tb_Score a join tb_StuInfo b on a.StuId=b.Id join tb_ClassInfo c on c.Id= b.ClassId join tb_Subject d on d.Id=a.SubjectId join tb_Schedule e on a.ScheduleId=e.Id where b.StuNum like @StuNum and b.StuName like @StuName and c.ClassName like @ClassName and d.SubjectName like @SubjectName and e.ScheduleName like @ScheduleName";
                AspNetPager1.AlwaysShow = true;
                AspNetPager1.PageSize = pagesize;
    
                string sql = "select top " + pagesize + "  a.*,b.StuNum,b.StuName,c.ClassName,d.SubjectName,e.ScheduleName from tb_Score a join tb_StuInfo b on a.StuId=b.Id join tb_ClassInfo c on c.Id= b.ClassId join tb_Subject d on d.Id=a.SubjectId join tb_Schedule e on a.ScheduleId=e.Id where b.StuNum like @StuNum and b.StuName like @StuName and c.ClassName like @ClassName and d.SubjectName like @SubjectName and e.ScheduleName like @ScheduleName and a.Id not in(select top " + (pageindex - 1) * pagesize + " Id from tb_Score)";
                SqlParameter[] parameters =
                    {                          
                        new SqlParameter("@StuNum","%"+txtStuNum.Text.Trim()+"%"),   
                        new SqlParameter("@StuName","%"+txtName.Text.Trim()+"%"),
                        new SqlParameter("@ClassName","%"+txtClass.Text.Trim()+"%"),
                        new SqlParameter("@SubjectName","%"+txtSubject.Text.Trim()+"%"),
                        new SqlParameter("@ScheduleName","%"+txtSchedule.Text.Trim()+"%")
                    };
                AspNetPager1.RecordCount = Convert.ToInt32(SqlHelper.ExecuteScalar(connStr, CommandType.Text, sql0, parameters));
                DataSet ds = SqlHelper.ExecuteDataset(connStr, CommandType.Text, sql, parameters);
                gvStudentScore.DataSource = ds;
                gvStudentScore.DataBind();
    

    三、结尾

    因为特别的原因有很多都没有展示,我也希望给才接触的asp.net的人有所帮助~~~感谢大家的阅读和支持,能给你们带来帮助也是我成长的一步~需要带数据库完整的直接加我(不白给)1076396021
    直接跳转

  • 相关阅读:
    图像分割之Dense Prediction with Attentive Feature Aggregation
    与中文对齐的英文等宽字体
    管家订菜与Scrum流程
    说说自己在2014年的阅读思路
    Hello World
    Bootstrap实现轮播
    普通Apache的安装与卸载
    Python中OS模块
    Python中文件读写
    Python装饰器
  • 原文地址:https://www.cnblogs.com/LJF111/p/12304842.html
Copyright © 2011-2022 走看看