• 大小: 6.12MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-02
  • 语言: C#
  • 标签: ASP.NET  

资源简介

网页大作业,学生信息管理系统,可以登录注册,连接学生表,可以增删改查

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.xml.Linq;
using System.IO;


namespace Data1_3
{
    public partial class AddStudent : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender EventArgs e)
        {            
            if (Session[“UserName“] == null || string.IsNullOrEmpty(Session[“UserName“].ToString()))
            {
                Response.Redirect(“~/Login.aspx?referUrl=“ + Server.UrlEncode(Request.Url.ToString()));
            }
           
            ((SiteMaster)this.Master).Pagetitle = “添加学生“;
            
            if (!IsPostBack)
            {
                divMessage.Visible = false;
            }
            else
            {
                divMessage.Visible = true;
            }
        }

        protected void btnOK_Click(object sender EventArgs e)
        {
            if (!IsValid)
                return;

            tbForm.Visible = false;

            ConnectionStringSettings mySettings = ConfigurationManager.ConnectionStrings[“ConnectionString“];
            if(mySettings == null || string.IsNullOrEmpty(mySettings.ConnectionString))
                throw new ApplicationException(“错误:找不到数据库连接字符串!“);

            string insertSql = “INSERT INTO students(StudentId StudentName ClassId Age Gender CV PhotoFile)“ +
                               “VALUES(@studentId @studentName @classId @age @gender @cv @photoFile)“;

            using(SqlConnection conn = new SqlConnection(mySettings.ConnectionString))
            {
                SqlTransaction tran;    //事务,防止出现数据库记录添加成功而学生照片没有成功保存。
                conn.Open();
                tran = conn.BeginTransaction();    // 开始事务
                using(SqlCommand cmd = new SqlCommand(insertSql conn))
                {
                    cmd.Transaction = tran;
                    cmd.Parameters.AddWithValue(“@studentId“ tbStudentId.Text.Trim());
                    cmd.Parameters.AddWithValue(“@studentName“ tbStudentName.Text.Trim());
                    cmd.Parameters.AddWithValue(“@classId“ ddlClass.SelectedValue);
                    cmd.Parameters.AddWithValue(“@age“ ddlAge.SelectedValue);
                    cmd.Parameters.AddWithValue(“@gender“ rblGender.SelectedValue);
                    cmd.Parameters.AddWithValue(“@cv“ Request.Params[“cv“]);
                    try
                    {
                        string photoFileName = fuPhoto.FileName;
                        string ext = Path.GetExtension(fuPhoto.FileName);
                        string newPhotoFileName = tbStudentId.Text.Trim() + ext;
                        string photoPath = Server.MapPath(“~/Up

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-24 22:13  Data\
     目录           0  2018-12-24 21:14  Data\Data1_3\
     目录           0  2018-12-24 22:13  Data\Data1_3\Data1_3\
     文件        5837  2018-12-19 00:28  Data\Data1_3\Data1_3\AddStudent.aspx
     文件        5047  2018-12-11 19:31  Data\Data1_3\Data1_3\AddStudent.aspx.cs
     文件        5099  2018-12-19 00:27  Data\Data1_3\Data1_3\AddStudent.aspx.designer.cs
     目录           0  2018-12-24 21:14  Data\Data1_3\Data1_3\App_Data\
     文件     2293760  2018-12-24 22:13  Data\Data1_3\Data1_3\App_Data\students.mdf
     文件      573440  2018-12-24 22:13  Data\Data1_3\Data1_3\App_Data\students_log.LDF
     文件        5958  2018-05-22 14:45  Data\Data1_3\Data1_3\DBHelper.cs
     文件       15733  2018-12-13 22:47  Data\Data1_3\Data1_3\Data1_3.csproj
     文件        1216  2018-12-13 22:47  Data\Data1_3\Data1_3\Data1_3.csproj.user
     文件          91  2018-05-12 07:51  Data\Data1_3\Data1_3\Global.asax
     文件        1101  2018-05-12 07:59  Data\Data1_3\Data1_3\Global.asax.cs
     文件        3202  2018-12-24 21:15  Data\Data1_3\Data1_3\Login.aspx
     文件        7443  2018-12-24 21:19  Data\Data1_3\Data1_3\Login.aspx.cs
     文件        2936  2018-12-24 21:15  Data\Data1_3\Data1_3\Login.aspx.designer.cs
     文件         591  2018-05-08 21:31  Data\Data1_3\Data1_3\Logout.aspx
     文件         544  2018-05-09 14:44  Data\Data1_3\Data1_3\Logout.aspx.cs
     文件        1186  2018-05-08 21:30  Data\Data1_3\Data1_3\Logout.aspx.designer.cs
     文件        3075  2018-12-19 00:32  Data\Data1_3\Data1_3\ModifyStudent.aspx
     文件        4686  2018-05-16 09:37  Data\Data1_3\Data1_3\ModifyStudent.aspx.cs
     文件        4043  2018-12-19 00:29  Data\Data1_3\Data1_3\ModifyStudent.aspx.designer.cs
     文件        2115  2018-05-08 19:44  Data\Data1_3\Data1_3\PasswordDigest.cs
     文件        1655  2018-12-18 21:44  Data\Data1_3\Data1_3\PersonalCenter.aspx
     文件        4163  2018-12-18 21:44  Data\Data1_3\Data1_3\PersonalCenter.aspx.cs
     文件        3605  2018-12-18 21:44  Data\Data1_3\Data1_3\PersonalCenter.aspx.designer.cs
     目录           0  2018-12-24 21:14  Data\Data1_3\Data1_3\Properties\
     文件        1304  2018-04-04 08:58  Data\Data1_3\Data1_3\Properties\AssemblyInfo.cs
     文件        2634  2018-12-18 23:48  Data\Data1_3\Data1_3\SiteMaster.Master
     文件        1645  2018-12-18 23:51  Data\Data1_3\Data1_3\SiteMaster.Master.cs
............此处省略252个文件信息

评论

共有 条评论