Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmCalculoFaturaComplementar
	Inherits System.Windows.Forms.Form
	'Private idblNumNf As Double
	'Private idblNsuNr As Double
	'Private idteBase As Date

	'Private Sub cmdFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFechar.Click
	'	Call Me.Close()
	'End Sub

	'Private Sub cmdGradeIncluirTributacao_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGradeIncluirTributacao.Click
	'	If Me.txtMesAnoRef.Text <> "" Then
	'		'Adciona na grade valores faturados
	'		Call Adiciona_mfgGradeItensFaturas(Me.txtMesAnoRef.Text, Me.txtTabCod_IdVlrIcms1.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1.Text), Me.txtVlrBaseIcms1.Text, 0)), 2, CDbl(IIf(IsNumeric(Me.txtVlrIcms1.Text), Me.txtVlrIcms1.Text, 0)), 2, Me.txtRefIcms1.Text)
	'		Call Adiciona_mfgGradeItensFaturas(Me.txtMesAnoRef.Text, Me.txtTabCod_IdVlrIcms2.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2.Text), Me.txtVlrBaseIcms2.Text, 0)), 2, CDbl(IIf(IsNumeric(Me.txtVlrIcms2.Text), Me.txtVlrIcms2.Text, 0)), 2, Me.txtRefIcms2.Text)
	'		Call Adiciona_mfgGradeItensFaturas(Me.txtMesAnoRef.Text, Me.txtTabCod_IdVlrPis.Text, CDbl(IIf(IsNumeric(Me.txtVlrBasePis.Text), Me.txtVlrBasePis.Text, 0)), 2, CDbl(IIf(IsNumeric(Me.txtVlrPis.Text), Me.txtVlrPis.Text, 0)), 2, Me.txtRefPis.Text)
	'		Call Adiciona_mfgGradeItensFaturas(Me.txtMesAnoRef.Text, Me.txtTabCod_IdVlrCofins.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins.Text), Me.txtVlrBaseCofins.Text, 0)), 2, CDbl(IIf(IsNumeric(Me.txtVlrCofins.Text), Me.txtVlrCofins.Text, 0)), 2, Me.txtRefCofins.Text)
	'		Call TotalizaGrade()
	'		'Adiciona itens faturados não impressos valores de base de tributação
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdBaseIcms1.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1.Text), Me.txtVlrBaseIcms1.Text, 0)), 2)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdBaseIcms2.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2.Text), Me.txtVlrBaseIcms2.Text, 0)), 2)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdBasePis.Text, CDbl(IIf(IsNumeric(Me.txtVlrBasePis.Text), Me.txtVlrBasePis.Text, 0)), 2)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdBaseCofins.Text, CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins.Text), Me.txtVlrBaseCofins.Text, 0)), 2)
	'		'Adiona itens não faturados não impressos aliquotas de tributação
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdAliqIcms1.Text, CDbl(IIf(IsNumeric(Me.txtVlrAliquotaIcms1.Text), Me.txtVlrAliquotaIcms1.Text, 0)), 5)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdAliqIcms2.Text, CDbl(IIf(IsNumeric(Me.txtVlrAliquotaIcms2.Text), Me.txtVlrAliquotaIcms2.Text, 0)), 5)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdAliqPis.Text, CDbl(IIf(IsNumeric(Me.txtVlrAliquotaPis.Text), Me.txtVlrAliquotaPis.Text, 0)), 5)
	'		Call Adiciona_mfgGradeItensFaturados(Me.txtMesAnoRef.Text, Me.txtTabCod_IdAliqCofins.Text, CDbl(IIf(IsNumeric(Me.txtVlrAliquotaCofins.Text), Me.txtVlrAliquotaCofins.Text, 0)), 5)
	'		'
	'		'adciona na grade de dados complementares os dados informados

	'		Call Adiciona_mfgGradeComplementaresDados(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CStr(Me.txtMesAno.Text), CDate(IIf(IsDate(Me.txtDt_Faturamento.Text), Me.txtDt_Faturamento.Text, idteBase)), CDate(IIf(IsDate(Me.txtDt_Apresenta.Text), Me.txtDt_Apresenta.Text, idteBase)), CDate(IIf(IsDate(Me.txtDt_Leit_Atual.Text), Me.txtDt_Leit_Atual.Text, idteBase)), CDate(IIf(IsDate(Me.txtDt_Leit_Anterior.Text), Me.txtDt_Leit_Anterior.Text, idteBase)), CDate(IIf(IsDate(Me.txtDt_Prox_Leit.Text), Me.txtDt_Prox_Leit.Text, idteBase)), CDate(IIf(IsDate(Me.txtDt_Vencto.Text), Me.txtDt_Vencto.Text, idteBase)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)))
	'		'adiciona na grade de itens dos dados complentares as informações dos campos (BASE ICMS PIS E COFINS e VALORES de ICMS PIS E COFINS
	'		'Base de tributação
	'		'Icms 1
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdBaseIcms1.Text), CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1_Nova.Text), Me.txtVlrBaseIcms1_Nova.Text, 0)))
	'		'Icms 2
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdBaseIcms2.Text), CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2_Nova.Text), Me.txtVlrBaseIcms2_Nova.Text, 0)))
	'		'Pis
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdBasePis.Text), CDbl(IIf(IsNumeric(Me.txtVlrBasePis_Nova.Text), Me.txtVlrBasePis_Nova.Text, 0)))
	'		'Cofins
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdBaseCofins.Text), CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins_Nova.Text), Me.txtVlrBaseCofins_Nova.Text, 0)))

	'		'Valores de tributação
	'		'Icms 1
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdVlrIcms1.Text), CDbl(IIf(IsNumeric(Me.txtVlrIcms1_Nova.Text), Me.txtVlrIcms1_Nova.Text, 0)))
	'		'Icms 2
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdVlrIcms2.Text), CDbl(IIf(IsNumeric(Me.txtVlrIcms2_Nova.Text), Me.txtVlrIcms2_Nova.Text, 0)))
	'		'Pis
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdVlrPis.Text), CDbl(IIf(IsNumeric(Me.txtVlrPis_Nova.Text), Me.txtVlrPis_Nova.Text, 0)))
	'		'Cofins
	'		Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsNumeric(Me.txtId_Fatura_Complementar_Dados.Text), Me.txtId_Fatura_Complementar_Dados.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CInt(VB.Right(Me.txtMesAnoRef.Text, 4) & VB.Left(Me.txtMesAnoRef.Text, 2)), 0, CStr(Me.txtTabCod_IdVlrCofins.Text), CDbl(IIf(IsNumeric(Me.txtVlrCofins_Nova.Text), Me.txtVlrCofins_Nova.Text, 0)))
	'	End If
	'End Sub

	'Private Sub cmdGravaDados_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGravaDados.Click
	'	'Chama a rotina para salvar os dados informados
	'	Call Grava_Dados_Informados()
	'End Sub

	'Private Sub cmdGravarFatura_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGravarFatura.Click
	'	Dim lstrCriterio As String
	'	If LeConfig("MESANOFATURAMENTO") = Me.txtMesAno.Text Then
	'		'Chama a rotina para gerar a fatura
	'		If Trim(Me.txtMesAno.Text) <> "" And Trim(Me.txtNrFatComp.Text) <> "" And Trim(Me.txtCons_Id.Text) <> "" And Trim(Me.txtUnid_Id.Text) <> "" Then
	'			lstrCriterio = "anomes = " & CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2))
	'			lstrCriterio = lstrCriterio & " AND fatura_complementar = " & CDbl(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0))
	'			lstrCriterio = lstrCriterio & " AND grupo = '" & IIf(Me.opbGrupoA.Checked, "A", "B") & "'"
	'			lstrCriterio = lstrCriterio & " AND cons_id = " & CInt(IIf(IsNumeric(Me.txtCons_Id.Text), Me.txtCons_Id.Text, 0))
	'			lstrCriterio = lstrCriterio & " AND unid_id = " & CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0))
	'			If VerificaExisteRegistro("fatura_complementar_dados", lstrCriterio) Then
	'				Call Grava_Fatura()
	'			Else
	'				Call cmdGravaDados_Click(cmdGravaDados, New System.EventArgs())
	'				Call Grava_Fatura()
	'			End If
	'		Else
	'			Call MsgBox("Você precisa preencher os todos os campos de referência antes de gerar a fatura!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
	'		End If
	'	Else
	'		Call MsgBox("Você não pode efetuar a gravação da fatura de um mês já encerrado!", MsgBoxStyle.Information, gstrTituloMensagem)
	'	End If
	'End Sub

	'Private Sub cmdImpFaturas_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImpFaturas.Click
	'	Dim lfrmImpFaturas As New frmImpFaturas
	'	If IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0) > 0 And IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0) > 0 Then
	'		idblNumNf = BuscaNumeroFaturaTransicao(CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)), idblNsuNr, CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)))
	'		If idblNumNf > 0 Then
	'			Call lfrmImpFaturas.GeraFaturaGrupoA(4, (Me.txtMesAno.Text), idblNumNf, 0, "nftransicao", CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)))
	'		Else
	'			Call MsgBox("Não existe fatura em transição desta unidade consumidora.", MsgBoxStyle.Exclamation, gstrTituloMensagem)
	'		End If
	'	Else
	'		Call MsgBox("Você precisa selecionar uma unidade consumidora e informar o número complementar.", MsgBoxStyle.Exclamation, gstrTituloMensagem)
	'	End If
	'	'UPGRADE_NOTE: Object lfrmImpFaturas 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"'
	'	lfrmImpFaturas = Nothing
	'End Sub

	'Private Sub cmdLocalizarFaturaComplementar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarFaturaComplementar.Click
	'	'Chama a tela de localização das faturas complementares
	'	Call frmLocalizaFaturaComplementar.SetaParametros(Me, Me.txtGrupo.Text, CInt(IIf(IsNumeric(Me.txtCons_Id.Text), Me.txtCons_Id.Text, 0)), CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)), CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)))
	'	Call frmLocalizaFaturaComplementar.Show()
	'End Sub

	'Private Sub frmCalculoFaturaComplementar_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 Me.Close()
	'	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 frmCalculoFaturaComplementar_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
	'	Call CenterForm(Me)
	'	idteBase = BuscaDataBD
	'	Me.txtMesAno.Text = LeConfig("MESANOFATURAMENTO")
	'	Me.txtMesAno.Text = FormataData(Me.txtMesAno, 1)
	'	Me.txtMesAnoRef.Text = Me.txtMesAno.Text
	'	Me.fmeDadosUc.Enabled = False
	'	Call Configura_Codigos()
	'	Call Monta_mfgGradeItensFaturas()
	'	Call Monta_mfgGradeComplementaresDados()
	'End Sub

	'Private Sub mfgGradeComplementaresDados_DblClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mfgGradeComplementaresDados.DblClick
	'	Call Inicializa_Referencia(Me.mfgGradeComplementaresDados.RowSel)
	'End Sub

	''UPGRADE_WARNING: Event opbGrupoA.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	'Private Sub opbGrupoA_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbGrupoA.CheckedChanged
	'	If eventSender.Checked Then
	'		Call Configura_Codigos()
	'	End If
	'End Sub

	''UPGRADE_WARNING: Event opbGrupoB.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	'Private Sub opbGrupoB_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbGrupoB.CheckedChanged
	'	If eventSender.Checked Then
	'		Call Configura_Codigos()
	'	End If
	'End Sub

	'Private Sub txtDt_Apresenta_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Apresenta.Enter
	'	With Me.txtDt_Apresenta
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Apresenta_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Apresenta.Leave
	'	txtDt_Apresenta.Text = FormataData(txtDt_Apresenta, 2)
	'End Sub

	'Private Sub txtDt_Faturamento_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Faturamento.Enter
	'	With Me.txtDt_Faturamento
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Faturamento_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Faturamento.Leave
	'	txtDt_Faturamento.Text = FormataData(txtDt_Faturamento, 2)
	'End Sub

	'Private Sub txtDt_Leit_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Leit_Anterior.Enter
	'	With Me.txtDt_Leit_Anterior
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Leit_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Leit_Anterior.Leave
	'	txtDt_Leit_Anterior.Text = FormataData(txtDt_Leit_Anterior, 2)
	'End Sub

	'Private Sub txtDt_Leit_Atual_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Leit_Atual.Enter
	'	With Me.txtDt_Leit_Atual
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Leit_Atual_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Leit_Atual.Leave
	'	txtDt_Leit_Atual.Text = FormataData(txtDt_Leit_Atual, 2)
	'End Sub

	'Private Sub txtDt_Prox_Leit_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Prox_Leit.Enter
	'	With Me.txtDt_Prox_Leit
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Prox_Leit_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Prox_Leit.Leave
	'	txtDt_Prox_Leit.Text = FormataData(txtDt_Prox_Leit, 2)
	'End Sub

	'Private Sub txtDt_Vencto_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Vencto.Enter
	'	With Me.txtDt_Vencto
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtDt_Vencto_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtDt_Vencto.Leave
	'	txtDt_Vencto.Text = FormataData(txtDt_Vencto, 2)
	'End Sub

	'Private Sub txtMesAno_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Enter
	'	With Me.txtMesAno
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtMesAno_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Leave
	'	Me.txtMesAno.Text = FormataData(txtMesAno, 1)
	'	If Trim(Me.txtMesAno.Text) <> "" Then
	'		Me.txtNrFatComp.Text = CStr(RetornaNrFatComp(CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)), IIf(Me.opbGrupoA.Checked, "A", "B"), CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0))))
	'	End If
	'End Sub

	'Private Sub txtMesAnoRef_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAnoRef.Enter
	'	With Me.txtMesAnoRef
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtMesAnoRef_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAnoRef.Leave
	'	Me.txtMesAnoRef.Text = FormataData(txtMesAnoRef, 1)
	'	Call Localiza_Dados_Faturamento()
	'End Sub

	'Private Sub txtNrFatComp_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtNrFatComp.Enter
	'	With Me.txtNrFatComp
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtNrFatComp_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtNrFatComp.Leave
	'	Me.txtNumNf.Text = CStr(BuscaNumeroFaturaTransicao(CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)), idblNsuNr, CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0))))
	'	If VerificaExisteFaturaArrecadacao(CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)), CDbl(IIf(IsNumeric(Me.txtNumNf.Text), Me.txtNumNf.Text, 0)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0))) Then
	'		Call MsgBox("A fatura " & Me.txtNumNf.Text & " se encontra em arrecadação, não poderá ser faturada!", MsgBoxStyle.Critical, gstrTituloMensagem)
	'		Me.txtNrFatComp.Text = CStr(0)
	'		Call Me.txtMesAno.Focus()
	'	Else
	'		'Call Limpa_Campos

	'		Call Monta_mfgGradeComplementaresDados()
	'		Call Enche_mfgGradeComplementaresDados(CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)), CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)), CStr(Me.txtGrupo.Text), CInt(IIf(IsNumeric(Me.txtCons_Id.Text), Me.txtCons_Id.Text, 0)), CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)))
	'	End If
	'End Sub

	'Private Sub txtVlrAliquotaCofins_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaCofins.Enter
	'	With Me.txtVlrAliquotaCofins
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaCofins_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrAliquotaCofins.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrAliquotaCofins.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrAliquotaCofins_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaCofins.Leave
	'	With Me.txtVlrAliquotaCofins
	'		.Text = VB6.Format(.Text, "#,#####0.00000")
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaIcms1_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaIcms1.Enter
	'	With Me.txtVlrAliquotaIcms1
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaIcms1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrAliquotaIcms1.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrAliquotaIcms1.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrAliquotaIcms1_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaIcms1.Leave
	'	With Me.txtVlrAliquotaIcms1
	'		.Text = VB6.Format(.Text, "#,#####0.00000")
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaIcms2_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaIcms2.Enter
	'	With Me.txtVlrAliquotaIcms2
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaIcms2_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrAliquotaIcms2.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrAliquotaIcms2.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrAliquotaIcms2_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaIcms2.Leave
	'	With Me.txtVlrAliquotaIcms2
	'		.Text = VB6.Format(.Text, "#,#####0.00000")
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaPis_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaPis.Enter
	'	With Me.txtVlrAliquotaPis
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrAliquotaPis_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrAliquotaPis.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrAliquotaPis.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrAliquotaPis_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrAliquotaPis.Leave
	'	With Me.txtVlrAliquotaPis
	'		.Text = VB6.Format(.Text, "#,#####0.00000")
	'	End With
	'End Sub

	'Private Sub txtVlrBaseCofins_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins_Anterior.Enter
	'	With Me.txtVlrBaseCofins_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseCofins_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseCofins_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseCofins_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseCofins_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins_Anterior.Leave
	'	With Me.txtVlrBaseCofins_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBaseCofins_Nova, txtVlrBaseCofins_Anterior, txtVlrBaseCofins)
	'End Sub

	'Private Sub txtVlrBaseCofins_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins.Enter
	'	With Me.txtVlrBaseCofins
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseCofins_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseCofins.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseCofins.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseCofins_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins.Leave
	'	With Me.txtVlrBaseCofins
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrBaseCofins_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins_Nova.Enter
	'	With Me.txtVlrBaseCofins_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseCofins_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseCofins_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseCofins_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseCofins_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseCofins_Nova.Leave
	'	With Me.txtVlrBaseCofins_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBaseCofins_Nova, txtVlrBaseCofins_Anterior, txtVlrBaseCofins)
	'End Sub

	'Private Sub txtVlrBaseIcms1_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1_Anterior.Enter
	'	With Me.txtVlrBaseIcms1_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms1_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms1_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms1_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms1_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1_Anterior.Leave
	'	With Me.txtVlrBaseIcms1_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBaseIcms1_Nova, txtVlrBaseIcms1_Anterior, txtVlrBaseIcms1)
	'End Sub

	'Private Sub txtVlrBaseIcms1_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1.Enter
	'	With Me.txtVlrBaseIcms1
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms1.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms1.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms1_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1.Leave
	'	With Me.txtVlrBaseIcms1
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms1_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1_Nova.Enter
	'	With Me.txtVlrBaseIcms1_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms1_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms1_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms1_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms1_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms1_Nova.Leave
	'	With Me.txtVlrBaseIcms1_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call AtualizaCampoVlrBasePisCofins_Nova()
	'	Call Calcula_Campo_Diferenca(txtVlrBaseIcms1_Nova, txtVlrBaseIcms1_Anterior, txtVlrBaseIcms1)
	'End Sub

	'Private Sub txtVlrBaseIcms2_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2_Anterior.Enter
	'	With Me.txtVlrBaseIcms2_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms2_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms2_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms2_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms2_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2_Anterior.Leave
	'	With Me.txtVlrBaseIcms2_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBaseIcms2_Nova, txtVlrBaseIcms2_Anterior, txtVlrBaseIcms2)
	'End Sub

	'Private Sub txtVlrBaseIcms2_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2.Enter
	'	With Me.txtVlrBaseIcms2
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms2_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms2.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms2.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms2_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2.Leave
	'	With Me.txtVlrBaseIcms2
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms2_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2_Nova.Enter
	'	With Me.txtVlrBaseIcms2_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBaseIcms2_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBaseIcms2_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBaseIcms2_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBaseIcms2_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBaseIcms2_Nova.Leave
	'	With Me.txtVlrBaseIcms2_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call AtualizaCampoVlrBasePisCofins_Nova()
	'	Call Calcula_Campo_Diferenca(txtVlrBaseIcms2_Nova, txtVlrBaseIcms2_Anterior, txtVlrBaseIcms2)
	'End Sub

	'Private Sub txtVlrBasePis_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis_Anterior.Enter
	'	With Me.txtVlrBasePis_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBasePis_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBasePis_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBasePis_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBasePis_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis_Anterior.Leave
	'	With Me.txtVlrBasePis_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBasePis_Nova, txtVlrBasePis_Anterior, txtVlrBasePis)
	'End Sub

	'Private Sub txtVlrBasePis_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis.Enter
	'	With Me.txtVlrBasePis
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBasePis_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBasePis.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBasePis.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBasePis_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis.Leave
	'	With Me.txtVlrBasePis
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrBasePis_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis_Nova.Enter
	'	With Me.txtVlrBasePis_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrBasePis_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrBasePis_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrBasePis_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrBasePis_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrBasePis_Nova.Leave
	'	With Me.txtVlrBasePis_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrBasePis_Nova, txtVlrBasePis_Anterior, txtVlrBasePis)
	'End Sub

	'Private Sub txtVlrCofins_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins_Anterior.Enter
	'	With Me.txtVlrCofins_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrCofins_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrCofins_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrCofins_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrCofins_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins_Anterior.Leave
	'	With Me.txtVlrCofins_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrCofins_Nova, txtVlrCofins_Anterior, txtVlrCofins)
	'End Sub

	'Private Sub txtVlrCofins_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins.Enter
	'	With Me.txtVlrCofins
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrCofins_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrCofins.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrCofins.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrCofins_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins.Leave
	'	With Me.txtVlrCofins
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrCofins_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins_Nova.Enter
	'	With Me.txtVlrCofins_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrCofins_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrCofins_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrCofins_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrCofins_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrCofins_Nova.Leave
	'	With Me.txtVlrCofins_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrCofins_Nova, txtVlrCofins_Anterior, txtVlrCofins)
	'End Sub

	'Private Sub txtVlrIcms1_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1_Anterior.Enter
	'	With Me.txtVlrIcms1_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms1_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms1_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms1_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms1_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1_Anterior.Leave
	'	With Me.txtVlrIcms1_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrIcms1_Nova, txtVlrIcms1_Anterior, txtVlrIcms1)
	'End Sub

	'Private Sub txtVlrIcms1_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1.Enter
	'	With Me.txtVlrIcms1
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms1_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms1.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms1.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms1_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1.Leave
	'	With Me.txtVlrIcms1
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrIcms1_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1_Nova.Enter
	'	With Me.txtVlrIcms1_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms1_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms1_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms1_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms1_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms1_Nova.Leave
	'	With Me.txtVlrIcms1_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrIcms1_Nova, txtVlrIcms1_Anterior, txtVlrIcms1)
	'End Sub

	'Private Sub txtVlrIcms2_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2_Anterior.Enter
	'	With Me.txtVlrIcms2_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms2_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms2_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms2_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms2_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2_Anterior.Leave
	'	With Me.txtVlrIcms2_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrIcms2_Nova, txtVlrIcms2_Anterior, txtVlrIcms2)
	'End Sub

	'Private Sub txtVlrIcms2_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2.Enter
	'	With Me.txtVlrIcms2
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms2_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms2.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms2.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms2_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2.Leave
	'	With Me.txtVlrIcms2
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrIcms2_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2_Nova.Enter
	'	With Me.txtVlrIcms2_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrIcms2_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrIcms2_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrIcms2_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrIcms2_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrIcms2_Nova.Leave
	'	With Me.txtVlrIcms2_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrIcms2_Nova, txtVlrIcms2_Anterior, txtVlrIcms2)
	'End Sub

	'Private Sub txtVlrPis_Anterior_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis_Anterior.Enter
	'	With Me.txtVlrPis_Anterior
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrPis_Anterior_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrPis_Anterior.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrPis_Anterior.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrPis_Anterior_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis_Anterior.Leave
	'	With Me.txtVlrPis_Anterior
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrPis_Nova, txtVlrPis_Anterior, txtVlrPis)
	'End Sub

	'Private Sub txtVlrPis_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis.Enter
	'	With Me.txtVlrPis
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrPis_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrPis.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrPis.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrPis_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis.Leave
	'	With Me.txtVlrPis
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'End Sub

	'Private Sub txtVlrPis_Nova_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis_Nova.Enter
	'	With Me.txtVlrPis_Nova
	'		.Text = CStr(CDbl(IIf(IsNumeric(.Text), .Text, 0)))
	'		.SelectionStart = 0
	'		.SelectionLength = CInt(Len(.Text))
	'	End With
	'End Sub

	'Private Sub txtVlrPis_Nova_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtVlrPis_Nova.KeyPress
	'	Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
	'	If KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then
	'		If KeyAscii = System.Windows.Forms.Keys.Delete Then
	'			KeyAscii = System.Windows.Forms.Keys.Snapshot
	'		End If
	'		If KeyAscii <> System.Windows.Forms.Keys.Snapshot Then
	'			KeyAscii = 0
	'		Else
	'			If InStr(1, Me.txtVlrPis_Nova.Text, ",") > 0 Then
	'				KeyAscii = 0
	'			End If
	'		End If
	'	End If
	'	eventArgs.KeyChar = Chr(KeyAscii)
	'	If KeyAscii = 0 Then
	'		eventArgs.Handled = True
	'	End If
	'End Sub

	'Private Sub txtVlrPis_Nova_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtVlrPis_Nova.Leave
	'	With Me.txtVlrPis_Nova
	'		.Text = VB6.Format(.Text, "#,##0.00")
	'	End With
	'	Call Calcula_Campo_Diferenca(txtVlrPis_Nova, txtVlrPis_Anterior, txtVlrPis)
	'End Sub

	'Private Sub txtZona_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtZona.Enter
	'	With Me.txtZona
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtZona_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtZona.Leave
	'	With Me.txtZona
	'		If Len(.Text) >= 1 Then
	'			If IsNumeric(.Text) Then
	'				.Text = VB6.Format(.Text, "000")
	'			Else
	'				.Text = ""
	'			End If
	'		End If
	'	End With
	'End Sub

	'Private Sub txtLivro_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLivro.Enter
	'	With Me.txtLivro
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtLivro_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLivro.Leave
	'	With Me.txtLivro
	'		If Len(.Text) >= 1 Then
	'			If IsNumeric(.Text) Then
	'				.Text = VB6.Format(.Text, "00")
	'			Else
	'				.Text = ""
	'			End If
	'		End If
	'	End With
	'End Sub

	'Private Sub txtConta_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtConta.Enter
	'	With Me.txtConta
	'		.SelectionStart = 0
	'		.SelectionLength = Len(.Text)
	'	End With
	'End Sub

	'Private Sub txtConta_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtConta.Leave
	'	With Me.txtConta
	'		If Len(.Text) >= 1 Then
	'			If IsNumeric(.Text) Then
	'				.Text = VB6.Format(.Text, "000000")
	'			Else
	'				.Text = ""
	'			End If
	'		End If
	'	End With
	'	'Chama a rotina para buscar os dados da unidade consumidora
	'	Call Localiza_UnidadeConsumidora()
	'End Sub

	'	Private Sub Localiza_UnidadeConsumidora()
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		Call Reinicializa_Tela()
	'		'
	'		If Trim(Me.txtZona.Text) <> "" And Trim(Me.txtLivro.Text) <> "" And Trim(Me.txtConta.Text) <> "" Then
	'			lstrSql = ""
	'			lstrSql = lstrSql & "SELECT * "
	'			lstrSql = lstrSql & "  FROM `unid" & IIf(Me.opbGrupoA.Checked, "a", "b") & "` "
	'			lstrSql = lstrSql & " WHERE `zona`  ='" & Me.txtZona.Text & "' "
	'			lstrSql = lstrSql & "   AND `livro` ='" & Me.txtLivro.Text & "' "
	'			lstrSql = lstrSql & "   AND `conta` ='" & Me.txtConta.Text & "' "
	'			Call Conectar(lstrSql, 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.txtCpfCnpjUC.Text = Trim(IIf(IsDbNull(.Fields("cpf_cnpj").value), "", .Fields("cpf_cnpj").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.txtNome.Text = Trim(IIf(IsDbNull(.Fields("nome").value), "", .Fields("nome").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.txtTA.Text = Trim(IIf(IsDbNull(.Fields("ta").value), IIf(Me.opbGrupoA.Checked, "01A400", "01B100"), .Fields("ta").value))
	'						Me.txtGrupo.Text = IIf(Me.opbGrupoA.Checked, "A", "B")
	'						'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.txtCons_Id.Text = CStr(CDbl(IIf(IsDbNull(.Fields("cons_id").value), 0, .Fields("cons_id").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.txtUnid_Id.Text = CStr(CDbl(IIf(IsDbNull(.Fields("unid_id").value), 0, .Fields("unid_id").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.txtRota.Text = Trim(IIf(IsDbNull(.Fields("rota").value), "0", .Fields("rota").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.txtSituacao.Text = Trim(IIf(IsDbNull(.Fields("situacao").value), "L", .Fields("situacao").value))
	'						Select Case Me.txtSituacao.Text
	'							Case Is = "L"
	'								Me.txtSituacao.Text = "LIGADO"
	'							Case Is = "D"
	'								Me.txtSituacao.Text = "DESLIGADO"
	'							Case Is = "C"
	'								Me.txtSituacao.Text = "CORTADO"
	'							Case Is = "N"
	'								Me.txtSituacao.Text = "NÃO LIGADO"
	'							Case Is = "I"
	'								Me.txtSituacao.Text = "INATIVADO" 'DESATIVADO"
	'							Case Else
	'								Me.txtSituacao.Text = ""
	'						End Select
	'						'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.txtRegiao.Text = UCase(IIf(IsDbNull(.Fields("regiao").value), "U", .Fields("regiao").value))
	'						Me.txtRegiao.Text = IIf(Me.txtRegiao.Text = "U", "Urbano", "Rural")
	'						'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.txtFase.Text = Trim(IIf(IsDbNull(.Fields("fase").value), "M", .Fields("fase").value))
	'						Select Case Me.txtFase.Text
	'							Case Is = "M"
	'								Me.txtFase.Text = "MONOFÁSICO"
	'							Case Is = "B"
	'								Me.txtFase.Text = "BIFÁSICO"
	'							Case Is = "T"
	'								Me.txtFase.Text = "TRIFÁSICO"
	'							Case Else
	'								Me.txtFase.Text = ""
	'						End Select
	'						'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.txtTensao.Text = Trim(IIf(IsDbNull(.Fields("tensao").value), "", .Fields("tensao").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.txtIdClasse.Text = VB6.Format(Trim(IIf(IsDbNull(.Fields("clas").value), "0000", .Fields("clas").value)), "0000")
	'						Me.txtDescrClasse.Text = BuscaDescricaoClasse(Me.txtIdClasse.Text)
	'						'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.txtIdBanco.Text = Trim(IIf(IsDbNull(.Fields("banco").value), "0", .Fields("banco").value))
	'						If IsNumeric(Me.txtIdBanco.Text) Then
	'							Me.txtDesBanco.Text = RetornaNomeBanco(CInt(Me.txtIdBanco.Text))
	'						Else
	'							Me.txtDesBanco.Text = ""
	'						End If
	'						'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.txtBancoAgencia.Text = Trim(IIf(IsDbNull(.Fields("agenc").value), "", .Fields("agenc").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.txtBancoCC.Text = Trim(IIf(IsDbNull(.Fields("cc").value), "", .Fields("cc").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.chkicms_demanda_lida.CheckState = IIf(Trim(IIf(IsDbNull(.Fields("icms_demanda_lida").value), "N", .Fields("icms_demanda_lida").value)) = "S", System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.chkparcialmente_cativo.CheckState = IIf(CShort(IIf(IsDbNull(.Fields("parcialmente_cativo").value), 0, .Fields("parcialmente_cativo").value)) = 1, System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.chklivre_especial.CheckState = IIf(CShort(IIf(IsDbNull(.Fields("livreespecial").value), 0, .Fields("livreespecial").value)) = 1, System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.chklivre_verde.CheckState = IIf(CShort(IIf(IsDbNull(.Fields("livre_verde").value), 0, .Fields("livre_verde").value)) = 1, System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.chklivre_leitura_consumo.CheckState = IIf(CShort(IIf(IsDbNull(.Fields("livre_leitura_consumo").value), 0, .Fields("livre_leitura_consumo").value)) = 1, System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.chkmicro_geracao.CheckState = IIf(CShort(IIf(IsDbNull(.Fields("micro_geracao").value), 0, .Fields("micro_geracao").value)) = 1, System.Windows.Forms.CheckState.Checked, System.Windows.Forms.CheckState.Unchecked)
	'						'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.txtCfop.Text = Trim(IIf(IsDbNull(.Fields("cfop").value), 0, .Fields("cfop").value))
	'						If CDbl(IIf(IsNumeric(Me.txtCfop.Text), Me.txtCfop.Text, 0)) = 0 Then
	'							Me.txtCfop.Text = VB6.Format(GetCFOP(Me.txtIdClasse.Text, Me.txtGrupo.Text) / 1000, "#,####0.0000")
	'						End If
	'					End If
	'					Call .Close()
	'					Me.txtDt_Faturamento.Text = "01/" & Me.txtMesAno.Text
	'					Me.txtDt_Apresenta.Text = "01/" & Me.txtMesAno.Text
	'					Me.txtDt_Vencto.Text = CStr(BuscaDtVcto(CDate(Me.txtDt_Apresenta.Text)))
	'				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
	'		Call Monta_mfgGradeItensFaturas()
	'	End Sub

	'	Private Sub Localiza_Dados_Faturamento()
	'		Dim lstrItens As String
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		Call Limpa_Campos()
	'		lstrSql = "SELECT * FROM `nf` WHERE `mesano` = '" & Me.txtMesAnoRef.Text & "' AND `grupo` = '" & Me.txtGrupo.Text & "' AND `unid_id` = " & Me.txtUnid_Id.Text
	'		Call Conectar(lstrSql, 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.txtDt_Leit_Atual.Text = VB6.Format(IIf(IsDbNull(.Fields("dataleit").value), idteBase, .Fields("dataleit").value), "dd/MM/yyyy")
	'					'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.txtDt_Leit_Anterior.Text = VB6.Format(IIf(IsDbNull(.Fields("dataleitant").value), idteBase, .Fields("dataleitant").value), "dd/MM/yyyy")

	'					'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"'
	'					lstrItens = IIf(IsDbNull(.Fields("itensserv").value), "", .Fields("itensserv").value)
	'					Me.txtVlrBaseIcms1_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdBaseIcms1.Text), "#,##0.00")
	'					Me.txtVlrIcms1_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdVlrIcms1.Text), "#,##0.00")

	'					Me.txtVlrBasePis_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdBasePis.Text), "#,##0.00")
	'					Me.txtVlrPis_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdVlrPis.Text), "#,##0.00")

	'					Me.txtVlrBaseCofins_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdBaseCofins.Text), "#,##0.00")
	'					Me.txtVlrCofins_Anterior.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdVlrCofins.Text), "#,##0.00")

	'					Me.txtVlrAliquotaIcms1.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdAliqIcms1.Text), "#,#####0.00000")
	'					Me.txtVlrAliquotaIcms2.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdAliqIcms2.Text), "#,#####0.00000")
	'					Me.txtVlrAliquotaPis.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdAliqPis.Text), "#,#####0.00000")
	'					Me.txtVlrAliquotaCofins.Text = VB6.Format(BuscaValorItem(lstrItens, Me.txtTabCod_IdAliqCofins.Text), "#,#####0.00000")
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		'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 Calcula_Campo_Diferenca(ByVal objText_Valor_Nova As System.Windows.Forms.TextBox, ByVal objText_Valor_Anterior As System.Windows.Forms.TextBox, ByRef objText_Valor As System.Windows.Forms.TextBox)
	'		Dim ldblValorNova As Double
	'		Dim ldblValorAnterior As Double
	'		ldblValorNova = CDbl(IIf(IsNumeric(objText_Valor_Nova.Text), objText_Valor_Nova.Text, 0))
	'		ldblValorAnterior = CDbl(IIf(IsNumeric(objText_Valor_Anterior.Text), objText_Valor_Anterior.Text, 0))
	'		objText_Valor.Text = VB6.Format(ldblValorNova - ldblValorAnterior, "#,##0.00")
	'		Call Atualiza_Campo_Referencia("Tributacao")
	'	End Sub

	'	Private Function BuscaDtVcto(ByVal adteApresentacao As Date) As Date
	'		Dim ldteAux As Date
	'		Dim lintQtd As Short
	'		Dim lintSem As Short
	'		Dim lblnFer As Boolean
	'		Dim lintDia As Short

	'		lintDia = IIf(CDbl(VB.Left(Trim(Me.txtIdClasse.Text), 1)) = 6, 10, 5)

	'		ldteAux = adteApresentacao
	'		lintQtd = 0
	'		While lintQtd < lintDia
	'			ldteAux = System.Date.FromOADate(ldteAux.ToOADate + 1)
	'			lblnFer = VerificaFeriado(ldteAux)
	'			lintSem = WeekDay(ldteAux, FirstDayOfWeek.Sunday)
	'			If (lintSem > 1 And lintSem < 7) Then
	'				If lblnFer = False Then lintQtd = lintQtd + 1
	'			End If
	'		End While
	'		BuscaDtVcto = ldteAux
	'	End Function

	'	Private Sub Atualiza_Campo_Referencia(ByVal astrTipo As String)
	'		Select Case astrTipo
	'			Case Is = "Tributacao"
	'				If CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1_Nova.Text), Me.txtVlrBaseIcms1_Nova.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1_Anterior.Text), Me.txtVlrBaseIcms1_Anterior.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrAliquotaIcms1.Text), Me.txtVlrAliquotaIcms1.Text, 0)) <> 0 Then
	'					Me.txtRefIcms1.Text = "((" & Me.txtVlrBaseIcms1_Nova.Text & " - " & Me.txtVlrBaseIcms1_Anterior.Text & ") x " & Me.txtVlrAliquotaIcms1.Text & "%)"
	'				End If
	'				If CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2_Nova.Text), Me.txtVlrBaseIcms2_Nova.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2_Anterior.Text), Me.txtVlrBaseIcms2_Anterior.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrAliquotaIcms2.Text), Me.txtVlrAliquotaIcms2.Text, 0)) <> 0 Then
	'					Me.txtRefIcms2.Text = "((" & Me.txtVlrBaseIcms2_Nova.Text & " - " & Me.txtVlrBaseIcms2_Anterior.Text & ") x " & Me.txtVlrAliquotaIcms2.Text & "%)"
	'				End If
	'				If CDbl(IIf(IsNumeric(Me.txtVlrBasePis_Nova.Text), Me.txtVlrBasePis_Nova.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrBasePis_Anterior.Text), Me.txtVlrBasePis_Anterior.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrAliquotaPis.Text), Me.txtVlrAliquotaPis.Text, 0)) <> 0 Then
	'					Me.txtRefPis.Text = "((" & Me.txtVlrBasePis_Nova.Text & " - " & Me.txtVlrBasePis_Anterior.Text & ") x " & Me.txtVlrAliquotaPis.Text & "%)"
	'				End If
	'				If CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins_Nova.Text), Me.txtVlrBaseCofins_Nova.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins_Anterior.Text), Me.txtVlrBaseCofins_Anterior.Text, 0)) <> 0 And CDbl(IIf(IsNumeric(Me.txtVlrAliquotaCofins.Text), Me.txtVlrAliquotaCofins.Text, 0)) <> 0 Then
	'					Me.txtRefCofins.Text = "((" & Me.txtVlrBaseCofins_Nova.Text & " - " & Me.txtVlrBaseCofins_Anterior.Text & ") x " & Me.txtVlrAliquotaCofins.Text & "%)"
	'				End If
	'		End Select
	'	End Sub

	'	Private Sub Grava_Fatura()

	'		Dim lstrItensserv As String
	'		Dim lstrItensImp As String
	'		Dim lstrPrepara As String
	'		Dim lblnExisteFatura As Boolean
	'		Dim lstrCodBarra As String
	'		Dim lstrDvCBarra As String
	'		Dim llngDias As Integer
	'		Dim ldblTotalBaseIcms As Double
	'		Dim ldblTotalVlrIcms As Double
	'		'
	'		Dim llngAux As Integer
	'		Dim lstrCodHash As String
	'		Dim lstrSql As String

	'		On Error GoTo Erro_Grava_Fatura
	'		lstrItensserv = ""
	'		'
	'		'Monta Itens da fatura
	'		'
	'		ldblTotalVlrIcms = 0
	'		With Me.mfgGradeItensFaturas
	'			For llngAux = 1 To .Rows - 1
	'				If Trim(.get_TextMatrix(llngAux, 1)) <> "" Then
	'					lstrItensserv = Trim(lstrItensserv) & Trim(.get_TextMatrix(llngAux, 1)) 'Código
	'					lstrItensserv = Trim(lstrItensserv) & "?" & Trim(Replace(Replace(.get_TextMatrix(llngAux, 4), ".", ""), ",", ".")) 'Valor
	'					lstrItensserv = Trim(lstrItensserv) & "$" & Trim(.get_TextMatrix(llngAux, 5)) & ";" 'referencia
	'					If Trim(.get_TextMatrix(llngAux, 1)) = Me.txtTabCod_IdVlrIcms1.Text Or Trim(.get_TextMatrix(llngAux, 1)) = Me.txtTabCod_IdVlrIcms2.Text Then
	'						ldblTotalVlrIcms = ldblTotalVlrIcms + CDbl(IIf(IsNumeric(.get_TextMatrix(llngAux, 4)), .get_TextMatrix(llngAux, 4), 0))
	'					End If
	'				End If
	'			Next llngAux
	'		End With
	'		lstrItensserv = Trim(lstrItensserv)
	'		'
	'		'Itens faturados não impressos
	'		'
	'		ldblTotalBaseIcms = 0
	'		With Me.mfgGradeItensFaturados
	'			For llngAux = 1 To .Rows - 1
	'				If Trim(.get_TextMatrix(llngAux, 1)) <> "" Then
	'					lstrItensserv = Trim(lstrItensserv) & Trim(.get_TextMatrix(llngAux, 1)) 'Código
	'					lstrItensserv = Trim(lstrItensserv) & "?" & Trim(Replace(Replace(.get_TextMatrix(llngAux, 2), ".", ""), ",", ".")) 'Valor
	'					lstrItensserv = Trim(lstrItensserv) & "$" & Trim(.get_TextMatrix(llngAux, 0)) & ";" 'referencia
	'					If Trim(.get_TextMatrix(llngAux, 1)) = Me.txtTabCod_IdBaseIcms1.Text Or Trim(.get_TextMatrix(llngAux, 1)) = Me.txtTabCod_IdBaseIcms2.Text Then
	'						ldblTotalBaseIcms = ldblTotalBaseIcms + CDbl(IIf(IsNumeric(.get_TextMatrix(llngAux, 2)), .get_TextMatrix(llngAux, 2), 0))
	'					End If
	'				End If
	'			Next llngAux
	'		End With
	'		lstrItensserv = Trim(lstrItensserv)

	'		'
	'		'Prepara itens para pré impressão
	'		'
	'		With Me.mfgGradeItensFaturas
	'			lstrItensImp = ""
	'			For llngAux = 1 To .Rows - 1
	'				If CDbl(IIf(IsNumeric(.get_TextMatrix(llngAux, 4)), .get_TextMatrix(llngAux, 4), 0)) <> 0 Then
	'					If Len(lstrItensImp) <> 0 Then lstrItensImp = lstrItensImp & "\r\n"
	'					lstrPrepara = .get_TextMatrix(llngAux, 0) & " " & VB.Left(.get_TextMatrix(llngAux, 2) & " " & .get_TextMatrix(llngAux, 5) & New String(" ", 104), 104) & VB.Right(New String(" ", 15) & VB6.Format(CDbl(.get_TextMatrix(llngAux, 4)) * IIf(CDbl(VB.Left(.get_TextMatrix(llngAux, 1), 4)) = 9070, -1, 1), "#,##0.00"), 15)
	'					lstrItensImp = lstrItensImp & lstrPrepara
	'				End If
	'			Next llngAux
	'		End With
	'		'
	'		Me.lblStatus.Text = " Gerando fatura..."
	'		Call Me.lblStatus.Refresh()
	'		'
	'		'Dias de conumo
	'		'UPGRADE_WARNING: DateDiff behavior may be different. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B38EC3F-686D-4B2E-B5A5-9E8E7A762E32"'
	'		llngDias = DateDiff(Microsoft.VisualBasic.DateInterval.Day, CDate(Me.txtDt_Leit_Anterior.Text), CDate(Me.txtDt_Leit_Atual.Text))
	'		'
	'		'Busca número da fatura na nftransicao com base no número complementar
	'		idblNumNf = BuscaNumeroFaturaTransicao(CInt(IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)), idblNsuNr, CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)))
	'		'
	'		If idblNumNf = 0 Then
	'			lblnExisteFatura = False
	'			lstrSql = "INSERT INTO `nftransicao` SET "

	'If gstrEmpresa_Sigla.ToUpper() = "CERES" Then

	'If gstrEmpresa_UF.ToUpper() = "RJ" Then
	'			idblNumNf = CDbl(LeConfig("ultimo.nr.fiscal.rj")) + 1
	'ElseIf gstrEmpresa_UF.ToUpper() = "MG" Then
	'			idblNumNf = CDbl(LeConfig("ultimo.nr.fiscal.mg")) + 1
	'End If

	'Else
	'			idblNumNf = CDbl(LeConfig("ultimo.nr.fiscal")) + 1
	'End If

	'			If gstrEmpresa_UF = "SC" Then
	'				idblNsuNr = CDbl(LeConfig("ultimo.nr.nsu")) + 1
	'			End If

	'		Else
	'			lblnExisteFatura = True
	'			lstrSql = "UPDATE `nftransicao` SET "
	'		End If
	'		Me.txtNumNf.Text = CStr(idblNumNf)
	'		'
	'		'Monta o código do reservado ao fisco
	'		lstrCodHash = MontaReservadoFisico(ldblTotalBaseIcms, ldblTotalVlrIcms)
	'		'
	'		'Monta o código de barras
	'		Call MontaCodBarras(idblNumNf, Me.txtMesAno.Text, CDbl(Replace(Me.lblTotalLiq.Text, ".", "")), Me.txtZona.Text, Me.txtLivro.Text, Me.txtConta.Text, lstrCodBarra, lstrDvCBarra)
	'		'
	'		'Inicio dos dados pra tabela
	'		Call myConC.Execute("START TRANSACTION")
	'		lstrSql = lstrSql & "  `numnf`      =  " & idblNumNf & vbCrLf
	'		lstrSql = lstrSql & ", `nsu`        =  " & idblNsuNr & vbCrLf
	'		lstrSql = lstrSql & ", `codclas`    = '" & Me.txtIdClasse.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `mesano`     = '" & Me.txtMesAno.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `mesano_ref` = " & CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)) & vbCrLf
	'		lstrSql = lstrSql & ", `cfop`       = " & Replace(CStr(CDbl(IIf(IsNumeric(Me.txtCfop.Text), Me.txtCfop.Text, 0))), ",", ".") & vbCrLf
	'		lstrSql = lstrSql & ", `ta`         = '" & Me.txtTA.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `grupo`      = '" & Me.txtGrupo.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `flgst`      = ''" & vbCrLf
	'		lstrSql = lstrSql & ", `valortot`   = " & Replace(Replace(Me.lblTotal.Text, ".", ""), ",", ".") & vbCrLf
	'		lstrSql = lstrSql & ", `valorliq`   = " & Replace(Replace(Me.lblTotalLiq.Text, ".", ""), ",", ".") & vbCrLf
	'		lstrSql = lstrSql & ", `codhash`    = '" & UCase(lstrCodHash) & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `itensserv`  = '" & lstrItensserv & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `itensimp`   = '" & lstrItensImp & "'" & vbCrLf
	'		'
	'		lstrSql = lstrSql & ", `datavenc`     = '" & VB6.Format(Me.txtDt_Vencto.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dataapr`      = '" & VB6.Format(Me.txtDt_Apresenta.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dataleit`     = '" & VB6.Format(Me.txtDt_Leit_Atual.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dataem`       = '" & VB6.Format(Me.txtDt_Faturamento.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dataleitant`  = '" & VB6.Format(Me.txtDt_Leit_Anterior.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dataproxleit` = '" & VB6.Format(Me.txtDt_Prox_Leit.Text, "yyyy-MM-dd") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `datapag`      = '0000-00-00'" & vbCrLf
	'		lstrSql = lstrSql & ", `dias`         = " & llngDias & vbCrLf
	'		'
	'		lstrSql = lstrSql & ", `cpf_cnpj` = '" & Replace(Replace(Replace(Me.txtCpfCnpjUC.Text, ".", ""), "-", ""), "/", "") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `cons_id`  = " & Me.txtCons_Id.Text & vbCrLf
	'		lstrSql = lstrSql & ", `unid_id`  = " & Me.txtUnid_Id.Text & vbCrLf
	'		lstrSql = lstrSql & ", `zona`     = '" & Me.txtZona.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `livro`    = '" & Me.txtLivro.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `conta`    = '" & Me.txtConta.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `fase`     = '" & VB.Left(Me.txtFase.Text, 1) & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `tensao`   = '" & Me.txtTensao.Text & "'" & vbCrLf
	'		'
	'		lstrSql = lstrSql & ", `rota`              = '" & Me.txtRota.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `caderno`           =  " & Mid(IIf(Me.txtRota.Text <> "", Me.txtRota.Text, "0000"), 3, 2) & vbCrLf
	'		lstrSql = lstrSql & ", `caderno_sequencia` =  " & VB.Right(IIf(Me.txtRota.Text <> "", Me.txtRota.Text, "0000"), 4) & vbCrLf
	'		lstrSql = lstrSql & ", `rota_quatro`       = '" & VB.Left(IIf(Me.txtRota.Text <> "", Me.txtRota.Text, "0000"), 4) & "'" & vbCrLf
	'		'
	'		lstrSql = lstrSql & ", `banarrec`       = " & CInt(IIf(IsNumeric(Me.txtIdBanco.Text), Me.txtIdBanco.Text, 0)) & vbCrLf
	'		lstrSql = lstrSql & ", `banco_fatur`    = '" & VB6.Format(Me.txtIdBanco.Text, "000") & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `banident`       = '" & Me.txtDesBanco.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `agencia`        = '" & Me.txtBancoAgencia.Text & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `conta_corrente` = '" & Me.txtBancoCC.Text & "'" & vbCrLf

	'		'
	'		lstrSql = lstrSql & ", `parcialmente_cativo` = " & IIf(Me.chkparcialmente_cativo.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		lstrSql = lstrSql & ", `periodo_teste`       = 0" & vbCrLf
	'		lstrSql = lstrSql & ", `livreespecial`       = " & IIf(Me.chklivre_especial.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		lstrSql = lstrSql & ", `livre_verde`         = " & IIf(Me.chklivre_verde.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		lstrSql = lstrSql & ", `micro_geracao`       = " & IIf(Me.chkmicro_geracao.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		'lstrSql = lstrSql & ", `micro_geracao_convenio_sefaz` = " & IIf(iblnMicroGeracaoConvenioSefaz, 1, 0)  & vbCrLf
	'		'lstrSql = lstrSql & ", `micro_geracao_distribuida` =  " & IIf(lblnMicroGeracaoDistribuida, 1, 0) & vbCrLf
	'		lstrSql = lstrSql & ", `irrigacao_aquicultura`       = " & IIf(Me.chkirrigacao_aquicultura.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		lstrSql = lstrSql & ", `tarifa_branca`       = " & IIf(Me.chktarifa_branca.CheckState = System.Windows.Forms.CheckState.Checked, 1, 0) & vbCrLf
	'		'lstrSql = lstrSql & ", `num_med`     = '" & lstrNumMed & "'" & vbCrLf
	'		'lstrSql = lstrSql & ", `const_med`   = '" & Strings.Replace(ldblFpmMed, ",", ".") & "'" & vbCrLf
	'		'lstrSql = lstrSql & ", `agrupa`      =  " & llngAgrupa & vbCrLf
	'		'lstrSql = lstrSql & ", `agrupa_rota` = '" & lstrAgrupaRota & "'" & vbCrLf
	'		'lstrSql = lstrSql & ", `agrupa_caderno`   = " & Strings.Mid(IIf(lstrAgrupaRota <> "", lstrAgrupaRota, "0000"), 3, 2) & vbCrLf
	'		'lstrSql = lstrSql & ", `agrupa_sequencia` = " & Strings.Mid(IIf(lstrAgrupaRota <> "", lstrAgrupaRota, "000000000"), 5, 5) & vbCrLf
	'		lstrSql = lstrSql & ", `codbarra`   = '" & lstrCodBarra & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `dvcodbarra` = '" & lstrDvCBarra & "'" & vbCrLf
	'		lstrSql = lstrSql & ", `fatura_complementar` = " & CInt(IIf(IsNumeric(Me.txtNrFatComp.Text), Me.txtNrFatComp.Text, 0)) & vbCrLf
	'		If lblnExisteFatura Then
	'			lstrSql = lstrSql & " WHERE `numnf`   = " & idblNumNf & " " & vbCrLf
	'			lstrSql = lstrSql & "   AND `mesano`  = '" & Me.txtMesAno.Text & "' " & vbCrLf
	'		End If
	'		Call myConC.Execute(lstrSql)
	'		If Not lblnExisteFatura Then

	'If gstrEmpresa_Sigla.ToUpper() = "CERES" Then

	'If gstrEmpresa_UF.ToUpper() = "RJ" Then
	'			Call GravaConfig("ultimo.nr.fiscal.rj", Trim(Str(idblNumNf)))
	'ElseIf gstrEmpresa_UF.ToUpper() = "MG" Then
	'			Call GravaConfig("ultimo.nr.fiscal.mg", Trim(Str(idblNumNf)))
	'End If

	'Else
	'			Call GravaConfig("ultimo.nr.fiscal", Trim(Str(idblNumNf)))
	'End If


	'			If gstrEmpresa_UF = "SC" Then
	'				Call GravaConfig("ultimo.nr.nsu", Trim(Str(idblNsuNr)))
	'			End If

	'		End If
	'		Call myConC.Execute("COMMIT")
	'		Call MsgBox("Fatura de número " & idblNumNf & " gerada com sucesso.", MsgBoxStyle.Information, gstrTituloMensagem)
	'		Call Me.txtConta.Focus()
	'Erro_Grava_Fatura: 
	'		If myConC.Errors.Count > 0 Then
	'			Call MsgBox("Código: " & myConC.Errors.Item(myConC.Errors.Count - 1).NativeError & vbCrLf & "Descrição:" & myConC.Errors.Item(myConC.Errors.Count - 1).Description, MsgBoxStyle.Critical, gstrTituloMensagem)
	'			Call myConC.Execute("ROLLBACK")
	'			Call MsgBox("Não foi possível gravar a fatura, tente novamente", MsgBoxStyle.Information, gstrTituloMensagem)
	'		ElseIf Err.Number > 0 Then 
	'			Call MsgBox(Err.Number & " - " & GetErrosVB(Err.Number, Err.Description), MsgBoxStyle.Information, gstrTituloMensagem)
	'			Call myConC.Execute("ROLLBACK")
	'			Call MsgBox("Não foi possível gravar a fatura, tente novamente", MsgBoxStyle.Information, gstrTituloMensagem)
	'		End If
	'	End Sub

	'	Private Function BuscaNumeroFaturaTransicao(ByVal alngUnidId As Integer, ByRef adblNsu As Double, ByVal alngNrComplmentar As Integer) As Double
	'		Dim ldblRet As Double
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		ldblRet = 0
	'		adblNsu = 0
	'		Me.lblStatus.Text = " Aguarde localizando o número da fatura em faturamento..."
	'		Call Me.lblStatus.Refresh()
	'		lstrSql = ""
	'		lstrSql = lstrSql & "SELECT `numnf`, `mesano`, `unid_id`, `grupo`, `mesano_ref`, `nsu` "
	'		lstrSql = lstrSql & "  FROM `nftransicao` "
	'		lstrSql = lstrSql & " WHERE `mesano` = '" & Me.txtMesAno.Text & "' "
	'		lstrSql = lstrSql & "   AND `mesano_ref` = " & CInt(VB.Right(Me.txtMesAno.Text, 4) & VB.Left(Me.txtMesAno.Text, 2)) & " "
	'		lstrSql = lstrSql & "   AND `unid_id` = " & alngUnidId & " "
	'		lstrSql = lstrSql & "   AND `grupo` = '" & Me.txtGrupo.Text & "' "
	'		lstrSql = lstrSql & "   AND `fatura_complementar` = " & alngNrComplmentar
	'		lstrSql = lstrSql & " LIMIT 0, 1 "
	'		Call Conectar(lstrSql, 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"'
	'					ldblRet = CDbl(IIf(IsDbNull(.Fields("numnf").value), 0, .Fields("numnf").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"'
	'					adblNsu = CDbl(IIf(IsDbNull(.Fields("nsu").value), 0, .Fields("nsu").value))
	'				Else
	'					ldblRet = 0
	'					adblNsu = 0
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		'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
	'		Me.lblStatus.Text = ""
	'		Call Me.lblStatus.Refresh()
	'		BuscaNumeroFaturaTransicao = ldblRet
	'	End Function

	'	Private Function MontaReservadoFisico(ByVal adblTotalBaseIcms As Double, ByVal adblTotalValorIcms As Double) As String
	'		'********************************************* arrumar
	'		Dim lstrCodHash As String
	'		Dim lstrAuxHash As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		lstrAuxHash = ""
	'		lstrAuxHash = lstrAuxHash & PreparaCampo((Me.txtCpfCnpjUC.Text), NUMERICO, 14, "0")
	'		lstrAuxHash = lstrAuxHash & PreparaCampo(CStr(idblNumNf), NUMERICO, 9, "0")
	'		lstrAuxHash = lstrAuxHash & PreparaCampo(Str(CDbl(Replace(Replace(VB6.Format(CDbl(Me.lblTotal.Text), "#,##0.00"), ",", ""), ".", ""))), NUMERICO, 12, "0")
	'		lstrAuxHash = lstrAuxHash & PreparaCampo(Str(CDbl(Replace(Replace(VB6.Format(adblTotalBaseIcms, "#,##0.00"), ",", ""), ".", ""))), NUMERICO, 12, "0")
	'		lstrAuxHash = lstrAuxHash & PreparaCampo(Str(CDbl(Replace(Replace(VB6.Format(adblTotalValorIcms, "#,##0.00"), ",", ""), ".", ""))), NUMERICO, 12, "0")
	'		Call Conectar("SELECT CONVERT(MD5('" & lstrAuxHash & "') USING latin1) `hash`", 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"'
	'					lstrCodHash = Trim(IIf(IsDbNull(.Fields("hash").value), "", .Fields("hash").value))
	'				Else
	'					lstrCodHash = ""
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		MontaReservadoFisico = lstrCodHash
	'	End Function

	'	Private Function VerificaExisteFaturaArrecadacao(ByVal alngAnoMes As Integer, ByVal adblNumNf As Double, ByVal alngComplementar As Integer) As Boolean
	'		Dim lblnRetorno As Boolean
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		lblnRetorno = False
	'		Me.lblStatus.Text = " Aguarde validando se o número da fatura se encontra em arrecadação..."
	'		Call Me.lblStatus.Refresh()
	'		lstrSql = "SELECT * FROM `nf` WHERE `mesano_ref` = " & alngAnoMes & " AND `numnf` = " & adblNumNf & " AND `fatura_complementar` = " & alngComplementar
	'		Call Conectar(lstrSql, lrstAux)
	'		With lrstAux
	'			If .State = ADODB.ObjectStateEnum.adStateOpen Then
	'				If .RecordCount > 0 Then
	'					lblnRetorno = True
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		Me.lblStatus.Text = ""
	'		Call Me.lblStatus.Refresh()
	'		'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
	'		VerificaExisteFaturaArrecadacao = lblnRetorno
	'	End Function

	'	Private Sub TotalizaGrade()
	'		Dim llngRow As Integer
	'		Dim ldblTot As Double
	'		Me.lblTotal.Text = "0,00"
	'		ldblTot = 0
	'		With Me.mfgGradeItensFaturas
	'			For llngRow = 1 To .Rows - 1
	'				ldblTot = ldblTot + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0))
	'			Next 
	'		End With
	'		Me.lblTotal.Text = VB6.Format(ldblTot, "#,##0.00")
	'		Me.lblTotalLiq.Text = VB6.Format(ldblTot, "#,##0.00")
	'	End Sub

	'	Private Sub Grava_Dados_Informados()
	'		Dim lstrCri As String
	'		Dim lblnVer As Boolean
	'		Dim lstrSql As String
	'		Dim llngGCD As Integer
	'		Dim llngGCI As Integer

	'		Dim ldblId As Double 'Id da tabela de fatura_complementar_dados (ID único auto_increment)
	'		Dim llngId_Itens As Integer 'Id da tabela de fatura_complementar_dados_itens (ID único conforme a tabela mãe e o ano e mês de referencia)

	'		Dim llngAnoMesRef As Integer
	'		Dim llngComplementar As Integer
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		On Error GoTo Erro_Grava_Dados_Informados
	'		If Trim(Me.mfgGradeComplementaresDados.get_TextMatrix(1, 0)) <> "" Then
	'			With Me.mfgGradeComplementaresDados
	'				For llngGCD = 1 To .Rows - 1
	'					If Trim(.get_TextMatrix(llngGCD, 0)) <> "" Then
	'						ldblId = CDbl(IIf(IsNumeric(.get_TextMatrix(llngGCD, 0)), .get_TextMatrix(llngGCD, 0), 0))
	'						If ldblId > 0 Then
	'							Call myConC.Execute("DELETE FROM `fatura_complementar_dados_itens` WHERE `id_fatura_complementar_dados` = " & ldblId)
	'							Call myConC.Execute("ALTER TABLE `fatura_complementar_dados_itens` AUTO_INCREMENT = 1")
	'						End If
	'						llngAnoMesRef = CInt(IIf(IsNumeric(.get_TextMatrix(llngGCD, 10)), .get_TextMatrix(llngGCD, 10), 0))
	'						llngComplementar = CInt(IIf(IsNumeric(.get_TextMatrix(llngGCD, 2)), .get_TextMatrix(llngGCD, 2), 0))
	'						lblnVer = VerificaExisteRegistro("`fatura_complementar_dados`", "`id` = " & ldblId)
	'						If Not lblnVer Then
	'							lblnVer = VerificaExisteRegistro("`fatura_complementar_dados`", "`id` = " & ldblId)
	'						End If
	'						If lblnVer Then
	'							lstrSql = "UPDATE "
	'						Else
	'							lstrSql = "INSERT INTO "
	'						End If
	'						Call myConC.Execute("START TRANSACTION")
	'						lstrSql = lstrSql & "`fatura_complementar_dados` SET"
	'						lstrSql = lstrSql & "  `anomes` = " & CInt(IIf(IsNumeric(.get_TextMatrix(llngGCD, 1)), .get_TextMatrix(llngGCD, 1), 0))
	'						lstrSql = lstrSql & ", `fatura_complementar` = " & CInt(IIf(IsNumeric(.get_TextMatrix(llngGCD, 2)), .get_TextMatrix(llngGCD, 2), 0))
	'						lstrSql = lstrSql & ", `mesano` = '" & CStr(.get_TextMatrix(llngGCD, 3)) & "'"
	'						lstrSql = lstrSql & ", `grupo` = '" & Me.txtGrupo.Text & "'"
	'						lstrSql = lstrSql & ", `cons_id` = " & IIf(IsNumeric(Me.txtCons_Id.Text), Me.txtCons_Id.Text, 0)
	'						lstrSql = lstrSql & ", `unid_id` = " & IIf(IsNumeric(Me.txtUnid_Id.Text), Me.txtUnid_Id.Text, 0)
	'						lstrSql = lstrSql & ", `zona` = '" & Me.txtZona.Text & "'"
	'						lstrSql = lstrSql & ", `livro` = '" & Me.txtLivro.Text & "'"
	'						lstrSql = lstrSql & ", `conta` = '" & Me.txtConta.Text & "'"
	'						lstrSql = lstrSql & ", `dataem` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 4)), .get_TextMatrix(llngGCD, 4), idteBase), "yyyy-MM-dd") & "'"
	'						lstrSql = lstrSql & ", `dataapr` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 5)), .get_TextMatrix(llngGCD, 5), idteBase), "yyyy-MM-dd") & "'"
	'						lstrSql = lstrSql & ", `dataleit` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 6)), .get_TextMatrix(llngGCD, 6), idteBase), "yyyy-MM-dd") & "'"
	'						lstrSql = lstrSql & ", `dataleitant` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 7)), .get_TextMatrix(llngGCD, 7), idteBase), "yyyy-MM-dd") & "'"
	'						lstrSql = lstrSql & ", `dataproxleit` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 8)), .get_TextMatrix(llngGCD, 8), idteBase), "yyyy-MM-dd") & "'"
	'						lstrSql = lstrSql & ", `datavenc` = '" & VB6.Format(IIf(IsDate(.get_TextMatrix(llngGCD, 9)), .get_TextMatrix(llngGCD, 9), idteBase), "yyyy-MM-dd") & "'"
	'						If lblnVer Then
	'							lstrSql = lstrSql & " WHERE `id` = " & ldblId
	'						End If
	'						Call Executar(lstrSql)
	'						If Not lblnVer 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"'
	'										ldblId = CDbl(IIf(IsDbNull(.Fields(0).value), 0, .Fields(0).value))
	'									End If
	'									Call .Close()
	'								End If
	'							End With
	'						End If
	'						'
	'						With Me.mfgGradeComplementaresItens
	'							For llngGCI = 1 To .Rows - 1
	'								If Trim(.get_TextMatrix(llngGCI, 0)) <> "" Then
	'									If CInt(IIf(IsNumeric(.get_TextMatrix(llngGCI, 1)), .get_TextMatrix(llngGCI, 1), 0)) = llngComplementar And CInt(IIf(IsNumeric(.get_TextMatrix(llngGCI, 2)), .get_TextMatrix(llngGCI, 2), 0)) = llngAnoMesRef Then
	'										lstrSql = "INSERT INTO `fatura_complementar_dados_itens` SET" & "  `anomes_ref` = " & llngAnoMesRef & ", `id_fatura_complementar_dados` = " & ldblId & ", `id_codigo` = '" & CStr(.get_TextMatrix(llngGCI, 4)) & "'" & ", `valor` = " & Replace(CStr(CDbl(IIf(IsNumeric(.get_TextMatrix(llngGCI, 5)), .get_TextMatrix(llngGCI, 5), 0))), ",", ".")
	'										Call myConC.Execute(lstrSql)
	'									End If
	'								End If
	'							Next llngGCI
	'						End With
	'					End If
	'				Next llngGCD
	'			End With
	'			Call myConC.Execute("COMMIT")
	'			Call MsgBox("Dados gravados com sucesso.", MsgBoxStyle.Information, gstrTituloMensagem)
	'		Else
	'			Call MsgBox("Para salvar os dados é necessário informar e adcionar!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
	'		End If
	'Erro_Grava_Dados_Informados: 
	'		If myConC.Errors.Count > 0 Then
	'			Call MsgBox("Código: " & myConC.Errors.Item(myConC.Errors.Count - 1).NativeError & vbCrLf & "Descrição:" & myConC.Errors.Item(myConC.Errors.Count - 1).Description, MsgBoxStyle.Critical, gstrTituloMensagem)
	'			Call myConC.Execute("ROLLBACK")
	'			Call MsgBox("Não foi possível gravar os dados informados, tente novamente", MsgBoxStyle.Information, gstrTituloMensagem)
	'		ElseIf Err.Number > 0 Then 
	'			Call MsgBox(Err.Number & " - " & GetErrosVB(Err.Number, Err.Description), MsgBoxStyle.Information, gstrTituloMensagem)
	'			Call myConC.Execute("ROLLBACK")
	'			Call MsgBox("Não foi possível gravar os dados informados, tente novamente", MsgBoxStyle.Information, 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 Preenche_Campos_Valores_Complementares(ByVal astrCodigo As String, ByVal adblValor As Double)

	'		If astrCodigo = Me.txtTabCod_IdBaseIcms1.Text Then
	'			Me.txtVlrBaseIcms1_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrBaseIcms1_Nova, txtVlrBaseIcms1_Anterior, txtVlrBaseIcms1)

	'		ElseIf astrCodigo = Me.txtTabCod_IdBaseIcms2.Text Then 
	'			Me.txtVlrBaseIcms2_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrBaseIcms2_Nova, txtVlrBaseIcms2_Anterior, txtVlrBaseIcms2)

	'		ElseIf astrCodigo = Me.txtTabCod_IdBasePis.Text Then 
	'			Me.txtVlrBasePis_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrBasePis_Nova, txtVlrBasePis_Anterior, txtVlrBasePis)

	'		ElseIf astrCodigo = Me.txtTabCod_IdBaseCofins.Text Then 
	'			Me.txtVlrBaseCofins_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrBaseCofins_Nova, txtVlrBaseCofins_Anterior, txtVlrBaseCofins)

	'		ElseIf astrCodigo = Me.txtTabCod_IdVlrIcms1.Text Then 
	'			Me.txtVlrIcms1_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrIcms1_Nova, txtVlrIcms1_Anterior, txtVlrIcms1)

	'		ElseIf astrCodigo = Me.txtTabCod_IdVlrIcms2.Text Then 
	'			Me.txtVlrIcms2_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrIcms2_Nova, txtVlrIcms2_Anterior, txtVlrIcms2)

	'		ElseIf astrCodigo = Me.txtTabCod_IdVlrPis.Text Then 
	'			Me.txtVlrPis_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrPis_Nova, txtVlrPis_Anterior, txtVlrPis)

	'		ElseIf astrCodigo = Me.txtTabCod_IdVlrCofins.Text Then 
	'			Me.txtVlrCofins_Nova.Text = VB6.Format(adblValor, "#,##0.00")
	'			Call Calcula_Campo_Diferenca(txtVlrCofins_Nova, txtVlrCofins_Anterior, txtVlrCofins)

	'		End If
	'	End Sub

	'	Private Sub Monta_mfgGradeComplementaresDados()
	'		With Me.mfgGradeComplementaresDados
	'			.Redraw = False
	'			Call .Clear()
	'			.set_Cols( , 11)
	'			.Rows = 2
	'			.FixedRows = 1
	'			'
	'			.set_TextMatrix(0, 0, "Id")
	'			.set_TextMatrix(0, 1, "Ano/Mês")
	'			.set_TextMatrix(0, 2, "Complementar")
	'			.set_TextMatrix(0, 3, "Mês/Ano")
	'			.set_TextMatrix(0, 4, "Faturamento")
	'			.set_TextMatrix(0, 5, "Apresentação")
	'			.set_TextMatrix(0, 6, "L.Atual")
	'			.set_TextMatrix(0, 7, "L.Anterior")
	'			.set_TextMatrix(0, 8, "L.Próxima")
	'			.set_TextMatrix(0, 9, "Vencimento")
	'			.set_TextMatrix(0, 10, "Ref.")
	'			.set_ColWidth(0,  , 0)
	'			.set_ColWidth(1,  , 0)
	'			.set_ColWidth(2,  , 0)
	'			.set_ColAlignment(3, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(4, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(5, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(6, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(7, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(8, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(9, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(10, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColWidth(4,  , 1100)
	'			.set_ColWidth(5,  , 1100)
	'			.set_ColWidth(6,  , 1100)
	'			.set_ColWidth(7,  , 1100)
	'			.set_ColWidth(8,  , 1100)
	'			.set_ColWidth(9,  , 1100)
	'			.set_ColWidth(10,  , 700)
	'			.Redraw = True
	'		End With

	'		With Me.mfgGradeComplementaresItens
	'			.Redraw = False
	'			Call .Clear()
	'			.set_Cols( , 6)
	'			.Rows = 2
	'			.FixedRows = 1
	'			'
	'			.set_TextMatrix(0, 0, "Id")
	'			.set_TextMatrix(0, 1, "Complementar")
	'			.set_TextMatrix(0, 2, "Ano/Mês Ref")
	'			.set_TextMatrix(0, 3, "Id Itens")
	'			.set_TextMatrix(0, 4, "Código")
	'			.set_TextMatrix(0, 5, "Valor")
	'			.Redraw = True
	'		End With
	'	End Sub

	'	Private Sub Monta_mfgGradeItensFaturas()
	'		With Me.mfgGradeItensFaturas
	'			.Redraw = False
	'			Call .Clear()
	'			.set_Cols( , 6)
	'			.Rows = 2
	'			.FixedRows = 1
	'			'
	'			.set_TextMatrix(0, 0, "Mês/Ano")
	'			.set_TextMatrix(0, 1, "Código")
	'			.set_TextMatrix(0, 2, "Descrição")
	'			.set_TextMatrix(0, 3, "Qtde")
	'			.set_TextMatrix(0, 4, "Valor")
	'			.set_TextMatrix(0, 5, "Referencia")
	'			'
	'			.set_ColWidth(0,  , 800)
	'			.set_ColWidth(1,  , 1000)
	'			.set_ColWidth(2,  , 5000)
	'			.set_ColWidth(3,  , 1480)
	'			.set_ColWidth(4,  , 1480)
	'			.set_ColWidth(5,  , 4000)
	'			'
	'			.set_ColAlignment(0, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(1, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(2, MSFlexGridLib.AlignmentSettings.flexAlignLeftCenter)
	'			.set_ColAlignment(3, MSFlexGridLib.AlignmentSettings.flexAlignRightCenter)
	'			.set_ColAlignment(4, MSFlexGridLib.AlignmentSettings.flexAlignRightCenter)
	'			.set_ColAlignment(5, MSFlexGridLib.AlignmentSettings.flexAlignLeftCenter)
	'			.Redraw = True
	'		End With

	'		With Me.mfgGradeItensFaturados
	'			.Redraw = False
	'			Call .Clear()
	'			.set_Cols( , 3)
	'			.Rows = 2
	'			.FixedRows = 1
	'			'
	'			.set_TextMatrix(0, 0, "Mês/Ano")
	'			.set_TextMatrix(0, 1, "Código")
	'			.set_TextMatrix(0, 2, "Valor")
	'			'
	'			.set_ColWidth(0,  , 800)
	'			.set_ColWidth(1,  , 1000)
	'			.set_ColWidth(2,  , 1480)
	'			'
	'			.set_ColAlignment(0, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(1, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
	'			.set_ColAlignment(2, MSFlexGridLib.AlignmentSettings.flexAlignRightCenter)
	'			.Redraw = True
	'		End With


	'	End Sub

	'	Private Sub Adiciona_mfgGradeItensFaturas(ByVal astrMesAno As String, ByVal astrCodigo As String, ByVal adblQtde As Double, ByVal aintQtde_CasasDecimais As Short, ByVal adblValor As Double, ByVal aintValor_CasasDecimais As Short, ByVal astrReferencia As String)
	'		Dim lblnAux As Boolean
	'		Dim llngRow As Integer
	'		Dim llngAux As Integer
	'		If adblValor <> 0 Then
	'			'Procura se existe antes de inserir
	'			lblnAux = False
	'			With Me.mfgGradeItensFaturas
	'				llngRow = .Rows - 1
	'				For llngAux = 1 To .Rows - 1
	'					If .get_TextMatrix(llngAux, 0) = astrMesAno And .get_TextMatrix(llngAux, 1) = astrCodigo Then
	'						llngRow = llngAux
	'						lblnAux = True
	'						llngAux = .Rows - 1
	'					End If
	'				Next llngAux
	'				.set_TextMatrix(llngRow, 0, astrMesAno)
	'				.set_TextMatrix(llngRow, 1, astrCodigo)
	'				.set_TextMatrix(llngRow, 2, BuscaDescricaoCodido(astrCodigo))
	'				.set_TextMatrix(llngRow, 3, VB6.Format(adblQtde, "#," & New String("#", aintQtde_CasasDecimais) & "0." & New String("0", aintQtde_CasasDecimais)))
	'				.set_TextMatrix(llngRow, 4, VB6.Format(adblValor, "#," & New String("#", aintValor_CasasDecimais) & "0." & New String("0", aintValor_CasasDecimais)))
	'				.set_TextMatrix(llngRow, 5, astrReferencia)
	'				If Not lblnAux Then .Rows = .Rows + 1
	'			End With
	'		End If
	'	End Sub

	'	Private Sub Adiciona_mfgGradeItensFaturados(ByVal astrMesAno As String, ByVal astrCodigo As String, ByVal adblValor As Double, ByVal aintValor_CasasDecimais As Short)
	'		Dim lblnAux As Boolean
	'		Dim llngRow As Integer
	'		Dim llngAux As Integer
	'		If adblValor <> 0 Then
	'			'Procura se existe antes de inserir
	'			lblnAux = False
	'			With Me.mfgGradeItensFaturados
	'				llngRow = .Rows - 1
	'				For llngAux = 1 To .Rows - 1
	'					If .get_TextMatrix(llngAux, 0) = astrMesAno And .get_TextMatrix(llngAux, 1) = astrCodigo Then
	'						llngRow = llngAux
	'						lblnAux = True
	'						llngAux = .Rows - 1
	'					End If
	'				Next llngAux
	'				.set_TextMatrix(llngRow, 0, astrMesAno)
	'				.set_TextMatrix(llngRow, 1, astrCodigo)
	'				.set_TextMatrix(llngRow, 2, VB6.Format(adblValor, "#," & New String("#", aintValor_CasasDecimais) & "0." & New String("0", aintValor_CasasDecimais)))
	'				If Not lblnAux Then .Rows = .Rows + 1
	'			End With
	'		End If
	'	End Sub

	'	Private Sub Adiciona_mfgGradeComplementaresDados(ByVal adblId As Double, ByVal alngAnoMes As Integer, ByVal alngComplementar As Integer, ByVal astrMesAno As String, ByVal adteEmissao As Date, ByVal adteApresentacao As Date, ByVal adteLeitura_Atual As Date, ByVal adteLeitura_Anterior As Date, ByVal adtePróxima_Leitura As Date, ByVal adteVencimento As Date, ByVal alngAnoMesRef As Integer)
	'		Dim lblnAux As Boolean
	'		Dim llngRow As Integer
	'		Dim llngAux As Integer
	'		'Procura se existe antes de inserir
	'		lblnAux = False
	'		With Me.mfgGradeComplementaresDados
	'			.Redraw = False
	'			llngRow = .Rows - 1
	'			For llngAux = 1 To .Rows - 1
	'				If CInt(IIf(IsNumeric(.get_TextMatrix(llngAux, 1)), .get_TextMatrix(llngAux, 1), 0)) = alngAnoMes And CInt(IIf(IsNumeric(.get_TextMatrix(llngAux, 10)), .get_TextMatrix(llngAux, 10), 0)) = alngAnoMesRef Then
	'					llngRow = llngAux
	'					lblnAux = True
	'					llngAux = .Rows - 1
	'				End If
	'			Next llngAux
	'			.set_TextMatrix(llngRow, 0, adblId)
	'			.set_TextMatrix(llngRow, 1, alngAnoMes)
	'			.set_TextMatrix(llngRow, 2, alngComplementar)
	'			.set_TextMatrix(llngRow, 3, astrMesAno)
	'			.set_TextMatrix(llngRow, 4, VB6.Format(adteEmissao, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 5, VB6.Format(adteApresentacao, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 6, VB6.Format(adteLeitura_Atual, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 7, VB6.Format(adteLeitura_Anterior, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 8, VB6.Format(adtePróxima_Leitura, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 9, VB6.Format(adteVencimento, "dd/MM/yyyy"))
	'			.set_TextMatrix(llngRow, 10, alngAnoMesRef)
	'			'
	'			If Not lblnAux Then .Rows = .Rows + 1
	'			.Redraw = True
	'		End With
	'	End Sub

	'	Private Sub Adiciona_mfgGradeComplementaresItens(ByVal adblId As Double, ByVal alngComplementar As Integer, ByVal alngAnoMesRef As Integer, ByVal alngIdItens As Integer, ByVal astrId_Codigo As String, ByVal adblValor As Double)
	'		Dim lblnAux As Boolean
	'		Dim llngRow As Integer
	'		Dim llngAux As Integer
	'		If adblValor <> 0 Then
	'			'Procura se existe antes de inserir
	'			lblnAux = False
	'			With Me.mfgGradeComplementaresItens
	'				.Redraw = False
	'				llngRow = .Rows - 1
	'				For llngAux = 1 To .Rows - 1
	'					If CStr(.get_TextMatrix(llngAux, 4)) = astrId_Codigo And CInt(IIf(IsNumeric(.get_TextMatrix(llngAux, 1)), .get_TextMatrix(llngAux, 1), 0)) = alngComplementar And CInt(IIf(IsNumeric(.get_TextMatrix(llngAux, 2)), .get_TextMatrix(llngAux, 2), 0)) = alngAnoMesRef Then
	'						llngRow = llngAux
	'						lblnAux = True
	'						llngAux = .Rows - 1
	'					End If
	'				Next llngAux
	'				.set_TextMatrix(llngRow, 0, adblId)
	'				.set_TextMatrix(llngRow, 1, alngComplementar)
	'				.set_TextMatrix(llngRow, 2, alngAnoMesRef)
	'				If alngIdItens > 0 Then
	'					.set_TextMatrix(llngRow, 3, alngIdItens)
	'				ElseIf CInt(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0)) = 0 Then 
	'					If llngRow = 1 Then
	'						.set_TextMatrix(llngRow, 3, CInt(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0)) + 1)
	'					Else
	'						If CInt(IIf(IsNumeric(.get_TextMatrix(llngRow - 1, 2)), .get_TextMatrix(llngRow - 1, 2), 0)) = alngAnoMesRef Then
	'							.set_TextMatrix(llngRow, 3, CInt(IIf(IsNumeric(.get_TextMatrix(llngRow - 1, 3)), .get_TextMatrix(llngRow - 1, 3), 0)) + 1)
	'						Else
	'							.set_TextMatrix(llngRow, 3, CInt(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0)) + 1)
	'						End If
	'					End If
	'				End If
	'				.set_TextMatrix(llngRow, 4, astrId_Codigo)
	'				.set_TextMatrix(llngRow, 5, adblValor)
	'				If Not lblnAux Then .Rows = .Rows + 1
	'				.Redraw = True
	'			End With
	'		End If
	'	End Sub

	'	Private Sub Enche_mfgGradeComplementaresDados(ByVal alngAnoMes As Integer, ByVal alngFaturaComplementa As Integer, ByVal astrGrupo As String, ByVal alngCons_Id As Integer, ByVal alngUnid_Id As Integer)
	'		Dim llngAnoMesRef As Integer
	'		Dim llngAnoMesRef_X As Integer
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		lstrSql = "SELECT "
	'		lstrSql = lstrSql & "  `fcd`.`id`"
	'		lstrSql = lstrSql & ", `fcd`.`anomes`"
	'		lstrSql = lstrSql & ", `fcd`.`fatura_complementar`"
	'		lstrSql = lstrSql & ", `fcd`.`mesano`"
	'		lstrSql = lstrSql & ", `fcd`.`dataem`"
	'		lstrSql = lstrSql & ", `fcd`.`dataapr`"
	'		lstrSql = lstrSql & ", `fcd`.`dataleit`"
	'		lstrSql = lstrSql & ", `fcd`.`dataleitant`"
	'		lstrSql = lstrSql & ", `fcd`.`dataproxleit`"
	'		lstrSql = lstrSql & ", `fcd`.`datavenc`"
	'		lstrSql = lstrSql & ", `fci`.`id` `id_tens`"
	'		lstrSql = lstrSql & ", `fci`.`anomes_ref`"
	'		lstrSql = lstrSql & ", `fci`.`id_codigo`"
	'		lstrSql = lstrSql & ", `fci`.`valor`"
	'		lstrSql = lstrSql & "  FROM `fatura_complementar_dados` `fcd`, `fatura_complementar_dados_itens` `fci`"
	'		lstrSql = lstrSql & " WHERE `fci`.`id_fatura_complementar_dados` = `fcd`.`id`"
	'		lstrSql = lstrSql & "   AND `fcd`.`anomes` = " & alngAnoMes
	'		lstrSql = lstrSql & "   AND `fcd`.`fatura_complementar` = " & alngFaturaComplementa
	'		lstrSql = lstrSql & "   AND `fcd`.`grupo` = '" & astrGrupo & "'"
	'		lstrSql = lstrSql & "   AND `fcd`.`cons_id` = " & alngCons_Id
	'		lstrSql = lstrSql & "   AND `fcd`.`unid_id` = " & alngUnid_Id
	'		lstrSql = lstrSql & " ORDER BY `fci`.`anomes_ref` ASC, `fci`.`id` ASC "
	'		Call Conectar(lstrSql, lrstAux)
	'		With lrstAux
	'			If .State = ADODB.ObjectStateEnum.adStateOpen Then
	'				If .RecordCount > 0 Then
	'					llngAnoMesRef_X = 0
	'					While Not .EOF
	'						'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"'
	'						llngAnoMesRef = CInt(IIf(IsDbNull(.Fields("anomes_ref").value), 0, .Fields("anomes_ref").value))
	'						If llngAnoMesRef_X <> llngAnoMesRef 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"'
	'							Call Adiciona_mfgGradeComplementaresDados(CDbl(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), CInt(IIf(IsDbNull(.Fields("anomes").value), 0, .Fields("anomes").value)), CInt(IIf(IsDbNull(.Fields("fatura_complementar").value), 0, .Fields("fatura_complementar").value)), CStr(IIf(IsDbNull(.Fields("mesano").value), "", .Fields("mesano").value)), CDate(IIf(IsDbNull(.Fields("dataem").value), idteBase, .Fields("dataem").value)), CDate(IIf(IsDbNull(.Fields("dataapr").value), idteBase, .Fields("dataapr").value)), CDate(IIf(IsDbNull(.Fields("dataleit").value), idteBase, .Fields("dataleit").value)), CDate(IIf(IsDbNull(.Fields("dataleitant").value), idteBase, .Fields("dataleitant").value)), CDate(IIf(IsDbNull(.Fields("dataproxleit").value), idteBase, .Fields("dataproxleit").value)), CDate(IIf(IsDbNull(.Fields("datavenc").value), idteBase, .Fields("datavenc").value)), CInt(IIf(IsDbNull(.Fields("anomes_ref").value), 0, .Fields("anomes_ref").value)))
	'							llngAnoMesRef_X = llngAnoMesRef
	'						End If
	'						'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"'
	'						Call Adiciona_mfgGradeComplementaresItens(CDbl(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value)), CInt(IIf(IsDbNull(.Fields("fatura_complementar").value), 0, .Fields("fatura_complementar").value)), CInt(IIf(IsDbNull(.Fields("anomes_ref").value), 0, .Fields("anomes_ref").value)), CDbl(IIf(IsDbNull(.Fields("id_tens").value), 0, .Fields("id_tens").value)), CStr(IIf(IsDbNull(.Fields("id_codigo").value), "", .Fields("id_codigo").value)), CDbl(IIf(IsDbNull(.Fields("valor").value), 0, .Fields("valor").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"'
	'						Call Preenche_Campos_Valores_Complementares(CStr(IIf(IsDbNull(.Fields("id_codigo").value), "", .Fields("id_codigo").value)), CDbl(IIf(IsDbNull(.Fields("valor").value), 0, .Fields("valor").value)))
	'						Call .MoveNext()
	'					End While
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		'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 Inicializa_Referencia(ByVal alngRow As Integer)
	'		Dim llngRow As Integer
	'		Dim llngAux As Integer
	'		With Me.mfgGradeComplementaresDados
	'			Me.txtId_Fatura_Complementar_Dados.Text = CStr(CDbl(IIf(IsNumeric(.get_TextMatrix(alngRow, 0)), .get_TextMatrix(alngRow, 0), 0)))
	'			Me.txtDt_Faturamento.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 4)), .get_TextMatrix(alngRow, 4), idteBase)), "dd/MM/yyyy")
	'			Me.txtDt_Apresenta.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 5)), .get_TextMatrix(alngRow, 5), idteBase)), "dd/MM/yyyy")
	'			Me.txtDt_Vencto.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 9)), .get_TextMatrix(alngRow, 9), idteBase)), "dd/MM/yyyy")
	'			Me.txtDt_Leit_Atual.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 6)), .get_TextMatrix(alngRow, 6), idteBase)), "dd/MM/yyyy")
	'			Me.txtDt_Leit_Anterior.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 7)), .get_TextMatrix(alngRow, 7), idteBase)), "dd/MM/yyyy")
	'			Me.txtDt_Prox_Leit.Text = VB6.Format(CDate(IIf(IsDate(.get_TextMatrix(alngRow, 8)), .get_TextMatrix(alngRow, 8), idteBase)), "dd/MM/yyyy")
	'			llngAux = CInt(IIf(IsNumeric(.get_TextMatrix(alngRow, 10)), .get_TextMatrix(alngRow, 10), 10))
	'			Me.txtMesAnoRef.Text = CStr(CInt(IIf(IsNumeric(.get_TextMatrix(alngRow, 10)), .get_TextMatrix(alngRow, 10), 10)))
	'			Me.txtMesAnoRef.Text = VB.Right(Me.txtMesAnoRef.Text, 2) & "/" & VB.Left(Me.txtMesAnoRef.Text, 4)
	'		End With
	'		Call Localiza_Dados_Faturamento()
	'		With Me.mfgGradeComplementaresItens
	'			For llngRow = 1 To .Rows - 1
	'				If CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 0)), .get_TextMatrix(llngRow, 0), 0)) = CDbl(Me.txtId_Fatura_Complementar_Dados.Text) Then
	'					Call Preenche_Campos_Valores_Complementares(CStr(.get_TextMatrix(llngRow, 4)), CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0)))
	'				End If
	'			Next llngRow
	'		End With

	'	End Sub

	'	Private Sub Configura_Codigos()
	'		Me.txtTabCod_IdBaseIcms1.Text = "0302030001"
	'		Me.txtTabCod_IdBaseIcms2.Text = "0302030003"
	'		Me.txtTabCod_IdBasePis.Text = "0302020033"
	'		Me.txtTabCod_IdBaseCofins.Text = "0302020034"
	'		Me.txtTabCod_IdVlrIcms1.Text = "0302030009"
	'		Me.txtTabCod_IdVlrIcms2.Text = "0302030010"
	'		Me.txtTabCod_IdVlrPis.Text = "0302020029"
	'		Me.txtTabCod_IdVlrCofins.Text = "0302020030"
	'		If Me.opbGrupoA.Checked Then
	'			Me.txtTabCod_IdAliqIcms1.Text = "0302030002"
	'			Me.txtTabCod_IdAliqIcms2.Text = "0302030013"
	'			Me.txtTabCod_IdAliqPis.Text = "40PIS00001"
	'			Me.txtTabCod_IdAliqCofins.Text = "40COF00001"
	'		Else
	'			Me.txtTabCod_IdAliqIcms1.Text = "0302030002"
	'			Me.txtTabCod_IdAliqIcms2.Text = "0302030013"
	'			Me.txtTabCod_IdAliqPis.Text = "0302990303"
	'			Me.txtTabCod_IdAliqCofins.Text = "0302990304"
	'		End If
	'		Call Reinicializa_Tela()
	'	End Sub

	'	Private Sub Limpa_Campos()

	'		Me.txtVlrBaseIcms1_Nova.Text = "0,00"
	'		Me.txtVlrBaseIcms2_Nova.Text = "0,00"
	'		Me.txtVlrBasePis_Nova.Text = "0,00"
	'		Me.txtVlrBaseCofins_Nova.Text = "0,00"

	'		Me.txtVlrBaseIcms1_Anterior.Text = "0,00"
	'		Me.txtVlrBaseIcms2_Anterior.Text = "0,00"
	'		Me.txtVlrBasePis_Anterior.Text = "0,00"
	'		Me.txtVlrBaseCofins_Anterior.Text = "0,00"

	'		Me.txtVlrBaseIcms1.Text = "0,00"
	'		Me.txtVlrBaseIcms2.Text = "0,00"
	'		Me.txtVlrBasePis.Text = "0,00"
	'		Me.txtVlrBaseCofins.Text = "0,00"

	'		Me.txtVlrIcms1_Nova.Text = "0,00"
	'		Me.txtVlrIcms2_Nova.Text = "0,00"
	'		Me.txtVlrPis_Nova.Text = "0,00"
	'		Me.txtVlrCofins_Nova.Text = "0,00"

	'		Me.txtVlrIcms1_Anterior.Text = "0,00"
	'		Me.txtVlrIcms2_Anterior.Text = "0,00"
	'		Me.txtVlrPis_Anterior.Text = "0,00"
	'		Me.txtVlrCofins_Anterior.Text = "0,00"

	'		Me.txtVlrIcms1.Text = "0,00"
	'		Me.txtVlrIcms2.Text = "0,00"
	'		Me.txtVlrPis.Text = "0,00"
	'		Me.txtVlrCofins.Text = "0,00"

	'		Me.txtRefIcms1.Text = ""
	'		Me.txtRefIcms2.Text = ""
	'		Me.txtRefPis.Text = ""
	'		Me.txtRefCofins.Text = ""

	'		Me.txtVlrAliquotaIcms1.Text = "0,00"
	'		Me.txtVlrAliquotaIcms2.Text = "0,00"
	'		Me.txtVlrAliquotaPis.Text = "0,00"
	'		Me.txtVlrAliquotaCofins.Text = "0,00"

	'	End Sub

	'	Private Sub Reinicializa_Tela()
	'		Call Limpa_Campos_UC()
	'		Me.txtNrFatComp.Text = "0"
	'		Me.txtNumNf.Text = ""
	'		Call Monta_mfgGradeComplementaresDados()
	'		Me.txtMesAnoRef.Text = ""
	'		Me.txtId_Fatura_Complementar_Dados.Text = ""
	'		Me.txtDt_Faturamento.Text = ""
	'		Me.txtDt_Apresenta.Text = ""
	'		Me.txtDt_Leit_Atual.Text = ""
	'		Me.txtDt_Leit_Anterior.Text = ""
	'		Me.txtDt_Prox_Leit.Text = ""
	'		Me.txtDt_Vencto.Text = ""
	'		Call Limpa_Campos()
	'		Call Monta_mfgGradeItensFaturas()
	'		Me.lblTotal.Text = "0,00"
	'		Me.lblTotalLiq.Text = "0,00"
	'	End Sub

	'	Private Sub Limpa_Campos_UC()
	'		Me.txtNome.Text = ""
	'		Me.txtGrupo.Text = ""
	'		Me.txtTA.Text = ""
	'		Me.txtRota.Text = ""
	'		Me.txtSituacao.Text = ""
	'		Me.txtCons_Id.Text = ""
	'		Me.txtUnid_Id.Text = ""
	'		Me.txtRegiao.Text = ""
	'		Me.txtFase.Text = ""
	'		Me.txtTensao.Text = ""
	'		Me.txtCfop.Text = ""
	'		Me.txtIdClasse.Text = ""
	'		Me.txtDescrClasse.Text = ""
	'		Me.txtCpfCnpjC.Text = ""
	'		Me.txtIdBanco.Text = ""
	'		Me.txtDesBanco.Text = ""
	'		Me.txtBancoAgencia.Text = ""
	'		Me.txtBancoCC.Text = ""
	'		Me.txtCpfCnpjUC.Text = ""
	'		Me.chkaliquota_diferenciada.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkencargos.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkicms_demanda_isenta.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkicms_demanda_lida.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkicms_diferido.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkirrigacao_aquicultura.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkisento_icms.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkisento_icms_tusd.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkisento_iluminacao.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkisento_reativo.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkleitura_demanda.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkleitura_reativo.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chklivre_leitura_consumo.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chklivre_verde.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chklivre_especial.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkmicro_geracao.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkparcialmente_cativo.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkqh.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chktarifa_branca.CheckState = System.Windows.Forms.CheckState.Unchecked
	'		Me.chkvencimento_proximo_mes.CheckState = System.Windows.Forms.CheckState.Unchecked
	'	End Sub

	'	Public Sub SetaCodigoRetornoPesquisa(ByVal adblNumNf As Double, ByVal adblNsuNr As Double, ByVal alngNrComp As Integer)
	'		Me.txtNumNf.Text = CStr(adblNumNf)
	'		Me.txtNrFatComp.Text = CStr(alngNrComp)
	'		idblNumNf = adblNumNf
	'		idblNsuNr = adblNsuNr
	'		Call Me.txtNrFatComp.Focus()
	'	End Sub

	'	Private Function RetornaNrFatComp(ByVal alngAnoMes As Integer, ByVal astrGrupo As String, ByVal alngUnidId As Integer) As Double
	'		Dim ldblRet As Double
	'		Dim lstrSql As String
	'		Dim lrstAux As ADODB.Recordset
	'		lrstAux = New ADODB.Recordset
	'		ldblRet = 1
	'		lstrSql = "SELECT MAX(`fatura_complementar`) `fatura_complementar` FROM `fatura_complementar_dados` WHERE "
	'		lstrSql = lstrSql & " `anomes` = " & alngAnoMes & " AND "
	'		lstrSql = lstrSql & " `grupo` = '" & astrGrupo & "' AND "
	'		lstrSql = lstrSql & " `unid_id` = " & alngUnidId
	'		Call Conectar(lstrSql, 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"'
	'					ldblRet = IIf(IsDbNull(.Fields("fatura_complementar").value), 0, .Fields("fatura_complementar").value) + 1
	'				End If
	'				Call .Close()
	'			End If
	'		End With
	'		RetornaNrFatComp = ldblRet
	'		'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 Function

	'	Private Sub AtualizaCampoVlrBasePisCofins_Nova()
	'		If CDbl(IIf(IsNumeric(Me.txtVlrBasePis_Nova.Text), Me.txtVlrBasePis_Nova.Text, 0)) = 0 Then
	'			Me.txtVlrBasePis_Nova.Text = VB6.Format(CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1_Nova.Text), Me.txtVlrBaseIcms1_Nova.Text, 0)) + CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2_Nova.Text), Me.txtVlrBaseIcms2_Nova.Text, 0)), "#,##0.00")
	'		End If
	'		If CDbl(IIf(IsNumeric(Me.txtVlrBaseCofins_Nova.Text), Me.txtVlrBaseCofins_Nova.Text, 0)) = 0 Then
	'			Me.txtVlrBaseCofins_Nova.Text = VB6.Format(CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms1_Nova.Text), Me.txtVlrBaseIcms1_Nova.Text, 0)) + CDbl(IIf(IsNumeric(Me.txtVlrBaseIcms2_Nova.Text), Me.txtVlrBaseIcms2_Nova.Text, 0)), "#,##0.00")
	'		End If
	'	End Sub
End Class