首页 > 代码库 > WebForm

WebForm

简单的人员管理系统

    人员页面

    添加人员

             --判断添加人员的各种条件限制

             -- 各种提示

   修改人员信息

            -- 人员原来信息绑定

            --密码不显示,密码不改时用原来密码

    人员删除     

 

 

技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// users 的摘要说明
/// </summary>
public class users
{
    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 string Birthdaystr
    {
        get
        {
            return Birthday.ToString("yyyy年MM月dd日");
        }
    }

    public int Age
    {
        get
        {
            return DateTime.Now.Year - Birthday.Year;
        }
    }


    public string Nation { get; set; }

    public string NationName
    {
        get
        {
            return new usernationData().selectname(Nation);
        }
    }

}
users

 

技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// usernation 的摘要说明
/// </summary>
public class usernation
{
    public string NationCode { get; set; }
    public string NationName { get; set; }
}
usernation

 

1、数据展示页

技术分享
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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>

    <style type="text/css">
        .div1 {
            width: 100%;
            height: 80px;
            text-align: center;
            line-height: 80px;
            font-size: 30px;
        }

        /*表格样式*/
        .tab {
            width: 100%;
            background-color: blue;
            text-align: center;
        }
    </style>


</head>
<body>
    <form id="form1" runat="server">
        <div class="div1">奇点0216班学生信息</div>

        <%--使用  Repeater 添加数据--%>
        <asp:Repeater ID="Repeater1" runat="server">

            <HeaderTemplate>
                <%-- 头模板--%>

                <table class="tab">
                    <tr style="color: white; height: 30px;">
                        <td>编号</td>
                        <td>用户名</td>
                        <td>密码</td>
                        <td>昵称</td>
                        <td>性别</td>
                        <td>生日</td>
                        <td>年龄</td>
                        <td>民族</td>
                        <td>设置</td>
                    </tr>
            </HeaderTemplate>



            <ItemTemplate>
                <%-- 项模板--%>

                <tr style="background-color: white;">
                    <td><%#Eval("Ids") %></td>
                    <td><%#Eval("Username") %></td>
                    <td><%#Eval("Password") %></td>
                    <td><%#Eval("Nickname") %></td>
                    <td><%#Eval("Sexstr") %></td>
                    <td><%#Eval("Birthdaystr") %></td>
                    <td><%#Eval("Age") %></td>
                    <td><%#Eval("NationName") %></td>
                    <td>
                        <a href=http://www.mamicode.com/"xiugai.aspx?i=<%#Eval("Ids") %>">编辑 </a>
                        <a onclick="return confirm(‘是否要删除<%#Eval("NickName") %>?‘);" href=http://www.mamicode.com/"shanchu.aspx?i=<%#Eval("Ids") %>">删除</a>
                    </td>
                </tr>

            </ItemTemplate>


            <FooterTemplate>
                     <%--脚模板--%>
                </table>
            </FooterTemplate>


        </asp:Repeater>

        <a href=http://www.mamicode.com/"zhuce.aspx" target="_blank">添加新同学</a>


    </form>
</body>
</html>
.aspx

 

技术分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)  
        {
                 //只在第一次加载时执行的代码
                 //数据展示时不需要,数据展示要展示最新数据
                 
        }
        Repeater1.DataSource = new usersData().selectAll();
        Repeater1.DataBind();  
                         
    }

}
.aspx.cs

 

效果图

技术分享

 

WebForm