Archive for the 'Intranet Integration' Category

29
May
09

#25 Birthdays & Service Anniversaries

Birthdays & Years of Service

Birthdays & Years of Service

Variation on a theme – here we display weekly birthdays & service anniversaries.

Stored Procedure:


Procedure SP_Weekly
as
Select EM.Employee as EmpNum
, EmployeePhoto
, isNull(EM.PreferredName,EM.FirstName) + ' ' + RTRIM( EM.LastName) as EmployeeName
, RTRIM(datepart(month,custEmp_BirthDate)) + '/' +  RTRIM(datepart(day,custEmp_BirthDate)) as DateField
, 'Birthday'  as Notes
From EmployeeCustomTabFields ECTF
Join EM on (EM.Employee = ECTF.Employee)
Where
datepart(week,custEmp_BirthDate) = datepart(week,getdate())
And Status = 'A'
Union All
Select EM.Employee as EmpNum
, EmployeePhoto
, isNull(EM.PreferredName,EM.FirstName) + ' ' + RTRIM( EM.LastName) as EmployeeName
, RTRIM(datepart(month,HireDate)) + '/' +  RTRIM(datepart(day,HireDate))
  + '/' +  RTRIM(datepart(year,HireDate)) as DateField
, Cast(DateDiff(year, HireDate, getdate()) as varchar(12)) + RTRIM(' Years of Service' )  as Notes
From EmployeeCustomTabFields ECTF
Join EM on (EM.Employee = ECTF.Employee)
Where
datepart(week,HireDate) = datepart(week,getdate())
And Status = 'A'
Order By 4
14
Jan
09

#19 Employee Directory Sharepoint Webpart Pt 1 – Stored Procedure

Starting with a new proc to select data of off the EM, Employee Custom Tab Fields and a union with a Auxilary data table to add in such things as printers, conference rooms, local police,  fire etc. I will build on this stored procedure defining a datagrid with filter controls in a Sharepoint webpart.

Virtualized Dev Environment: SQL 2005, Windows 2003 server, Visual Studio 2008, Sharepoint Extensions

This proc allows wildcard searches on fields and does not filter if a null is passed.  The union to the auxiliary table poses some challenges so I created a UDF dbo.IgnoreNullParm to return ‘1′ or ‘0′ to effectively turn off the union ‘leg’ when we are passed a filter parm that does not exist for that table (i.e. Initials).

Proc Def:

Create Procedure [dbo].[searchEmployees]
(
@FirstName        nvarchar(50)
,@LastName        nvarchar(50)
,@Initials              nvarchar(03)
,@Phone               nvarchar(20)
,@Office                nvarchar(50)
,@Dept                  nvarchar(50)
,@EmpNum        nvarchar(04)
)
as
Select
EM.Employee
, isNull(EM.PreferredName,EM.FirstName) 		as FirstName
, (RTRIM(EM.LastName) + ' ' + isNull(Suffix,'')) 	as LastName
, EM.MiddleName
, EM.Org                                                    as PrimaryDept
, EM.Region
, EM.WorkPhone
, EM.WorkPhoneExt
, EM.MobilePhone
, ECTF.Cust5ULPhysical                                as Office
, ECTF.custSecondaryDepartment                as SecondaryDept
From
EM
Join EmployeeCustomTabFields ECTF on ( ECTF.Employee = EM.Employee )
Where
EM.Status = 'A'
And    (         EM.FirstName     like  Case When (@FirstName is null)    Then '%' Else RTRIM(@FirstName)    + '%' End
OR    EM.PreferredName      like  Case When (@FirstName is null)    Then '%' Else RTRIM(@FirstName)    + '%' End
)
And    EM.LastName         like  Case When (@LastName is null) Then '%' Else RTRIM(@LastName)    + '%' End
And    SUBSTRING(EM.FirstName,1,1)
+  RTRIM(Case When(DATALENGTH(EM.MiddleName) = 0) Then '' Else  SUBSTRING(EM.MiddleName,1,1) End )
+  SUBSTRING(EM.LastName,1,1)  LIKE Case When (@Initials is null) Then '%' Else  @Initials  End
And    (        EM.WorkPhone    like '%' + isNull(@Phone,'%') + '%'
OR    EM.WorkPhoneExt like '%' + isNull(@Phone,'%') + '%'
OR    EM.MobilePhone    like '%' + isNull(@Phone,'%') + '%' )
And ECTF.Cust5ULPhysical = isNull(@Office, ECTF.Cust5ULPhysical)
And ( EM.Org like '%' + isNull(@Dept,'%') + '%'
OR ECTF.custSecondaryDepartment like '%' + isNull(@Dept,'%') + '%'  )
And EM.Employee like  isNull(@EmpNum,'%') + '%'
 UNION ALL
Select  EmpNum                     as Employee
, FirstName
, LastName
, ''                            as MiddleName
, ''                            as PrimaryDept
, ''                            as Region
, Phone                        as WorkPhone
, PhoneExt                        as WorkPhoneExt
, ''                             as MobilePhone
, ECTF_Cust5ULPhysical            as Office
, ''                            as SecondaryDept
From OfficeAux OA
Where
OA.FirstName        like  Case When (@FirstName is null) Then '%' Else RTRIM(@FirstName)    + '%' End
And    OA.LastName         like  Case When (@LastName is null)     Then '%' Else RTRIM(@LastName)        + '%' End
And '1'    = dbo.IgnoreNullParm(@Initials)        <em> -- if parm is null ignore it otherwise this effectively 'turns off union' if parm is not null</em>
And '1'    = dbo.IgnoreNullParm(@Dept)           <em>-- if parm is null ignore it otherwise this effectively 'turns off union' if parm is not null</em>
And    (        OA.Phone        like '%' + isNull(@Phone,'%')  + '%'
OR    OA.PhoneExt    like '%' + isNull(@Phone,'%')  + '%')
And ECTF_Cust5ULPhysical = isNull(@Office, ECTF_Cust5ULPhysical)
And EmpNum  like  isNull(@EmpNum,'%') + '%'


UDF


Create function [dbo].[IgnoreNullParm]
(
@Field  nvarchar(50)
)
Returns bit
-- Sends back True '1' if Parm is null
-- Setup in where clause as Where '1' = IgnoreNullParm(@parm)
-- Allows you to effectively turn off a union 'leg' if a parm is not null and ignore it if not null
as

Begin

Declare @bReturn as  bit

Select  @bReturn = Case When (@Field is null) Then '1' Else '0' End

Return @bReturn

End

Auxilary Table:


CREATE TABLE [dbo].[OfficeAux](
[ID] [uniqueidentifier] NOT NULL,
[ECTF_Cust5ULPhysical] [varchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[XName] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[EmpNum] [char](3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FirstName] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LastName] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[PhoneExt] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Phone] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MobilePhone] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[isActive] [bit] NULL,
[lastUpdated] [datetime] NULL,
[lastUpdater] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
End
12
Jun
08

#13 A Look At Integrating Employee Training History

Training History

This grid (Telerik RadGrid) summarizes for department manager their employee’s CEUs. We house all the data as a custom tab grid within the Employee Info Center.  Note some image features are intentially blocked out for privacy.

10
Jun
08

#10 List of Some Things We Have Integrated

Employee Directory - custom filter, Visual Directory fed from EM and Employee Custom Fields tables

Training Request System - fed from VE Vendor table, merged with custom data and one-click auto loaded back into Deltek EM Custom grid table to store training history. Heavy use of Telerik radgrid to group PDH/CEU credits for date ranges. Other features include nag emails, SRS reports and a review process on sponsor and event.

Training History Bulk Loaded - Define the event (title,dates, hours) - select participants and  bulk load the training history for these employees.

Client Files Tab Bulk Loaded - define the file name, UNC path (not lettered drive) & bulk load the clients file tab of all clients with a link. We use this to link back to an asp.net page so this ‘loader’ (as an option) changes the ending parm on the link to the internal Client CL table ID.

Client Profiles - Over 100 fields are stored on client to keep track of their preferences. This is loosely integrated via the client Files Tab link mentioned above.

Birthday List- simple asp.net user control display Employee name, birth Month & Day (not Year ;-) ) on our intranet with links to their picture. Easily moved to Sharepoint via SmartPart

SRS Phone List- 2 multi-column reports displaying employees ext, direct, mobile and office rendered automatically as a PDF via SQL Report Services link using EM and custom tables.

File Folders- simple method call to create file folders for projects on our servers.

Outlook Folders- Not entirely integrated but sends support staff an email with a link to an asp.net page which creates Outlook Folders with the proper permissions. The WF that sends and email could be replaced with a call to this underlying code but we have not done it yet since that page was written in the asp.net 2.0 framework.

I have created numerous stored procedures, views, UDFs and some custom methods to make Work Flow work better for us. To be honest you can do lots out of the box.  In some cases we used some of these more hands on methods because we had not upgraded to 5.0 at that point (i.e. Project Number Generator SP and asp.net page (see post #02 Simple Popup) which we installed while on 4.0)

In some scenarios we could have used a very complex stored procedure but chose to use a series of SQL Views to simplify and layer in a solution that would allow us to view intermediate results. The end product of all these calculations were pushed(via a Stored Procedure) into a custom field on the ProjectCustomTabFields table.

I will add more to this list as I get time. If you have questions and/or would like more details please post a comment or contact me directly.

23
May
08

#05 Employee Directory

Update: Post #19 offers a Stored Procedure and a (part 2+)  Sharepoint Webpart code for an employee directory.

Note: This uses asp.net 1.1 framework – should migrate to 2.0+ just fine but has not been tested on the newer frameworks. I plan to replace the data calls using the DAAB see Post #04. It should at least show you how easy you can filter and post to a grid.

As I spend time & convert this over to use a better data access layer I will repost but as is should give you an idea of what to do (if you know asp.net).

First here is what it looks like:


asp.net

<asp:dropdownlist id=”dlRecordsPerPage” runat=”server” AutoPostBack=”True”>
<asp:ListItem Value=”25″ Selected=”True”>25</asp:ListItem>
<asp:ListItem Value=”50″>50</asp:ListItem>
<asp:ListItem Value=”100″>100</asp:ListItem>
<asp:ListItem Value=”500″>500</asp:ListItem>
</asp:dropdownlist>
<asp:button id=”ExportToExcel” runat=”server” CssClass=”b1″ Visible=”False” Text=” Export to Excel”></asp:button>
<asp:datagrid id=”DataGrid1″ Width=”680px” BorderStyle=”None” Height=”20px” OnSortCommand=”DataGrid1_SortCommand”
AllowSorting=”True” OnPageIndexChanged=”DataGrid1_PageIndexChanged” Runat=”Server” PageSize=”25″
GridLines=”Vertical” CellPadding=”3″ BorderWidth=”1px” AllowPaging=”True” BorderColor=”#999999″
BackColor=”White” AutoGenerateColumns=”False”>

<SelectedItemStyle Font-Bold=”True” ForeColor=”White” BackColor=”#008A8C”></SelectedItemStyle>
<AlternatingItemStyle Height=”20px” BackColor=”Gainsboro”></AlternatingItemStyle>
<ItemStyle Height=”20px” ForeColor=”Black” BackColor=”#EEEEEE”></ItemStyle>
<HeaderStyle Font-Bold=”True” HorizontalAlign=”Center” Height=”40px” ForeColor=”White” BackColor=”#000084″></HeaderStyle>
<FooterStyle Height=”20px” ForeColor=”Black” BackColor=”#CCCCCC”></FooterStyle>
<Columns>
<asp:BoundColumn DataField=”PersonID” HeaderText=”Emp ID” SortExpression=”A.Employee”>
<ItemStyle Wrap=”False” HorizontalAlign=”Center” Width=”40px” CssClass=”smallAlert”></ItemStyle>
</asp:BoundColumn>
<asp:HyperLinkColumn Text=”<img border=’0′ src=’/newnet/images/intranet/person.gif’ />” Target=”_self”
DataNavigateUrlField=”PersonID” DataNavigateUrlFormatString=”http://intranet/newnet/resources/EmployeeView.aspx?id={0}”
HeaderText=”View ” Visible=”false”>
<ItemStyle CssClass=”smallredC”></ItemStyle>
</asp:HyperLinkColumn>
<asp:HyperLinkColumn Text=”<img border=’0′ src=’/newnet/images/intranet/email.gif’ />” DataNavigateUrlField=”Email”
DataNavigateUrlFormatString=”mailto:{0}” HeaderText=”Email”>
<ItemStyle HorizontalAlign=”Center” Width=”100px” CssClass=”smallredC”></ItemStyle>
</asp:HyperLinkColumn>
<asp:HyperLinkColumn Text=”<img border=’0′ src=’/newnet/images/intranet/person.gif’ />” DataNavigateUrlField=”Employee”
DataNavigateUrlFormatString=”http://intranet/newnet/images/emp/{0}.jpg” HeaderText=”Photo”>
<ItemStyle HorizontalAlign=”Center” Width=”100px” CssClass=”smallredC”></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField=”FirstName” HeaderText=”First Name” SortExpression=”FirstName”>
<ItemStyle Wrap=”False” Width=”90px” CssClass=”smallred”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”LastName” HeaderText=”Last Name” SortExpression=”LastName”>
<ItemStyle Wrap=”False” Width=”90px” CssClass=”smallred”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”WorkPhoneExt” HeaderText=”Ext”>
<ItemStyle Wrap=”False” Width=”35px” CssClass=”smalldetail”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”WorkPhone” HeaderText=”Direct”>
<ItemStyle Wrap=”False” Width=”65px” CssClass=”smalldetail”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”MobilePhone” HeaderText=”Mobile”>
<ItemStyle Wrap=”False” Width=”75px” CssClass=”smalldetail”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”Org” HeaderText=”Primary Dept” SortExpression=”Org”>
<ItemStyle Wrap=”False” CssClass=”smallredC”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”custSecondaryDepartment” HeaderText=”Secondary Dept” SortExpression=”C.custSecondaryDepartment”>
<ItemStyle Wrap=”False” CssClass=”smallredC”></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField=”Office” HeaderText=”Office” SortExpression=”B.Cust5ULPhysical”>
<ItemStyle Wrap=”False” CssClass=”smallredC”></ItemStyle>
</asp:BoundColumn>
</Columns>
<PagerStyle Height=”20px” HorizontalAlign=”Center” ForeColor=”Black” BackColor=”#999999″ Mode=”NumericPages”></PagerStyle>
</asp:datagrid>

C#:

Note: The embedded query should be cleaned up using join clauses and the should be replaced by a stored procedure perhaps using WHEN CASE to ignore unused filter parms.

public void BindDataGrid( string sOrderParm )
{

SqlDataAdapter daList;
DataSet dsClients;

SqlConnection conn = new SqlConnection(connstring);
conn.Open();
string strDeptCode = “%” + dlDepartment.SelectedValue.ToString() + “%”;
string strRegionCode = “%” + dlRegion.SelectedValue.ToString() + “%”;

string strSQL = ” Select A.Employee , (RTRIM(LastName) + ‘ ‘ + ISNULL(Suffix,”)) as LastName , PreferredName As FirstName, MiddleName, Org, Region, WorkPhone, WorkPhoneExt, MobilePhone, B.Cust5ULPhysical As Office, C.custSecondaryDepartment “;
strSQL += ” , RTRIM(A.Employee) As PersonID, A.Email “;
strSQL += ” FROM EM A , EmployeeCustomTabFields B, EmployeeCustomTabFields C “;
strSQL += ” WHERE A.Status = ‘A’ “;
strSQL += ” AND A.Employee = B.Employee “;
strSQL += ” AND A.Employee = C.Employee “;
strSQL += ” AND A.[LastName] Like ‘” + txtLastName.Text.Trim() + “%’ And A.[Employee] Like ‘” + txtEmpID.Text.Trim() + “%’ And ( A.[PreferredName] Like ‘” + txtFirstName.Text.Trim() + “%’ OR A.[FirstName] like ‘” + txtFirstName.Text.Trim() + “%’ ) AND ( A.[Org] like ‘” + strDeptCode + “%’ or C.custSecondaryDepartment like ‘%” + strDeptCode + “%’ ) AND ( A.WorkPhone like ‘%” + txtPhone.Text.Trim() + “%’ OR A.WorkPhoneExt like ‘%” + txtPhone.Text.Trim() + “%’ OR A.MobilePhone like ‘%” + txtPhone.Text.Trim() + “%’) “;
strSQL += ” AND B.Cust5ULPhysical like ‘%” + strRegionCode + “%’ “;
strSQL += ” Order By ” + sOrderParm;

daList = new SqlDataAdapter(strSQL, conn );
dsClients = new DataSet();
daList.Fill( dsClients );
DataGrid1.PageSize = Int32.Parse(dlRecordsPerPage.SelectedValue.ToString());
DataGrid1.DataSource = dsClients;
try
{
DataGrid1.DataBind();
if (DataGrid1.Items.Count == 0)
{
txtError.Text = “No Records Found”;
txtError.Visible = true;
DataGrid1.Visible = false;

}
else
{
ExportToExcel.Visible = true;
DataGrid1.Visible = true;
txtError.Visible = false;
txtTest.Visible = false;
}
}
catch
{
txtError.Text = “No Records Found”;
txtError.Visible = true;
DataGrid1.Visible = false;
}
finally
{
if (conn != null) { conn.Close(); conn.Dispose(); }
if (daList != null) { daList.Dispose(); }
if (dsClients != null) { dsClients.Dispose(); }
}

}