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" %><%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>