I have a small code that shows inactive and active users from the ms access DB. - <%@ Page Language="VB" MasterPageFile="~/MasterPageAdmin.master" Title="Welcome" %>
-
<%@ Import Namespace="System.Data" %>
-
<%@ Import Namespace="System.Data.OleDb" %>
-
<%@ Import Namespace="System.Drawing" %>
-
-
<script language="VB" runat="server">
-
-
Public Function GetInActiveDays(ByVal strLastLoginDate As String) As Integer
-
Dim date1 As Date = New Date()
-
Dim date2 As Date = New Date()
-
Dim time As TimeSpan
-
-
date1 = Date.Parse(strLastLoginDate)
-
date2 = Date.Now
-
time = date2.Subtract(date1)
-
-
Return time.Days
-
End Function
-
-
Public Function IsInActiveUser(ByVal strLastLoginDate As String) As String
-
Dim strStatus As String = "Active"
-
Dim FontColor As Color = Color.Blue
-
-
If (GetInActiveDays(strLastLoginDate) > 2) Then
-
strStatus = "Inactive"
-
End If
-
-
Return strStatus
-
End Function
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
-
lbdt.Text = Date.Now
-
BindGridView2()
-
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data\origin_timesheet.mdb") & ";")
-
myConnection.Open()
-
-
-
Dim strQuery As String = "UPDATE Employee SET CurrentLoginDate=?"
-
Dim myCommand As New OleDbCommand(strQuery, myConnection)
-
myCommand.CommandType = CommandType.Text
-
-
-
myCommand.Parameters.Add("@p1", OleDbType.DBDate).Value = Date.Now
-
myCommand.ExecuteNonQuery()
-
myConnection.Close()
-
End Sub
-
-
Sub BindGridView2()
-
Dim myConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data\origin_timesheet.mdb") & ";")
-
myConnection.Open()
-
-
-
Dim strQuery As String = "SELECT * FROM Employee"
-
Dim myDataAdapter As New OleDbDataAdapter(strQuery, myConnection)
-
Dim ds As New DataSet
-
-
-
myDataAdapter.Fill(ds)
-
GridView2.DataSource = ds
-
GridView2.DataBind()
-
-
ds.Dispose()
-
myDataAdapter.Dispose()
-
ds = Nothing
-
myDataAdapter = Nothing
-
myConnection.Close()
-
End Sub
-
-
</script>
-
-
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
-
<br />
-
<br />
-
<span
-
style="color: #000033"><span style="font-family: Verdana"><span style="font-size: 11pt"><br />
-
<br />
-
<br />
-
<span class="wtxt">Your status is set to: <span style="color: red">Administrator<br />
-
<br />
-
<asp:GridView id="GridView2" runat="server" Width="700px" AllowSorting="True" AutoGenerateColumns="False" Font-Names="Verdana" EmptyDataText="No record found." EmptyDataRowStyle-ForeColor="White" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" Font-Size="8pt" GridLines="None">
-
<Columns>
-
<asp:TemplateField HeaderText="Users">
-
<ItemStyle Width="400px" VerticalAlign="Top" BorderColor="Transparent"/>
-
<HeaderStyle HorizontalAlign="Left"/>
-
<ItemTemplate>
-
<asp:Label ID="lblUser" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.UserName", "") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="Real Name">
-
<ItemStyle Width="400px" VerticalAlign="Top" BorderColor="Transparent"/>
-
<HeaderStyle HorizontalAlign="Left"/>
-
<ItemTemplate>
-
<asp:Label ID="lblRealName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.RealName", "") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="Last Login Date">
-
<ItemStyle Width="400px" VerticalAlign="Top" BorderColor="Transparent"/>
-
<HeaderStyle HorizontalAlign="Left"/>
-
<ItemTemplate>
-
<asp:Label ID="lblDate" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.LastLoginDate", "{0:MM/dd/yyyy}") %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
<asp:TemplateField HeaderText="InActive - More Than 2 Days?">
-
<ItemStyle Width="800px" VerticalAlign="Top" BorderColor="Transparent"/>
-
<HeaderStyle HorizontalAlign="Left"/>
-
<ItemTemplate>
-
<asp:Label ID="lblInActive" runat="server" Text='<%# IsInActiveUser(DataBinder.Eval(Container, "DataItem.LastLoginDate", "{0:MM/dd/yyyy}")) %>'></asp:Label>
-
</ItemTemplate>
-
</asp:TemplateField>
-
</Columns>
-
<EmptyDataRowStyle ForeColor="White" />
-
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
-
<RowStyle BackColor="#FFFFCC" ForeColor="Black" />
-
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
-
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
-
<HeaderStyle BackColor="Gray" Font-Bold="True" ForeColor="Black" Font-Size="8pt" />
-
</asp:GridView>
-
<asp:Label ID="lblInActive" runat="server" Text='<%# IsInActiveUser(DataBinder.Eval(Container, "DataItem.Date", "{0:MM/dd/yyyy}")) %>'></asp:Label><br />
-
<span class="wtxt">Current system date & time:</span>
-
<asp:Label ID="lbdt" runat="server"></asp:Label></span></span></span></span></asp:Content>
Here i wanted to show the inactive users in red .. i think its got something to do with this function, but i dont know the color change code for string. - Public Function IsInActiveUser(ByVal strLastLoginDate As String) As String
-
Dim strStatus As String = "Active"
-
Dim FontColor As Color = Color.Blue
-
-
If (GetInActiveDays(strLastLoginDate) > 2) Then
-
strStatus = "Inactive"
-
End If
-
-
Return strStatus
-
End Function
Please advise
Thanks in advance ..
1 2612 jhardman 3,406
Recognized Expert Specialist Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dm1608 |
last post by:
I have a GridView that is using an ObjectDataSource to populate.
One of my columns is named "Status" and can have a value of "Complete",
"Error", "Active", and "Unknown". I would like to have the text for the
word "Error" displayed in RED letters. How can I do this with a GridView
control?
|
by: needin4mation |
last post by:
protected void Page_Load(object sender, EventArgs e)
{
TextBox mpTextBox =
(TextBox)(Master.FindControl("txtFreeSearch"));
Response.Write("mp" + mpTextBox.Text); //only works the second
time
}
|
by: Jim in Arizona |
last post by:
I have a gridview that's being populated from an access db query. The
problem I'm having is that the date/time fields in access that are
populating the gridview are showing both date and time, when the field
should only be showing one or the other (date or time).
Even on the back end of the database where the column properties are, I
have chosen the smallest date/time formats. When the aspx page runs, it
shows the date and time (ie:in a...
|
by: Dan |
last post by:
Issue making textbox visible based on specific input from a radio button
list in an EditItemTemplate
I want to setup a gridview that when in edit mode and when the user
selects "Other" from a radiolist that a text box will appear and the
user can input text.
I can get the textbox to appear after selecting other in the radiolist;
however, the selected value in the radiolist disappears. I believe this
is due to the databind call.
|
by: Ashton |
last post by:
Hello,
I have a GridView; once the page is loaded I can sort it just fine, I
can sort it as many times as I would like, I can sort any of the
columns.
After clicking on Search and the GridView is updated with new data the
sort does not work.
I'm using C# and Ajax for the implementation, below is the code,
| |
by: =?Utf-8?B?Y2hyaXM=?= |
last post by:
I have a perent gridview which includes in a template field a child gridview.
Child gridview includes command buttons for opening different windows based
on its row selected.
I used the code below. The event for RowDataBound is executed, rows get
different color, but event for RowCommand is not executed. What could be the
problem ?
Thanks a lot in advance.
|
by: Blasting Cap |
last post by:
I've got a gridview (that I converted over from a datagrid, which had
been working properly), that is doubling up the number of rows returned.
When it was running as a datagrid, the same code sent back the
proper number of rows. The only thing different I am doing is to
display the number of rows returned in the footer of the gridview.
The Bindgrid is as follows:
Sub BindGrid()
Session("reportlevel") = Session("availabilityrptlevel")
|
by: =?Utf-8?B?UGhpbCBKb2huc29u?= |
last post by:
Hi,
I need to have a column in a gridview that cycles through a set of comma
delimited values
i.e. if you imagine a column where in one row the value might be "111,222"
and in the next row it might be "111,222,333,444".
Instead of displaying the whole string, I need to split the string by the
comma delimeter and show each value long enough so that every value will be
|
by: Ben |
last post by:
Hi,
The gridview contains a radiobuttonlist with boolean values (true/false)
coming from a database.
In normal mode, the gridview displays True or False for that field.
What i want is to change True' and 'False' by 'Yes' and 'No' in normal mode.
I tried this, but still get True / False.
Thanks for help
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |