*********************ASP PAGE ******************************************* <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="siteAgreements_ChangeSiteID.aspx.vb" Inherits="siteAgreements_ChangeSiteID" EnableEventValidation = "False" Trace="false"%> <%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
Site Terms Agreements - Manage Agreements

       

         






   
*****************************Code Behind lots of commented out code from all the differnt soluntions I've tried This may be causing the problem*********************************************************************** Imports System.Configuration Imports System.IO Imports System.Data Imports System.Data.SqlClient Imports Microsoft.Reporting.WebForms Imports System.Reflection Partial Class siteAgreements_ChangeSiteID Inherits System.Web.UI.Page 'Private sm As ScriptManager = ScriptManager.GetCurrent(Me) Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Dim mp1 = Master.FindControl("panelm1") If Session("menuVisible") = "True" Then Session("menuVisible") = "False" Else Session("menuVisible") = "True" mp1.visible = Session("menuVisible") If mp1.Visible = "False" Then Label44.Text = "<-- Show Menu " Else Label44.Text = "<-- Hide Menu " End Sub Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then validateUser() setTreeviewVisible() 'load switch Site ID List boxes LoadSwitchIDListBoxes() Else 'Server.ScriptTimeout = 180 End If End Sub Sub validateUser() Dim logUserID = HttpContext.Current.User.Identity.Name.ToString() logUserID = Right(logUserID, Len(logUserID) - InStr(logUserID, "\")) Dim conn As SqlConnection Dim cmdSelect As SqlCommand Dim strSelect As String Dim settings As ConnectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings("coda_ConnectionString") Dim connstr As String = settings.ConnectionString conn = New SqlConnection(connstr) conn.Open() strSelect = "select userID from tbl_users where userID = @userID and (contractsAdmin = 1 or MIS = 1)and active = 1" cmdSelect = New SqlCommand(strSelect, conn) cmdSelect.Parameters.AddWithValue("@userID", logUserID) Dim authUser = cmdSelect.ExecuteScalar() conn.Close() If Len(authUser) = 0 Then Response.Redirect("main.aspx?errMsg=1") Else lblChangedBy.Text = logUserID End If End Sub Sub setTreeviewVisible() If Len(Session("menuVisible")) = 0 Then Session("menuVisible") = "True" Session.Timeout = 720 End If Dim mp1 = Master.FindControl("panelm1") mp1.visible = Session("menuVisible") If Session("menuVisible") = "True" Then Label44.Text = "<-- Hide Menu" Else Label44.Text = "<-- Show Menu" End Sub Protected Sub LoadSwitchIDListBoxes() Dim conn As SqlConnection Dim cmdSelect As SqlCommand Dim strSelect As String Dim settings As ConnectionStringSettings = System.Configuration.ConfigurationManager.ConnectionStrings("coda_ConnectionString") Dim connstr As String = settings.ConnectionString conn = New SqlConnection(connstr) Dim drSites As SqlDataReader Dim drCustomers As SqlDataReader If lstIDSwitch1.Items.Count > 0 Then lstIDSwitch1.Items.Clear() End If If lstIDSwitch2.Items.Count > 0 Then lstIDSwitch2.Items.Clear() End If Try conn.Open() strSelect = "EXEC isp_GetCustSiteIDsForModifyAgreementsSwitch @SelectedSearchCriteria" cmdSelect = New SqlCommand(strSelect, conn) cmdSelect.Parameters.AddWithValue("SelectedSearchCriteria", "Customer") drCustomers = cmdSelect.ExecuteReader() While drCustomers.Read() Dim lstInfo As New ListItem lstInfo.Text = drCustomers("Name").ToString() lstInfo.Value = drCustomers("ID") lstIDSwitch1.Items.Add(lstInfo) End While cmdSelect.Dispose() drCustomers.Close() cmdSelect = New SqlCommand(strSelect, conn) cmdSelect.Parameters.AddWithValue("SelectedSearchCriteria", "Site") drSites = cmdSelect.ExecuteReader() While drSites.Read() Dim lstInfo As New ListItem lstInfo.Text = drSites("Name").ToString() lstInfo.Value = drSites("ID") lstIDSwitch2.Items.Add(lstInfo) End While cmdSelect.Dispose() drCustomers.Close() Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() Finally conn.Close() End Try End Sub Protected Function GetBrowsePath(ByVal strArgument) As String Dim strServerName = ConfigurationManager.AppSettings("ContractServerName") Return "\\" & strServerName & strArgument End Function Protected Sub cmdSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSearch.Click Try lblError.Visible = False gvCustomersOrSites.Columns(1).HeaderText = lblSelectedSearchCriteria.Text + " ID#" gvCustomersOrSites.Columns(2).HeaderText = lblSelectedSearchCriteria.Text + " Name" gvCustomersOrSites.Visible = True SetFocus(txtSearchID) gvCustomersOrSites.SelectedIndex = -1 HideOrShowSwitchIDPanels(False) If gvCustomersOrSites.Rows.Count > 0 Then 'TODO: this code will need change to account for serching by site or customer gvDocs.Visible = False lblFoundDocs.Visible = False Else gvCustomersOrSites.EmptyDataText = "No documents found for this " & lblSelectedSearchCriteria.Text & " site." End If Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub gvCustomersOrSites_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvCustomersOrSites.SelectedIndexChanged loadgvDocsDataGrid(gvCustomersOrSites.SelectedValue, lblSelectedSearchCriteria.Text, lblSelectedSearchCriteriaOpp.Text) End Sub Private Sub loadgvDocsDataGrid(ByVal iSearchID As Integer, ByVal sSearchCritera As String, ByVal sOppSearchCriteria As String) Try lblError.Visible = False txtSearchID.Text = iSearchID.ToString() gvDocs.DataSourceID = "tbl_Documents" gvDocs.DataBind() gvDocs.Visible = True gvDocs.Focus() lblFoundDocs.Visible = True If gvDocs.Rows.Count > 0 Then 'Update the display message lblFoundDocs.Text = "Documents for this " + sSearchCritera + ":" ''update Column headders gvDocs.Columns(2).HeaderText = sSearchCritera + " ID#" gvDocs.Columns(3).HeaderText = sSearchCritera + " Name" Else lblFoundDocs.Text = "No Documents found for this " + sSearchCritera + "." End If 'Now set the search critera text. If this method is called by gvCustomersOrSites_SelectedIndexChanged, the value will be set to what it was before. If not it may change based on the type of change made by the user. lblSelectedSearchCriteria.Text = sSearchCritera lblSelectedSearchCriteriaOpp.Text = sOppSearchCriteria 'TODO: May want to clear the search critera here Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub rbSearch_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rbCustomerSearch.CheckedChanged, rbSiteSearch.CheckedChanged Try gvCustomersOrSites.Visible = False lblError.Visible = False HideOrShowSwitchIDPanels(False) lblFoundDocs.Visible = False 'lstIDSwitch2.SelectedIndex = -1 'lstIDSwitch1.SelectedIndex = -1 If rbCustomerSearch.Checked Then lblSelectedSearchCriteria.Text = "Customer" lblSelectedSearchCriteriaOpp.Text = "Site" lblSearchID.Text = "Customer No. : " lblSearchName.Text = "Customer Name :" cbChangeDocAssociationType.Text = "Change Document to Site Document" lblChangeToID.Text = "Site ID to Change to: " End If If rbSiteSearch.Checked Then lblSelectedSearchCriteria.Text = "Site" lblSelectedSearchCriteriaOpp.Text = "Customer" lblSearchID.Text = "Site No. : " lblSearchName.Text = "Site Name :" cbChangeDocAssociationType.Text = "Change Document to Customer Document" lblChangeToID.Text = "Customer ID to Change to: " End If Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub gvDocs_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvDocs.RowEditing ' gvDocs.EditIndex = gvDocs. 'show the switch panels HideOrShowSwitchIDPanels(True) End Sub Protected Sub gvDocs_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles gvDocs.RowUpdated Try 'Need to update the disply with the proper customer or site and associated document information If (e.OldValues("ChangeToBoolean")) Then 'Need to update the Cutomer or site displayed If (e.OldValues("SelectedSearchCriteria") = "Customer") Then loadgvDocsDataGrid(e.OldValues("NewRID"), "Site", "Customer") Else loadgvDocsDataGrid(e.OldValues("NewRID"), "Customer", "Site") End If 'If (e.OldValues("ChangeToBoolean") = "Customer") Then Else 'Don't need to update the customer or site displayed If (e.OldValues("SelectedSearchCriteria") = "Customer") Then loadgvDocsDataGrid(e.OldValues("ID"), "Customer", "Site") Else loadgvDocsDataGrid(e.OldValues("NewRID"), "Site", "Customer") End If 'If (e.OldValues("ChangeToBoolean") = "Customer") Then End If ' If (e.OldValues("ChangeToBoolean")) Then HideOrShowSwitchIDPanels(False) Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub 'Protected Sub cbChangeDocAssociationType_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) ' Try ' Dim cbSender As CheckBox ' cbSender = sender ' Dim ddlNewSiteOrCustomerNames As DropDownList ' ddlNewSiteOrCustomerNames = gvDocs.Rows(gvDocs.EditIndex).FindControl("ddlCustOrSiteNamesSwitch") ' If cbSender.Checked = "true" Then ' 'enable the switch to controls ' ddlNewSiteOrCustomerNames.Enabled = True ' lblChangeDocType.Text = "true" ' 'Select the first value in the drop down ' Dim ddCustOrSite As DropDownList ' Dim lblCustOrSiteID As Label ' ddCustOrSite = gvDocs.Rows(gvDocs.EditIndex).FindControl("ddlCustOrSiteNamesSwitch") ' lblCustOrSiteID = gvDocs.Rows(gvDocs.EditIndex).FindControl("lblIDNumEditSwitch") ' ddCustOrSite.SelectedIndex = 0 ' lblCustOrSiteID.Text = ddCustOrSite.SelectedValue ' Else ' 'disable the swith to controls ' ddlNewSiteOrCustomerNames.Enabled = False ' lblChangeDocType.Text = "false" ' End If ' Catch ex As Exception ' lblError.Visible = True ' lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() ' End Try 'End Sub Protected Sub gvDocs_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles gvDocs.RowCancelingEdit HideOrShowSwitchIDPanels(False) End Sub Protected Sub gvDocs_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvDocs.PageIndexChanged HideOrShowSwitchIDPanels(False) End Sub Protected Sub HideOrShowSwitchIDPanels(ByVal blShowPanel As Boolean) Try pnlSwitchInfo.Visible = blShowPanel 'If blShowPanel Then ' Select Case lblSelectedSearchCriteria.Text ' Case "Customer" ' pnlSwitch2.Visible = blShowPanel ' Case Else 'Site' ' pnlSwitch1.Visible = blShowPanel ' End Select 'Else ' pnlSwitch1.Visible = False ' pnlSwitch2.Visible = False 'End If Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub gvDocs_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvDocs.RowUpdating 'Before doing the update, Set the Id associated with the name in the name drop downs in the Documents Grid view Try 'First must determine if the user is trying to switch the document type ''lblCustOrSiteID = gvDocs.Rows(gvDocs.EditIndex).FindControl("lblIDnumEdit") ''lblCustOrSiteID.Text = dSender.SelectedValue.ToString() 'lblCustOrSiteID.Text = dSender.SelectedValue.ToString() ' Case "dsCustOrSiteIDsSwitch" ''lblCustOrSiteID = gvDocs.Rows(gvDocs.EditIndex).FindControl("lblIDNumEditSwitch") ''lblCustOrSiteID.Text = dSender.SelectedValue.ToString() Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub lstIDSwitch2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstIDSwitch2.SelectedIndexChanged 'SwitchIDTypeListBox_SelectedIndexChanged(sender, e) End Sub Protected Sub lstIDSwitch1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstIDSwitch1.SelectedIndexChanged 'SwitchIDTypeListBox_SelectedIndexChanged(sender, e) End Sub Protected Sub SwitchIDTypeListBox_SelectedIndexChanged(ByVal sender As ListBox, ByVal e As System.EventArgs) Try 'This is only applicable if the data grid for documents is in edit mode 'If gvDocs.EditIndex >= 0 Then ' Dim iSelectedIndex As Integer ' iSelectedIndex = gvDocs.EditIndex ' Dim lblLabelForInfo As Label ' Dim ddlDropDownForInfo As DropDownList ' Dim cbCheckBoxForInfo As CheckBox ' Dim txtTextBoxForInfo As TextBox ' Select Case lblSelectedSearchCriteria.Text ' Case "Customer" ' 'The custmer information is in the grid ' Select Case sender.ID ' Case "lstIDSwitch1" ' ''change customer ID to another customer ID ' 'lblLabelForInfo = gvDocs.Rows(iSelectedIndex).FindControl("lblIDNumEdit") ' 'ddlDropDownForInfo = gvDocs.Rows(iSelectedIndex).FindControl("ddlCustOrSiteNames") ' 'lblLabelForInfo.Text = sender.SelectedValue.ToString() ' 'ddlDropDownForInfo.SelectedValue = sender.SelectedValue ' Case Else 'lstIDSwitch2 ' 'Change customer Document to Site document ' txtTextBoxForInfo = gvDocs.Rows(iSelectedIndex).FindControl("txtChangeToID") ' cbCheckBoxForInfo = gvDocs.Rows(iSelectedIndex).FindControl("cbChangeDocAssociationType") ' txtTextBoxForInfo.Text = sender.SelectedValue.ToString() ' cbCheckBoxForInfo.Checked = True ' End Select ' Case Else 'Site ' 'The site information is in the grid ' End Select 'Else 'MsgBox("You must select a record to edit.", MsgBoxStyle.Information, "No record selected") 'sender.SelectedIndex = -1 'End If 'If gvDocs.EditIndex >= 0 Then Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub Protected Sub cbChangeDocAssociationType_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbChangeDocAssociationType.CheckedChanged Try If Not cbChangeDocAssociationType.Checked Then txtChangeToID.Text = "0" End If Catch ex As Exception lblError.Visible = True lblError.Text = "The following error occurred during " + Reflection.MethodInfo.GetCurrentMethod.Name() + " method execution: " + ex.Message() End Try End Sub End Class