Option Strict Off
Option Explicit On
Friend Class frmCadUniProcessos
	Inherits System.Windows.Forms.Form
	Private iFrmQuemChama As System.Windows.Forms.Form
	Private ifrmLocalizar As frmLocalizadorGeral
	Private iblnNovo As Boolean
	Private istrTabela As String
	Private istrPriKey() As String
	Private istrForKey() As String
	Private irstTabela As DataTable

	'Private irstTabela As ADODB.Recordset
	'Private iTextBox() As clsCtrlEventos

	Private Sub cmdExcluir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExcluir.Click
		Try
			Call ctrl_form_ExcluirRegistros(Me, istrTabela, istrPriKey)
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: cmdExcluir_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub
	Private Sub cmdFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFechar.Click
		Call Me.Close()
	End Sub

	Private Sub cmdLocalizar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizar.Click
		Try
			Call frmLocalizadorGeral.Show()
			Call frmLocalizadorGeral.SetParametros(istrTabela, Me.Text, Me)
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: cmdLocalizar_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Private Sub cmdNovo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNovo.Click
		Try
			iblnNovo = True
			Call ctrl_form_LimpaCamposPadrao(Me)
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: cmdNovo_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Private Sub cmdSalvar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSalvar.Click
		Try
			Call ctrl_form_SalvarRegistro(Me, istrTabela, istrPriKey, irstTabela, iblnNovo)
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: cmdSalvar_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Private Sub frmCadUniProcessos_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim vControl As System.Windows.Forms.Control
		Dim lstrKeyPri As String
		Dim lintAux As Short
		Try
			'Call CenterFormQuemChama(Me, iFrmQuemChama)
			istrTabela = "caduni_processos"
			irstTabela = New DataTable
			'ifrmLocalizar = New frmLocalizadorGeralNovo
			Call ctrl_form_LimpaCamposPadrao(Me)
			istrPriKey = ctrl_form_GetChavesKeyTable(istrTabela, "PRIMARY")
			istrForKey = ctrl_form_GetChavesKeyTable(istrTabela, "FOREIGN")
			lstrKeyPri = ctrl_form_MontaPrimaryKeyTable(Me, istrPriKey)
			'Call SetaCodigo(istrTabela, lstrKeyPri)
			'Inicializa a classe de eventos dos objetos TextBox
			lintAux = 0
			'For Each vControl In Me.Controls
			'	'UPGRADE_WARNING: TypeOf has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
			'	If TypeOf vControl Is System.Windows.Forms.TextBox Then
			'		'ReDim Preserve iTextBox(lintAux)
			'		'iTextBox(lintAux) = New clsCtrlEventos
			'		'iTextBox(lintAux).TextBox = vControl
			'		'lintAux = lintAux + 1
			'	End If
			'Next vControl
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: frmCadUniProcessos_Load" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub
	
	Private Sub frmCadUniProcessos_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		Try
			Call ctrl_form_FormKeyPress(Me, KeyAscii)
			eventArgs.KeyChar = Chr(KeyAscii)
			If KeyAscii = 0 Then
				eventArgs.Handled = True
			End If
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: frmCadUniProcessos_KeyPress" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Private Sub frmCadUniProcessos_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		Try
			If Not iFrmQuemChama Is Nothing Then iFrmQuemChama.Enabled = True
			iFrmQuemChama = Nothing
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: frmCadUniProcessos_FormClosed" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Public Sub SetaCodigo(ByVal astrTabela As String, ByRef astrPriKey As String)
		Dim lstrKeyPri As String
		Try
			iblnNovo = False
			txtId.Text = astrPriKey
			lstrKeyPri = ctrl_form_MontaPrimaryKeyTable(Me, istrPriKey)
			Call ctrl_form_SetaCodigo(Me, astrTabela, istrTabela, lstrKeyPri, irstTabela)
			'Call ctrl_form_SetaCodigo(Me, astrTabela, istrTabela, astrPriKey, irstTabela)
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: SetaCodigo" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub

	Public Sub SetaParametros(ByRef afrmQuemChama As System.Windows.Forms.Form)
		Try
			iFrmQuemChama = afrmQuemChama
			iFrmQuemChama.Enabled = False
		Catch ex As Exception
			MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: SetaParametros" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
			Exit Sub
		End Try
	End Sub
End Class