Session is expiring immediately the page is loaded

S

skaliyamoorthy

Gurus,

Please help me out. I've weird problem.


i am developing asp.net application (nothing complecated) in locally in

XP machine and deploy the appplication in windows 2003 server, IIS6.0.
everything was working fine until last week. suddenly from yesterday
one particular page is getting session expired immediately right after
the page is loaded. But this is page is working fine in my local
machine. only happening in win2003. I could not find any reason why it
is happening. I pasted the code below. please help me out. i am running

out of time.


Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Globalization


Public Class InspectionProcess
Inherits System.Web.UI.Page


#Region " Web Form Designer Generated Code "


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


End Sub
Protected WithEvents Tr1 As System.Web.UI.HtmlControls.HtmlTableRow

Protected WithEvents tdOption As
System.Web.UI.HtmlControls.HtmlTableCell
Protected WithEvents trcritical As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents img_Critical As
System.Web.UI.HtmlControls.HtmlImage
Protected WithEvents trmajor As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents lbl_ALI As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Style As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Cover As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Team As System.Web.UI.WebControls.Label
Protected WithEvents lbl_Finishes As
System.Web.UI.WebControls.Label
Protected WithEvents lbl_InsType As System.Web.UI.WebControls.Label

Protected WithEvents lbl_CriticalCount As
System.Web.UI.WebControls.Label
Protected WithEvents clst_DefectType As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_Component As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_Location As
System.Web.UI.WebControls.DropDownList
Protected WithEvents btn_AddCr As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents lbl_MajorCount As
System.Web.UI.WebControls.Label
Protected WithEvents clst_DefectTypeMajor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_ComponentMajor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_LocationMajor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents btn_AddMa As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents clst_DefectTypeMinor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_ComponentMinor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents clst_LocationMinor As
System.Web.UI.WebControls.DropDownList
Protected WithEvents btn_AddMi As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents ctxt_Comments As
System.Web.UI.WebControls.TextBox
Protected WithEvents cchk_Unfixed As
System.Web.UI.WebControls.CheckBox
Protected WithEvents copt_Fixed As
System.Web.UI.WebControls.RadioButtonList
Protected WithEvents btn_Finish As System.Web.UI.WebControls.Button

Protected WithEvents btn_Cancel As System.Web.UI.WebControls.Button

Protected WithEvents hid_xmlMA As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents hid_xmlMI As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents trminor As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents hid_MAScore As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents row_UnitUnfixed As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents row_UnitFix As
System.Web.UI.HtmlControls.HtmlTableRow
Protected WithEvents hid_xmlCR As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents hid_CRScore As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents hid_MIScore As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents hid_CellThreshold As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents hid_UnitScore As
System.Web.UI.HtmlControls.HtmlInputHidden
Protected WithEvents lbl_Options As System.Web.UI.WebControls.Label

Protected WithEvents lbl_RadioBtnError As
System.Web.UI.WebControls.Label
Protected WithEvents lbl_FOB As System.Web.UI.WebControls.Label
Protected WithEvents img_Cover As
System.Web.UI.HtmlControls.HtmlImage
Protected WithEvents img_Option As
System.Web.UI.HtmlControls.HtmlImage
Protected WithEvents btn_DeleteMI As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents btn_DeleteCr As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents btn_DeleteMa As
System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents lbl_InspectionStatus As
System.Web.UI.WebControls.Label
Protected WithEvents lbl_Error As System.Web.UI.WebControls.Label
Protected WithEvents pnlInspectionProcess As
System.Web.UI.WebControls.Panel
Protected WithEvents reRadio As
System.Web.UI.WebControls.RequiredFieldValidator
Protected WithEvents img_Major As
System.Web.UI.HtmlControls.HtmlImage
Protected WithEvents dtxt_InsDate As
System.Web.UI.WebControls.TextBox


'NOTE: The following placeholder declaration is required by the Web

Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object


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


#Region "Variable Declaration"
Private strConstr As String
Private dsCritical As DataSet
Dim BLProcIns As ProcessInspection
Private Shared dtInsHistory As DataTable
Private Shared dtInsProcess As DataTable
Dim dtUnits As DataTable
Private Shared intCntCR As Integer
Private Shared intCntMA As Integer
Private Shared intCntMI As Integer
Private Shared intScoreCR As Integer
Private Shared intScoreMA As Integer
Private Shared intScoreMI As Integer
Private Shared intThreshold As Integer
Private Shared dsInspection As DataSet
#End Region


#Region "PageLoad Event"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


Try
lbl_Error.Visible = False


btn_Finish.Attributes.Add("OnClick", "javascript:return
fnValidateDate();")
btn_Cancel.Attributes.Add("OnClick", "javascript:return
fnCancel();")


If Not IsPostBack Then
Dim culture As CultureInfo = New CultureInfo("")
Dim strCurrentDate As String =
Convert.ToString(DateTime.Today, culture)


dtxt_InsDate.Text = strCurrentDate.Substring(0, 10)
lbl_InsType.Text = "Inspection Type : " +
Session("InspType")


hid_UnitScore.Value = 100


GetALIDetails()


FillDefectType("CR")
FillDefectType("MA")
FillDefectType("MI")
FillComponent()
FillLocation()
GetUnitScoreThreshold()


End If


MakeHistoryDataTable()
MakeDataTable()
MakeUnitsDataTable()


btn_AddCr.Attributes.Add("onclick",
"javascript:fnAddDefectXMLCR();")
btn_AddMa.Attributes.Add("onclick",
"javascript:fnAddDefectXMLMA();")
btn_AddMi.Attributes.Add("onclick",
"javascript:fnAddDefectXMLMI();")


Response.Write("<xml
id='dsoInspectionAttributes'><test><Process ImageDef='' DefectName=''
Location='' Component='' DefectID='' DefectTypeID='' LocationID=''
ComponentID='' Status='_blank' /></test></xml>")
Response.Write("<xml
id='dsoInspectionAttributesMA'><test><Process ImageDef='' DefectName=''

Location='' Component='' DefectID='' DefectTypeID='' LocationID=''
ComponentID='' Status='_blank' /></test></xml>")
Response.Write("<xml
id='dsoInspectionAttributesMI'><test><Process ImageDef='' DefectName=''

Location='' Component='' DefectID='' DefectTypeID='' LocationID=''
ComponentID='' Status='_blank' /></test></xml>")
Catch ce As clsCustomException
lbl_Error.Text = ce.CustomMessage
lbl_Error.Visible = True
pnlInspectionProcess.Visible = False
End Try
End Sub
Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
' clst_DefectType.Attributes.Add("OnChange",
"javascript:fnChangeCritical(this);")
' clst_DefectTypeMajor.Attributes.Add("OnChange",
"javascript:fnChangeMajor(this);")
' clst_DefectTypeMinor.Attributes.Add("OnChange",
"javascript:fnChangeMinor(this);")
MyBase.Render(output)
End Sub


#End Region


#Region "GetALI Details"
Private Sub GetALIDetails()


Dim strUnitOptions As String = ""
Dim strImagePath = clsConnection.GetImagesPath()


' Checks if ALI exists in the QRS database
If Session("RetrievalSource") = 1 Then
'DECLARATION PART
Dim dsALI As DataSet
Dim dsALIOpt As DataSet
Dim i As Integer = 0
Dim dr As DataRow


'INSTANTIATING BL PROCESSINSPECTION
BLProcIns = New ProcessInspection


'CALLING BL METHOD GETALIDETAILS
dsALI = BLProcIns.GetALIDetails(Session("ALI#"),
Session("UserRoleID"))


If (dsALI.Tables(0).Rows.Count > 0) Then
For i = 0 To dsALI.Tables(0).Rows.Count - 1
dr = dsALI.Tables(0).Rows(i)
lbl_ALI.Text = dr("UnitID")
If dr("Style") Is System.DBNull.Value Then
lbl_Style.Text = ""
Else
lbl_Style.Text = dr("Style")
End If
If dr("CoverNo") Is System.DBNull.Value Then
lbl_Cover.Text = ""
Else
lbl_Cover.Text = dr("CoverNo")
End If
If dr("FOB") Is System.DBNull.Value Then
lbl_FOB.Text = ""
Else
lbl_FOB.Text = dr("FOB")
End If
If dr("TeamName") Is System.DBNull.Value Then
lbl_Team.Text = ""
Else
lbl_Team.Text = dr("TeamName")
End If
If dr("Finishes") Is System.DBNull.Value Then
lbl_Finishes.Text = ""
Else
lbl_Finishes.Text = dr("Finishes")
End If
If dr("InspectionStatus") Is System.DBNull.Value
Then
lbl_InspectionStatus.Text = ""
Else
lbl_InspectionStatus.Text =
dr("InspectionStatus")
End If
Next


' Gets the Unit Options
If dsALI.Tables.Count > 1 Then
Dim dtOptions As DataTable = dsALI.Tables(1)


'TO DISPLAY THE UNIT OPTIONS FROM DATABASE
Dim strOptions As String = String.Empty
Dim drRow As DataRow
For Each drRow In dtOptions.Rows
strOptions += "<a
onclick='javascript:fnOpenImage(""" & drRow(0) & """);'
class='imageLink' target='Image.aspx'>" + CStr(drRow(0)) + "</a>" + " ,

"
strUnitOptions += CStr(drRow(0)) + ","
Next


strOptions = strOptions.TrimEnd(" ").TrimEnd(New
Char() {","})


lbl_Options.Text = strOptions
End If
End If
Else
Dim arrUnitDetails As ArrayList = New ArrayList
arrUnitDetails = Session("UnitDetailsFromSFT")


lbl_ALI.Text = arrUnitDetails(0)
lbl_Style.Text = arrUnitDetails(1)
lbl_Cover.Text = arrUnitDetails(2)
lbl_FOB.Text = arrUnitDetails(4)
lbl_Team.Text = arrUnitDetails(3)
lbl_Team.Text = Session("TeamName")
Dim strFinishes As String = arrUnitDetails(5)
lbl_Finishes.Text = strFinishes.TrimEnd(" ").TrimEnd(New
Char() {", "})
lbl_InspectionStatus.Text = "Unit Inspection Not Started"


Dim z As Int32 = arrUnitDetails.Count
Dim j As Int32
Dim tempStr As String
If z > 6 Then
For j = 6 To arrUnitDetails.Count - 1
tempStr += "<a onclick='javascript:fnOpenImage("""
& arrUnitDetails.Item(j) & """);' class='imageLink'
target='Image.aspx'>" + CStr(arrUnitDetails.Item(j)) + "</a>" + " , "
strUnitOptions += CStr(arrUnitDetails.Item(j)) +
","
Next
lbl_Options.Text = tempStr.TrimEnd(" ").TrimEnd(New
Char() {","})
Else
End If
End If


If lbl_Cover.Text <> "" Then
img_Cover.Src = strImagePath + lbl_Cover.Text + ".gif"
img_Cover.Attributes.Add("OnClick",
"javascript:window.open('Image.aspx?Image=" & lbl_Cover.Text & "','','
left=20,top=20,width=500,height=500,toolbar=no,resizable=no');")
Else
img_Cover.Visible = False
End If


If strUnitOptions <> "" Then
img_Option.Src = strImagePath + strUnitOptions.Substring(0,

strUnitOptions.IndexOf(",")) + ".gif"
img_Option.Attributes.Add("OnClick",
"javascript:window.open('Image.aspx?Image=" &
strUnitOptions.Substring(0, strUnitOptions.IndexOf(",")) & "','','
left=20,top=20,width=500,height=500,toolbar=no,resizable=no');")
Else
img_Option.Visible = False
End If
End Sub
#End Region


#Region "Fill Combos"
Private Sub FillDefectType(ByVal DefStr As String)
Dim dsDefType As DataSet
Dim drDefType As SqlDataReader
Dim SqlParm As SqlParameter
Dim i As Integer
Dim dr As DataRow


'INSTANTIATING BL PROCESSINSPECTION
BLProcIns = New ProcessInspection
dsDefType = BLProcIns.FillDefectType(DefStr,
Session("UserRoleID"))


If DefStr = "CR" Then
clst_DefectType.DataSource = dsDefType.Tables(0)
clst_DefectType.DataValueField = "CodeID"
clst_DefectType.DataTextField = "Description"
clst_DefectType.DataBind()
Dim lstSelect As New ListItem
clst_DefectType.Items.Insert(0, "Select One")
clst_DefectType.SelectedIndex = 0
ElseIf DefStr = "MA" Then
clst_DefectTypeMajor.DataSource = dsDefType.Tables(0)
clst_DefectTypeMajor.DataValueField = "CodeID"
clst_DefectTypeMajor.DataTextField = "Description"
clst_DefectTypeMajor.DataBind()
clst_DefectTypeMajor.Items.Insert(0, "Select One")
clst_DefectTypeMajor.SelectedIndex = 0
ElseIf DefStr = "MI" Then
clst_DefectTypeMinor.DataSource = dsDefType.Tables(0)
clst_DefectTypeMinor.DataValueField = "CodeID"
clst_DefectTypeMinor.DataTextField = "Description"
clst_DefectTypeMinor.DataBind()
clst_DefectTypeMinor.Items.Insert(0, "Select One")
clst_DefectTypeMinor.SelectedIndex = 0
End If
End Sub


Private Sub FillComponent()
Dim dsComp As DataSet
Dim drComp As SqlDataReader
Dim i As Integer = 0
Dim dr As DataRow
clst_Component.Items.Clear()
clst_ComponentMajor.Items.Clear()
clst_ComponentMinor.Items.Clear()


BLProcIns = New ProcessInspection
dsComp = BLProcIns.FillComponent(Session("UserRoleID"))


' Checks if there are components
If (dsComp.Tables(0).Rows.Count > 0) Then
clst_Component.DataSource = dsComp.Tables(0)
clst_Component.DataValueField = "CodeID"
clst_Component.DataTextField = "Description"
clst_Component.DataBind()


Dim lstSelect As New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_Component.Items.Insert(0, lstSelect)
clst_Component.SelectedIndex = 0


clst_ComponentMajor.DataSource = dsComp.Tables(0)
clst_ComponentMajor.DataValueField = "CodeID"
clst_ComponentMajor.DataTextField = "Description"
clst_ComponentMajor.DataBind()


lstSelect = New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_ComponentMajor.Items.Insert(0, lstSelect)
clst_ComponentMajor.SelectedIndex = 0


clst_ComponentMinor.DataSource = dsComp.Tables(0)
clst_ComponentMinor.DataValueField = "CodeID"
clst_ComponentMinor.DataTextField = "Description"
clst_ComponentMinor.DataBind()


lstSelect = New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_ComponentMinor.Items.Insert(0, lstSelect)
clst_ComponentMinor.SelectedIndex = 0
End If


End Sub
Private Sub FillLocation()


Dim dsLoc As DataSet
Dim i As Integer = 0
Dim dr As DataRow
clst_Location.Items.Clear()
clst_LocationMajor.Items.Clear()
clst_LocationMinor.Items.Clear()


BLProcIns = New ProcessInspection
dsLoc = BLProcIns.FillLocation(Session("UserRoleID"))


' Checks if there are locations
If (dsLoc.Tables(0).Rows.Count > 0) Then
clst_Location.DataSource = dsLoc.Tables(0)
clst_Location.DataValueField = "CodeID"
clst_Location.DataTextField = "Description"
clst_Location.DataBind()


Dim lstSelect As New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_Location.Items.Insert(0, lstSelect)
clst_Location.SelectedIndex = 0


clst_LocationMajor.DataSource = dsLoc.Tables(0)
clst_LocationMajor.DataValueField = "CodeID"
clst_LocationMajor.DataTextField = "Description"
clst_LocationMajor.DataBind()


lstSelect = New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_LocationMajor.Items.Insert(0, lstSelect)
clst_LocationMajor.SelectedIndex = 0


clst_LocationMinor.DataSource = dsLoc.Tables(0)
clst_LocationMinor.DataValueField = "CodeID"
clst_LocationMinor.DataTextField = "Description"
clst_LocationMinor.DataBind()


lstSelect = New ListItem
lstSelect.Value = 0
lstSelect.Text = "Select One"
clst_LocationMinor.Items.Insert(0, lstSelect)
clst_LocationMinor.SelectedIndex = 0
End If
End Sub
#End Region


#Region "Miscellaneous"
Private Sub GetUnitScoreThreshold()
''''GET VALUES FROM DB
Dim arrScores As New ArrayList
Dim strCellID As String


If (Session("TeamName") <> "") Then
strCellID = CStr(Session("TeamName")).Substring(0, 3)
Else
strCellID = ""
End If


BLProcIns = New ProcessInspection
Try
arrScores =
BLProcIns.GetThresholdScore(Session.Item("ALI#"),
Session.Item("UserRoleID"), strCellID)
hid_CRScore.Value = arrScores(0).ToString()
hid_MAScore.Value = arrScores(1).ToString()
hid_MIScore.Value = arrScores(2).ToString()
hid_CellThreshold.Value = arrScores(3).ToString()
Catch ce As clsCustomException
Dim objErrorLog As clsErrorLog = New clsErrorLog
objErrorLog.LogError("0", ce.CustomMessage,
"InspectionProcess.aspx.vb", DateTime.Today, Session("LoginID"),
Session("UserRoleID"))
Session("CellMessage") = ce.CustomMessage
Response.Redirect("UnitDetails.aspx", False)
End Try


End Sub


Private Sub MakeDataTable()
' Create a DataTable.
dtInsProcess = New DataTable("UnitInspectionProcessDetails")


' Create a DataColumn and set various properties.
Dim colDefectID As DataColumn = New DataColumn
colDefectID.DataType = System.Type.GetType("System.Int32")
colDefectID.AllowDBNull = False
colDefectID.Caption = "DefectID"
colDefectID.ColumnName = "DefectID"


dtInsProcess.Columns.Add(colDefectID)


Dim colDefectTypeID As DataColumn = New DataColumn
colDefectTypeID.DataType = System.Type.GetType("System.Int32")
colDefectTypeID.AllowDBNull = False
colDefectTypeID.Caption = "DefectTypeID"
colDefectTypeID.ColumnName = "DefectTypeID"


dtInsProcess.Columns.Add(colDefectTypeID)


Dim colComponentID As DataColumn = New DataColumn
colComponentID.DataType = System.Type.GetType("System.Int32")
colComponentID.AllowDBNull = True
colComponentID.Caption = "ComponentID"
colComponentID.ColumnName = "ComponentID"


dtInsProcess.Columns.Add(colComponentID)


Dim colLocationID As DataColumn = New DataColumn
colLocationID.DataType = System.Type.GetType("System.Int32")
colLocationID.AllowDBNull = True
colLocationID.Caption = "LocationID"
colLocationID.ColumnName = "LocationID"


dtInsProcess.Columns.Add(colLocationID)


End Sub
Private Sub MakeHistoryDataTable()
' Create a DataTable.
dtInsHistory = New DataTable("UnitInspectionHistories")


' Create a DataColumn and set various properties.
Dim dcCol As DataColumn = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "UnitID"
dcCol.ColumnName = "UnitID"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.Int32")
dcCol.AllowDBNull = False
dcCol.Caption = "InspectionTypeCD"
dcCol.ColumnName = "InspectionTypeCD"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "RoleID"
dcCol.ColumnName = "RoleID"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "Comments"
dcCol.ColumnName = "Comments"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "UnitFixedIND"
dcCol.ColumnName = "UnitFixedIND"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "InspectionScore"
dcCol.ColumnName = "InspectionScore"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "CreatedBy"
dcCol.ColumnName = "CreatedBy"


dtInsHistory.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "CurrentDate"
dcCol.ColumnName = "CurrentDate"


dtInsHistory.Columns.Add(dcCol)


End Sub


Private Sub MakeUnitsDataTable()
' Create a DataTable.
dtUnits = New DataTable("Units")


' Create a DataColumn and set various properties.
Dim dcCol As DataColumn = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "UnitID"
dcCol.ColumnName = "UnitID"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "Style"
dcCol.ColumnName = "Style"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "CoverNo"
dcCol.ColumnName = "CoverNo"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "TeamName"
dcCol.ColumnName = "TeamName"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "FOB"
dcCol.ColumnName = "FOB"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "CellID"
dcCol.ColumnName = "CellID"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "Finishes"
dcCol.ColumnName = "Finishes"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "LayNo"
dcCol.ColumnName = "LayNo"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.Int32")
dcCol.AllowDBNull = True
dcCol.Caption = "InspectionStatusCD"
dcCol.ColumnName = "InspectionStatusCD"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = False
dcCol.Caption = "InspectionDate"
dcCol.ColumnName = "InspectionDate"


dtUnits.Columns.Add(dcCol)


dcCol = New DataColumn
dcCol.DataType = System.Type.GetType("System.String")
dcCol.AllowDBNull = True
dcCol.Caption = "Options"
dcCol.ColumnName = "Options"


dtUnits.Columns.Add(dcCol)


End Sub


' Adds the defect details to the Inspection Process datatable
Public Sub ReadXml(ByVal strXml As String)
Dim drwRow As DataRow
Dim xmlDoc As New System.Xml.XmlDocument
Dim xmlNode As System.Xml.XmlNode
Dim xmlChild As System.Xml.XmlNode


xmlDoc.LoadXml(strXml)


For Each xmlNode In xmlDoc.ChildNodes(0)
For Each xmlChild In xmlNode.ChildNodes
Select Case
xmlChild.Attributes.ItemOf("Status").InnerText
Case "added"
drwRow = dtInsProcess.NewRow()


drwRow("DefectID") =
xmlChild.Attributes.ItemOf("DefectID").InnerText
drwRow("DefectTypeID") =
xmlChild.Attributes.ItemOf("DefectTypeID").InnerText
If
xmlChild.Attributes.ItemOf("LocationID").InnerText <> 0 Then
drwRow("LocationID") =
xmlChild.Attributes.ItemOf("LocationID").InnerText
End If
If
xmlChild.Attributes.ItemOf("ComponentID").InnerText <> 0 Then
drwRow("ComponentID") =
xmlChild.Attributes.ItemOf("ComponentID").InnerText
End If


dtInsProcess.Rows.Add(drwRow)
End Select
Next
Next
End Sub


' Adds the inspection details to the Inspection History datatable
Private Sub SaveInspectionHistory()
Dim drRow As DataRow
Dim intScore As Integer
Dim intInspectionTypeCD As Int32
Dim strComments As String


drRow = dtInsHistory.NewRow()
drRow("UnitID") = Session("ALI#")
drRow("InspectionTypeCD") = Session("InspTypeCode")
drRow("RoleID") = Session.Item("UserRoleID")


drRow("Comments") = ctxt_Comments.Text


If hid_UnitScore.Value <> 100 Then
If hid_UnitScore.Value < hid_CellThreshold.Value Then
If (copt_Fixed.SelectedValue = "0") Then
drRow("UnitFixedIND") = "1"
ElseIf (copt_Fixed.SelectedValue = "1") Then
If Session("UserRoleID") = 3 Or
Session("UserRoleID") = 5 Then
Session("ShowGenerateRMT") = 1
End If
drRow("UnitFixedIND") = "0"
Else
If Session("UserRoleID") = 3 Or
Session("UserRoleID") = 5 Then
Session("ShowGenerateRMT") = 1
End If
drRow("UnitFixedIND") = Nothing
End If
Else
If cchk_Unfixed.Checked = True Then
If Session("UserRoleID") = 3 Or
Session("UserRoleID") = 5 Then
Session("ShowGenerateRMT") = 1
End If
drRow("UnitFixedIND") = "0"
Else
drRow("UnitFixedIND") = Nothing
End If
End If
End If


drRow("InspectionScore") = hid_UnitScore.Value


drRow("CreatedBy") = Session.Item("LoginID")
drRow("CurrentDate") = dtxt_InsDate.Text


dtInsHistory.Rows.Add(drRow)


End Sub


' Adds the Unit Details to the Unit datatable
Private Sub SaveUnitDetails()
Dim drRow As DataRow


' Checkcs if the data has been retrieved from QRS or SFT
If Session("RetrievalSource") = 2 Then
Dim arrUnitDetails As ArrayList = New ArrayList
arrUnitDetails = Session("UnitDetailsFromSFT")


drRow = dtUnits.NewRow()
drRow("UnitID") = Session("ALI#")
drRow("Style") = arrUnitDetails(1)
drRow("CoverNo") = arrUnitDetails(2)
drRow("TeamName") = Session("TeamName")
If arrUnitDetails(3) = "None" Then
drRow("FOB") = ""
Else
drRow("FOB") = arrUnitDetails(3)
End If


drRow("CellID") = CStr(Session("TeamName")).Substring(0, 3)

Dim strFinishes As String = arrUnitDetails(5)
drRow("Finishes") = strFinishes.TrimEnd(" ").TrimEnd(New
Char() {", "})
drRow("LayNo") = arrUnitDetails(4)
drRow("InspectionDate") = dtxt_InsDate.Text


Dim z As Int32 = arrUnitDetails.Count
Dim j As Int32
Dim tempStr As String
If z > 6 Then
For j = 6 To arrUnitDetails.Count - 1
tempStr += CStr(arrUnitDetails.Item(j)) + ","
Next
Else
End If


drRow("Options") = tempStr


dtUnits.Rows.Add(drRow)
Else
drRow = dtUnits.NewRow()


drRow("UnitID") = Session("ALI#")


drRow("TeamName") = lbl_Team.Text
drRow("CellID") = lbl_Team.Text.Substring(0, 3)


drRow("InspectionStatusCD") = Session("InspTypeCode")


drRow("InspectionDate") = dtxt_InsDate.Text


dtUnits.Rows.Add(drRow)
End If
End Sub
#End Region


#Region "Button Events"
Private Sub btn_Finish_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Finish.Click
Dim strXmlCR As String
Dim strXmlMA As String
Dim strXmlMI As String
Dim intReturnValue As Integer
Dim blnFromDB As Boolean


If Session("RetrievalSource") = 1 Then
blnFromDB = True
Else
blnFromDB = False
End If


SaveInspectionHistory()
SaveUnitDetails()


strXmlCR = hid_xmlCR.Value()
strXmlCR = "<xml id='dsoInspectionAttributes'>" & strXmlCR &
"</xml>"
'Getting Critical data into datatable
ReadXml(strXmlCR)


strXmlMA = hid_xmlMA.Value()
strXmlMA = "<xml id='dsoInspectionAttributesMA'>" & strXmlMA &
"</xml>"
'Getting Major data into datatable
ReadXml(strXmlMA)


strXmlMI = hid_xmlMI.Value()
strXmlMI = "<xml id='dsoInspectionAttributesMI'>" & strXmlMI &
"</xml>"
'Getting Minor data into datatable
ReadXml(strXmlMI)


BLProcIns = New ProcessInspection


Dim dsUnits As DataSet = New DataSet("Units")
dsUnits.Tables.Add(dtUnits)


Dim dsUnitHistories As DataSet = New
DataSet("UnitInspectionHistories")
dsUnitHistories.Tables.Add(dtInsHistory)


Dim dsUnitProcessDetails As DataSet = New
DataSet("UnitInspectionProcessDetails")
dsUnitProcessDetails.Tables.Add(dtInsProcess)


Try
intReturnValue =
BLProcIns.SaveInspectionProcessData(Session("UserroleID"), dsUnits,
dsUnitHistories, dsUnitProcessDetails, _
Session("PlantID"), Session("LoginID"), blnFromDB,
Session("ALI#"))


If (intReturnValue > 0) Then
Session("RetrievalSource") = 1
Response.Redirect("UnitDetails.aspx")
End If
Catch ce As clsCustomException
lbl_Error.Text = "Error while updating inspection results"
lbl_Error.Visible = True
lbl_Error.CssClass = "ErrMessage"
End Try
End Sub


Private Sub btn_Cancel_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btn_Cancel.Click
Response.Redirect("WelcomePage.aspx", False)
End Sub
#End Region


End Class


and the class file for this codebehind is,


Imports System.Data
Imports System.Data.SqlClient
Imports QRS.clsDBAccess


Public Class ProcessInspection
Public Function GetALIDetails(ByVal strALI As String, ByVal
intRoleID As Integer) As DataSet
Try
Return
clsDBAccess.ExecuteDataset(QRS.clsConnection.GetConnectionString(intRoleID)­,

"p_GetALIDetails", New SqlParameter("@UnitID", strALI))
Catch ce As clsCustomException
Throw
End Try
End Function


Public Function FillDefectType(ByVal strDefectSeverity As String,
ByVal intRoleID As Integer) As DataSet
Try
Return
clsDBAccess.ExecuteDataset(QRS.clsConnection.GetConnectionString(intRoleID)­,

"p_GetDefectType", New SqlParameter("@DefTypeDesc", strDefectSeverity))

Catch ce As clsCustomException
Throw ce
End Try
End Function


Public Function FillComponent(ByVal intRoleID As Integer) As
DataSet
Try
Return
clsDBAccess.ExecuteDataset(QRS.clsConnection.GetConnectionString(intRoleID)­,

"p_GetComponents")
Catch ce As clsCustomException
Throw ce
End Try
End Function


Public Function FillLocation(ByVal intRoleID As Integer) As DataSet

Try
Return
clsDBAccess.ExecuteDataset(QRS.clsConnection.GetConnectionString(intRoleID)­,

"p_GetUnitLocations")
Catch ce As clsCustomException
Throw ce
End Try
End Function


Public Function GetThresholdScore(ByVal strUnitID As String, ByVal
intUserRoleID As Integer, ByVal strCellID As String) As ArrayList
Dim arrScores As New ArrayList
Dim reader As SqlDataReader
Dim objParameter(1) As SqlParameter
objParameter(0) = New SqlParameter
objParameter(0).ParameterName = "@UnitID"
objParameter(0).SqlDbType = SqlDbType.VarChar
objParameter(0).Value = strUnitID


objParameter(1) = New SqlParameter
objParameter(1).ParameterName = "@CellID"
objParameter(1).SqlDbType = SqlDbType.VarChar
objParameter(1).Value = strCellID


Try
reader =
clsDBAccess.ExecuteReader(QRS.clsConnection.GetConnectionString(intUserRole­ID),

"p_GetThresholdScore", objParameter)
If reader.HasRows Then
While reader.Read()
arrScores.Add(reader.GetValue(0)) ''Critical
Score
arrScores.Add(reader.GetValue(1)) ''Major Score
arrScores.Add(reader.GetValue(2)) ''Minor Score
arrScores.Add(reader.GetValue(3))
''ThresholdScore
End While
End If
Return arrScores
Catch ce As clsCustomException
Throw ce
End Try
End Function


Public Function SaveInspectionProcessData(ByVal intUserRoleID As
Integer, ByVal dsUnits As DataSet, ByVal dsHistories As DataSet, ByVal
dsDetails As DataSet, _
ByVal strPlantID As String, ByVal strLoginID As String, ByVal
blnFromDB As Boolean, ByVal strUnitID As String) As Integer


Dim dtUnits As DataTable = dsUnits.Tables("Units")
Dim dtHistories As DataTable =
dsHistories.Tables("UnitInspectionHistories")
Dim dtDetails As DataTable =
dsDetails.Tables("UnitInspectionProcessDetails")


Dim sbUnits As System.Text.StringBuilder = New
System.Text.StringBuilder(1000)
Dim sbHistories As System.Text.StringBuilder = New
System.Text.StringBuilder(1000)
Dim sbDetails As System.Text.StringBuilder = New
System.Text.StringBuilder(1000)


Dim swUnits As System.IO.StringWriter = New
System.IO.StringWriter(sbUnits)
Dim swHistories As System.IO.StringWriter = New
System.IO.StringWriter(sbHistories)
Dim swDetails As System.IO.StringWriter = New
System.IO.StringWriter(sbDetails)


Dim col As DataColumn


For Each col In dtUnits.Columns
col.ColumnMapping = System.Data.MappingType.Attribute
Next


For Each col In dtHistories.Columns
col.ColumnMapping = System.Data.MappingType.Attribute
Next


For Each col In dtDetails.Columns
col.ColumnMapping = System.Data.MappingType.Attribute
Next


dsUnits.WriteXml(swUnits, System.Data.XmlWriteMode.WriteSchema)

dsHistories.WriteXml(swHistories,
System.Data.XmlWriteMode.WriteSchema)
dsDetails.WriteXml(swDetails,
System.Data.XmlWriteMode.WriteSchema)


'Please refer to p_InsertInspectionProcessData procedure for
the Inspection Score, threshold, User role and
'inspection Process parameter business rules.


Dim strSpName As String = "p_InsertInspectionProcessData"


Dim objParameter(6) As SqlParameter
objParameter(0) = New SqlParameter("@InspectionData",
System.Data.SqlDbType.NText)
objParameter(0).Value = sbUnits.ToString()
objParameter(1) = New SqlParameter("@InsertHistory",
System.Data.SqlDbType.NText)
objParameter(1).Value = sbHistories.ToString()
objParameter(2) = New SqlParameter("@DetailData",
System.Data.SqlDbType.NText)
objParameter(2).Value = sbDetails.ToString()
objParameter(3) = New SqlParameter("@PlantID",
System.Data.SqlDbType.VarChar)
objParameter(3).Value = strPlantID
objParameter(4) = New SqlParameter("@LoginID",
System.Data.SqlDbType.VarChar)
objParameter(4).Value = strLoginID
objParameter(5) = New SqlParameter("@FromDB",
System.Data.SqlDbType.Bit)
objParameter(5).Value = blnFromDB
objParameter(6) = New SqlParameter("@UnitID",
System.Data.SqlDbType.VarChar)
objParameter(6).Value = strUnitID


Try
Dim intReturn As Integer =
clsDBAccess.ExecuteScalar(clsConnection.GetConnectionString(intUserRoleID),

strSpName, objParameter)
Return intReturn
Catch ce As clsCustomException
Dim objErrorLog As clsErrorLog = New clsErrorLog
objErrorLog.LogError(0, ce.CustomMessage,
"clsProcessInspection.vb", DateTime.Today.ToShortDateString(),
strLoginID, intUserRoleID)
Throw ce
End Try
End Function
End Class


Thanks in Advanc


SK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top