1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
|
<%@ Page Language="VB" MasterPageFile="~/Nested Master Pages/user.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">
<div>
<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 ID, UserId, Year, Make, Model, Type, MilesHours, VinSerial, Description, Location, Price, SignUpDate, LastLockOutDate,
Name=CASE WHEN rownum=1 then Name else Char(32) end,
Company=CASE WHEN rownum=1 then Company else Char(32) end,
Phone=CASE WHEN rownum=1 then Phone else Char(32) end,
WebsiteURL=CASE WHEN rownum=1 then WebsiteURL else Char(32) end,
Email=CASE WHEN rownum=1 then Email else Char(32) end,
EquipmentID,
ImageID1, EquipmentID1, Title1, ImageData1, MIMEType1,
ImageID2, EquipmentID2, Title2, ImageData2, MIMEType2,
ImageID3, EquipmentID3, Title3, ImageData3, MIMEType3,
ImageID4, EquipmentID4, Title4, ImageData4, MIMEType4,
ImageID5, EquipmentID5, Title5, ImageData5, MIMEType5,
ImageID6, EquipmentID6, Title6, ImageData6, MIMEType6
FROM (
SELECT rownum=row_number() over (partition by UserProfile.company, UserProfile.websiteurl ORDER BY E.SignUpDate DESC),
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.LastLockOutDate,
UserProfile.Name, UserProfile.Company, UserProfile.Phone, UserProfile.WebsiteURL, UserProfile.Email, E.EquipmentID,
GetCustomerImage_1.ImageID AS ImageID1, GetCustomerImage_1.EquipmentID AS EquipmentID1, GetCustomerImage_1.Title AS Title1, GetCustomerImage_1.ImageData AS ImageData1, GetCustomerImage_1.MIMEType AS MIMEType1,
GetCustomerImage_2.ImageID AS ImageID2, GetCustomerImage_2.EquipmentID AS EquipmentID2, GetCustomerImage_2.Title AS Title2, GetCustomerImage_2.ImageData AS ImageData2, GetCustomerImage_2.MIMEType AS MIMEType2,
GetCustomerImage_3.ImageID AS ImageID3, GetCustomerImage_3.EquipmentID AS EquipmentID3, GetCustomerImage_3.Title AS Title3, GetCustomerImage_3.ImageData AS ImageData3, GetCustomerImage_3.MIMEType AS MIMEType3,
GetCustomerImage_4.ImageID AS ImageID4, GetCustomerImage_4.EquipmentID AS EquipmentID4, GetCustomerImage_4.Title AS Title4, GetCustomerImage_4.ImageData AS ImageData4, GetCustomerImage_4.MIMEType AS MIMEType4,
GetCustomerImage_5.ImageID AS ImageID5, GetCustomerImage_5.EquipmentID AS EquipmentID5, GetCustomerImage_5.Title AS Title5, GetCustomerImage_5.ImageData AS ImageData5, GetCustomerImage_5.MIMEType AS MIMEType5,
GetCustomerImage_6.ImageID AS ImageID6, GetCustomerImage_6.EquipmentID AS EquipmentID6, GetCustomerImage_6.Title AS Title6, GetCustomerImage_6.ImageData AS ImageData6, GetCustomerImage_6.MIMEType AS MIMEType6
FROM Equipment AS E INNER JOIN
UserProfile ON E.UserId = UserProfile.UserId
OUTER APPLY GetCustomerImage(1, E.EquipmentID) AS GetCustomerImage_1
OUTER APPLY GetCustomerImage(2, E.EquipmentID) AS GetCustomerImage_2
OUTER APPLY GetCustomerImage(3, E.EquipmentID) AS GetCustomerImage_3
OUTER APPLY GetCustomerImage(4, E.EquipmentID) AS GetCustomerImage_4
OUTER APPLY GetCustomerImage(5, E.EquipmentID) AS GetCustomerImage_5
OUTER APPLY GetCustomerImage(6, E.EquipmentID) AS GetCustomerImage_6
WHERE E.IsLockedOut = 'False' and and (Signupdate between @BeginDate And @EndDate)
) SQ
ORDER BY userId, SignUpDate DESC">
<SelectParameters>
<asp:parameter Name="UserID" DbType="String" />
<asp:Parameter DefaultValue="07/22/2010" Name="SignUpDate" Type="DateTime" />
<asp:Parameter Name="BeginDate" Type="DateTime" />
<asp:Parameter Name="EndDate" Type="DateTime" />
</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"/>
</div>
</asp:Content>
|