this module allow user to select project for different client then automatic queued the available batchname or. The system not allowed to issue same batchname on same user in task code:
• E1 - (entry 1)
• E2 - (entry 2)
• CO - (compare)
• QC - (QC Sampling)
Option Explicit On
Public Class
frmProjectSelection
Private Sub frmProjectSelection_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
gsProjectName = ""
getLoadClientID()
If gsTask = "QC" Then
Me.Height = 210
btnOk.Top = 125
btnCancel.Top = 125
Label3.Visible = True
tbPercent.Visible = True
Label4.Visible = True
End If
End Sub
Private Sub cbClient_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cbClient.SelectedIndexChanged
getLoadClientName()
getLoadProjectName()
Me.Text = gsLabel
cbBatchCode.Items.Clear()
End Sub
Private Sub getLoadClientID()
gsSQL = "SELECT cl1_id FROM clients_1 ORDER BY cl1_id"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
cbClient.Items.Clear()
Do While reader.Read
With cbClient
.Items.Add(reader(0).ToString)
End With
Loop
End Sub
Private Sub getLoadClientName()
gsSQL = "SELECT cl1_id, cl1_name FROM clients_1 WHERE cl1_id = '" & cbClient.Text & "'"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
Do While reader.Read
lbClientName.Text = reader(1).ToString
Loop
End Sub
Private Sub getLoadProjectName()
gsSQL = "SELECT pr1_name FROM project_1 WHERE cl1_id = '" & cbClient.Text & "' ORDER BY pr1_name"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
cbProjectName.Items.Clear()
Do While reader.Read
With cbProjectName
.Items.Add(reader(0).ToString)
End With
Loop
End Sub
Private Sub getProjectID1()
gsSQL = "SELECT cl2_id, pr1_id,pr1_name FROM project_1 WHERE pr1_name = '" & cbProjectName.Text & "'"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
Do While reader.Read
gsClient2 = reader(0).ToString
gsProject1 = reader(1).ToString
Loop
End Sub
Private Sub getProjectID2()
gsSQL = "SELECT pr2_bcode FROM project_2 WHERE cl1_id = '" & _
cbClient.Text & "' AND cl2_id = '" & gsClient2 & "' & _
AND pr1_id = '" & gsProject1 & "' ORDER BY pr2_bcode"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
cbBatchCode.Items.Clear()
Do While reader.Read
With cbBatchCode
.Items.Add(reader(0).ToString)
End With
Loop
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub cbProjectName_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cbProjectName.SelectedIndexChanged
getProjectID1()
getProjectID2()
Me.Text = gsLabel
End Sub
Private Sub cbBatchCode_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles
cbBatchCode.SelectedIndexChanged
Call getLoadBatchName()
End Sub
Private Sub btnOk_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnOk.Click
Dim dbSchema As String
If isEmpty(cbClient.Text, "Client Code") = True Then
cbClient.Focus()
Exit Sub
ElseIf isEmpty(cbProjectName.Text, "Project Name") = True Then
cbProjectName.Focus()
Exit Sub
ElseIf isEmpty(cbBatchCode.Text, "Batch Code") = True Then
cbBatchCode.Focus()
Exit Sub
Else
If gsTask = "QC" Then
If isEmpty(tbPercent.Text, "QC Percent") = True Then
tbPercent.Focus()
Exit Sub
End If
End If
End If
gsImageLocation = ImageServerLocation(cbBatchCode.Text)
gsProjectName = ProjectCode(cbProjectName.Text)
Select Case gsProjectName
Case "FACL1900" '"FA CL 1900"
dbSchema = "RES-1900"
Case "FACLADC" '"FA CL ADC"
dbSchema = "RES-ADC"
Case "FACLFM" '"FA CL Foreclosure / Mapping"
dbSchema = "RES-MAP"
Case "FACLEF" '"FA CL EFX"
dbSchema = "RES-EFX"
Case Else
gsProjectName = ""
MessageBox.Show(cbProjectName.Text & " is not available on this batching program.", _
"Batching", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit Sub
End Select
If isProjectTaskAllowed(gsUser, cbClient.Text, gsTask) = False Then
MessageBox.Show("Checked """ & gsUser & """ - Task Properties." & _
vbCrLf & "Asked the System Administrator regarding this error.", _
"S2xDE Software", MessageBoxButtons.OK, MessageBoxIcon.Information)
gsProjectName = ""
Exit Sub
End If
If gsTask = "QC" Then giPercent = tbPercent.Text
gsBatchCode = cbBatchCode.Text
If isPending(gsUser) = False Then
gsDatabase = "RES-TRACKING"
Select Case gsTask
Case "E1", "E2" '//-ENTRY-1 & ENTRY-2
gsSQL = "SELECT DISTINCT batch_hdr.ba_no " & _
"FROM batch_hdr INNER JOIN " & _
" monitoring ON batch_hdr.pr2_bcode = '" & cbBatchCode.Text & "' " & _
"WHERE (EXISTS " & _
" (SELECT ba_no " & _
"FROM monitoring " & _
"WHERE tk1_id = 'BA' AND NOT EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring WHERE " & gsSQL2 & _
" AND batch_hdr.Ba_No = monitoring.Ba_No))) " & _
"ORDER BY batch_hdr.ba_no"
Case "CO" '//-COMPARE
gsSQL = "SELECT DISTINCT batch_hdr.ba_no " & _
"FROM batch_hdr INNER JOIN " & _
" monitoring ON batch_hdr.pr2_bcode = '" & cbBatchCode.Text & "' " & _
"WHERE (EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'E1' AND monitoring.user_id <> '" & gsUser & "' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'E2' AND monitoring.user_id <> '" & gsUser & "' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'CO' AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT pending.ba_no FROM pending " & _
" WHERE pending.ba_no = batch_hdr.ba_no)) " & _
"ORDER BY batch_hdr.ba_no"
Case "RE" '//-RESEARCH
gsSQL = "SELECT DISTINCT batch_hdr.ba_no " & _
"FROM batch_hdr INNER JOIN " & _
" monitoring ON batch_hdr.pr2_bcode = '" & cbBatchCode.Text & "' " & _
"WHERE (EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'CO' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'RE' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT pending.ba_no FROM pending " & _
" WHERE pending.ba_no = batch_hdr.ba_no)) " & _
"ORDER BY batch_hdr.ba_no"
Case "QC" '//-QC SAMPLING
gsSQL = "SELECT DISTINCT batch_hdr.ba_no " & _
"FROM batch_hdr INNER JOIN " & _
" monitoring ON batch_hdr.pr2_bcode = '" & cbBatchCode.Text & "' " & _
"WHERE (EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'E1' AND monitoring.user_id <> '" & gsUser & "' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'E2' AND monitoring.user_id <> '" & gsUser & "' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'CO' AND monitoring.user_id <> '" & gsUser & "' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'RE' " & _
" AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT monitoring.ba_no FROM monitoring " & _
" WHERE monitoring.tk1_id = 'QC' AND monitoring.ba_no = batch_hdr.ba_no) " & _
" AND NOT EXISTS " & _
" (SELECT pending.ba_no FROM pending " & _
" WHERE pending.ba_no = batch_hdr.ba_no)) " & _
"ORDER BY batch_hdr.ba_no"
End Select
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.ConnProcess & _
gsDatabase, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
If oTable.Rows.Count <= 0 Then
gsProjectName = ""
MessageBox.Show("No available Batch for Task ID = """ & _
gsTask & """.", "S2xDE", MessageBoxButtons.OK, MessageBoxIcon.Information)
Exit Sub
Else
Do While reader.Read
gsBatchNo = reader(0).ToString()
gbPending = False
Exit Do
Loop
End If
'Add to Pending table
AddBatchPending(gsUser, gsBatchNo, gsTask, cbProjectName.Text)
'Add to Monitoring table
AddMonitoring(gsBatchNo, gsTask, gsUser, ServerDateTime)
TaskHeader(gsBatchNo, gsUser, ServerDateTime, gsTask & "_hdr", dbSchema)
Else
Dim iResponse As Int16
If gsTask = "ED" Or gsTask = "CV" Then
MessageBox.Show("Pending Job for """ & gsTask & _
""" Task." & vbCrLf & "Remove Batches in the Processing listbox to Finished," & _
vbCrLf & "before we continue another Task.", "Pending Task", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
gsProjectName = ""
Else
iResponse = MessageBox.Show("Pending Job for """ & gsTask & _
""" Task, Batch No. """ & gsBatchNo & """... Append [Y/N]?", _
"Confirm: " & gsLabel, MessageBoxButtons.YesNo, MessageBoxIcon.Information)
If iResponse = 6 Then
gbPending = True
Else
gsProjectName = ""
End If
End If
End If
Me.Close()
End Sub
Private Sub tbPercent_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbPercent.KeyPress
e.KeyChar = ChrW(modKeys.Keyed(AscW(e.KeyChar), EnumCharType.vbNumericOnly, EnumKeyExec.vbEnterBackSpace))
Select Case AscW(e.KeyChar)
Case System.Windows.Forms.Keys.Return
AutoTab()
End Select
End Sub
Private Sub getLoadBatchName()
gsSQL = "SELECT cl1_id, pr2_bcode,pr2_name FROM project_2 WHERE cl1_id = '" & _
cbClient.Text & "' AND pr2_bcode = '" & cbBatchCode.Text & "'"
Dim oTable As DataTable = clsDbConnection.ExecuteTable(clsDbConnection.CONSTRING, CommandType.Text, gsSQL)
Dim reader As New DataTableReader(oTable)
reader.Read()
Me.Text = gsLabel & " -> " & reader(2).ToString
reader.Close()
oTable = Nothing
End Sub
End Class
FREE PDF BOOK DOWNLOAD