<%@ Page Language="VB" MasterPageFile="~/Nested Master Pages/admin.master" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
Public Sub Page_Load()
currentUser = Membership.GetUser()
SqlDataSource1.SelectParameters("UserId").DefaultValue = currentUser.ProviderUserKey.ToString()
SqlDataSource1.DataBind()
End Sub
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'If Cancel button is clicked, send user to Default
Response.Redirect("~/Annonymous/index.aspx")
End Sub
Dim currentUser As MembershipUser
Dim TotalUnitPrice As Decimal = 0.0
Function GetUnitPrice(ByVal fltOrderAmount As Decimal) As Decimal
TotalUnitPrice += fltOrderAmount
Return fltOrderAmount
End Function
Function GetTotal() As Decimal
Return TotalUnitPrice
End Function
Protected Sub btnexportexcel_click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Clear()
Response.Buffer = True
'For Word:
'Response.AddHeader("content-disposition", "attachment;filename=data.doc")
'Response.ContentType = "application/vnd.ms-word"
'For Excel
Response.AddHeader("content-disposition", "attachment;filename=SummaryReport.xls")
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
SqlDataSource1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.[End]()
End Sub
Protected Sub OnSelectedData(ByVal sender As Object, ByVal e As SqlDataSourceStatusEventArgs)
' Set the record count label
MessageLabel.Text = "Total Records: " + e.AffectedRows.ToString()
End Sub
</script>
<%-- Add content controls here --%>
<asp:Content ID="Content2" runat="server" contentplaceholderid="ContentPlaceHolder4">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager>
Begin Date <asp:TextBox ID="BeginDate" runat="server" Width="70"></asp:TextBox>
<asp:Image id="Image1" runat="server" ImageUrl="~/images1/calendar_scheduleHS.png" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="BeginDate" PopupButtonID="Image1">
</asp:CalendarExtender>
End Date <asp:TextBox ID="EndDate" runat="server" Width="70"></asp:TextBox>
<asp:Image id="Image2" runat="server" ImageUrl="~/images1/calendar_scheduleHS.png" />
<asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="EndDate" PopupButtonID="Image2">
</asp:CalendarExtender>
<asp:GridView ID="GridView2" AllowSorting="true" AllowPaging="true" Runat="server" Width="860"
DataSourceID="SqlDataSource1" ShowFooter="true" DataKeyNames="Id" Font-Size="XX-Small" AutoGenerateColumns="False" FooterStyle-HorizontalAlign="Right">
<Columns>
<asp:TemplateField ItemStyle-BackColor = "#F4F4F4" HeaderStyle-BackColor="#A1C1D9" HeaderStyle-Font-Size="9" HeaderStyle-Width="300" ItemStyle-HorizontalAlign="Center" HeaderText="Company Infomation">
<ItemTemplate>
<asp:Label ID="lblCompany" runat="server" BackColor = "#F4F4F4" Text='<%# Eval("Company") %>'></asp:Label>
<asp:Label ID="lblName" runat="server" BackColor = "#F4F4F4" Text='<%#Eval("Name")%>'></asp:Label><br />
<asp:Label ID="Lblphone" runat="server" BackColor = "#F4F4F4" Text='<%#Eval("Phone")%>'></asp:Label><br />
<asp:Label ID="LblWebSiteUrl" runat="server" BackColor = "#F4F4F4" Text='<%#Eval("WebSiteUrl")%>'></asp:Label>
<asp:Label ID="LblEmail" runat="server" BackColor = "#F4F4F4" Text='<%#Eval("Email")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText=" ID " DataField="ID" HeaderStyle-BackColor="#A1C1D9" ReadOnly="true" ControlStyle-Width="20" />
<asp:BoundField HeaderText=" Year " DataField="Year" HeaderStyle-BackColor="#A1C1D9" ItemStyle-HorizontalAlign="Center" ControlStyle-Width="30" />
<asp:BoundField HeaderText=" Make " DataField="Make" HeaderStyle-BackColor="#A1C1D9" ItemStyle-Width="150"/>
<asp:BoundField HeaderText=" Model " DataField="Model" HeaderStyle-BackColor="#A1C1D9" ItemStyle-Width="100" />
<asp:BoundField HeaderText=" Type " DataField="Type" HeaderStyle-BackColor="#A1C1D9" ItemStyle-Width="150" />
<asp:BoundField HeaderText=" MilesHours " DataField="MilesHours" HeaderStyle-BackColor ="#A1C1D9" ItemStyle-HorizontalAlign="Right" ControlStyle-Width="60" />
<asp:BoundField HeaderText=" VinSerial " DataField="VinSerial" HeaderStyle-BackColor ="#A1C1D9" ItemStyle-HorizontalAlign="Center" ControlStyle-Width="60" />
<asp:BoundField HeaderText=" Description " DataField="Description" HeaderStyle-BackColor="#A1C1D9" ItemStyle-Width="150" />
<asp:BoundField HeaderText=" Location " DataField="Location" HeaderStyle-BackColor ="#A1C1D9" FooterText="Company Total" ItemStyle-Width="150"/>
<asp:TemplateField HeaderText="Price" HeaderStyle-BackColor="#A1C1D9" FooterStyle-Font-Bold="True" HeaderStyle-Width="40" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
$<%# GetUnitPrice(Decimal.Parse(Eval("Price").ToString())).ToString("N0")%>
</ItemTemplate>
<FooterTemplate>
$<%# GetTotal().ToString("N0") %>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Sign Up Date" HeaderStyle-BackColor="#A1C1D9" ItemStyle-HorizontalAlign="Center" dataformatstring="{0:M-dd-yyyy}" DataField="SignUpDate" HeaderStyle-Width="70" />
<asp:BoundField HeaderText="Ending Date" HeaderStyle-BackColor="#A1C1D9" ItemStyle-HorizontalAlign="Center" dataformatstring="{0:M-dd-yyyy}" DataField="LastLockOutDate" HeaderStyle-Width="70" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" OnSelected="OnSelectedData" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
SelectCommand="SELECT E.ID, E.UserId, E.Year, E.Make, E.Model, E.Type, E.MilesHours, E.VinSerial, E.Description, E.Location, E.Price, E.SignUpDate, E.EquipmentID
FROM [Used_Trucks].[dbo].[Equipment] E
WHERE E.IsLockedOut = 'True' and (Signupdate between CONVERT(datetime, @BeginDate, 101) And CONVERT(datetime, @EndDate, 101))
ORDER BY userId, SignUpDate DESC">
<SelectParameters>
<asp:ControlParameter Name="BeginDate" controlId="CalendarExtender1" PropertyName="SelectedDate" />
<asp:ControlParameter Name="EndDate" ControlID="CalendarExtender2" PropertyName="SelectedDate"/>
</SelectParameters>
</asp:SqlDataSource>
<table align="center">
<tr><td align="center">
<asp:Button ID="btnExportExcel" runat="server" Text="ExportToExcel" CausesValidation="false" onclick="btnexportExcel_click" />
</td></tr>
</table>
<asp:label id="MessageLabel" forecolor="Red" runat="server"/>
</asp:Content>
|