Option Strict Off
Option Explicit On
Friend Class frmCadTransformador
	Inherits System.Windows.Forms.Form
	Private ifrmQuemChama As System.Windows.Forms.Form
	Private ifrmLocalizar As frmLocalizadorGeral
	Private iblnNovo As Boolean
	
	Private Sub cmdExcluir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExcluir.Click
		If Trim(Me.txtId.Text) <> "0" Then
			If MsgBox("Deseja realmente excluir este registro!", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, gstrTituloMensagem) = MsgBoxResult.Yes Then
				If Executar("DELETE FROM `transformador` WHERE `transformador`.`id` = " & CInt(Me.txtId.Text)) Then
					Call Executar("OPTIMIZE TABLE `transformador`")
					Call LimpaCampos()
					Call MsgBox("Registro eliminado!", MsgBoxStyle.Information, gstrTituloMensagem)
				Else
					If MsgBox("Deseja desativar este registro!", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, gstrTituloMensagem) = MsgBoxResult.Yes Then
						Call Executar("UPDATE `transformador` SET `situacao` = 'Inativo' WHERE `transformador`.`id` = " & CInt(Me.txtId.Text))
						Call SetaCodigo("transformador", CInt(Me.txtId.Text))
					End If
				End If
			End If
		End If
	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("vwtransformador", "Transformador", Me)
	End Sub
	
	Private Sub cmdLocalizarTransformadorTipoUnidade_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarTransformadorTipoUnidade.Click
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("transformador_tipo_unidade", "Tipo da Unidade", Me)
	End Sub
	
	Private Sub cmdLocalizarTransformadorTipoPosto_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarTransformadorTipoPosto.Click
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("transformador_tipo_posto", "Tipo Posto", Me)
	End Sub
	
	Private Sub cmdLocalizarProprietario_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarProprietario.Click
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("proprietario", "Proprietário", Me)
	End Sub
	
	Private Sub cmdLocalizarAlimentador_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarAlimentador.Click
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("alimentador", "Alimentador", Me)
	End Sub
	
	Private Sub cmdLocalizarSituacao_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarSituacao.Click
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("situacao", "Situação", Me)
	End Sub
	
	Private Sub cmdNovo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNovo.Click
		iblnNovo = True
		Call LimpaCampos()
	End Sub
	
	Private Sub cmdSalvar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSalvar.Click
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		lstrSql = ""
		If Me.txtId.Text = "0" Or iblnNovo Then
			lstrSql = lstrSql & "INSERT INTO " & vbCrLf
		Else
			lstrSql = lstrSql & "UPDATE " & vbCrLf
		End If
		lstrSql = lstrSql & "       `transformador` SET "
		lstrSql = lstrSql & "       `descricao`                    = """ & Trim(Me.txtDescricao.Text) & """, " & vbCrLf
		lstrSql = lstrSql & "       `idtransformador_tipo_unidade` = " & CInt(Me.txtIdTransformadorTipoUnidade.Text) & ", " & vbCrLf
		lstrSql = lstrSql & "       `idtransformador_tipo_posto`   = " & CInt(Me.txtIdTransformadorTipoPosto.Text) & ", " & vbCrLf
		lstrSql = lstrSql & "       `idproprietario`               = " & CInt(Me.txtIdProprietario.Text) & ", " & vbCrLf
		lstrSql = lstrSql & "       `idsituacao`                   = " & CInt(Me.txtIdSituacao.Text) & ", " & vbCrLf
		lstrSql = lstrSql & "       `idalimentador`                = " & CInt(Me.txtIdAlimentador.Text) & " " & vbCrLf
		lstrSql = lstrSql & "       `situacao`   = 'Ativo', " & vbCrLf
		lstrSql = lstrSql & "       `idusuarios` = " & glngUsuario_Id & " "
		If Not iblnNovo And Me.txtId.Text <> "0" Then
			lstrSql = lstrSql & " WHERE `transformador`.`id` = " & CInt(Me.txtId.Text)
		End If
		If Executar(lstrSql) Then
			If Me.txtId.Text = "0" Or iblnNovo Then
				Call Conectar("SELECT LAST_INSERT_ID() ", lrstAux)
				With lrstAux
					If .State = ADODB.ObjectStateEnum.adStateOpen Then
						If .RecordCount > 0 Then
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtId.Text = CStr(CInt(IIf(IsDbNull(.Fields(0).value), 0, .Fields(0).value)))
						End If
						Call .Close()
					End If
				End With
			End If
			Call SetaCodigo("transformador", CInt(Me.txtId.Text))
			Call MsgBox("As informações foram salvas com sucesso.", MsgBoxStyle.Information, gstrTituloMensagem)
		Else
			Call MsgBox("Problema na gravação, favor verificar!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
		End If
		'UPGRADE_NOTE: Object lrstAux 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"'
		lrstAux = Nothing
	End Sub
	
	Private Sub frmCadTransformador_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Call CenterForm(Me)
		ifrmLocalizar = New frmLocalizadorGeral
		Call LimpaCampos()
	End Sub
	
	Private Sub frmCadTransformador_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Escape Then
			Call cmdFechar_Click(cmdFechar, New System.EventArgs())
		ElseIf KeyAscii = System.Windows.Forms.Keys.Return Then 
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmCadTransformador_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		If ifrmQuemChama Is Nothing Then
			'
		Else
			ifrmQuemChama.Enabled = True
		End If
	End Sub
	
	Public Sub SetaCodigo(ByVal astrTabela As String, ByVal alngId_A As Integer, Optional ByVal alngId_B As Integer = 0, Optional ByVal alngId_C As Integer = 0, Optional ByVal alngId_D As Integer = 0)
		Dim lintDig As Short
		Dim lintAux As Short
		Dim lstrAux As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		If ValidaView(astrTabela) Then
			astrTabela = Mid(astrTabela, 3)
		End If
		If alngId_A > 0 Then
			lstrAux = ""
			lstrSql = ""
			lstrSql = lstrSql & "SELECT * " & vbCrLf
			lstrSql = lstrSql & "  FROM `" & astrTabela & "` " & vbCrLf
			lstrSql = lstrSql & " WHERE `id` = " & alngId_A
			Call Conectar(lstrSql, lrstAux)
			With lrstAux
				If .State = ADODB.ObjectStateEnum.adStateOpen Then
					If .RecordCount > 0 Then
						If LCase(Mid(Me.txtIdTransformadorTipoUnidade.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdTransformadorTipoUnidade.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDsTransformadorTipoUnidade.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
						ElseIf LCase(Mid(Me.txtIdTransformadorTipoPosto.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdTransformadorTipoPosto.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDsTransformadorTipoPosto.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
						ElseIf LCase(Mid(Me.txtIdProprietario.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdProprietario.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDsProprietario.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
						ElseIf LCase(Mid(Me.txtIdAlimentador.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdAlimentador.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDsAlimentador.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
						ElseIf LCase(Mid(Me.txtIdSituacao.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdSituacao.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDsSituacao.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
						Else
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtId.Text = FormatNumber(CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), 0)
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtDescricao.Text = Trim(IIf(IsDbNull(.Fields("descricao").value), "", .Fields("descricao").value))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdTransformadorTipoUnidade.Text = CStr(CInt(IIf(IsDbNull(.Fields("idtransformador_tipo_unidade").value), 0, .Fields("idtransformador_tipo_unidade").value)))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdTransformadorTipoPosto.Text = CStr(CInt(IIf(IsDbNull(.Fields("idtransformador_tipo_posto").value), 0, .Fields("idtransformador_tipo_posto").value)))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdProprietario.Text = CStr(CInt(IIf(IsDbNull(.Fields("idproprietario").value), 0, .Fields("idproprietario").value)))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdSituacao.Text = CStr(CInt(IIf(IsDbNull(.Fields("idsituacao").value), 0, .Fields("idsituacao").value)))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.txtIdAlimentador.Text = CStr(CInt(IIf(IsDbNull(.Fields("idalimentador").value), 0, .Fields("idalimentador").value)))
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							Me.lblSituacao.Text = "Situação: " & Trim(IIf(IsDbNull(.Fields("situacao").value), "Ativo", .Fields("situacao").value)) & "  -  último acesso: " & BuscaNomeUsuario(CInt(IIf(IsDbNull(.Fields("idusuarios").value), 0, .Fields("idusuarios").value)))
							Call txtIdTransformadorTipoUnidade_Leave(txtIdTransformadorTipoUnidade, New System.EventArgs())
							Call txtIdTransformadorTipoPosto_Leave(txtIdTransformadorTipoPosto, New System.EventArgs())
							Call txtIdProprietario_Leave(txtIdProprietario, New System.EventArgs())
							Call txtIdAlimentador_Leave(txtIdAlimentador, New System.EventArgs())
							Call txtIdSituacao_Leave(txtIdSituacao, New System.EventArgs())
							iblnNovo = False
							Call Me.txtDescricao.Focus()
						End If
					Else
						Call MsgBox("Não foi possível encontrar o registro!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
						If LCase(Mid(Me.txtIdTransformadorTipoUnidade.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then
							Me.txtDsTransformadorTipoUnidade.Text = ""
							Call Me.txtIdTransformadorTipoUnidade.Focus()
						ElseIf LCase(Mid(Me.txtIdTransformadorTipoPosto.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							Me.txtDsTransformadorTipoPosto.Text = ""
							Call Me.txtIdTransformadorTipoPosto.Focus()
						ElseIf LCase(Mid(Me.txtIdProprietario.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							Me.txtDsProprietario.Text = ""
							Call Me.txtIdProprietario.Focus()
						ElseIf LCase(Mid(Me.txtIdAlimentador.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							Me.txtDsAlimentador.Text = ""
							Call Me.txtIdAlimentador.Focus()
						ElseIf LCase(Mid(Me.txtIdSituacao.Name, 6)) = LCase(Replace(astrTabela, "_", "")) Then 
							Me.txtDsSituacao.Text = ""
							Call Me.txtIdSituacao.Focus()
						End If
					End If
					Call .Close()
				End If
			End With
		End If
		'UPGRADE_NOTE: Object lrstAux 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"'
		lrstAux = Nothing
	End Sub
	
	Private Sub LimpaCampos()
		Me.txtId.Text = "0"
		Me.txtDescricao.Text = ""
		Me.txtIdTransformadorTipoUnidade.Text = ""
		Me.txtDsTransformadorTipoUnidade.Text = ""
		Me.txtIdTransformadorTipoPosto.Text = ""
		Me.txtDsTransformadorTipoPosto.Text = ""
		Me.txtIdProprietario.Text = ""
		Me.txtDsProprietario.Text = ""
		Me.txtIdAlimentador.Text = ""
		Me.txtDsAlimentador.Text = ""
		Me.txtIdSituacao.Text = ""
		Me.txtDsSituacao.Text = ""
		Me.lblSituacao.Text = ""
	End Sub
	
	Private Sub txtIdTransformadorTipoUnidade_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdTransformadorTipoUnidade.Enter
		With Me.txtIdTransformadorTipoUnidade
			.Text = Replace(.Text, ".", "")
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtIdTransformadorTipoUnidade_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtIdTransformadorTipoUnidade.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtIdTransformadorTipoUnidade_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdTransformadorTipoUnidade.Leave
		With Me.txtIdTransformadorTipoUnidade
			If IsNumeric(.Text) Then
				Call SetaCodigo("transformador_tipo_unidade", CInt(.Text))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = FormatNumber(IIf(Len(.Text) = 0, 0, .Text), 0)
			Else
				Me.txtDsTransformadorTipoUnidade.Text = ""
			End If
		End With
	End Sub
	
	Private Sub txtIdTransformadorTipoPosto_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdTransformadorTipoPosto.Enter
		With Me.txtIdTransformadorTipoPosto
			.Text = Replace(.Text, ".", "")
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtIdTransformadorTipoPosto_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtIdTransformadorTipoPosto.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtIdTransformadorTipoPosto_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdTransformadorTipoPosto.Leave
		With Me.txtIdTransformadorTipoPosto
			If IsNumeric(.Text) Then
				Call SetaCodigo("transformador_tipo_posto", CInt(.Text))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = FormatNumber(IIf(Len(.Text) = 0, 0, .Text), 0)
			Else
				Me.txtDsTransformadorTipoPosto.Text = ""
			End If
		End With
	End Sub
	
	Private Sub txtIdProprietario_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdProprietario.Enter
		With Me.txtIdProprietario
			.Text = Replace(.Text, ".", "")
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtIdProprietario_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtIdProprietario.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtIdProprietario_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdProprietario.Leave
		With Me.txtIdProprietario
			If IsNumeric(.Text) Then
				Call SetaCodigo("proprietario", CInt(.Text))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = FormatNumber(IIf(Len(.Text) = 0, 0, .Text), 0)
			Else
				Me.txtDsProprietario.Text = ""
			End If
		End With
	End Sub
	
	Private Sub txtIdAlimentador_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdAlimentador.Enter
		With Me.txtIdAlimentador
			.Text = Replace(.Text, ".", "")
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtIdAlimentador_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtIdAlimentador.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtIdAlimentador_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdAlimentador.Leave
		With Me.txtIdAlimentador
			If IsNumeric(.Text) Then
				Call SetaCodigo("alimentador", CInt(.Text))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = FormatNumber(IIf(Len(.Text) = 0, 0, .Text), 0)
			Else
				Me.txtDsAlimentador.Text = ""
			End If
		End With
	End Sub
	
	Private Sub txtIdSituacao_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdSituacao.Enter
		With Me.txtIdSituacao
			.Text = Replace(.Text, ".", "")
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtIdSituacao_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtIdSituacao.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtIdSituacao_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIdSituacao.Leave
		With Me.txtIdSituacao
			If IsNumeric(.Text) Then
				Call SetaCodigo("situacao", CInt(.Text))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = FormatNumber(IIf(Len(.Text) = 0, 0, .Text), 0)
			Else
				Me.txtDsSituacao.Text = ""
			End If
		End With
	End Sub
	
	Public Sub SetaParametros(ByRef afrmQuemChama As System.Windows.Forms.Form)
		ifrmQuemChama = afrmQuemChama
		ifrmQuemChama.Enabled = False
	End Sub
End Class