首页 > 代码库 > ERP员工入登记查询(六)

ERP员工入登记查询(六)

实现的功能:

技术分享

视图的创建:

--两个表的查询select  a.*,b.* from [dbo].[Department] as a inner join [dbo].[UserManager] as bon a.DepartmentId=b.DepartmentId--三个表的查询select  a.*,b.*,c.* from [dbo].[Department] as a ,[dbo].[UserManager] as b, [dbo].[tbRose] as  cwhere  a.DepartmentId=b.DepartmentId and c.RoseID=b.RoleId--创建视图  查询中不能有相同的列CREATE VIEW UserInfoViewASselect  a.[DepartmentName],b.*,c.[RoseName] from [dbo].[Department] as a ,[dbo].[UserManager] as b, [dbo].[tbRose] as  cwhere  a.DepartmentId=b.DepartmentId and c.RoseID=b.RoleIdselect * from [dbo].[UserInfoView]

 直接在视图中修改员工状态:

SELECT   a.DepartmentName, b.UserId, b.LoginName, b.UserName, b.Password, b.DepartmentId, b.RoleId, b.Birthday, b.Mobile,                 b.Email, b.Photo, b.Address, b.LastLoginDate, b.Sex, b.DisplayOrder, b.Sate, c.RoseName,                 CASE b.sate WHEN ‘True‘ THEN ‘正式员工‘ ELSE ‘试用期员工‘ END AS StateNameFROM      dbo.Department AS a INNER JOIN                dbo.UserManager AS b ON a.DepartmentId = b.DepartmentId INNER JOIN                dbo.tbRose AS c ON b.RoleId = c.RoseID

 前台页面显示的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserListShow.aspx.cs" Inherits="BioErpWeb.HRSystem.UserListShow" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <link href="http://www.mamicode.com/Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />    <style type="text/css">    td{ text-align:center;}    .tdsearch{ line-height:30px;}    </style></head><body>    <form id="form1" runat="server">    <div>         <table class="maintable">             <tr>                 <td colspan="4" class="titlebar">                     <span>员工信息查询系统</span>                 </td>             </tr>             <tr>                 <td class="tdsearch">                     <asp:Label ID="Label1" runat="server" Text="员工姓名"></asp:Label>                     <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>                 </td>                 <td class="tdsearch">                     <asp:Label ID="Label2" runat="server" Text="部门"></asp:Label>                     <asp:DropDownList ID="ddlDepartMent" Width="150" runat="server">                     </asp:DropDownList>                 </td>                 <td class="tdsearch">                     <asp:Label ID="Label3" runat="server" Text="员工的状态"></asp:Label>                     <asp:DropDownList ID="ddlState" Width="150" runat="server">                         <asp:ListItem Value="http://www.mamicode.com/1">在职</asp:ListItem>                         <asp:ListItem Value="http://www.mamicode.com/2">离职</asp:ListItem>                         <asp:ListItem Selected="True" Value="http://www.mamicode.com/0">--请选择--</asp:ListItem>                     </asp:DropDownList>                 </td>                 <td class="tdsearch">                     <asp:ImageButton ID="imgbutnSearch" Width="46" Height="22" runat="server" ImageUrl="~/Web/images/Btnsearch.gif" />                 </td>             </tr>             <tr>                 <td colspan="4" class="bottomtd">                     <asp:GridView ID="GridView1" Width="100%"  runat="server"  AutoGenerateColumns="False" DataKeyNames="UserId">                         <Columns>                                                <asp:TemplateField HeaderText="员工编号">                                 <ItemTemplate>                                     <asp:Label ID="Label4" runat="server" Text=‘<%# Eval("UserID") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                             <asp:TemplateField HeaderText="员工姓名">                                 <ItemTemplate>                                     <asp:Label ID="Label5" runat="server" Text=‘<%# Eval("UserName") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                             <asp:TemplateField HeaderText="所属部门">                                 <ItemTemplate>                                      <asp:Label ID="Label6" runat="server" Text=‘<%# Eval("DepartmentName") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                             <asp:TemplateField HeaderText="角色">                                 <ItemTemplate>                                      <asp:Label ID="Label7" runat="server" Text=‘<%# Eval("RoseName") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                             <asp:TemplateField HeaderText="手机号码">                                <ItemTemplate>                                      <asp:Label ID="Label8" runat="server" Text=‘<%# Eval("Mobile") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                             <asp:TemplateField HeaderText="Email">                                <ItemTemplate>                                      <asp:Label ID="Label9" runat="server" Text=‘<%# Eval("Email") %>‘></asp:Label>                                 </ItemTemplate>                                                          </asp:TemplateField>                             <asp:TemplateField HeaderText="状态">                                <ItemTemplate>                                      <asp:Label ID="Label10" runat="server" Text=‘<%# Eval("StateName") %>‘></asp:Label>                                 </ItemTemplate>                             </asp:TemplateField>                                                    </Columns>                     </asp:GridView>                 </td>             </tr>     </table>    </div>    </form></body></html>

 

ERP员工入登记查询(六)