Option Strict Off
Option Explicit On
Friend Class frmCadUniProcessos
	Inherits System.Windows.Forms.Form
	Private iFrmQuemChama As System.Windows.Forms.Form
	Private ifrmLocalizar As frmLocalizadorGeralNovo
	Private iblnNovo As Boolean
	Private istrTabela As String
	Private istrPriKey() As String
	Private istrForKey() As String
	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
		Call mdlControleForms.ctrl_form_ExcluirRegistros(Me, istrTabela, istrPriKey)
	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
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros(istrTabela, Me.Text, Me)
	End Sub
	
	Private Sub cmdNovo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNovo.Click
		iblnNovo = True
		Call mdlControleForms.ctrl_form_LimpaCamposPadrao(Me)
	End Sub
	
	Private Sub cmdSalvar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSalvar.Click
		Call mdlControleForms.ctrl_form_SalvarRegistro(Me, istrTabela, istrPriKey, irstTabela, iblnNovo)
	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
		Call CenterFormQuemChama(Me, iFrmQuemChama)
		istrTabela = "caduni_processos"
		irstTabela = New ADODB.Recordset
		ifrmLocalizar = New frmLocalizadorGeralNovo
		Call mdlControleForms.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
	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)
		Call mdlControleForms.ctrl_form_FormKeyPress(Me, KeyAscii)
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmCadUniProcessos_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		If Not iFrmQuemChama Is Nothing Then iFrmQuemChama.Enabled = True
		'UPGRADE_NOTE: Object iFrmQuemChama may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		iFrmQuemChama = Nothing
		'UPGRADE_NOTE: Object ifrmLocalizar may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		ifrmLocalizar = Nothing
		'UPGRADE_NOTE: Object irstTabela may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		irstTabela = Nothing
	End Sub
	
	Public Sub SetaCodigo(ByVal astrTabela As String, ByRef astrPriKey As String)
		Call mdlControleForms.ctrl_form_SetaCodigo(Me, astrTabela, istrTabela, astrPriKey, irstTabela)
	End Sub
	
	Public Sub SetaParametros(ByRef afrmQuemChama As System.Windows.Forms.Form)
		iFrmQuemChama = afrmQuemChama
		iFrmQuemChama.Enabled = False
	End Sub
End Class