• 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>
  • 相关阅读:
    【面积并】 Atlantis
    【动态前k大 贪心】 Gone Fishing
    【复杂枚举】 library
    【双端队列bfs 网格图建图】拯救大兵瑞恩
    【奇偶传递关系 边带权】 奇偶游戏
    【权值并查集】 supermarket
    CF w4d3 A. Pythagorean Theorem II
    CF w4d2 C. Purification
    CF w4d2 B. Road Construction
    CF w4d2 A. Cakeminator
  • 原文地址:https://www.cnblogs.com/pricks/p/1744428.html
Copyright © 2020-2023  润新知