If lblHeaderBottomBatchStatus.Text = "QA" Then
foundstatus = "Posted"
nextstatus = "Completed"
End If
Dim item1 As Integer = 0
Dim item2 As Integer = 0
For i As Integer = 0 To dt.Rows.Count - 1
If foundstatus = "" Then
If dt.Rows(i).Item(1).ToString = lblHeaderBottomBatchStatus.Text Then
foundstatus = dt.Rows(i).Item(1).ToString
If item1 = 0 Then
item1 = i
End If
If foundstatus = dt.Rows(dt.Rows.Count - 1).Item(1).ToString Then
nextstatus = foundstatus
item2 = dt.Rows.Count
Exit For
End If
End If
Else
If dt.Rows(i).Item(1).ToString <> foundstatus Then
If nextstatus = "" Then
nextstatus = dt.Rows(i).Item(1).ToString
If nextstatus <> foundstatus Then
item2 = i
End If
End If
Else
item2 = dt.Rows.Count
End If
End If
Next
For i As Integer = item1 To item2 - 1
If dt.Rows(i).Item(0).ToString <> "CPUBatchNumber" Then
If dt.Rows(i).Item(0).ToString <> "AttachedImages" Then
Dim tb As TextBox = FindControl("txt" & dt.Rows(i).Item(0).ToString)
If tb.Text = "" Then
allfieldscompleted = False
End If
ElseIf dt.Rows(i).Item(0).ToString = "AttachedImages" Then
If cbAttachedImages.Checked = False And txtNumberOfImagesAttached.Text = "" Then
allfieldscompleted = False
End If
End If
End If
Next
For i As Integer = 0 To dt.Rows.Count - 1
If dt.Rows(i).Item(0).ToString <> "CPUBatchNumber" Then
Dim currfield As TextBox = FindControl("txt" & dt.Rows(i).Item(0).ToString)
If currfield.Text <> "" Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, currfield.ID.ToString.Remove(0, 3), currfield.Text)
End If
End If
Next
If allfieldscompleted = False Then
If lblBatchStatus.Text = "QA" Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "WorkFlowStatus", "QA")
updatedbatcharray.Clear()
updatedbatcharray.Add(lblBatchID.Text)
updatedbatcharray.Add(lblUserID.Text)
updatedbatcharray.Add("WorkFlowStatus")
updatedbatcharray.Add("QA")
updatedbatcharray.Add("")
SQLInserts.RunInsertWithParams("V2InsertBatchTrack ingLog", "CMBSConnectionString", SQLParams.GetParameters("V2InsertBatchTrackingLog" , "CMBSConnectionString"), updatedbatcharray)
End If
Exit Sub
Else
If lblBatchStatus.Text <> "Completed" Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "LastStatusChange", Date.Now)
If nextstatus = dt.Rows(dt.Rows.Count - 1).Item(1).ToString And item2 = dt.Rows.Count Then
nextstatus = "Completed"
updatedbatcharray.Add(nextstatus)
Else
updatedbatcharray.Add(nextstatus)
End If
If nextstatus = "Completed" Then
Dim skipdatasets As DataTable = SQLSelects.GetDataTable("V2SelectERADatasetsToPost ByCheck", "CMBSConnectionString")
Dim skipdsarray As New ArrayList
For i As Integer = 0 To skipdatasets.Rows.Count - 1
skipdsarray.Add(skipdatasets.Rows(i).Item(0).ToStr ing)
Next
If skipdsarray.Contains(lblDataset.Text) And lblHeaderBottomBatchType.Text = "ERA" Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "ScanTo", "CMBS / CPR")
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "QABy", lblUserID.Text)
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "QAByDate", Date.Now)
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "PostedBy", lblUserID.Text)
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "PostedByDate", Date.Now)
If lblMatchedV.Text = "Yes" Or txtCMBSBatchTotal.Text = "0.00" Or cbPostDateOverride.Checked = True Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "WorkFlowStatus", "Completed")
Response.Redirect("Batch.aspx")
Else
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "WorkFlowStatus", "Posted")
Dim fullURL As String = "alert('All batch requirements not met to close. Please do not close in CPU. Batch sent to post.');"
ScriptManager.RegisterStartupScript(Me, GetType(String), "", fullURL, True)
Exit Sub
End If
End If
Dim disallowendofmonthdt As DataTable = SQLSelects.GetDataTableWithParam("V2SelectEndOfMon thByDataset", CS, "@Dataset", lblDataset.Text)
Dim endofmonth As DateTime
If disallowendofmonthdt.Rows.Count > 0 Then
endofmonth = disallowendofmonthdt.Rows(0)("EndOfMonth").ToStrin g()
Else
endofmonth = Date.Now
End If
Else
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "WorkFlowStatus", nextstatus)
End If
Dim lfstatus As String = "New"
Select Case nextstatus
Case "Posted"
lfstatus = "Scanned"
Case "Completed"
lfstatus = "Complete"
If lblBatchStatus.Text = "QA" Then
Dim disallowdt As DataTable = SQLSelects.GetDataTable("V2SelectBatchTrackingDisc repancyDisallowBatchCloseReason", CS)
Dim disallowarray As New ArrayList
For d As Integer = 0 To disallowdt.Rows.Count - 1
disallowarray.Add(disallowdt.Rows(d).Item("Reason" ).ToString)
Next
Dim dv As DataView = V2SelectBatchTrackingDiscrepanciesByBatchID.Select (DataSourceSelectArguments.Empty)
For Each row As DataRow In dv.Table.Rows
Dim cb As Boolean = row("Resolved")
If cb = False Then
If disallowarray.Contains(row("Reason")) Then
If lblBatchStatus.Text = "QA" Then
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "WorkFlowStatus", "QA")
updatedbatcharray.Clear()
updatedbatcharray.Add(lblBatchID.Text)
updatedbatcharray.Add(lblUserID.Text)
updatedbatcharray.Add("WorkFlowStatus")
updatedbatcharray.Add("QA")
updatedbatcharray.Add("")
SQLInserts.RunInsertWithParams("V2InsertBatchTrack ingLog", "CMBSConnectionString", SQLParams.GetParameters("V2InsertBatchTrackingLog" , "CMBSConnectionString"), updatedbatcharray)
End If
SQLUpdates.RunUpdateWithParam("V2UpdateBatchTracki ngBatchFromPosted", CS, "@BatchID", lblBatchID.Text)
Dim fullURL As String = "alert('All batch requirements not met to close. Please validate all discrepancies are resolved.');"
ScriptManager.RegisterStartupScript(Me, GetType(String), "", fullURL, True)
Response.Redirect("Batch.aspx")
End If
End If
Next
Dim discHT As Hashtable = bt.GetBatchDiscrepancyTotalsBatchId(lblBatchID.Tex t)
End If
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "PostedBy", lblUserID.Text)
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "PostedByDate", Date.Now)
End Select
If lfstatus <> "New" And lblHeaderBottomBatchType.Text <> "ERA" Then
Dim LFNS As DataTable = _
SQLSelects.GetDataTableWithParam("V2SelectLaserfic heRepositoryByDataset", _
"CMBSConnectionString", "@Dataset", _
lblHeaderBottomBatchNumber.Text.Substring(0, 3))
LF.UpdateTemplateV2(LFNS.Rows(0).Item("Application ServerName").ToString, _
LFNS.Rows(0).Item("RepositoryName").ToString, _
lblLaserficheTocId.Text, lfstatus)
End If
End If
End If
If (nextstatus = "Posted" And lblScanTo.Text = "LAPIZ") Or _
(nextstatus = "Posted" And lblScanTo.Text = "TEK HEALTH") Then
'-------------------------------------------------------
'------------------UPDATE InDepartment to ScanTo--------
bt.UpdateBatchFieldByBatchIdEntryFieldAndValue(lbl BatchID.Text, "InDepartment", lblScanTo.Text)
updatedbatcharray.Clear()
updatedbatcharray.Add(lblBatchID.Text)
updatedbatcharray.Add(lblUserID.Text)
updatedbatcharray.Add("ScanTo")
updatedbatcharray.Add(lblScanTo.Text)
updatedbatcharray.Add("")
SQLInserts.RunInsertWithParams("V2InsertBatchTrack ingLog", "CMBSConnectionString", SQLParams.GetParameters("V2InsertBatchTrackingLog" , "CMBSConnectionString"), updatedbatcharray)
End If
If nextstatus <> "Completed" Then
Dim paramsval As New ArrayList
paramsval.Add(lblUserID.Text) ' UserId
paramsval.Add(nextstatus) ' WFS
paramsval.Add(lblHeaderBottomBatchType.Text) ' BatchType
paramsval.Add(lblHeaderBottomBatchNumber.Text.ToSt ring.Substring(0, 3)) ' Dataset
Dim nextstepview As Integer = SQLSelects.GetStringResultWithParams("V2BatchTrack ingAllowNextStep", CS, SQLParams.GetParameters("V2BatchTrackingAllowNextS tep", CS), paramsval)
updatedbatcharray.Clear()
updatedbatcharray.Add(nextstatus)
updatedbatcharray.Add(lblHeaderBottomBatchType.Tex t)
updatedbatcharray.Add(lblBatchID.Text)
SQLUpdates.RunUpdateWithParams("V2UpdateBatchTrack ingInDepartment", CS, SQLParams.GetParameters("V2UpdateBatchTrackingInDe partment", CS), updatedbatcharray)
If nextstepview = 0 Then
bt.UpdateBatchInUseByBatchIDAndUser(lblBatchID.Tex t, "", "Out")
Response.Redirect(Request.Url.ToString)
End If
End If
Bookmarks