Saturday, March 24, 2012

This takes forever!!

I know this is a lot of code, but I was wandering why this takes forever to
render on the web page??

*************ASPX PAGE******************************

<%@dotnet.itags.org. Register TagPrefix="uc1" TagName="_Header" src="http://pics.10026.com/?src=_Header.ascx" %>
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="machine.aspx.vb"
Inherits="ASPNETProduct.ASPNETProduct.machine"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>machine</title>
<meta content="Microsoft Visual Studio.NET 7.0" name=GENERATOR>
<meta content="Visual Basic 7.0" name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5
name=vs_targetSchema>
<script src="http://pics.10026.com/?src=include/tabbed.js" type=text/javascript></script
<script src="http://pics.10026.com/?src=include/newWindow.js" type=text/javascript></script>
<LINK href="http://links.10026.com/?link=styles.css" type=text/css rel=STYLESHEET >
<script language=JavaScript>
function fnCallDialog(theURL)
{
var res = showModalDialog(theURL,window,"status:false; dialogHide:Yes;
resizable: No; scroll:No; status: No; help: No; edge:
Sunken;dialogWidth:684px;dialogHeight:560px");
if( res == 1 ){
location.href="Quotes/newQuote.aspx";
}
}
</script>
</HEAD>
<body background=images\background.gif MS_POSITIONING="GridLayout">
<uc1:_header id=_Header1 runat="server"></uc1:_header>
<form id=Form1 method=post runat="server"><asp:label id=Label2
style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 64px"
runat="server" CssClass="objtext"
Width="40px">Search</asp:label><asp:textbox id=searchVal style="Z-INDEX:
104; LEFT: 104px; POSITION: absolute; TOP: 56px" runat="server"
CssClass="objtext" Width="272px"></asp:textbox><asp:label id=Label3
style="Z-INDEX: 108; LEFT: 392px; POSITION: absolute; TOP: 64px"
runat="server" CssClass="objtext"
Width="16px">By</asp:label><br> <asp:label id=lblStatus style="Z-INDEX:
101; LEFT: 8px; POSITION: absolute; TOP: 472px" Font-Name="verdana"
ForeColor="#ff0000" Runat="server" Font-Size="12px"></asp:label>
<asp:datagrid id=availMachList style="Z-INDEX: 102; LEFT: 8px; POSITION:
absolute; TOP: 200px" runat="server" Width="100%"
OnItemDataBound="availMachList_ItemDataBound" CellPadding="3"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False">
<SelectedItemStyle Font-Size="Smaller" Font-Bold="True" Wrap="False"
BackColor="LightBlue">
</SelectedItemStyle
<EditItemStyle Font-Size="Smaller" Wrap="False" BackColor="Silver">
</EditItemStyle
<AlternatingItemStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
BorderStyle="Groove" BackColor="#FFFFCC">
</AlternatingItemStyle
<ItemStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
BackColor="#FFFFCC">
</ItemStyle
<HeaderStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
HorizontalAlign="Left" BackColor="#CCFFFF">
</HeaderStyle
<FooterStyle Wrap="False">
</FooterStyle
<Columns>
<asp:TemplateColumn HeaderText="Select">
<HeaderStyle Wrap="False" HorizontalAlign="Center" Width="10px">
</HeaderStyle
<ItemStyle Wrap="False" HorizontalAlign="Center">
</ItemStyle
<ItemTemplate>
<asp:Checkbox ID="chkSelection" Runat="server" />
<asp:Label ID="hdnStoreID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "Stock_No") %>' Runat=server />
<asp:Label ID="machineID" Visible="False" Text='<%#
DataBinder.Eval(Container.DataItem, "machineID") %>' Runat=server /
</ItemTemplate
<FooterStyle Wrap="False">
</FooterStyle>
</asp:TemplateColumn>
<asp:HyperLinkColumn SortExpression="Stock_No"
DataNavigateURLField="Stock_No"
DataNavigateUrlFormatString="javascript:CenterWindow('machineInfo.aspx?Stock
_No={0}','550', '480');" HeaderText="STOCK NUMBER" DataTextField="Stock_No"
/>
<asp:TemplateColumn SortExpression="MACH_CODE" HeaderText="MACHINE CODE">
<HeaderStyle Wrap="False">
</HeaderStyle
<ItemStyle Wrap="False">
</ItemStyle
<ItemTemplate>
<asp:Label id=Label8 runat="server" Text='<%# DataBinder.Eval(Contain
er, "DataItem.MACH_CODE") %>'>
</asp:Label
</ItemTemplate
<FooterStyle Wrap="False">
</FooterStyle
<EditItemTemplate>
<P>
<asp:TextBox id=txtMACH_CODE runat="server" Width="108px" Text='<%#
DataBinder.Eval(Container, "DataItem.MACH_CODE") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator id="valMACH_CODE" runat="server"
ErrorMessage="MACH_CODE is required" ControlToValidate="txtMACH_CODE"
Display="None"></asp:RequiredFieldValidator></P
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="machineSIZE" HeaderText="machineSIZE">
<HeaderStyle Wrap="False">
</HeaderStyle
<ItemStyle Wrap="False">
</ItemStyle
<ItemTemplate>
<asp:Label id=Label9 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.machineSIZE") %>'>
</asp:Label
</ItemTemplate
<FooterStyle Wrap="False">
</FooterStyle
<EditItemTemplate>
<P>
<asp:TextBox id=txtSIZE runat="server" Width="107px" Text='<%#
DataBinder.Eval(Container, "DataItem.SIZE") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator id="valSIZE" runat="server"
ErrorMessage="SIZE is required" ControlToValidate="txtSIZE"
Display="None"></asp:RequiredFieldValidator></P
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="MACHINE" HeaderText="MACHINE">
<HeaderStyle Wrap="False">
</HeaderStyle
<ItemStyle Wrap="False">
</ItemStyle
<ItemTemplate>
<asp:Label id=Label7 runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.MACHINE") %>'>
</asp:Label
</ItemTemplate
<FooterStyle Wrap="False">
</FooterStyle
<EditItemTemplate>
<P>
<asp:TextBox id=txtMACHINE runat="server" Width="100px" Text='<%#
DataBinder.Eval(Container, "DataItem.MACHINE") %>'>
</asp:TextBox></P
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="ASKING_PRI" HeaderText="Price">
<HeaderStyle Wrap="False">
</HeaderStyle
<ItemStyle Wrap="False">
</ItemStyle
<ItemTemplate>
<asp:Label id="Label4" runat="server" Text='<%#
ChangeColor(DataBinder.Eval(Container,
"DataItem.ASKING_PRI"),DataBinder.Eval(Container, "DataItem.Sold_To")) %>'>
</asp:Label
</ItemTemplate
<FooterStyle Wrap="False">
</FooterStyle>
</asp:TemplateColumn>
</Columns
<PagerStyle ForeColor="Black" Wrap="False" Mode="NumericPages">
</PagerStyle>
</asp:datagrid><asp:label id=Label1 style="Z-INDEX: 105; LEFT: 16px;
POSITION: absolute; TOP: 96px" runat="server" CssClass="objtext"
Width="80px">Machine Code </asp:label><asp:dropdownlist id=theMachCode
style="Z-INDEX: 106; LEFT: 104px; POSITION: absolute; TOP: 88px"
runat="server" CssClass="objtext" DataTextField="FULLDESC"
DataValueField="CATNUM"
OnSelectedIndexChanged="theMachCode_SelectedIndexChanged"
AutoPostBack="True"></asp:dropdownlist><asp:button id=Button1
style="Z-INDEX: 107; LEFT: 328px; POSITION: absolute; TOP: 120px"
runat="server" CssClass="inputSubmit"
Text="Search"></asp:button><asp:dropdownlist id=searchBy style="Z-INDEX:
109; LEFT: 416px; POSITION: absolute; TOP: 56px" runat="server"
CssClass="objtext">
<asp:ListItem Value="0" Selected="True">Optional</asp:ListItem>
<asp:ListItem Value="MACHINE">Machine</asp:ListItem>
<asp:ListItem Value="SERIAL_NO">Serial Number</asp:ListItem>
<asp:ListItem Value="STOCK_NO">Stock Number</asp:ListItem>
</asp:dropdownlist><asp:label id=Label5 style="Z-INDEX: 110; LEFT: 16px;
POSITION: absolute; TOP: 128px" runat="server" CssClass="objtext">View
By</asp:label><asp:dropdownlist id=DropDownView style="Z-INDEX: 111; LEFT:
104px; POSITION: absolute; TOP: 120px" runat="server" CssClass="objtext">
<asp:ListItem Value="1" Selected="True">Inventory</asp:ListItem>
<asp:ListItem Value="2">Sold</asp:ListItem>
<asp:ListItem Value="3">All</asp:ListItem>
</asp:dropdownlist><asp:label id=Label6 style="Z-INDEX: 112; LEFT: 200px;
POSITION: absolute; TOP: 128px" runat="server"
CssClass="objtext">Records</asp:label><asp:dropdownlist id=recordsCount
style="Z-INDEX: 113; LEFT: 256px; POSITION: absolute; TOP: 120px"
runat="server" CssClass="objtext">
<asp:ListItem Value="1000000" Selected="True">All</asp:ListItem>
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="50">50</asp:ListItem>
<asp:ListItem Value="100">100</asp:ListItem>
<asp:ListItem Value="1000">1000</asp:ListItem>
</asp:dropdownlist><asp:panel id=Panel1
style="Z-INDEX: 114; LEFT: 16px; POSITION: absolute; TOP: 168px"
runat="server" Width="104px" Height="6px" Visible="False">
<asp:Button id=Button4 runat="server" CssClass="inputSubmit" Text="View
Machines"></asp:Button></asp:panel><asp:panel
id=Panel2 style="Z-INDEX: 115; LEFT: 128px; POSITION: absolute; TOP: 168px"
runat="server" Width="104px" Visible="False">
<asp:Button id=Button2 runat="server" CssClass="inputSubmit" Text="Quote
Machines" Visible="True"></asp:Button></asp:panel><asp:panel
id=Panel3 style="Z-INDEX: 116; LEFT: 240px; POSITION: absolute; TOP: 168px"
runat="server" Width="96px" Height="16px" Visible="False">
<asp:Button id=Button3 runat="server" CssClass="inputSubmit" Text="Add to
Invoice"></asp:Button></asp:panel><asp:label id=Label11 style="Z-INDEX: 117;
LEFT: 488px; POSITION: absolute; TOP: 168px" runat="server"
CssClass="objtext" ForeColor="Red" Visible="False"></asp:label>
<asp:Panel id=Panel4 style="Z-INDEX: 118; LEFT: 352px; POSITION: absolute;
TOP: 168px" runat="server" Width="8px" Visible="False">
<asp:Button id=Button5 runat="server" CssClass="inputSubmit" Text="Add to
Sales"></asp:Button></asp:Panel></form>
</body>
</HTML
********************Code
Behind******************************************** **************
************************************************** **************************
************

Imports System.Data.SqlClient
Namespace ASPNETProduct
Public Class machine
Inherits System.Web.UI.Page
Protected WithEvents availMachList As
System.Web.UI.WebControls.DataGrid
Shared SelSort As String = ""
Protected WithEvents lblStatus As System.Web.UI.WebControls.Label
Protected WithEvents searchVal As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents theMachCode As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents searchBy As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents DropDownView As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Label6 As System.Web.UI.WebControls.Label
Protected WithEvents recordsCount As
System.Web.UI.WebControls.DropDownList
Protected WithEvents Button2 As System.Web.UI.WebControls.Button
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents Panel2 As System.Web.UI.WebControls.Panel
Protected WithEvents Button3 As System.Web.UI.WebControls.Button
Protected WithEvents Panel3 As System.Web.UI.WebControls.Panel
Protected WithEvents Button4 As System.Web.UI.WebControls.Button
Protected WithEvents Label11 As System.Web.UI.WebControls.Label
Protected WithEvents RequiredFieldValidator1 As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents Panel4 As System.Web.UI.WebControls.Panel
Protected WithEvents Button5 As System.Web.UI.WebControls.Button
Shared SelSortDir As String = "ASC" 'sort direction

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim CheckCookie As HttpCookie
CheckCookie = Request.Cookies("misc")
If CheckCookie Is Nothing Then
Session("pageRedir") = "machine.aspx"
Response.Redirect("mainLog.aspx")
Else
Session("pageRedir") = ""
End If
If Page.IsPostBack = False Then
Dim MachCodeList As New ASPNETProduct.machinedb()

theMachCode.DataSource = MachCodeList.GetAvailMachCodeList()
theMachCode.DataBind()
theMachCode.Items.Insert(0, New ListItem("All", "A0000"))
' FillDataGrid()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
FillDataGrid()
End Sub
'************************************************* ******
'
' GetBrowsePath() is a helper method used to create the url
' to the document. If the size of the content stored in the
' database is non-zero, it creates a path to browse that.
' Otherwise, the FileNameUrl value is used.
'
' This method is used in the databinding expression for
' the browse Hyperlink within the DataGrid, and is called
' for each row when DataGrid.DataBind() is called. It is
' defined as a helper method here (as opposed to inline
' within the template) to improve code organization and
' avoid embedding logic within the content template.
'
'************************************************* ******'

Function GetBrowsePath(ByVal documentId As Integer) As String

' if there is content in the database, create an
' url to browse it
Return "~/ViewDocument.aspx?DocumentID=" & documentId.ToString()

End Function

Function FillDataGrid()
Dim theSearchVal, theSearchBy, theSearchView, theMachCode1,
thecode As String
theSearchVal = searchVal.Text
theSearchBy = searchBy.SelectedItem.Value
theMachCode1 = theMachCode.SelectedItem.Value
theSearchView = DropDownView.SelectedItem.Value
Dim availMach As New ASPNETProduct.machinedb()
Dim dstMachList As DataSet
dstMachList = availMach.GetAvailMach(theSearchVal, theSearchBy,
theMachCode1, theSearchView, SelSort, SelSortDir)
availMachList.DataSource = dstMachList
Panel1.Visible = True
Panel2.Visible = True
Panel3.Visible = True
Panel4.Visible = True

' If recordsCount.SelectedItem.Value = "all" Then
' availMachList.PageSize = dstMachList.

' Else
availMachList.PageSize = recordsCount.SelectedItem.Value

' Button2.Visible = True
' End If
availMachList.DataBind()

End Function

Private Sub availMachList_ItemCreated(ByVal sender As Object, ByVal
e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
availMachList.ItemCreated
Dim elemType As ListItemType = e.Item.ItemType
If (elemType = ListItemType.Header) Then
Dim strsortby As String = CStr(viewstate("SortExpression"))
'Get the Field to sort by from the ViewState
Dim strSortAscending As String =
CStr(viewstate("SortAscending"))
Dim strOrder As String
If strSortAscending = "yes" Or IsNothing(strSortAscending)
Then 'Get the direction from the ViewState
strOrder = " 6" 'Down Arrorw
Else
strOrder = " 5" 'Up Arrow
End If

Dim i As Integer

'You must go through each column to determin what one to put
the arrow by

For i = 0 To availMachList.Columns.Count Step +1
If i < availMachList.Columns.Count Then
If strsortby =
availMachList.Columns(i).SortExpression And Not IsNothing(strsortby) Then
Dim cell As TableCell = e.Item.Cells(i)
Dim lblSorted As Label = New Label() 'Make a
new label to put by the sort field
lblSorted.Font.Name = "webdings"
lblSorted.Font.Size = FontUnit.XSmall
lblSorted.ForeColor =
lblSorted.ForeColor.DodgerBlue
lblSorted.Text = strOrder
cell.Controls.Add(lblSorted)
End If
End If
Next i
End If
End Sub

Private Sub availMachList_SortCommand(ByVal source As Object, ByVal
e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
availMachList.SortCommand
'This helps determine what direction to sort in. If already
Ascending with a field, it will
'do descending and vice versa.

If SelSort = e.SortExpression Then
If SelSortDir = "ASC" Then
SelSortDir = "DESC"
viewstate("SortAscending") = "no"
Else
SelSortDir = "ASC"
viewstate("SortAscending") = "yes"
End If
End If

SelSort = e.SortExpression
viewstate("SortExpression") = e.SortExpression
FillDataGrid()
End Sub

Private Sub availMachList_PageIndexChanged(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
availMachList.PageIndexChanged
availMachList.CurrentPageIndex = e.NewPageIndex
FillDataGrid()
End Sub

Private Sub availMachList_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
availMachList.SelectedIndexChanged
availMachList.CurrentPageIndex = 0
FillDataGrid()
End Sub
Sub availMachList_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='#ffffcc'")
e.Item.Attributes.Add("onclick",
"this.style.backgroundColor='ffff99'")
' e.Item.Attributes.Remove()
Else
End If
End Sub
Sub btnSelect_OnClick(ByVal sender As Object, ByVal e As EventArgs)
Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strStoreName As String
Dim strStoreID As String
Dim MyHashTable As New Hashtable()
Dim machNum As Integer
machNum = 0
For Each myDataGridItem In availMachList.Items
chkSelected = myDataGridItem.FindControl("chkSelection")
If chkSelected.Checked Then

MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"), Label).Text,
CType(myDataGridItem.FindControl("Label7"), Label).Text)
machNum = +machNum + 1
' strStoreName =
CType(myDataGridItem.FindControl("Label7"), Label).Text
'strStoreID =
CType(myDataGridItem.FindControl("machineID"), Label).Text
' lblStatus.Text += "The store name is <b>" &
strStoreName & "</b>"
' lblStatus.Text += " and the StoreID is <b>" &
strStoreID & "</b><br>"
End If
Next
Session("hashtest") = MyHashTable
Session("machNum") = machNum
' Dim sUrl As String = "viewMachine.aspx?OrderId=" &
CType(myDataGridItem.FindControl("Label10"), Label).Text
' Dim sFeatures As String =
"'height=500;width=500;left=100;top=50'"
'Dim arr = "showModalDialog('viewMachine.aspx?2', '',
'font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em')"
' Create a client script to open the window
' Dim sScript As String
' sScript &= "<script language=javascript> "
' sScript &= arr
' sScript &= "window.open('" & sUrl & "',''," & sFeatures &
");"
' sScript &= "</script>"
' Write it into the output stream for immediate execution
' Response.Write(sScript)

' Dim sScript As String
Dim sScript As New System.Text.StringBuilder
sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
sScript.Append("fnCallDialog('viewMachine.aspx')" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)
RegisterStartupScript("ForceDefaultToScript", sScript.ToString)
'Response.Write(sScript)

End Sub
Function ChangeColor(ByVal value, ByVal value1)
If IsDBNull(value) Then
value = 0
End If
If IsDBNull(value1) Then
ChangeColor = Format(value, "#,###.00")
Else
ChangeColor = "<font color='red'>" & Format(value,
"#,###.00") & "</font>"
End If
End Function

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strStoreName As String
Dim strStoreID As String
Dim MyHashTable As New Hashtable()
Dim machSalesNum As String
machSalesNum = ""

Dim machNum = 0
Dim theval As String
For Each myDataGridItem In availMachList.Items
chkSelected = myDataGridItem.FindControl("chkSelection")
If chkSelected.Checked Then
machNum = +machNum + 1

MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"), Label).Text,
CType(myDataGridItem.FindControl("Label7"), Label).Text)
theval = CType(myDataGridItem.FindControl("machineID"),
Label).Text
machSalesNum = machSalesNum + CStr(theval) + ","
End If
Next
If machNum = 0 Then
Label11.Text = "Please Select at least one machine to Quote"
Label11.Visible = True
Else
Label11.Visible = False
Session("hashQuote") = MyHashTable
Session("machQuoteNum") = machSalesNum
Response.Redirect("quotes/newQuote.aspx")
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strStoreName As String
Dim strStoreID As String
Dim MyHashTable As New Hashtable
Dim machSalesNum As String
machSalesNum = ""
Dim machNum = 0
Dim theval As String
For Each myDataGridItem In availMachList.Items
chkSelected = myDataGridItem.FindControl("chkSelection")
If chkSelected.Checked Then
machNum = +machNum + 1

MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"), Label).Text,
CType(myDataGridItem.FindControl("Label7"), Label).Text)
theval = CType(myDataGridItem.FindControl("machineID"),
Label).Text
'machNum = machNum + "'" + CStr(theval) + "',"
machSalesNum = machSalesNum + CStr(theval) + ","
End If
Next
If machNum = 0 Then
Label11.Text = "Please Select at least one machine to
Invoice"
Label11.Visible = True
Else
Label11.Visible = False
Session("hashQuote") = MyHashTable
Session("machSalesNum") = machSalesNum
Response.Redirect("quotes/QuoteConvert.aspx")
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strStoreName As String
Dim strStoreID As String
Dim MyHashTable As New Hashtable
Dim machNum = 0
For Each myDataGridItem In availMachList.Items
chkSelected = myDataGridItem.FindControl("chkSelection")
If chkSelected.Checked Then

MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"), Label).Text,
CType(myDataGridItem.FindControl("Label7"), Label).Text)
machNum = +machNum + 1
' strStoreName =
CType(myDataGridItem.FindControl("Label7"), Label).Text
'strStoreID =
CType(myDataGridItem.FindControl("machineID"), Label).Text
' lblStatus.Text += "The store name is <b>" &
strStoreName & "</b>"
' lblStatus.Text += " and the StoreID is <b>" &
strStoreID & "</b><br>"
End If
Next
Session("hashtest") = MyHashTable
Session("machNum") = machNum
' Dim sUrl As String = "viewMachine.aspx?OrderId=" &
CType(myDataGridItem.FindControl("Label10"), Label).Text
' Dim sFeatures As String =
"'height=500;width=500;left=100;top=50'"
'Dim arr = "showModalDialog('viewMachine.aspx?2', '',
'font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em')"
' Create a client script to open the window
' Dim sScript As String
' sScript &= "<script language=javascript> "
' sScript &= arr
' sScript &= "window.open('" & sUrl & "',''," & sFeatures &
");"
' sScript &= "</script>"
' Write it into the output stream for immediate execution
' Response.Write(sScript)

' Dim sScript As String
If machNum = 0 Then
Label11.Text = "Please Select at least one machine to view"
Label11.Visible = True
Else
Label11.Visible = False
Dim sScript As New System.Text.StringBuilder
sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
sScript.Append("fnCallDialog('viewMachine.aspx')" & vbCrLf)
sScript.Append("</SCRIPT>" & vbCrLf)
RegisterStartupScript("ForceDefaultToScript",
sScript.ToString)
'Response.Write(sScript)
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strStoreName As String
Dim strStoreID As String
Dim MyHashTable As New Hashtable
Dim machSalesAddNum As String
machSalesAddNum = ""
Dim machNum = 0
Dim theval As String
For Each myDataGridItem In availMachList.Items
chkSelected = myDataGridItem.FindControl("chkSelection")
If chkSelected.Checked Then
machNum = +machNum + 1

MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"), Label).Text,
CType(myDataGridItem.FindControl("Label7"), Label).Text)
theval = CType(myDataGridItem.FindControl("machineID"),
Label).Text
'machNum = machNum + "'" + CStr(theval) + "',"
machSalesAddNum = machSalesAddNum + CStr(theval) + ","
End If
Next
If machNum = 0 Then
Label11.Text = "Please Select at least one machine"
Label11.Visible = True
Else
Label11.Visible = False
Session("hashQuote") = MyHashTable
Session("machSalesAddNum") = machSalesAddNum
Response.Redirect("sales/Sales.aspx")
End If
End Sub

Sub theMachCode_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
FillDataGrid()
End Sub

End Class
End Namespace

********************GetAvailMach****************** **************************
**************
************************************************** **************************
************

Public Function GetAvailMach(ByVal theSearchVal As String, ByVal theSearchBy
As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String, ByVal
SelSort As String, ByVal SelSortDir As String) As DataSet

' Create Instance of Connection and Command Object

Dim myConnection As New
SqlConnection(ConfigurationSettings.AppSettings("connectionString"))

Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)

' Mark the Command as a SPROC

myCommand.SelectCommand.CommandType = CommandType.StoredProcedure

' Add Parameters to SPROC

Dim parametertheSearchVal As New SqlParameter("@dotnet.itags.org.theSearchVal",
SqlDbType.NVarChar, 100)

parametertheSearchVal.Value = theSearchVal

myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)

Dim parametertheSearchBy As New SqlParameter("@dotnet.itags.org.theSearchBy",
SqlDbType.NVarChar, 100)

parametertheSearchBy.Value = theSearchBy

myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)

Dim parameterMACH_CODE1 As New SqlParameter("@dotnet.itags.org.MACH_CODE",
SqlDbType.NVarChar, 50)

parameterMACH_CODE1.Value = MACH_CODE1

myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)

Dim parametertheSearchView As New SqlParameter("@dotnet.itags.org.theSearchView",
SqlDbType.NVarChar, 50)

parametertheSearchView.Value = theSearchView

myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)

Dim parameterSelSort As New SqlParameter("@dotnet.itags.org.SelSort", SqlDbType.NVarChar, 50)

parameterSelSort.Value = SelSort

myCommand.SelectCommand.Parameters.Add(parameterSe lSort)

Dim parameterSelSortDir As New SqlParameter("@dotnet.itags.org.SelSortDir",
SqlDbType.NVarChar, 10)

parameterSelSortDir.Value = SelSortDir

myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)

' Create and Fill the DataSet

Dim myDataSet As New DataSet

myCommand.Fill(myDataSet)

' Return the datareader

Return myDataSet

End Function

********************SelectOpenInventory*********** **************************
*********************
************************************************** **************************
************

CREATE PROCEDURE SelectOpenInventory
(
@dotnet.itags.org.theSearchVal nvarchar (100),
@dotnet.itags.org.theSearchBy nvarchar (20),
@dotnet.itags.org.MACH_CODE nvarchar (50),
@dotnet.itags.org.theSearchView nvarchar (2),
@dotnet.itags.org.SelSort nvarchar(50),
@dotnet.itags.org.SelSortDir nvarchar(10)

)
AS
SET NOCOUNT ON;
DECLARE @dotnet.itags.org.SQLString varchar(1050)
SET @dotnet.itags.org.SQLString = 'SELECT DISTINCT
InventoryRecord.MACH_CODE,
InventoryRecord.machineSIZE,
InventoryRecord.MACHINE,
InventoryRecord.ASKING_PRI,
InventoryRecord.machineID,
InventoryRecord.STOCK_NO,
InventoryRecord.SOLD_TO,
InventoryRecord.codesID,
MachineCodes.CATNUM,
MachineCodes.DESCRIPTION
FROM
InventoryRecord
INNER JOIN MachineCodes ON InventoryRecord.codesID = MachineCodes.codesID'

IF @dotnet.itags.org.theSearchView = '1'
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
WHERE InventoryRecord.Sold_To IS NULL '

IF @dotnet.itags.org.theSearchView = '2'
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
WHERE InventoryRecord.Sold_To IS NOT NULL '

IF @dotnet.itags.org.theSearchView = '3'
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
WHERE (InventoryRecord.Sold_To IS NULL or InventoryRecord.Sold_To IS NOT
NULL) '

IF @dotnet.itags.org.theSearchBy <>'0'
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
AND InventoryRecord.' + @dotnet.itags.org.theSearchBy + ' like ''' + @dotnet.itags.org.theSearchVal + '%'''

IF @dotnet.itags.org.MACH_CODE <> 'A0000'
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
AND InventoryRecord.mach_Code = ''' + @dotnet.itags.org.MACH_CODE + ''''

IF @dotnet.itags.org.SelSort = ''
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
ORDER BY MachineCodes.CATNUM, InventoryRecord.machineSIZE,
InventoryRecord.MACHINE'

IF @dotnet.itags.org.SelSort <> ''
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
order by ' + @dotnet.itags.org.SelSort + ''

IF @dotnet.itags.org.SelSortDir <> ''
SET @dotnet.itags.org.SQLString = @dotnet.itags.org.SQLString + '
' + @dotnet.itags.org.SelSortDir + ''

print @dotnet.itags.org.SQLString
EXEC (@dotnet.itags.org.SQLString)
GO
--

______________________
David Fetrow
HelixPoint LLC.
http://www.helixpoint.com
davef@dotnet.itags.org.helixpoint.com

Interested in Affordable Email Marketing?
Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
If you are interested in becoming a Reseller of HelixPoint products, contact
davef@dotnet.itags.org.helixpoint.com
______________________It seems to be much faster when I remore this line

<asp:HyperLinkColumn SortExpression="Stock_No"
DataNavigateURLField="Stock_No"
DataNavigateUrlFormatString="javascript:CenterWindow('machineInfo.aspx?Stock
_No={0}','550', '480');" HeaderText="STOCK NUMBER" DataTextField="Stock_No"
/
"Helixpoint" <dave@.helixpoint.com> wrote in message
news:%23XT8vDgVDHA.1928@.TK2MSFTNGP12.phx.gbl...
> I know this is a lot of code, but I was wandering why this takes forever
to
> render on the web page??
> *************ASPX PAGE******************************
> <%@. Register TagPrefix="uc1" TagName="_Header" src="http://pics.10026.com/?src=_Header.ascx" %>
> <%@. Page Language="vb" AutoEventWireup="false"
Codebehind="machine.aspx.vb"
> Inherits="ASPNETProduct.ASPNETProduct.machine"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <title>machine</title>
> <meta content="Microsoft Visual Studio.NET 7.0" name=GENERATOR>
> <meta content="Visual Basic 7.0" name=CODE_LANGUAGE>
> <meta content=JavaScript name=vs_defaultClientScript>
> <meta content=http://schemas.microsoft.com/intellisense/ie5
> name=vs_targetSchema>
> <script src="http://pics.10026.com/?src=include/tabbed.js" type=text/javascript></script>
> <script src="http://pics.10026.com/?src=include/newWindow.js" type=text/javascript></script>
> <LINK href="http://links.10026.com/?link=styles.css" type=text/css rel=STYLESHEET >
> <script language=JavaScript>
> function fnCallDialog(theURL)
> {
> var res = showModalDialog(theURL,window,"status:false; dialogHide:Yes;
> resizable: No; scroll:No; status: No; help: No; edge:
> Sunken;dialogWidth:684px;dialogHeight:560px");
> if( res == 1 ){
> location.href="Quotes/newQuote.aspx";
> }
> }
> </script>
> </HEAD>
> <body background=images\background.gif MS_POSITIONING="GridLayout">
> <uc1:_header id=_Header1 runat="server"></uc1:_header>
> <form id=Form1 method=post runat="server"><asp:label id=Label2
> style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 64px"
> runat="server" CssClass="objtext"
> Width="40px">Search</asp:label><asp:textbox id=searchVal style="Z-INDEX:
> 104; LEFT: 104px; POSITION: absolute; TOP: 56px" runat="server"
> CssClass="objtext" Width="272px"></asp:textbox><asp:label id=Label3
> style="Z-INDEX: 108; LEFT: 392px; POSITION: absolute; TOP: 64px"
> runat="server" CssClass="objtext"
> Width="16px">By</asp:label><br> <asp:label id=lblStatus
style="Z-INDEX:
> 101; LEFT: 8px; POSITION: absolute; TOP: 472px" Font-Name="verdana"
> ForeColor="#ff0000" Runat="server" Font-Size="12px"></asp:label>
> <asp:datagrid id=availMachList style="Z-INDEX: 102; LEFT: 8px; POSITION:
> absolute; TOP: 200px" runat="server" Width="100%"
> OnItemDataBound="availMachList_ItemDataBound" CellPadding="3"
> AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False">
> <SelectedItemStyle Font-Size="Smaller" Font-Bold="True" Wrap="False"
> BackColor="LightBlue">
> </SelectedItemStyle>
> <EditItemStyle Font-Size="Smaller" Wrap="False" BackColor="Silver">
> </EditItemStyle>
> <AlternatingItemStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
> BorderStyle="Groove" BackColor="#FFFFCC">
> </AlternatingItemStyle>
> <ItemStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
> BackColor="#FFFFCC">
> </ItemStyle>
> <HeaderStyle Font-Size="11px" Font-Names="Arial" Wrap="False"
> HorizontalAlign="Left" BackColor="#CCFFFF">
> </HeaderStyle>
> <FooterStyle Wrap="False">
> </FooterStyle>
> <Columns>
> <asp:TemplateColumn HeaderText="Select">
> <HeaderStyle Wrap="False" HorizontalAlign="Center" Width="10px">
> </HeaderStyle>
> <ItemStyle Wrap="False" HorizontalAlign="Center">
> </ItemStyle>
> <ItemTemplate>
> <asp:Checkbox ID="chkSelection" Runat="server" />
> <asp:Label ID="hdnStoreID" Visible="False" Text='<%#
> DataBinder.Eval(Container.DataItem, "Stock_No") %>' Runat=server />
> <asp:Label ID="machineID" Visible="False" Text='<%#
> DataBinder.Eval(Container.DataItem, "machineID") %>' Runat=server />
> </ItemTemplate>
> <FooterStyle Wrap="False">
> </FooterStyle>
> </asp:TemplateColumn>
> <asp:HyperLinkColumn SortExpression="Stock_No"
> DataNavigateURLField="Stock_No"
DataNavigateUrlFormatString="javascript:CenterWindow('machineInfo.aspx?Stock
> _No={0}','550', '480');" HeaderText="STOCK NUMBER"
DataTextField="Stock_No"
> />
> <asp:TemplateColumn SortExpression="MACH_CODE" HeaderText="MACHINE CODE">
> <HeaderStyle Wrap="False">
> </HeaderStyle>
> <ItemStyle Wrap="False">
> </ItemStyle>
> <ItemTemplate>
> <asp:Label id=Label8 runat="server" Text='<%#
DataBinder.Eval(Contain
> er, "DataItem.MACH_CODE") %>'>
> </asp:Label>
> </ItemTemplate>
> <FooterStyle Wrap="False">
> </FooterStyle>
> <EditItemTemplate>
> <P>
> <asp:TextBox id=txtMACH_CODE runat="server" Width="108px"
Text='<%#
> DataBinder.Eval(Container, "DataItem.MACH_CODE") %>'>
> </asp:TextBox>
> <asp:RequiredFieldValidator id="valMACH_CODE" runat="server"
> ErrorMessage="MACH_CODE is required" ControlToValidate="txtMACH_CODE"
> Display="None"></asp:RequiredFieldValidator></P>
> </EditItemTemplate>
> </asp:TemplateColumn>
> <asp:TemplateColumn SortExpression="machineSIZE" HeaderText="machineSIZE">
> <HeaderStyle Wrap="False">
> </HeaderStyle>
> <ItemStyle Wrap="False">
> </ItemStyle>
> <ItemTemplate>
> <asp:Label id=Label9 runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.machineSIZE") %>'>
> </asp:Label>
> </ItemTemplate>
> <FooterStyle Wrap="False">
> </FooterStyle>
> <EditItemTemplate>
> <P>
> <asp:TextBox id=txtSIZE runat="server" Width="107px" Text='<%#
> DataBinder.Eval(Container, "DataItem.SIZE") %>'>
> </asp:TextBox>
> <asp:RequiredFieldValidator id="valSIZE" runat="server"
> ErrorMessage="SIZE is required" ControlToValidate="txtSIZE"
> Display="None"></asp:RequiredFieldValidator></P>
> </EditItemTemplate>
> </asp:TemplateColumn>
> <asp:TemplateColumn SortExpression="MACHINE" HeaderText="MACHINE">
> <HeaderStyle Wrap="False">
> </HeaderStyle>
> <ItemStyle Wrap="False">
> </ItemStyle>
> <ItemTemplate>
> <asp:Label id=Label7 runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.MACHINE") %>'>
> </asp:Label>
> </ItemTemplate>
> <FooterStyle Wrap="False">
> </FooterStyle>
> <EditItemTemplate>
> <P>
> <asp:TextBox id=txtMACHINE runat="server" Width="100px" Text='<%#
> DataBinder.Eval(Container, "DataItem.MACHINE") %>'>
> </asp:TextBox></P>
> </EditItemTemplate>
> </asp:TemplateColumn>
> <asp:TemplateColumn SortExpression="ASKING_PRI" HeaderText="Price">
> <HeaderStyle Wrap="False">
> </HeaderStyle>
> <ItemStyle Wrap="False">
> </ItemStyle>
> <ItemTemplate>
> <asp:Label id="Label4" runat="server" Text='<%#
> ChangeColor(DataBinder.Eval(Container,
> "DataItem.ASKING_PRI"),DataBinder.Eval(Container, "DataItem.Sold_To"))
%>'>
> </asp:Label>
> </ItemTemplate>
> <FooterStyle Wrap="False">
> </FooterStyle>
> </asp:TemplateColumn>
> </Columns>
> <PagerStyle ForeColor="Black" Wrap="False" Mode="NumericPages">
> </PagerStyle>
> </asp:datagrid><asp:label id=Label1 style="Z-INDEX: 105; LEFT: 16px;
> POSITION: absolute; TOP: 96px" runat="server" CssClass="objtext"
> Width="80px">Machine Code </asp:label><asp:dropdownlist id=theMachCode
> style="Z-INDEX: 106; LEFT: 104px; POSITION: absolute; TOP: 88px"
> runat="server" CssClass="objtext" DataTextField="FULLDESC"
> DataValueField="CATNUM"
> OnSelectedIndexChanged="theMachCode_SelectedIndexChanged"
> AutoPostBack="True"></asp:dropdownlist><asp:button id=Button1
> style="Z-INDEX: 107; LEFT: 328px; POSITION: absolute; TOP: 120px"
> runat="server" CssClass="inputSubmit"
> Text="Search"></asp:button><asp:dropdownlist id=searchBy style="Z-INDEX:
> 109; LEFT: 416px; POSITION: absolute; TOP: 56px" runat="server"
> CssClass="objtext">
> <asp:ListItem Value="0" Selected="True">Optional</asp:ListItem>
> <asp:ListItem Value="MACHINE">Machine</asp:ListItem>
> <asp:ListItem Value="SERIAL_NO">Serial Number</asp:ListItem>
> <asp:ListItem Value="STOCK_NO">Stock Number</asp:ListItem>
> </asp:dropdownlist><asp:label id=Label5 style="Z-INDEX: 110; LEFT:
16px;
> POSITION: absolute; TOP: 128px" runat="server" CssClass="objtext">View
> By</asp:label><asp:dropdownlist id=DropDownView style="Z-INDEX: 111; LEFT:
> 104px; POSITION: absolute; TOP: 120px" runat="server" CssClass="objtext">
> <asp:ListItem Value="1" Selected="True">Inventory</asp:ListItem>
> <asp:ListItem Value="2">Sold</asp:ListItem>
> <asp:ListItem Value="3">All</asp:ListItem>
> </asp:dropdownlist><asp:label id=Label6 style="Z-INDEX: 112; LEFT:
200px;
> POSITION: absolute; TOP: 128px" runat="server"
> CssClass="objtext">Records</asp:label><asp:dropdownlist id=recordsCount
> style="Z-INDEX: 113; LEFT: 256px; POSITION: absolute; TOP: 120px"
> runat="server" CssClass="objtext">
> <asp:ListItem Value="1000000" Selected="True">All</asp:ListItem>
> <asp:ListItem Value="10">10</asp:ListItem>
> <asp:ListItem Value="50">50</asp:ListItem>
> <asp:ListItem Value="100">100</asp:ListItem>
> <asp:ListItem Value="1000">1000</asp:ListItem>
> </asp:dropdownlist><asp:panel id=Panel1
> style="Z-INDEX: 114; LEFT: 16px; POSITION: absolute; TOP: 168px"
> runat="server" Width="104px" Height="6px" Visible="False">
> <asp:Button id=Button4 runat="server" CssClass="inputSubmit" Text="View
> Machines"></asp:Button></asp:panel><asp:panel
> id=Panel2 style="Z-INDEX: 115; LEFT: 128px; POSITION: absolute; TOP:
168px"
> runat="server" Width="104px" Visible="False">
> <asp:Button id=Button2 runat="server" CssClass="inputSubmit" Text="Quote
> Machines" Visible="True"></asp:Button></asp:panel><asp:panel
> id=Panel3 style="Z-INDEX: 116; LEFT: 240px; POSITION: absolute; TOP:
168px"
> runat="server" Width="96px" Height="16px" Visible="False">
> <asp:Button id=Button3 runat="server" CssClass="inputSubmit" Text="Add to
> Invoice"></asp:Button></asp:panel><asp:label id=Label11 style="Z-INDEX:
117;
> LEFT: 488px; POSITION: absolute; TOP: 168px" runat="server"
> CssClass="objtext" ForeColor="Red" Visible="False"></asp:label>
> <asp:Panel id=Panel4 style="Z-INDEX: 118; LEFT: 352px; POSITION: absolute;
> TOP: 168px" runat="server" Width="8px" Visible="False">
> <asp:Button id=Button5 runat="server" CssClass="inputSubmit" Text="Add to
> Sales"></asp:Button></asp:Panel></form>
> </body>
> </HTML>
>
>
> ********************Code
> Behind******************************************** **************
************************************************** **************************
> ************
> Imports System.Data.SqlClient
> Namespace ASPNETProduct
> Public Class machine
> Inherits System.Web.UI.Page
> Protected WithEvents availMachList As
> System.Web.UI.WebControls.DataGrid
> Shared SelSort As String = ""
> Protected WithEvents lblStatus As System.Web.UI.WebControls.Label
> Protected WithEvents searchVal As
System.Web.UI.WebControls.TextBox
> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
> Protected WithEvents Label2 As System.Web.UI.WebControls.Label
> Protected WithEvents theMachCode As
> System.Web.UI.WebControls.DropDownList
> Protected WithEvents Label3 As System.Web.UI.WebControls.Label
> Protected WithEvents searchBy As
> System.Web.UI.WebControls.DropDownList
> Protected WithEvents Label5 As System.Web.UI.WebControls.Label
> Protected WithEvents DropDownView As
> System.Web.UI.WebControls.DropDownList
> Protected WithEvents Label6 As System.Web.UI.WebControls.Label
> Protected WithEvents recordsCount As
> System.Web.UI.WebControls.DropDownList
> Protected WithEvents Button2 As System.Web.UI.WebControls.Button
> Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
> Protected WithEvents Panel2 As System.Web.UI.WebControls.Panel
> Protected WithEvents Button3 As System.Web.UI.WebControls.Button
> Protected WithEvents Panel3 As System.Web.UI.WebControls.Panel
> Protected WithEvents Button4 As System.Web.UI.WebControls.Button
> Protected WithEvents Label11 As System.Web.UI.WebControls.Label
> Protected WithEvents RequiredFieldValidator1 As
> System.Web.UI.WebControls.RequiredFieldValidator
> Protected WithEvents Panel4 As System.Web.UI.WebControls.Panel
> Protected WithEvents Button5 As System.Web.UI.WebControls.Button
> Shared SelSortDir As String = "ASC" 'sort direction
> #Region " Web Form Designer Generated Code "
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> End Sub
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form
Designer
> 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
> #End Region
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim CheckCookie As HttpCookie
> CheckCookie = Request.Cookies("misc")
> If CheckCookie Is Nothing Then
> Session("pageRedir") = "machine.aspx"
> Response.Redirect("mainLog.aspx")
> Else
> Session("pageRedir") = ""
> End If
> If Page.IsPostBack = False Then
> Dim MachCodeList As New ASPNETProduct.machinedb()
> theMachCode.DataSource =
MachCodeList.GetAvailMachCodeList()
> theMachCode.DataBind()
> theMachCode.Items.Insert(0, New ListItem("All", "A0000"))
> ' FillDataGrid()
> End If
> End Sub
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles Button1.Click
> FillDataGrid()
> End Sub
> '************************************************* ******
> '
> ' GetBrowsePath() is a helper method used to create the url
> ' to the document. If the size of the content stored in the
> ' database is non-zero, it creates a path to browse that.
> ' Otherwise, the FileNameUrl value is used.
> '
> ' This method is used in the databinding expression for
> ' the browse Hyperlink within the DataGrid, and is called
> ' for each row when DataGrid.DataBind() is called. It is
> ' defined as a helper method here (as opposed to inline
> ' within the template) to improve code organization and
> ' avoid embedding logic within the content template.
> '
> '************************************************* ******'
> Function GetBrowsePath(ByVal documentId As Integer) As String
> ' if there is content in the database, create an
> ' url to browse it
> Return "~/ViewDocument.aspx?DocumentID=" &
documentId.ToString()
> End Function
> Function FillDataGrid()
> Dim theSearchVal, theSearchBy, theSearchView, theMachCode1,
> thecode As String
> theSearchVal = searchVal.Text
> theSearchBy = searchBy.SelectedItem.Value
> theMachCode1 = theMachCode.SelectedItem.Value
> theSearchView = DropDownView.SelectedItem.Value
> Dim availMach As New ASPNETProduct.machinedb()
> Dim dstMachList As DataSet
> dstMachList = availMach.GetAvailMach(theSearchVal,
theSearchBy,
> theMachCode1, theSearchView, SelSort, SelSortDir)
> availMachList.DataSource = dstMachList
> Panel1.Visible = True
> Panel2.Visible = True
> Panel3.Visible = True
> Panel4.Visible = True
> ' If recordsCount.SelectedItem.Value = "all" Then
> ' availMachList.PageSize = dstMachList.
> ' Else
> availMachList.PageSize = recordsCount.SelectedItem.Value
> ' Button2.Visible = True
> ' End If
> availMachList.DataBind()
>
> End Function
>
> Private Sub availMachList_ItemCreated(ByVal sender As Object,
ByVal
> e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> availMachList.ItemCreated
> Dim elemType As ListItemType = e.Item.ItemType
> If (elemType = ListItemType.Header) Then
> Dim strsortby As String =
CStr(viewstate("SortExpression"))
> 'Get the Field to sort by from the ViewState
> Dim strSortAscending As String =
> CStr(viewstate("SortAscending"))
> Dim strOrder As String
> If strSortAscending = "yes" Or IsNothing(strSortAscending)
> Then 'Get the direction from the ViewState
> strOrder = " 6" 'Down Arrorw
> Else
> strOrder = " 5" 'Up Arrow
> End If
> Dim i As Integer
> 'You must go through each column to determin what one to
put
> the arrow by
> For i = 0 To availMachList.Columns.Count Step +1
> If i < availMachList.Columns.Count Then
> If strsortby =
> availMachList.Columns(i).SortExpression And Not IsNothing(strsortby) Then
> Dim cell As TableCell = e.Item.Cells(i)
> Dim lblSorted As Label = New Label() 'Make a
> new label to put by the sort field
> lblSorted.Font.Name = "webdings"
> lblSorted.Font.Size = FontUnit.XSmall
> lblSorted.ForeColor =
> lblSorted.ForeColor.DodgerBlue
> lblSorted.Text = strOrder
> cell.Controls.Add(lblSorted)
> End If
> End If
> Next i
> End If
> End Sub
>
> Private Sub availMachList_SortCommand(ByVal source As Object,
ByVal
> e As System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
> availMachList.SortCommand
> 'This helps determine what direction to sort in. If already
> Ascending with a field, it will
> 'do descending and vice versa.
> If SelSort = e.SortExpression Then
> If SelSortDir = "ASC" Then
> SelSortDir = "DESC"
> viewstate("SortAscending") = "no"
> Else
> SelSortDir = "ASC"
> viewstate("SortAscending") = "yes"
> End If
> End If
> SelSort = e.SortExpression
> viewstate("SortExpression") = e.SortExpression
> FillDataGrid()
> End Sub
> Private Sub availMachList_PageIndexChanged(ByVal source As Object,
> ByVal e As System.Web.UI.WebControls.DataGridPageChangedEvent Args) Handles
> availMachList.PageIndexChanged
> availMachList.CurrentPageIndex = e.NewPageIndex
> FillDataGrid()
> End Sub
> Private Sub availMachList_SelectedIndexChanged(ByVal sender As
> Object, ByVal e As System.EventArgs) Handles
> availMachList.SelectedIndexChanged
> availMachList.CurrentPageIndex = 0
> FillDataGrid()
> End Sub
> Sub availMachList_ItemDataBound(ByVal sender As Object, ByVal e As
> DataGridItemEventArgs)
> If e.Item.ItemType = ListItemType.Item Or _
> e.Item.ItemType = ListItemType.AlternatingItem Then
> e.Item.Attributes.Add("onmouseover",
> "this.style.backgroundColor='Silver'")
> e.Item.Attributes.Add("onmouseout",
> "this.style.backgroundColor='#ffffcc'")
> e.Item.Attributes.Add("onclick",
> "this.style.backgroundColor='ffff99'")
> ' e.Item.Attributes.Remove()
> Else
> End If
> End Sub
> Sub btnSelect_OnClick(ByVal sender As Object, ByVal e As
EventArgs)
> Dim myDataGridItem As DataGridItem
> Dim chkSelected As System.Web.UI.WebControls.CheckBox
> Dim strStoreName As String
> Dim strStoreID As String
> Dim MyHashTable As New Hashtable()
> Dim machNum As Integer
> machNum = 0
> For Each myDataGridItem In availMachList.Items
> chkSelected = myDataGridItem.FindControl("chkSelection")
> If chkSelected.Checked Then
> MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"),
Label).Text,
> CType(myDataGridItem.FindControl("Label7"), Label).Text)
> machNum = +machNum + 1
> ' strStoreName =
> CType(myDataGridItem.FindControl("Label7"), Label).Text
> 'strStoreID =
> CType(myDataGridItem.FindControl("machineID"), Label).Text
> ' lblStatus.Text += "The store name is <b>" &
> strStoreName & "</b>"
> ' lblStatus.Text += " and the StoreID is <b>" &
> strStoreID & "</b><br>"
> End If
> Next
> Session("hashtest") = MyHashTable
> Session("machNum") = machNum
> ' Dim sUrl As String = "viewMachine.aspx?OrderId=" &
> CType(myDataGridItem.FindControl("Label10"), Label).Text
> ' Dim sFeatures As String =
> "'height=500;width=500;left=100;top=50'"
> 'Dim arr = "showModalDialog('viewMachine.aspx?2', '',
> 'font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em')"
> ' Create a client script to open the window
> ' Dim sScript As String
> ' sScript &= "<script language=javascript> "
> ' sScript &= arr
> ' sScript &= "window.open('" & sUrl & "',''," & sFeatures &
> ");"
> ' sScript &= "</script>"
> ' Write it into the output stream for immediate execution
> ' Response.Write(sScript)
> ' Dim sScript As String
> Dim sScript As New System.Text.StringBuilder
> sScript.Append("<SCRIPT language=""javascript"">" & vbCrLf)
> sScript.Append("fnCallDialog('viewMachine.aspx')" & vbCrLf)
> sScript.Append("</SCRIPT>" & vbCrLf)
> RegisterStartupScript("ForceDefaultToScript",
sScript.ToString)
> 'Response.Write(sScript)
>
> End Sub
> Function ChangeColor(ByVal value, ByVal value1)
> If IsDBNull(value) Then
> value = 0
> End If
> If IsDBNull(value1) Then
> ChangeColor = Format(value, "#,###.00")
> Else
> ChangeColor = "<font color='red'>" & Format(value,
> "#,###.00") & "</font>"
> End If
> End Function
> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles Button2.Click
> Dim myDataGridItem As DataGridItem
> Dim chkSelected As System.Web.UI.WebControls.CheckBox
> Dim strStoreName As String
> Dim strStoreID As String
> Dim MyHashTable As New Hashtable()
> Dim machSalesNum As String
> machSalesNum = ""
> Dim machNum = 0
> Dim theval As String
> For Each myDataGridItem In availMachList.Items
> chkSelected = myDataGridItem.FindControl("chkSelection")
> If chkSelected.Checked Then
> machNum = +machNum + 1
> MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"),
Label).Text,
> CType(myDataGridItem.FindControl("Label7"), Label).Text)
> theval =
CType(myDataGridItem.FindControl("machineID"),
> Label).Text
> machSalesNum = machSalesNum + CStr(theval) + ","
> End If
> Next
> If machNum = 0 Then
> Label11.Text = "Please Select at least one machine to
Quote"
> Label11.Visible = True
> Else
> Label11.Visible = False
> Session("hashQuote") = MyHashTable
> Session("machQuoteNum") = machSalesNum
> Response.Redirect("quotes/newQuote.aspx")
> End If
> End Sub
> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles Button3.Click
> Dim myDataGridItem As DataGridItem
> Dim chkSelected As System.Web.UI.WebControls.CheckBox
> Dim strStoreName As String
> Dim strStoreID As String
> Dim MyHashTable As New Hashtable
> Dim machSalesNum As String
> machSalesNum = ""
> Dim machNum = 0
> Dim theval As String
> For Each myDataGridItem In availMachList.Items
> chkSelected = myDataGridItem.FindControl("chkSelection")
> If chkSelected.Checked Then
> machNum = +machNum + 1
> MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"),
Label).Text,
> CType(myDataGridItem.FindControl("Label7"), Label).Text)
> theval =
CType(myDataGridItem.FindControl("machineID"),
> Label).Text
> 'machNum = machNum + "'" + CStr(theval) + "',"
> machSalesNum = machSalesNum + CStr(theval) + ","
> End If
> Next
> If machNum = 0 Then
> Label11.Text = "Please Select at least one machine to
> Invoice"
> Label11.Visible = True
> Else
> Label11.Visible = False
> Session("hashQuote") = MyHashTable
> Session("machSalesNum") = machSalesNum
> Response.Redirect("quotes/QuoteConvert.aspx")
> End If
> End Sub
> Private Sub Button4_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles Button4.Click
> Dim myDataGridItem As DataGridItem
> Dim chkSelected As System.Web.UI.WebControls.CheckBox
> Dim strStoreName As String
> Dim strStoreID As String
> Dim MyHashTable As New Hashtable
> Dim machNum = 0
> For Each myDataGridItem In availMachList.Items
> chkSelected = myDataGridItem.FindControl("chkSelection")
> If chkSelected.Checked Then
> MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"),
Label).Text,
> CType(myDataGridItem.FindControl("Label7"), Label).Text)
> machNum = +machNum + 1
> ' strStoreName =
> CType(myDataGridItem.FindControl("Label7"), Label).Text
> 'strStoreID =
> CType(myDataGridItem.FindControl("machineID"), Label).Text
> ' lblStatus.Text += "The store name is <b>" &
> strStoreName & "</b>"
> ' lblStatus.Text += " and the StoreID is <b>" &
> strStoreID & "</b><br>"
> End If
> Next
> Session("hashtest") = MyHashTable
> Session("machNum") = machNum
> ' Dim sUrl As String = "viewMachine.aspx?OrderId=" &
> CType(myDataGridItem.FindControl("Label10"), Label).Text
> ' Dim sFeatures As String =
> "'height=500;width=500;left=100;top=50'"
> 'Dim arr = "showModalDialog('viewMachine.aspx?2', '',
> 'font-family:Verdana; font-size:12; dialogWidth:30em; dialogHeight:35em')"
> ' Create a client script to open the window
> ' Dim sScript As String
> ' sScript &= "<script language=javascript> "
> ' sScript &= arr
> ' sScript &= "window.open('" & sUrl & "',''," & sFeatures &
> ");"
> ' sScript &= "</script>"
> ' Write it into the output stream for immediate execution
> ' Response.Write(sScript)
> ' Dim sScript As String
> If machNum = 0 Then
> Label11.Text = "Please Select at least one machine to
view"
> Label11.Visible = True
> Else
> Label11.Visible = False
> Dim sScript As New System.Text.StringBuilder
> sScript.Append("<SCRIPT language=""javascript"">" &
vbCrLf)
> sScript.Append("fnCallDialog('viewMachine.aspx')" &
vbCrLf)
> sScript.Append("</SCRIPT>" & vbCrLf)
> RegisterStartupScript("ForceDefaultToScript",
> sScript.ToString)
> 'Response.Write(sScript)
> End If
> End Sub
> Private Sub Button5_Click(ByVal sender As System.Object, ByVal e
As
> System.EventArgs) Handles Button5.Click
> Dim myDataGridItem As DataGridItem
> Dim chkSelected As System.Web.UI.WebControls.CheckBox
> Dim strStoreName As String
> Dim strStoreID As String
> Dim MyHashTable As New Hashtable
> Dim machSalesAddNum As String
> machSalesAddNum = ""
> Dim machNum = 0
> Dim theval As String
> For Each myDataGridItem In availMachList.Items
> chkSelected = myDataGridItem.FindControl("chkSelection")
> If chkSelected.Checked Then
> machNum = +machNum + 1
> MyHashTable.Add(CType(myDataGridItem.FindControl("machineID"),
Label).Text,
> CType(myDataGridItem.FindControl("Label7"), Label).Text)
> theval =
CType(myDataGridItem.FindControl("machineID"),
> Label).Text
> 'machNum = machNum + "'" + CStr(theval) + "',"
> machSalesAddNum = machSalesAddNum + CStr(theval) + ","
> End If
> Next
> If machNum = 0 Then
> Label11.Text = "Please Select at least one machine"
> Label11.Visible = True
> Else
> Label11.Visible = False
> Session("hashQuote") = MyHashTable
> Session("machSalesAddNum") = machSalesAddNum
> Response.Redirect("sales/Sales.aspx")
> End If
> End Sub
> Sub theMachCode_SelectedIndexChanged(ByVal sender As
System.Object,
> ByVal e As System.EventArgs)
> FillDataGrid()
> End Sub
> End Class
> End Namespace
>
>
********************GetAvailMach****************** **************************
> **************
************************************************** **************************
> ************
> Public Function GetAvailMach(ByVal theSearchVal As String, ByVal
theSearchBy
> As String, ByVal MACH_CODE1 As String, ByVal theSearchView As String,
ByVal
> SelSort As String, ByVal SelSortDir As String) As DataSet
> ' Create Instance of Connection and Command Object
> Dim myConnection As New
> SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
> Dim myCommand As New SqlDataAdapter("SelectOpenInventory", myConnection)
> ' Mark the Command as a SPROC
> myCommand.SelectCommand.CommandType = CommandType.StoredProcedure
> ' Add Parameters to SPROC
> Dim parametertheSearchVal As New SqlParameter("@.theSearchVal",
> SqlDbType.NVarChar, 100)
> parametertheSearchVal.Value = theSearchVal
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchVal)
> Dim parametertheSearchBy As New SqlParameter("@.theSearchBy",
> SqlDbType.NVarChar, 100)
> parametertheSearchBy.Value = theSearchBy
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchBy)
>
> Dim parameterMACH_CODE1 As New SqlParameter("@.MACH_CODE",
> SqlDbType.NVarChar, 50)
> parameterMACH_CODE1.Value = MACH_CODE1
> myCommand.SelectCommand.Parameters.Add(parameterMA CH_CODE1)
>
> Dim parametertheSearchView As New SqlParameter("@.theSearchView",
> SqlDbType.NVarChar, 50)
> parametertheSearchView.Value = theSearchView
> myCommand.SelectCommand.Parameters.Add(parameterth eSearchView)
> Dim parameterSelSort As New SqlParameter("@.SelSort", SqlDbType.NVarChar,
50)
> parameterSelSort.Value = SelSort
> myCommand.SelectCommand.Parameters.Add(parameterSe lSort)
> Dim parameterSelSortDir As New SqlParameter("@.SelSortDir",
> SqlDbType.NVarChar, 10)
> parameterSelSortDir.Value = SelSortDir
> myCommand.SelectCommand.Parameters.Add(parameterSe lSortDir)
>
>
> ' Create and Fill the DataSet
> Dim myDataSet As New DataSet
> myCommand.Fill(myDataSet)
> ' Return the datareader
> Return myDataSet
> End Function
>
********************SelectOpenInventory*********** **************************
> *********************
************************************************** **************************
> ************
> CREATE PROCEDURE SelectOpenInventory
> (
> @.theSearchVal nvarchar (100),
> @.theSearchBy nvarchar (20),
> @.MACH_CODE nvarchar (50),
> @.theSearchView nvarchar (2),
> @.SelSort nvarchar(50),
> @.SelSortDir nvarchar(10)
> )
> AS
> SET NOCOUNT ON;
> DECLARE @.SQLString varchar(1050)
> SET @.SQLString = 'SELECT DISTINCT
> InventoryRecord.MACH_CODE,
> InventoryRecord.machineSIZE,
> InventoryRecord.MACHINE,
> InventoryRecord.ASKING_PRI,
> InventoryRecord.machineID,
> InventoryRecord.STOCK_NO,
> InventoryRecord.SOLD_TO,
> InventoryRecord.codesID,
> MachineCodes.CATNUM,
> MachineCodes.DESCRIPTION
> FROM
> InventoryRecord
> INNER JOIN MachineCodes ON InventoryRecord.codesID =
MachineCodes.codesID'
> IF @.theSearchView = '1'
> SET @.SQLString = @.SQLString + '
> WHERE InventoryRecord.Sold_To IS NULL '
> IF @.theSearchView = '2'
> SET @.SQLString = @.SQLString + '
> WHERE InventoryRecord.Sold_To IS NOT NULL '
> IF @.theSearchView = '3'
> SET @.SQLString = @.SQLString + '
> WHERE (InventoryRecord.Sold_To IS NULL or InventoryRecord.Sold_To IS NOT
> NULL) '
> IF @.theSearchBy <>'0'
> SET @.SQLString = @.SQLString + '
> AND InventoryRecord.' + @.theSearchBy + ' like ''' + @.theSearchVal +
'%'''
> IF @.MACH_CODE <> 'A0000'
> SET @.SQLString = @.SQLString + '
> AND InventoryRecord.mach_Code = ''' + @.MACH_CODE + ''''
>
> IF @.SelSort = ''
> SET @.SQLString = @.SQLString + '
> ORDER BY MachineCodes.CATNUM, InventoryRecord.machineSIZE,
> InventoryRecord.MACHINE'
> IF @.SelSort <> ''
> SET @.SQLString = @.SQLString + '
> order by ' + @.SelSort + ''
> IF @.SelSortDir <> ''
> SET @.SQLString = @.SQLString + '
> ' + @.SelSortDir + ''
> print @.SQLString
> EXEC (@.SQLString)
> GO
> --
> ______________________
> David Fetrow
> HelixPoint LLC.
> http://www.helixpoint.com
> davef@.helixpoint.com
> Interested in Affordable Email Marketing?
> Check out the HelixMailer at http://www.helixpoint.com/helixmailer.asp
> If you are interested in becoming a Reseller of HelixPoint products,
contact
> davef@.helixpoint.com
> ______________________

0 comments:

Post a Comment