2017-5-21 项目实战( 小型人员管理系统)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// nation 的摘要说明
/// </summary>
public class nation
{
    public string nationcode { get; set; }
    public string nationname { get; set; }
}
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// nationdata 的摘要说明
/// </summary>
public class nationdata
{
    SqlConnection conn=null;
    SqlCommand cmd = null;

    public nationdata()
    {
        conn = new SqlConnection("server=.;database=data0216;user=sa;pwd=123;");
        cmd = conn.CreateCommand();
    }
    public List<nation> selectall() 
    {
        List<nation> nlist = new List<nation>();
        cmd.CommandText = "select * from nation";
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        while(dr.Read())
        {
            nation n = new nation();
            n.nationcode = dr[0].ToString();
            n.nationname = dr[1].ToString();
            nlist.Add(n);
        }
        conn.Close();
        return nlist;
    }

    public string selectnationname(string ncode)
    {
        string end = "暂无";
        cmd.CommandText = "select * from nation where nationcode=@a";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a", ncode);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            dr.Read();
            end = dr["nationname"].ToString();
        }
        conn.Close();
        return end;
    }

}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// user1 的摘要说明
/// </summary>
public class user1
{
    public int ids { get; set; }
    public string username { get; set; }
    public string password { get; set; }
    public string nickname { get; set; }
    public bool sex { get; set; }
    public string sexstr 
    {
        
        get 
    {
        return sex ? "" : "";

    }
    }
    public DateTime birthday { get; set; }
    public int age {
        get
        {
            return DateTime.Now.Year - birthday.Year;
        } 
    }
    public string nation { get; set; }

    public string whiteorred 
    {
        get
        {
            return age>16?"white":"red";
        }
    }
    public string nationname
    {
        get 
        {
            return new nationdata().selectnationname(nation);
        }
    }
}
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// user1data 的摘要说明
/// </summary>
public class user1data
{
    SqlConnection conn=null;
    SqlCommand cmd=null;
    public user1data()
    {
        conn = new SqlConnection("server=.;database=data0216;user=sa;pwd=123;");
        cmd = conn.CreateCommand();
    }
    public List<user1> selectall() 
    {
        List<user1> ulist = new List<user1>();
        cmd.CommandText = "select * from user1";
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        while(dr.Read())
        {
            user1 u = new user1();
            u.ids = Convert.ToInt32(dr[0]);
            u.username = dr[1].ToString();
            u.password = dr[2].ToString();
            u.nickname = dr[3].ToString();
            u.sex = Convert.ToBoolean(dr[4]);
            u.birthday = Convert.ToDateTime(dr[5]);
            u.nation = dr[6].ToString();
            ulist.Add(u);
        }
        conn.Close();
        return ulist;
    }
    public user1 selectuser(string ids)
    {
        user1 u = null;
        cmd.CommandText = "select * from user1 where ids=@a";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a",ids);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
       if(dr.HasRows)
       {
           u = new user1();
           dr.Read();
            u.ids = Convert.ToInt32(dr[0]);
            u.username = dr[1].ToString();
            u.password = dr[2].ToString();
            u.nickname = dr[3].ToString();
            u.sex = Convert.ToBoolean(dr[4]);
            u.birthday = Convert.ToDateTime(dr[5]);
            u.nation = dr[6].ToString();
       }
      
        conn.Close();
        return u;
    }
    public user1 selectusername(string uname)
    {
        user1 u = null;
        cmd.CommandText = "select * from user1 where username=@a";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a", uname);
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            u = new user1();
            dr.Read();
            u.ids = Convert.ToInt32(dr[0]);
            u.username = dr[1].ToString();
            u.password = dr[2].ToString();
            u.nickname = dr[3].ToString();
            u.sex = Convert.ToBoolean(dr[4]);
            u.birthday = Convert.ToDateTime(dr[5]);
            u.nation = dr[6].ToString();
        }

        conn.Close();
        return u;
    }
    public int insertuser(user1 u) 
    {
        int end = 0;
        cmd.CommandText = "insert into user1 values(@a,@b,@c,@d,@e,@f)";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a",u.username);
        cmd.Parameters.AddWithValue("@b",u.password);
        cmd.Parameters.AddWithValue("@c",u.nickname);
        cmd.Parameters.AddWithValue("@d",u.sex);
        cmd.Parameters.AddWithValue("@e",u.birthday);
        cmd.Parameters.AddWithValue("@f",u.nation);
        conn.Open();
        end = cmd.ExecuteNonQuery();
        conn.Close();

        return end;
    }

    public int deleteuser(string id) 
    {
        int end = 0;
        cmd.CommandText = "delete from user1 where ids=@a";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a",id);
        conn.Open();
        end = cmd.ExecuteNonQuery();
        conn.Close();
        return end;
    }

    public int updateuser(user1 u)
    {
        cmd.Parameters.Clear();
        int end = 0;
        if (u.password.Length > 0)
        {
            cmd.CommandText = "update user1 set password=@a,nickname=@b,sex=@c,birthday=@d,nation=@e where ids=@f";
            cmd.Parameters.AddWithValue("@a", u.password);
        }
        else { cmd.CommandText = "update user1 set nickname=@b,sex=@c,birthday=@d,nation=@e where ids=@f"; }
        cmd.Parameters.AddWithValue("@b",u.nickname);
        cmd.Parameters.AddWithValue("@c",u.sex);
        cmd.Parameters.AddWithValue("@d",u.birthday);
        cmd.Parameters.AddWithValue("@e",u.nation);
        cmd.Parameters.AddWithValue("@f",u.ids);
        conn.Open();
        end = cmd.ExecuteNonQuery();
        conn.Close();
        return end;
    }



    public bool hasuser (string uname,string password)
    {
        bool ok = false;
        cmd.CommandText = "select * from user1 where uname=@a and password=@b";
        cmd.Parameters.Clear();
        cmd.Parameters.AddWithValue("@a", uname);
        cmd.Parameters.AddWithValue("@b", password);
      
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows) { ok = true; }
        conn.Close();

        return ok;
    }

}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <table style="100%;text-align:center;background-color:navy;">
        <tr style="color:white;height:50px;">
            <td>编号</td>
             <td>用户名</td>
             <td>密码</td>
             <td>昵称</td>
             <td>性别</td>
             <td>生日</td>
            <td>年龄</td>
             <td>民族</td>
            <td>编辑</td>
        </tr>
        <asp:Repeater ID="Repeater1" runat="server">
           <ItemTemplate>
     <tr style="background-color:<%#Eval("whiteorred")%>;">
            <td><%#Eval("ids")%></td>
             <td><%#Eval("username")%></td>
             <td><%#Eval("password")%></td>
             <td><%#Eval("nickname")%></td>
             <td><%#Eval("sexstr")%></td>
             <td><%#Eval("birthday","{0:yyyy年MM月dd日}")%></td>
             <td><%#Eval("age") %></td>
             <td><%#Eval("nationname")%></td>
         <td>
             <input type="button" hehe="<%#Eval("ids")%>" class="btn1" value="编辑" />
             <a onclick="return confirm('是否要删除<%#Eval("nickname")%>?');" href="delete.aspx?i=<%#Eval("ids") %>">删除</a>
         </td>
        </tr>
               </ItemTemplate>
            </asp:Repeater>
    </table>
        <a href="Insert.aspx" target="_blank"><input type="button" value="注册" style="100px;height:40px;"/></a>
    </form>
</body>
</html>
<script type="text/javascript">
    var btns = document.getElementsByClassName("btn1");
    for(var i=0;i<btns.length;i++)
    {
        btns[i].onclick = function () { window.open("update.aspx?i=" +this.getAttribute('hehe'), "_blank", "toolbar=no menubar=no width=500 height=500") }
    }

   
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {

        }
        Repeater1.DataSource = new user1data().selectall();

        Repeater1.DataBind();
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="delete.aspx.cs" Inherits="delete" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    </div>
    </form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class delete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string s = Request["i"];
        int a = new user1data().deleteuser(s);
        //if (a > 0) { Literal1.Text = "<script>alert('删除成功!');window.location.href='Default1.aspx';</script>"; }
        //else { Literal1.Text = "<script>alert('删除失败!');window.location.href='Default1.aspx';</script>"; }
        Response.Redirect("Default1.aspx");
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="insert.aspx.cs" Inherits="insert" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>用户注册</h1>
       用户名: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Label ID="uname_error" runat="server" Text=""></asp:Label><br />
        密码:<asp:TextBox ID="TextBox2" TextMode="Password" runat="server"></asp:TextBox><br />
        确认密码:<asp:TextBox ID="TextBox3" TextMode="Password" runat="server"></asp:TextBox><asp:Label ID="pwd_error" runat="server" Text=""></asp:Label><br />
        昵称:<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><asp:Label ID="nick_error" runat="server" Text=""></asp:Label><br />
       <span style="float:left;"> 性别:</span><asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Text="" Value="true" Selected="True"></asp:ListItem>
             <asp:ListItem Text="" Value="false"></asp:ListItem>
        </asp:RadioButtonList>

        生日:<asp:DropDownList ID="Dr_year"  runat="server"></asp:DropDownList><asp:DropDownList ID="Dr_month" runat="server"></asp:DropDownList><asp:DropDownList ID="Dr_day" runat="server"></asp:DropDownList>日<br />
       民族: <asp:DropDownList ID="Dr_nation" runat="server"></asp:DropDownList><br />
        <asp:Button OnClientClick="return go();" ID="Button1" runat="server" Text="注册" Style="200px;height:50px;" />
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var pwdok = false;
    var nickok = false;
    var p1 = document.getElementById("TextBox2");
    var p2 = document.getElementById("TextBox3");
    p1.onkeyup = function () { pwdisok(p1,p2); }
    p2.onkeyup = function () { pwdisok(p1,p2); }
    function pwdisok(pwd1,pwd2)
    {
      
        if (pwd1.value != pwd2.value) {
            document.getElementById("pwd_error").innerText = "两次密码不一致!";
            document.getElementById("pwd_error").style.color = "red";
            pwdok = false;
        }
        else
        {
            document.getElementById("pwd_error").innerText = "正确";
            document.getElementById("pwd_error").style.color = "green";
            pwdok = true;
        }
    }
    document.getElementById("TextBox4").onkeyup = function ()
    {
        if (this.value.length > 0) { nickok = true; }
        else { nickok = false;}
    }
    function go()
    {
        return pwdok&&nickok;
    }

    document.getElementById("Dr_year").onchange = function ()
    {
        var mon = document.getElementById("Dr_month");
        var day = document.getElementById("Dr_day");
        if (mon.value == "2")
        {
            if (this.value % 4 == 0 && this.value % 100 != 0)
            {
                day.options.length = 0;
                for (var i = 1; i < 30; i++)
                {
                    var op = document.createElement("option");
                    op.value = i;
                    op.innerHTML = i;
                    day.appendChild(op);
                }
            }

            else
            {
                day.options.length = 0;
                for (var i = 1; i < 29; i++) {
                    var op = document.createElement("option");
                    op.value = i;
                    op.innerHTML = i;
                    day.appendChild(op);
                }
            }
        }
       
       
    }



    document.getElementById("Dr_month").onchange = function ()
    {
        var day = document.getElementById("Dr_day");
        if (this.value == "2")
        {
            if (this.value % 4 == 0 && this.value % 100 != 0) {
                day.options.length = 0;
                for (var i = 1; i < 30; i++) {
                    var op = document.createElement("option");
                    op.value = i;
                    op.innerHTML = i;
                    day.appendChild(op);
                }
            }

            else {
                day.options.length = 0;
                for (var i = 1; i < 29; i++) {
                    var op = document.createElement("option");
                    op.value = i;
                    op.innerHTML = i;
                    day.appendChild(op);
                }
            }
        }
        else if (this.value == "1" || this.value == "3" || this.value == "5" || this.value == "7" || this.value == "8" || this.value == "10" || this.value == "12")
        {
            day.options.length = 0;
            for (var i = 1; i < 32; i++)
            {
                var op = document.createElement("option");
                op.value = i;
                op.innerHTML = i;
                day.appendChild(op);
            }
        }
        else if (this.value == "4" || this.value == "6" || this.value == "9" || this.value == "11")
        {
            day.options.length = 0;
            for (var i = 1; i < 31; i++) {
                var op = document.createElement("option");
                op.value = i;
                op.innerHTML = i;
                day.appendChild(op);
            }
        }
    }


</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class insert : System.Web.UI.Page
{
  
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Click += Button1_Click;
        Dr_year.SelectedIndexChanged += Dr_year_SelectedIndexChanged;
        if(!IsPostBack)
        {
            //添加年月日
            for (int i = DateTime.Now.Year; i >=1900;i-- ) 
            {
                ListItem li = new ListItem(i.ToString(),i.ToString());
            Dr_year.Items.Add(li);
            }
            for (int i = 1; i < 13;i++ ) 
            {
                ListItem li = new ListItem(i.ToString(), i.ToString());
                Dr_month.Items.Add(li);
            }
            for (int i = 1; i < 32; i++)
            {
                ListItem li = new ListItem(i.ToString(), i.ToString());
                Dr_day.Items.Add(li);
            }
            Dr_nation.DataSource = new nationdata().selectall();
            Dr_nation.DataTextField = "nationname";
            Dr_nation.DataValueField = "nationcode";
            Dr_nation.DataBind();
        }
        
    }

    void Dr_year_SelectedIndexChanged(object sender, EventArgs e)
    {
       if(Dr_month.SelectedValue=="2")
       {
           if(Convert.ToInt32(Dr_year.SelectedValue)%4==0&&Convert.ToInt32(Dr_year.SelectedValue)%100!=0)
           {
               Dr_day.Items.Clear();
               for (int i = 1; i < 30;i++ )
               {
                   ListItem li = new ListItem(i.ToString(),i.ToString());
                   Dr_day.Items.Add(li);
               }
           }
       }
    }

    void Button1_Click(object sender, EventArgs e)
    {
        //判断用户名是否存在 
        user1 uuuu= new user1data().selectusername(TextBox1.Text);
        if(uuuu!=null)
        {
            uname_error.Text = "用户名已存在!!";
            return;
        }
        user1 u = new user1();
        u.username = TextBox1.Text;
        u.password = TextBox3.Text;
        u.nickname = TextBox4.Text;
        u.sex = RadioButtonList1.Items[0].Selected;
        u.birthday = Convert.ToDateTime(Dr_year.SelectedValue + "-" + Dr_month.SelectedValue + "-" + Dr_day.SelectedValue);
        u.nation = Dr_nation.SelectedValue;
        int a = new user1data().insertuser(u);
        if (a > 0)
        {
            Response.Redirect("insertimg.aspx");
        }
        else
        {
            Response.Redirect("insertimg.aspx");
        }
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="insertimg.aspx.cs" Inherits="insertimg" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server" style="text-align:center;">
    <div style="500px;height:400px;background-color:pink;margin:0 auto;margin-top:80px;">
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        <span id="sp1"></span>
        <span id="div1">xxx</span>秒后自动返回主页面,如未返回请<a href="Default1.aspx">点击此处。</a>
    
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var ss = 5;
    document.getElementById("div1").innerHTML = ss;
    window.setInterval(function ()
    {
        ss--;
        if (ss < 1) { window.location.href = "Default1.aspx";}
        document.getElementById("div1").innerHTML = ss;

    },
    1000)


</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class insertimg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string s = Request["i"];
        if (s == "1") { Label1.Text = "恭喜你,注册成功!"; Label1.ForeColor = System.Drawing.Color.Green; }
        else { Label1.Text = "失败!"; Label1.ForeColor = System.Drawing.Color.Red; }
    }
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="update.aspx.cs" Inherits="update" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>用户修改</h1>
            
       用户名: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Label ID="uname_error" runat="server" Text=""></asp:Label><br />
        密码:<asp:TextBox ID="TextBox2" TextMode="Password" runat="server"></asp:TextBox><br />
        确认密码:<asp:TextBox ID="TextBox3" TextMode="Password" runat="server"></asp:TextBox><asp:Label ID="pwd_error" runat="server" Text=""></asp:Label><br />
        昵称:<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox><asp:Label ID="nick_error" runat="server" Text=""></asp:Label><br />
       <span style="float:left;"> 性别:</span><asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Text="" Value="true" Selected="True"></asp:ListItem>
             <asp:ListItem Text="" Value="false"></asp:ListItem>
        </asp:RadioButtonList>

        生日:<asp:DropDownList ID="Dr_year" runat="server"></asp:DropDownList><asp:DropDownList ID="Dr_month" runat="server"></asp:DropDownList><asp:DropDownList ID="Dr_day" runat="server"></asp:DropDownList>日<br />
       民族: <asp:DropDownList ID="Dr_nation" runat="server"></asp:DropDownList><br />
        <asp:Button OnClientClick="return go();" ID="Button1" runat="server" Text="修改" Style="200px;height:50px;" />
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var pwdok = false;
    var nickok = false;
    var p1 = document.getElementById("TextBox2");
    var p2 = document.getElementById("TextBox3");
    p1.onkeyup = function () { pwdisok(p1, p2); }
    p2.onkeyup = function () { pwdisok(p1, p2); }
    function pwdisok(pwd1, pwd2) {

        if (pwd1.value != pwd2.value) {
            document.getElementById("pwd_error").innerText = "两次密码不一致!";
            document.getElementById("pwd_error").style.color = "red";
            pwdok = false;
        }
        else {
            document.getElementById("pwd_error").innerText = "正确";
            document.getElementById("pwd_error").style.color = "green";
            pwdok = true;
        }
    }
    document.getElementById("TextBox4").onkeyup = function () {
        if (this.value.length > 0) { nickok = true; }
        else { nickok = false; }
    }
    function go() {
        if (document.getElementById("TextBox4").value.length > 0) { nickok = true; }
        if (document.getElementById("TextBox2").value.length == 0 && document.getElementById("TextBox3").value.length == 0)
        {
            pwdok = true;
        }
        return pwdok && nickok;
    }
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class update : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Button1.Click += Button1_Click;
        if (!IsPostBack)
        {
            string s = Request["i"];
            user1 uu = new user1data().selectuser(s);
            TextBox1.Text = uu.username;
            TextBox1.ReadOnly = true;
            TextBox4.Text = uu.nickname;
            if (uu.sex)
            {
                RadioButtonList1.Items[0].Selected = true;
            }
            else 
            {
                RadioButtonList1.Items[1].Selected = true;
            }
            //添加年月日
            for (int i = DateTime.Now.Year; i >= 1900; i--)
            {
                ListItem li = new ListItem(i.ToString(), i.ToString());
                
                if (li.Text == uu.birthday.Year.ToString()) { li.Selected = true; }
                Dr_year.Items.Add(li);
            }
            for (int i = 1; i < 13; i++)
            {
                ListItem li = new ListItem(i.ToString(), i.ToString());
                if (li.Text == uu.birthday.Month.ToString()) { li.Selected = true; }
                Dr_month.Items.Add(li);
            }
            for (int i = 1; i < 32; i++)
            {
                ListItem li = new ListItem(i.ToString(), i.ToString());
                if (li.Text == uu.birthday.Day.ToString()) { li.Selected = true; }
                Dr_day.Items.Add(li);
            }
            Dr_nation.DataSource = new nationdata().selectall();
            Dr_nation.DataTextField = "nationname";
            Dr_nation.DataValueField = "nationcode";
            Dr_nation.DataBind();
           
            foreach(ListItem li in Dr_nation.Items)
            {
                if (li.Value == uu.nation) { li.Selected = true; }
            }
        }

    }
    void Button1_Click(object sender, EventArgs e)
    {
       
        user1 u = new user1();
        u.username = TextBox1.Text;
        u.password = TextBox3.Text;
        u.nickname = TextBox4.Text;
        u.sex = RadioButtonList1.Items[0].Selected;
        u.birthday = Convert.ToDateTime(Dr_year.SelectedValue + "-" + Dr_month.SelectedValue + "-" + Dr_day.SelectedValue);
        u.nation = Dr_nation.SelectedValue;
        u.ids = Convert.ToInt32(Request["i"]);
        int a = new user1data().updateuser(u);
        if (a > 0)
        {
            Response.Write("<script>alert('修改成功'); window.opener.location.href='Default1.aspx'; window.close();</script>");
        }
        else
        {
            Response.Write("<script>alert('修改失败!!!');</script>");
        }
    }
}
<?xml version="1.0" encoding="utf-8"?>

<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
      <compilation debug="false" targetFramework="4.0" />
    </system.web>

</configuration>
原文地址:https://www.cnblogs.com/zhengqian/p/6917064.html