⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default7.aspx.cs

📁 好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!好东东!
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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;

public partial class Default7 : System.Web.UI.Page
{
    public SqlCommandBuilder scb;
    string student;
    protected void Page_Load(object sender, EventArgs e)
    {
        student = this.Session["name"].ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DateTime date;
        if (Button1.Text == "修改")
        {
            Button1.Text = "保存";
            DropDownList1.Enabled = true;
            TextBox2.Enabled = true;
            TextBox3.Enabled = true;
            TextBox4.Enabled = true;
        }
        else if (Button1.Text == "保存")
        {
            if (!(DropDownList1.Text == "" && TextBox2.Text == "" && TextBox3.Text == "" && TextBox4.Text == ""))
            {
                Button1.Text = "修改";
                DropDownList1.Enabled = false;
                TextBox2.Enabled = false;
                TextBox3.Enabled = false;
                TextBox4.Enabled = false;
                string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
                SqlConnection myConn = new SqlConnection(myConnstr);
                string sql = "select 学号,政治面貌,出生日期,家庭住址,备注 from 学生表 where 学号='" + student + "'";
                SqlCommand myComm = new SqlCommand(sql, myConn);
                SqlDataAdapter myDataAdapter = new SqlDataAdapter();
                myDataAdapter.SelectCommand = myComm;
                DataSet myDataSet = new DataSet();
                myConn.Open();
                myDataAdapter.Fill(myDataSet, "学生表");
                DataTable myDataTable = myDataSet.Tables["学生表"];
                foreach (DataRow myDataRow in myDataTable.Rows)
                {
                    myDataTable.PrimaryKey = new DataColumn[] { myDataTable.Columns["学号"] };
                    DataRow myEditDataRow = myDataTable.Rows.Find(student);
                    scb = new SqlCommandBuilder(myDataAdapter);
                    if (DropDownList1.Text != "")
                        myDataSet.Tables["学生表"].Rows[0]["政治面貌"] = DropDownList1.Text;
                    if (TextBox2.Text != "")
                    {
                        date = DateTime.Parse(TextBox2.Text);
                        myDataSet.Tables["学生表"].Rows[0]["出生日期"] = date;
                    }
                    if (TextBox3.Text != "")
                        myDataSet.Tables["学生表"].Rows[0]["家庭住址"] = TextBox3.Text;
                    if (TextBox4.Text != "")
                        myDataSet.Tables["学生表"].Rows[0]["备注"] = TextBox4.Text;
                    myDataAdapter.Update(myDataSet.Tables["学生表"]);
                    Response.Write("<script>alert('信息修改完成!');</script>");
                }
            }
            else
                Response.Write("<script>alert('输入不能为空!');</script>");
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        //if(Response.Write("<script>alert('确定注销!');</script>"))
        this.Response.Redirect("登陆页面.aspx");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -