• ASP.NET&Spring.NET&NHibernate最佳实践(六)——第3章人事子系统(3)


    3.6. 人事子系统表示层(Web)
    修改Depts.aspx
    <asp:Panel ID="Panel1" runat="server" GroupingText="部门列表">
            
    <br />
            
    <asp:GridView ID="GridView1" runat="server" DataSourceID="odsDepts" DataKeyNames="ID"
                AutoGenerateColumns
    ="False" Width="100%" AllowPaging="true" PageSize="10">
                
    <Columns>
                    
    <asp:TemplateField>
                        
    <ItemTemplate>
                            
    <asp:Button ID="btnEdit" runat="server" CommandName="Edit" Text="编辑" />
                            
    <asp:Button ID="btnDelete" runat="server" CommandName="Delete" Text="删除" OnClientClick="return confirm('您真的要删除吗?')" />
                        
    </ItemTemplate>
                        
    <EditItemTemplate>
                            
    <asp:Button ID="btnUpdate" runat="server" CommandName="Update" Text="更新" />
                            
    <asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="取消" />
                        
    </EditItemTemplate>
                    
    </asp:TemplateField>
                    
    <asp:BoundField HeaderText="部门代码" DataField="Code" />
                    
    <asp:BoundField HeaderText="部门名称" DataField="Name" />
                
    </Columns>
            
    </asp:GridView>
        
    </asp:Panel>
        
    <hr />
        
    <asp:Panel ID="Panel2" runat="server" GroupingText="新增部门">
            
    <br />
            
    <asp:FormView ID="FormView1" runat="server" DataSourceID="odsDepts" DefaultMode="Insert">
                
    <InsertItemTemplate>
                    
    <table width="100%" border="0" cellpadding="2" cellspacing="2">
                        
    <tr>
                            
    <td>
                                部门代码
    </td>
                            
    <td>
                                
    <asp:TextBox ID="txtCode" runat="server" Width="200" Text='<%# Bind("Code") %>' />
                            
    </td>
                        
    </tr>
                        
    <tr>
                            
    <td>
                                部门名称
    </td>
                            
    <td>
                                
    <asp:TextBox ID="txtGroupName" runat="server" Width="200" Text='<%# Bind("Name") %>' />
                            
    </td>
                        
    </tr>
                    
    </table>
                    
    <p>
                        
    <asp:Button ID="btnInsert" runat="server" CommandName="Insert" Text="新增" />
                    
    </p>
                
    </InsertItemTemplate>
            
    </asp:FormView>
        
    </asp:Panel>
        
    <asp:ObjectDataSource ID="odsDepts" runat="server" TypeName="Guushuuse.SalaryPrj.HR.Helper.HRHelper"
            SelectMethod
    ="GetAllDepts" InsertMethod="CreateDept" UpdateMethod="UpdateDept"
            DeleteMethod
    ="DeleteDept"></asp:ObjectDataSource>
    修改Employees.aspx
    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
        CodeFile
    ="Employees.aspx.cs" Inherits="Employees" 
    %>

    <asp:Content ID="LeftColumnContent" ContentPlaceHolderID="LeftColumnZone" runat="server">
    </asp:Content>
    <asp:Content ID="MiddleColumnContent" ContentPlaceHolderID="MiddleColumnZone" runat="server">
        
    <asp:Panel ID="Panel1" runat="server" GroupingText="员工列表">
            
    <br />
            
    <asp:GridView ID="GridView1" runat="server" DataSourceID="odsEmployees" DataKeyNames="ID"
                AutoGenerateColumns
    ="False" Width="100%" AllowPaging="true" PageSize="10">
                
    <Columns>
                    
    <asp:TemplateField>
                        
    <ItemTemplate>
                            
    <asp:Button ID="btnEdit" runat="server" CommandName="Edit" Text="编辑" />
                            
    <asp:Button ID="btnDelete" runat="server" CommandName="Delete" Text="删除" OnClientClick="return confirm('您真的要删除吗?')" />
                        
    </ItemTemplate>
                        
    <EditItemTemplate>
                            
    <asp:Button ID="btnUpdate" runat="server" CommandName="Update" Text="更新" />
                            
    <asp:Button ID="btnCancel" runat="server" CommandName="Cancel" Text="取消" />
                        
    </EditItemTemplate>
                    
    </asp:TemplateField>
                    
    <asp:BoundField HeaderText="工号" DataField="Code" />
                    
    <asp:BoundField HeaderText="姓名" DataField="Name" />
                    
    <asp:TemplateField HeaderText="部门">
                        
    <ItemTemplate>
                            
    <asp:Label ID="lblDeptName" runat="server" Text='<%# Eval("DeptName") %>' />
                        
    </ItemTemplate>
                        
    <EditItemTemplate>
                            
    <asp:DropDownList ID="lstDepts" runat="server" DataTextField="Name" DataValueField="ID"
                                DataSourceID
    ="odsDepts" SelectedValue='<%# Bind("DeptID") %>'>
                            
    </asp:DropDownList>
                        
    </EditItemTemplate>
                    
    </asp:TemplateField>
                
    </Columns>
            
    </asp:GridView>
        
    </asp:Panel>
        
    <hr />
        
    <asp:Panel ID="Panel2" runat="server" GroupingText="新增员工">
            
    <br />
            
    <asp:FormView ID="FormView1" runat="server" DataSourceID="odsEmployees" DefaultMode="Insert">
                
    <InsertItemTemplate>
                    
    <table width="100%" border="0" cellpadding="2" cellspacing="2">
                        
    <tr>
                            
    <td>
                                工号
    </td>
                            
    <td>
                                
    <asp:TextBox ID="txtCode" runat="server" Width="200" Text='<%# Bind("Code") %>' />
                            
    </td>
                        
    </tr>
                        
    <tr>
                            
    <td>
                                姓名
    </td>
                            
    <td>
                                
    <asp:TextBox ID="txtGroupName" runat="server" Width="200" Text='<%# Bind("Name") %>' />
                            
    </td>
                        
    </tr>
                        
    <tr>
                            
    <td>
                                部门
    </td>
                            
    <td>
                                
    <asp:DropDownList ID="lstDepts" runat="server" DataTextField="Name" DataValueField="ID"
                                    DataSourceID
    ="odsDepts" SelectedValue='<%# Bind("DeptID") %>'>
                                
    </asp:DropDownList>
                            
    </td>
                        
    </tr>
                    
    </table>
                    
    <p>
                        
    <asp:Button ID="btnInsert" runat="server" CommandName="Insert" Text="新增" />
                    
    </p>
                
    </InsertItemTemplate>
            
    </asp:FormView>
        
    </asp:Panel>
        
    <asp:ObjectDataSource ID="odsEmployees" runat="server" TypeName="Guushuuse.SalaryPrj.HR.Helper.HRHelper"
            SelectMethod
    ="GetAllEmployees" InsertMethod="CreateEmployee" UpdateMethod="UpdateEmployee"
            DeleteMethod
    ="DeleteEmployee"></asp:ObjectDataSource>
        
    <asp:ObjectDataSource ID="odsDepts" runat="server" TypeName="Guushuuse.SalaryPrj.HR.Helper.HRHelper"
            SelectMethod
    ="GetAllDepts"></asp:ObjectDataSource>
    </asp:Content>
  • 相关阅读:
    硬盘安装Win 7系统Windows 7 系统硬盘安装教程(图解)
    修改phpMyAdmin导入SQL文件的大小限制
    金三银四面试季节之Java 核心面试技术点
    2015年校园招聘12家IT公司面试体验
    正则表达式小结
    【译文】NginScript – 为什么我们要实现自己的JS引擎?
    经典算法合集
    【高级JSE技术】线程池
    【高性能服务器】Tomcat剖析
    【高性能服务器】Nginx剖析
  • 原文地址:https://www.cnblogs.com/pricks/p/1744428.html
Copyright © 2020-2023  润新知