Click here to Skip to main content
15,885,366 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to Work On MAC Application Pin
Eddy Vluggen24-Jan-10 21:32
professionalEddy Vluggen24-Jan-10 21:32 
QuestionRemove Javascript controls from export to excel - VB.Net Pin
technette22-Jan-10 14:00
technette22-Jan-10 14:00 
AnswerRe: Remove Javascript controls from export to excel - VB.Net Pin
Mycroft Holmes24-Jan-10 10:49
professionalMycroft Holmes24-Jan-10 10:49 
GeneralRe: Remove Javascript controls from export to excel - VB.Net Pin
technette25-Jan-10 8:22
technette25-Jan-10 8:22 
GeneralRe: Remove Javascript controls from export to excel - VB.Net Pin
Mycroft Holmes25-Jan-10 10:30
professionalMycroft Holmes25-Jan-10 10:30 
GeneralRe: Remove Javascript controls from export to excel - VB.Net Pin
technette25-Jan-10 11:07
technette25-Jan-10 11:07 
GeneralRe: Remove Javascript controls from export to excel - VB.Net Pin
Mycroft Holmes25-Jan-10 12:00
professionalMycroft Holmes25-Jan-10 12:00 
GeneralRe: Remove Javascript controls from export to excel - VB.Net Pin
technette25-Jan-10 12:32
technette25-Jan-10 12:32 
When I rewrite the code, I will be creating stored procedures for the various select statements because there are 13 pages of code that is written as javascript functions and vb code that display on a "select" page so the selection is not currently tied to the gridview.

The following code may appear to display in a gridview but this is not functioning in the actual program. Each query displays in another page "Select", which opens a separate window.

I will probable have to try programming in javascript using a remove element function of some type as opposed to html for now.
I was trying to do a temporary fix to buy more time while I re-design and re-write.

Sample code from one page...I cut out a lot.


Public Property DateSortDirection() As String
Get
Return ViewState("DateSortDirection")
End Get
Set(ByVal value As String)
ViewState("DateSortDirection") = value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.DateSortDirection = "ASC"
End If

ibtnVersion.Attributes.Add("onClick", "OpenUpdateDate();")
ibtnHelp.Attributes.Add("onClick", "OpenHelp();")
ibtnMap.Attributes.Add("onClick", "OpenJobWindow('Location');")
End Sub
Function PadQuotes(ByVal sTxt As Object)
Dim iX As Integer

iX = InStr(sTxt, "'")
Do While iX > 0
sTxt = Left$(sTxt, iX) & "'" & Right$(sTxt, Len(sTxt) - iX)
iX = iX + 2 ' get past inserted quotes
If Len(sTxt) < iX Then
iX = 0
Else
iX = InStr(iX, sTxt, "'")
End If
Loop

PadQuotes = sTxt

End Function
Function GetURL() As String
'CntrNoLst("[Contract].[Contract]")
Dim stringcntr As String = "2;3,5;7;"
Return "http://localhost/webapplication2/cntrprofilegen.aspx?page=cntrgen&id=" & stringcntr
End Function

Function CntrNoLst(ByVal sSortStr As String) As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String
Dim sFrom As String
Dim sWhere As String
Dim sOrder As String

' queryString = "SELECT DISTINCT [Contract].[Contract], [Contract].[ContractDesc], [JobKeys].[ClientName], [JobKeys].[ProjMgrName], " & _
'"[Contract].[ContractValue], [Contract].[BeginDate], [Contract].[EndDate], " & _
'"[Entity].[EntityName] "

queryString = "SELECT DISTINCT Contract.Contract, Contract.ContractDesc, JobKeys.ClientName, " & _
"JobKeys.ProjMgrName, Contract.ContractValue, Contract.BeginDate, Contract.EndDate, Entity.EntityName"
sFrom = "FROM Contract INNER JOIN " & _
"JobKeys ON Contract.Contract = JobKeys.Contract INNER JOIN " & _
"Entity ON JobKeys.Entity = Entity.Entity INNER JOIN " & _
"Office ON JobKeys.Office = Office.Office "
sWhere = "WHERE 1=1"
'=================================
'sFrom = "FROM [Contract], [JobKeys], [Entity], [Office] "
'sWhere = "WHERE [Contract].[Contract]=[JobKeys].[Contract] AND [JobKeys].[Entity] = [Entity].[Entity] AND [JobKeys].[Office] = [Office].[Office] "
Dim iWhereLen As String = Len(sWhere)
sOrder = " ORDER by " & sSortStr

If Len(txtJob.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[Job] in (" & CreateInStatement(PadQuotes(txtJob.Text)) & ") "
End If

If Len(txtProjectMgr.Text) > 1 Then
sWhere = sWhere & " and [JobKeys].[ProjMgrNum] in (" & CreateInStatement(PadQuotes(txtProjectMgr.Text)) & ") "
End If

If Len(lstCntrTerm.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [JobKeys].[ContractTerms] in (" & CreateInStatement(lstCntrTerm.SelectedItem.Value) & ") "
End If

If Len(txtClient.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[Client] in (" & CreateInStatement(PadQuotes(txtClient.Text)) & ") "
End If

If Len(txtClientName.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[ClientName] in (" & CreateInStatement(PadQuotes(txtClientName.Text)) & ") "

End If

'If lstAllEntity.Enabled = False Then
If Len(lstEntity.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [JobKeys].[Entity] in (" & CreateInStatement(lstEntity.SelectedItem.Value) & ") "
End If
'End If

'If lstEntity.Enabled = False Then
' If Len(lstAllEntity.SelectedItem.Value) > 1 Then
' sWhere = sWhere & " AND [JobKeys].[Entity] in (" & CreateInStatement(lstAllEntity.SelectedItem.Value) & ") "
' End If
'End If

If Len(txtProposal.Text) > 1 Then
sWhere = sWhere & " and [JobKeys].[Proposal] in (" & CreateInStatement(PadQuotes(txtProposal.Text)) & ") "
End If

If Len(txtContract.Text) > 1 Then
sWhere = sWhere & " and [JobKeys].[Contract] in (" & CreateInStatement(txtContract.Text) & ") "
End If

If Len(lstStatus.SelectedItem.Value) > 1 Or Len(lstBusArrang.SelectedItem.Value) > 1 Or Len(lstStand.SelectedItem.Value) > 1 Then
'sFrom = sFrom & ", [Contract] "
sWhere = sWhere & " and [Contract].[Contract] = [JobKeys].[Contract] "
If Len(lstStatus.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[Status] in (" & CreateInStatement(lstStatus.SelectedItem.Value) & ") "
End If
If Len(lstBusArrang.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[BusArrangement] in (" & CreateInStatement(lstBusArrang.SelectedItem.Value) & ") "
End If
If Len(lstStand.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[StdIndustry] in (" & CreateInStatement(lstStand.SelectedItem.Value) & ") "
End If
End If

'If lstAllOffice.Enabled = False Then
If Len(lstOffice.SelectedItem.Value) > 0 Then
sWhere = sWhere & " AND [JobKeys].[Office] in (" & CreateInStatement(lstOffice.SelectedItem.Text) & ") "
End If
'End If

'If lstOffice.Enabled = False Then
' If Len(lstAllOffice.SelectedItem.Value) > 0 Then
' sWhere = sWhere & " AND [JobKeys].[Office] in (" & CreateInStatement(lstAllOffice.SelectedItem.Text) & ") "
' End If
'End If

If Len(txtProjectID.Text) > 0 Then
sWhere = sWhere & " AND [JobKeys].[Project] in (" & CreateInStatement(PadQuotes(txtProjectID.Text)) & ") "
End If


If Len(txtCntrValue.Text) > 0 Then
sWhere = sWhere & " AND [Contract].[ContractValue] >= " & ConvertToDollars(PadQuotes(txtCntrValue.Text)) & " "
End If

If Len(lstScope.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'ScopeSrvcs' AND [JobBDCodes].[BDCode] in "
'sWhere = sWhere & " ('" & CreateInStatement(lstScope.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstScope.SelectedItem.Value) & ") "
End If

If Len(lstComMkt.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'CoMrktg' AND [JobBDCodes].[BDCode] in"
'sWhere = sWhere & " ('" & CreateInStatement(lstComMkt.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstComMkt.SelectedItem.Value) & ") "
End If

If Len(lstCorpMkt.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'CorpMrktg' AND [JobBDCodes].[BDCode] in"
'sWhere = sWhere & " ('" & CreateInStatement(lstCorpMkt.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstCorpMkt.SelectedItem.Value) & ") "
End If

If Len(lstSF254.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].BDCodeType = 'SF254' AND [JobBDCodes].BDCode in"
'sWhere = sWhere & " ('" & CreateInStatement(lstSF254.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstSF254.SelectedItem.Value) & ") "
End If

'-------- Nel
If Len(txtSubcntr.Text) > 0 Then
'txtSubcntr = Replace(txtSubcntr.Text, "'", "''")
sFrom = sFrom & ", [JobSubcontractors], [Subcontractor] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobSubcontractors].[Job] "
'sWhere = sWhere & " AND JS.SubcontractorName in (" & CreateInStatement(txtSubcntr.Text) & ") "
sWhere = sWhere & " AND [JobSubcontractors].[SubcontractorName]=[Subcontractor].[SubcontractorName]" & _
"and [Subcontractor].[Subcontractor] in (" & CreateInStatement(PadQuotes(txtSubcntr.Text)) & ") "
End If
'-----------

If IsDate(txtCloseDate.Text) Then
sWhere = sWhere & " AND ([JobKeys].[ClosedDate] IS NULL or [JobKeys].[ClosedDate] >= '"
sWhere = sWhere & txtCloseDate.Text & "')"
End If


If iWhereLen = Len(sWhere) Then ' no criteria entered!
lblMsg.Text = "Selection criteria must be entered before initiating a search"
Else
lblMsg.Text = ""

queryString = queryString & " " & sFrom & " " & sWhere & "" & sOrder

Dim queryString2 As String
Dim queryString3 As String

'queryString3 = "INSERT INTO ContractNo (Contract, ContractDesc, ClientName, ProjMgrName, ContractValue, BeginDate, EndDate, EntityName) VALUES(3022, 'John', 'Smith', 2101,3022, 'John', 'Smith', 2101)"
'Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString3, sqlConnection)

Dim sqlCommand1 As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()

Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand1.ExecuteReader(System.Data.ConnectionState.Executing)
Dim stringcntr As String

While dataReader.Read()
stringcntr &= dataReader("Contract").ToString() & ";"
End While
'lbl3.Text = stringcntr
End If
End Function

Public Function CreateInStatement(ByVal sData As String)
' This routine will take in a vanilla text string,
' and create an SQL 'in' statement
Dim iCnt As Integer
Dim iX As Integer
Dim sText As String

iCnt = InStr(sData, ",")
If iCnt = 0 Then
CreateInStatement = "'" & sData & "'"
Exit Function
End If

iX = 0
Do While iCnt > 0
sText = sText & "'" & Trim$(Mid$(sData, iX + 1, iCnt - iX - 1)) & "', "
iX = iCnt
iCnt = InStr(iX + 1, sData, ",")
Loop
' now append last key
sText = sText & "'" & Trim$(Right$(sData, Len(sData) - iX)) & "'"

CreateInStatement = sText

End Function
Public Function ConvertToDollars(ByVal sAmt As String)
' This routine will strip off any dollars signs, comma, etc.
Dim sHoldAmt As String
Dim sHoldTxt As String
Dim iCnt As Integer

For iCnt = 1 To Len(sAmt)
sHoldTxt = Mid$(sAmt, iCnt, 1)
If Val(sHoldTxt) > 0 Or sHoldTxt = "0" Or sHoldTxt = "." Then
sHoldAmt = sHoldAmt & sHoldTxt
End If
Next

ConvertToDollars = sHoldAmt

End Function

Function Qrysf254() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select distinct [BDCodeDesc], [BDCode] from [BDCodes] " & _
"where [BDCodeType] = 'SF254' ORDER BY [BDCodeDesc]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function

Function Qrystand() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select distinct [BDCodeDesc], [BDCode] from [BDCodes] " & _
"where [BDCodeType] = 'StdIndustr' ORDER BY [BDCodeDesc]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qryscope() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select distinct [BDCodeDesc], [BDCode] from [BDCodes] " & _
"where [BDCodeType] = 'ScopeSrvcs' ORDER BY [BDCodeDesc]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qrycommakt() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "SELECT [BDCode], [BDCodeDesc] FROM [BDCodes] " & _
"WHERE [BDCodeType] = 'CoMrktg' ORDER BY [BDCodeDesc] "

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qrycorpmkt() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "SELECT [BDCode], [BDCodeDesc] FROM [BDCodes] " & _
"WHERE [BDCodeType] = 'CorpMrktg' ORDER BY [BDCodeDesc] "

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function


Function Qryoffice() As System.Data.SqlClient.SqlDataReader
'Dim connectionString As String = "server='PARSQL21'; user id='BusDev';password='psbd'; Database='hawk'"
'Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select DISTINCT [Office], [OfficeName] from [Office] " & _
" ORDER BY [OfficeName]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function


Function Qrycntrterm() As System.Data.SqlClient.SqlDataReader
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select distinct [ContractTermsText], [ContractTerms] " & _
"from [ContractTerms] ORDER BY [ContractTermsText]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qrystatus() As System.Data.SqlClient.SqlDataReader
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select Distinct [Status] from [Contract] order by [Status]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qrybusarrang() As System.Data.SqlClient.SqlDataReader
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "SELECT [BDCodeDesc],[BDCode] FROM [BDCodes] " & _
"WHERE [BDCodeType] = 'BusArrange' ORDER BY [BDCodeDesc] "

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function
Function Qryentity() As System.Data.SqlClient.SqlDataReader
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String = "Select DISTINCT [Entity], [EntityName] from [Entity] " & _
" ORDER BY [EntityName]"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function

Function Qryemp(ByVal sSortStr As String) As System.Data.SqlClient.SqlDataReader
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim queryString As String
Dim sFrom As String
Dim sWhere As String
Dim sOrder As String


queryString = "SELECT DISTINCT Contract.Contract, Contract.ContractDesc, JobKeys.ClientName, JobKeys.ProjMgrName, " & _
"Contract.ContractValue, Contract.BeginDate, " & _
"Contract.EndDate, Entity.EntityName "
sFrom = "FROM Contract INNER JOIN JobKeys ON Contract.Contract = JobKeys.Contract " & _
"INNER JOIN Entity ON JobKeys.Entity = Entity.Entity " & _
"CROSS JOIN Office "
sWhere = "WHERE 1=1"

Dim iWhereLen As String = Len(sWhere)
sOrder = " ORDER by " & sSortStr

If Len(txtJob.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[Job] in (" & CreateInStatement(PadQuotes(txtJob.Text)) & ") "
End If

If Len(txtProjectMgr.Text) > 1 Then
sWhere = sWhere & " and [JobKeys].[ProjMgrNum] in (" & CreateInStatement(PadQuotes(txtProjectMgr.Text)) & ") "
End If

If Len(lstCntrTerm.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [JobKeys].[ContractTerms] in (" & CreateInStatement(lstCntrTerm.SelectedItem.Value) & ") "
End If

If Len(txtClient.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[Client] in (" & CreateInStatement(PadQuotes(txtClient.Text)) & ") "
End If

If Len(txtClientName.Text) > 1 Then
sWhere = sWhere & " AND [JobKeys].[ClientName] in (" & CreateInStatement(PadQuotes(txtClientName.Text)) & ") "
End If


If Len(lstStatus.SelectedItem.Value) > 1 Or Len(lstBusArrang.SelectedItem.Value) > 1 Or Len(lstStand.SelectedItem.Value) > 1 Then
'sFrom = sFrom & ", [Contract] "
sWhere = sWhere & " and [Contract].[Contract] = [JobKeys].[Contract] "
If Len(lstStatus.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[Status] in (" & CreateInStatement(lstStatus.SelectedItem.Value) & ") "
End If
If Len(lstBusArrang.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[BusArrangement] in (" & CreateInStatement(lstBusArrang.SelectedItem.Value) & ") "
End If
If Len(lstStand.SelectedItem.Value) > 1 Then
sWhere = sWhere & " AND [Contract].[StdIndustry] in (" & CreateInStatement(lstStand.SelectedItem.Value) & ") "
End If
End If

If Len(lstOffice.SelectedItem.Value) > 0 Then
sWhere = sWhere & " AND [JobKeys].[Office] in (" & CreateInStatement(lstOffice.SelectedItem.Value) & ") "
End If

If Len(txtProjectID.Text) > 0 Then
sWhere = sWhere & " AND [JobKeys].[Project] in (" & CreateInStatement(PadQuotes(txtProjectID.Text)) & ") "
End If


If Len(txtCntrValue.Text) > 0 Then
sWhere = sWhere & " AND [Contract].[ContractValue] >= " & ConvertToDollars(PadQuotes(txtCntrValue.Text)) & " "
End If

If Len(lstScope.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'ScopeSrvcs' AND [JobBDCodes].[BDCode] in "
'sWhere = sWhere & " ('" & CreateInStatement(lstScope.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstScope.SelectedItem.Value) & ") "
End If

If Len(lstComMkt.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'CoMrktg' AND [JobBDCodes].[BDCode] in"
'sWhere = sWhere & " ('" & CreateInStatement(lstComMkt.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstComMkt.SelectedItem.Value) & ") "
End If

If Len(lstCorpMkt.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].[BDCodeType] = 'CorpMrktg' AND [JobBDCodes].[BDCode] in"
'sWhere = sWhere & " ('" & CreateInStatement(lstCorpMkt.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstCorpMkt.SelectedItem.Value) & ") "
End If

If Len(lstSF254.SelectedItem.Value) > 0 Then
sFrom = sFrom & ", [JobBDCodes] "
sWhere = sWhere & " AND [JobKeys].[Job] = [JobBDCodes].[Job] "
sWhere = sWhere & " AND [JobBDCodes].BDCodeType = 'SF254' AND [JobBDCodes].BDCode in"
'sWhere = sWhere & " ('" & CreateInStatement(lstSF254.SelectedItem.Value) & "') "
sWhere = sWhere & " (" & CreateInStatement(lstSF254.SelectedItem.Value) & ") "
End If


If IsDate(txtCloseDate.Text) Then
sWhere = sWhere & " AND ([JobKeys].[ClosedDate] IS NULL or [JobKeys].[ClosedDate] >= '"
sWhere = sWhere & txtCloseDate.Text & "')"
End If


If iWhereLen = Len(sWhere) Then ' no criteria entered!
lblMsg.Text = "Selection criteria must be entered before initiating a search"
Else
lblMsg.Text = ""

queryString = queryString & " " & sFrom & " " & sWhere & "" & sOrder




Dim queryString2 As String
Dim queryString3 As String

'queryString3 = "INSERT INTO ContractNo (Contract, ContractDesc, ClientName, ProjMgrName, ContractValue, BeginDate, EndDate, EntityName) VALUES(3022, 'John', 'Smith', 2101,3022, 'John', 'Smith', 2101)"
'Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString3, sqlConnection)

Dim sqlCommand1 As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()

Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand1.ExecuteReader(System.Data.ConnectionState.Executing)

'While dataReader.Read()
'lbl3.Text &= dataReader("Contract").ToString() & ";"
'End While

Return dataReader

End If
End Function

Private Sub lstEntity_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstEntity.Init
lstEntity.DataSource = Qryentity()
lstEntity.DataBind()

lstEntity.Items.Insert(0, "")
lstEntity.SelectedIndex = 0
End Sub
'Private Sub lstAllEntity_Init(ByVal sender As System.Object, ByVal e As System.EventArgs)
' lstAllEntity.DataSource = QryAllentity()
' lstAllEntity.DataBind()

' lstAllEntity.Items.Insert(0, "")
' lstAllEntity.SelectedIndex = 0
'End Sub

Private Sub lstOffice_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstOffice.Init
lstOffice.DataSource = Qryoffice()
lstOffice.DataBind()

lstOffice.Items.Insert(0, "")
lstOffice.SelectedIndex = 0
End Sub
'Private Sub lstAllOffice_Init(ByVal sender As System.Object, ByVal e As System.EventArgs)
' lstAllOffice.DataSource = QryAlloffice()
' lstAllOffice.DataBind()

' lstOffice.Items.Insert(0, "")
' lstOffice.SelectedIndex = 0
'End Sub

Private Sub lstCntrTerm_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCntrTerm.Init
lstCntrTerm.DataSource = Qrycntrterm()
lstCntrTerm.DataBind()

lstCntrTerm.Items.Insert(0, "")
lstCntrTerm.SelectedIndex = 0
End Sub

Private Sub lstStatus_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstStatus.Init
lstStatus.DataSource = Qrystatus()
lstStatus.DataBind()

lstStatus.Items.Insert(0, "")
lstStatus.SelectedIndex = 0
End Sub

Private Sub lstBusArrang_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstBusArrang.Init
lstBusArrang.DataSource = Qrybusarrang()
lstBusArrang.DataBind()

lstBusArrang.Items.Insert(0, "")
lstBusArrang.SelectedIndex = 0
End Sub

Private Sub lstStand_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstStand.Init
lstStand.DataSource = Qrystand()
lstStand.DataBind()

lstStand.Items.Insert(0, "")
lstStand.SelectedIndex = 0
End Sub

Private Sub lstScope_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstScope.Init
lstScope.DataSource = Qryscope()
lstScope.DataBind()

lstScope.Items.Insert(0, "")
lstScope.SelectedIndex = 0
End Sub

Private Sub lstComMkt_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstComMkt.Init
lstComMkt.DataSource = Qrycommakt()
lstComMkt.DataBind()

lstComMkt.Items.Insert(0, "")
lstComMkt.SelectedIndex = 0
End Sub

Private Sub lstCorpMkt_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCorpMkt.Init
lstCorpMkt.DataSource = Qrycorpmkt()
lstCorpMkt.DataBind()

lstCorpMkt.Items.Insert(0, "")
lstCorpMkt.SelectedIndex = 0
End Sub

Private Sub lstSF254_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSF254.Init
lstSF254.DataSource = Qrysf254()
lstSF254.DataBind()

lstSF254.Items.Insert(0, "")
lstSF254.SelectedIndex = 0
End Sub

Private Sub imgSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgSearch.Click
gridContract.Visible = True
gridContract.DataSource = Qryemp("[Contract].[Contract]")
gridContract.DataBind()
CntrNoLst("[Contract].[Contract]")
lblrecordnum.Text = rsnum & " rows returned"
End Sub


Private Sub gridContract_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles gridContract.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
arrlstCntr.Add(CType(e.Item.DataItem, System.Data.Common.DbDataRecord).Item("Contract"))
'((System.Data.Common.DbDataRecord)e.Item.DataItem)["solution"].ToString();
rsnum = arrlstCntr.Count
End If
End Sub

Private Sub gridContract_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles gridContract.SortCommand
Dim NewSortExpr As String

Select Case e.SortExpression
Case "Contract"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Contract].[Contract] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Contract].[Contract] Asc"
Me.DateSortDirection = "ASC"
End If

Case "ContractDesc"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Contract].[ContractDesc] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Contract].[ContractDesc] Asc"
Me.DateSortDirection = "ASC"
End If

Case "ClientName"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[JobKeys].[ClientName] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[JobKeys].[ClientName] Asc"
Me.DateSortDirection = "ASC"
End If

Case "ProjMgrName"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[JobKeys].[ProjMgrName] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[JobKeys].[ProjMgrName] Asc"
Me.DateSortDirection = "ASC"
End If

Case "ContractValue"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Contract].[ContractValue] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Contract].[ContractValue] Asc"
Me.DateSortDirection = "ASC"
End If

Case "BeginDate"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Contract].[BeginDate] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Contract].[BeginDate] Asc"
Me.DateSortDirection = "ASC"
End If

Case "EndDate"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Contract].[EndDate] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Contract].[EndDate] Asc"
Me.DateSortDirection = "ASC"
End If

Case "EntityName"
If Me.DateSortDirection = "ASC" Then
NewSortExpr = "[Entity].[EntityName] Desc"
Me.DateSortDirection = "DESC"
Else
NewSortExpr = "[Entity].[EntityName] Asc"
Me.DateSortDirection = "ASC"
End If
End Select

gridContract.DataSource = Qryemp(NewSortExpr)
gridContract.DataBind()

End Sub

End Class
QuestionI don't know why I have this error Pin
Curious 200922-Jan-10 5:51
Curious 200922-Jan-10 5:51 
AnswerRe: I don't know why I have this error Pin
DJ Matthews22-Jan-10 6:01
DJ Matthews22-Jan-10 6:01 
GeneralRe: I don't know why I have this error Pin
Curious 200922-Jan-10 6:33
Curious 200922-Jan-10 6:33 
AnswerRe: I don't know why I have this error Pin
loyal ginger22-Jan-10 6:31
loyal ginger22-Jan-10 6:31 
GeneralRe: I don't know why I have this error Pin
Curious 200922-Jan-10 6:39
Curious 200922-Jan-10 6:39 
GeneralRe: I don't know why I have this error Pin
loyal ginger22-Jan-10 7:10
loyal ginger22-Jan-10 7:10 
GeneralRe: I don't know why I have this error Pin
Curious 200922-Jan-10 7:35
Curious 200922-Jan-10 7:35 
GeneralRe: I don't know why I have this error Pin
loyal ginger22-Jan-10 7:44
loyal ginger22-Jan-10 7:44 
GeneralRe: I don't know why I have this error Pin
Curious 200922-Jan-10 8:49
Curious 200922-Jan-10 8:49 
QuestionDatabase record to textboxes Pin
offroaderdan22-Jan-10 5:06
offroaderdan22-Jan-10 5:06 
AnswerRe: Database record to textboxes Pin
Eddy Vluggen23-Jan-10 5:48
professionalEddy Vluggen23-Jan-10 5:48 
QuestionHow can I import table from one database to another thru a from in VB.net Pin
waner michaud22-Jan-10 3:30
waner michaud22-Jan-10 3:30 
AnswerRe: How can I import table from one database to another thru a from in VB.net Pin
Eddy Vluggen23-Jan-10 5:04
professionalEddy Vluggen23-Jan-10 5:04 
GeneralRe: How can I import table from one database to another thru a from in VB.net Pin
waner michaud23-Jan-10 7:23
waner michaud23-Jan-10 7:23 
GeneralRe: How can I import table from one database to another thru a from in VB.net Pin
Eddy Vluggen24-Jan-10 1:36
professionalEddy Vluggen24-Jan-10 1:36 
GeneralRe: How can I import table from one database to another thru a from in VB.net Pin
waner michaud25-Jan-10 4:12
waner michaud25-Jan-10 4:12 
GeneralRe: How can I import table from one database to another thru a from in VB.net Pin
Eddy Vluggen25-Jan-10 7:58
professionalEddy Vluggen25-Jan-10 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.