Option Strict Off
Option Explicit On

Imports fatd_faturamento.BLL.Repositorio
Imports fatd_faturamento.ENTIDADE

Friend Class frmCadastroComposicaoTarifa
    Inherits System.Windows.Forms.Form
    Dim vPrepararFlexGrid As Boolean
    Dim vResp As Short
    'Private ifrmQuemChama As System.Windows.Forms.Form
    ' Private iblnMontaGrade As Boolean

#Region "Propriedades"

    Private Sub frmCadComposicaoTarifa_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load

        Try

            Me.cmbData.SelectedIndex = -1
            Me.txtDescricao.Text = String.Empty
            PrepararFlexGrid()
            PreencheCombobox()

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub cmbData_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles cmbData.KeyPress

        Dim KeyAscii As Short = Asc(eventArgs.KeyChar)

        Try

            If KeyAscii = System.Windows.Forms.Keys.Return Then
                TabEnter(KeyAscii, eventArgs)
            ElseIf 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.Help Then
                    KeyAscii = 0
                End If
            End If

            eventArgs.KeyChar = Chr(KeyAscii)

            If KeyAscii = 0 Then
                eventArgs.Handled = True
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub cmbData_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbData.Leave

        Try

            With Me.cmbData
                .Text = FData(.Text)
                If CShort(Len(.Text)) > 0 Then
                    If Not IsDate(.Text) Then
                        MessageBox.Show("O valor informado não é uma data válida!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        .Text = String.Empty
                    End If
                Else
                    If .SelectedIndex > 0 Then
                        .SelectedIndex = 0
                    End If
                End If
            End With

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub mfgDados_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mfgDados.ClickEvent

        Try
            mfgDados_EnterCell(mfgDados, New System.EventArgs())
        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub mfgDados_EnterCell(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mfgDados.EnterCell

        Try

            If vPrepararFlexGrid Then
                With Me.mfgDados
                    Me.txtPercentual.SetBounds(VB6.TwipsToPixelsX(.CellLeft + VB6.PixelsToTwipsX(.Left)), VB6.TwipsToPixelsY(.CellTop + VB6.PixelsToTwipsY(.Top)), VB6.TwipsToPixelsX(.CellWidth), VB6.TwipsToPixelsY(.CellHeight))
                    Me.txtPercentual.Visible = True
                    Me.txtPercentual.Focus()
                    Me.txtPercentual.Text = .get_TextMatrix(.Row, .Col)
                End With
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub mfgDados_KeyPressEvent(ByVal eventSender As System.Object, ByVal eventArgs As AxMSFlexGridLib.DMSFlexGridEvents_KeyPressEvent) Handles mfgDados.KeyPressEvent

        Try

            If vPrepararFlexGrid Then
                If eventArgs.keyAscii = System.Windows.Forms.Keys.Return Then
                    eventArgs.keyAscii = 0
                End If
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub txtPercentual_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtPercentual.Enter


        Try

            If vPrepararFlexGrid Then
                With Me.txtPercentual
                    .SelectionStart = 0
                    .SelectionLength = CInt(Len(.Text))
                End With
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub txtPercentual_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtPercentual.KeyPress

        Dim KeyAscii As Short = Asc(eventArgs.KeyChar)

        Try

            If KeyAscii = System.Windows.Forms.Keys.Return Then

                AtualizaValorGrade((Me.mfgDados), (Me.txtPercentual))

                With Me.mfgDados

                    Call .Focus()
                    If .Col < .Cols - 1 Then
                        .Col = .Col + 1
                    Else
                        .Col = .FixedCols
                        If .Row < .Rows - 1 Then
                            .Row = .Row + 1
                        Else
                            .Col = .FixedCols
                            .Row = .FixedRows
                        End If
                    End If

                End With

            ElseIf 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.txtPercentual.Text, ",") > 0 Then
                        KeyAscii = 0
                    End If
                End If
            End If

            eventArgs.KeyChar = Chr(KeyAscii)

            If KeyAscii = 0 Then
                eventArgs.Handled = True
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try


    End Sub

    Private Sub txtPercentual_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtPercentual.Leave

        Try
            AtualizaValorGrade((Me.mfgDados), (Me.txtPercentual))
        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub cmdSalvar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSalvar.Click

        'Dim ldblEnr As Double
        'Dim ldblEne As Double
        'Dim ldblTra As Double
        'Dim ldblDis As Double
        'Dim ldblPer As Double
        'Dim ldblEnc As Double
        'Dim ldblTic As Double
        'Dim ldblTpc As Double
        'Dim llngRow As Integer

        Dim ldblEnr
        Dim ldblEne
        Dim ldblTra
        Dim ldblDis
        Dim ldblPer
        Dim ldblEnc
        Dim ldblTic
        Dim ldblTpc
        Dim llngRow As Integer


        Dim objTarifaComposicao As New entidadeTarifaComposicao

        Try

            If IsDate(Me.cmbData.Text) Then

                If Me.txtDescricao.Text <> String.Empty Then

                    With Me.mfgDados

                        For llngRow = 1 To .Rows - 1

                            'ldblEnr = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 1)), .get_TextMatrix(llngRow, 1), 0), ".", ""))
                            'ldblEne = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0), ".", ""))
                            'ldblTra = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0), ".", ""))
                            'ldblDis = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0), ".", ""))
                            'ldblEnc = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0), ".", ""))
                            'ldblPer = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 6)), .get_TextMatrix(llngRow, 6), 0), ".", ""))
                            'ldblTic = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 7)), .get_TextMatrix(llngRow, 7), 0), ".", ""))
                            'ldblTpc = Convert.ToDouble(Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 8)), .get_TextMatrix(llngRow, 8), 0), ".", ""))

                            ldblEnr = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 1)), .get_TextMatrix(llngRow, 1), 0), ".", "")
                            ldblEne = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0), ".", "")
                            ldblTra = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0), ".", "")
                            ldblDis = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0), ".", "")
                            ldblEnc = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0), ".", "")
                            ldblPer = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 6)), .get_TextMatrix(llngRow, 6), 0), ".", "")
                            ldblTic = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 7)), .get_TextMatrix(llngRow, 7), 0), ".", "")
                            ldblTpc = Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 8)), .get_TextMatrix(llngRow, 8), 0), ".", "")

                            objTarifaComposicao.REFERENCIA = Convert.ToDateTime(cmbData.Text)
                            objTarifaComposicao.DESCRICAO = Replace(Me.txtDescricao.Text, "'", "\'")
                            objTarifaComposicao.ENERGIA_REAL = ldblEnr 'Convert.ToDecimal(Replace(CStr(ldblEnr), ",", "."))
                            objTarifaComposicao.ENERGIA = ldblEne 'Convert.ToDecimal(Replace(CStr(ldblEne), ",", "."))
                            objTarifaComposicao.TRANSMISSAO = ldblTra 'Convert.ToDecimal(Replace(CStr(ldblTra), ",", "."))
                            objTarifaComposicao.DISTRIBUICAO = ldblDis 'Convert.ToDecimal(Replace(CStr(ldblDis), ",", "."))
                            objTarifaComposicao.ENC_SETORIAIS = ldblEnc 'Convert.ToDecimal(Replace(CStr(ldblEnc), ",", "."))
                            objTarifaComposicao.PERDAS = ldblPer 'Convert.ToDecimal(Replace(CStr(ldblPer), ",", "."))
                            objTarifaComposicao.TRIBUTOS_ICMS = ldblTic 'Convert.ToDecimal(Replace(CStr(ldblTic), ",", "."))
                            objTarifaComposicao.TRIBUTOS_PIS_COFINS = ldblTpc 'Convert.ToDecimal(Replace(CStr(ldblTpc), ",", "."))

                            If Not lDelete(objTarifaComposicao) Then
                                MessageBox.Show("Tarifa Composição não pode ser excluida!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                Exit Sub
                            End If

                            If lInsert(objTarifaComposicao) Then
                                MessageBox.Show("Tarifa Composição criada com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)

                            Else
                                MessageBox.Show("Tarifa Composição não pode ser criada!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                Exit Sub
                            End If


                        Next llngRow

                    End With

                Else
                    MessageBox.Show("Você precisa informar alguma descrição para esta composição!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If

            Else
                MessageBox.Show("Você precisa informar a data de referência!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try


    End Sub

    Private Sub cmdExcluir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExcluir.Click

        Dim objTarifaComposicao As New entidadeTarifaComposicao


        Try

            vResp = MessageBox.Show("Deseja realmente excluir este registro?", "Confirmação de Exclusão", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)

            If vResp = DialogResult.Yes Then

                objTarifaComposicao.REFERENCIA = Convert.ToDateTime(cmbData.Text)

                If Not lDelete(objTarifaComposicao) Then
                    MessageBox.Show("Tensão não pode ser excluído!", "Confirmação de Exclusão", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else
                    MessageBox.Show("Tensão excluído com sucesso!", "Confirmação de Exclusão", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    PrepararFlexGrid()
                    Me.cmbData.SelectedIndex = -1
                    Me.txtDescricao.Text = String.Empty
                End If


            ElseIf vResp = DialogResult.Cancel Then
                Exit Sub
            End If


        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try


    End Sub

    Private Sub cmdLocalizar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizar.Click
        Dim ldblEnr As Double
        Dim ldblEne As Double
        Dim ldblTra As Double
        Dim ldblDis As Double
        Dim ldblPer As Double
        Dim ldblEnc As Double
        Dim ldblTic As Double
        Dim ldblTpc As Double

        Dim vlist

        Dim objTarifaComposicao As New entidadeTarifaComposicao
        Dim repositorioTarifaComposicao As New repositorioTarifaComposicao

        Try
            PrepararFlexGrid()

            objTarifaComposicao.REFERENCIA = Convert.ToDateTime(cmbData.Text)

            vlist = repositorioTarifaComposicao.Select(objTarifaComposicao)

            If vlist.Count > 0 Then

                For Each objTarifaComposicaoFor As entidadeTarifaComposicao In vlist

                    ldblEnr = IIf(IsDBNull(objTarifaComposicaoFor.ENERGIA_REAL), 0, objTarifaComposicaoFor.ENERGIA_REAL)
                    ldblEne = IIf(IsDBNull(objTarifaComposicaoFor.ENERGIA), 0, objTarifaComposicaoFor.ENERGIA)
                    ldblTra = IIf(IsDBNull(objTarifaComposicaoFor.TRANSMISSAO), 0, objTarifaComposicaoFor.TRANSMISSAO)
                    ldblDis = IIf(IsDBNull(objTarifaComposicaoFor.DISTRIBUICAO), 0, objTarifaComposicaoFor.DISTRIBUICAO)
                    ldblEnc = IIf(IsDBNull(objTarifaComposicaoFor.ENC_SETORIAIS), 0, objTarifaComposicaoFor.ENC_SETORIAIS)
                    ldblPer = IIf(IsDBNull(objTarifaComposicaoFor.PERDAS), 0, objTarifaComposicaoFor.PERDAS)
                    ldblTic = IIf(IsDBNull(objTarifaComposicaoFor.TRIBUTOS_ICMS), 0, objTarifaComposicaoFor.TRIBUTOS_ICMS)
                    ldblTpc = IIf(IsDBNull(objTarifaComposicaoFor.TRIBUTOS_PIS_COFINS), 0, objTarifaComposicaoFor.TRIBUTOS_PIS_COFINS)

                    Me.txtDescricao.Text = IIf(IsDBNull(objTarifaComposicaoFor.DESCRICAO), "", objTarifaComposicaoFor.DESCRICAO)

                    With Me.mfgDados
                        .set_TextMatrix(.Rows - 1, 0, Format(Convert.ToDouble(ldblEnr + ldblTra + ldblDis + ldblEnc + ldblPer + ldblTic + ldblTpc), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 1, Format(Convert.ToDouble(ldblEnr), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 2, Format(Convert.ToDouble(ldblEne), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 3, Format(Convert.ToDouble(ldblTra), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 4, Format(Convert.ToDouble(ldblDis), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 5, Format(Convert.ToDouble(ldblEnc), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 6, Format(Convert.ToDouble(ldblPer), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 7, Format(Convert.ToDouble(ldblTic), "#,#####0.00000"))
                        .set_TextMatrix(.Rows - 1, 8, Format(Convert.ToDouble(ldblTpc), "#,#####0.00000"))
                    End With


                Next

            End If


        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try


    End Sub


    Private Sub cmdFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFechar.Click

        Try

            lClose()

        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub frmCadComposicaoTarifa_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

        Try
            If Not vfrmOld Is Nothing Then
                vfrmOld.Enabled = True
            End If
        Catch ex As Exception
            MessageBox.Show("Ocorreu um Erro Inesperado. Favor, Contate o Administrador do Sistema ou a Equipe de Suporte de sua localidade! ", "Fatal - Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub



#End Region

#Region "Métodos"

    Private Sub PrepararFlexGrid()

        Try

            vPrepararFlexGrid = False

            With Me.mfgDados
                Call .Clear()
                .Cols = 9
                .Rows = 2
                .FixedRows = 1
                .FixedCols = 2
                .set_TextMatrix(0, 0, "Total")
                .set_TextMatrix(0, 1, "Energia Real")
                .set_TextMatrix(0, 2, "Energia")
                .set_TextMatrix(0, 3, "Transmissão")
                .set_TextMatrix(0, 4, "Distribuição")
                .set_TextMatrix(0, 5, "Enc.Setoriais")
                .set_TextMatrix(0, 6, "Perdas")
                .set_TextMatrix(0, 7, "Trib.Icms")
                .set_TextMatrix(0, 8, "Trib.Pis/Cof.")
                .set_ColWidth(0, 1000)
                .set_ColWidth(1, 1000)
                .set_ColWidth(2, 1000)
                .set_ColWidth(3, 1000)
                .set_ColWidth(4, 1000)
                .set_ColWidth(5, 1000)
                .set_ColWidth(6, 1000)
                .set_ColWidth(7, 1000)
                .set_ColWidth(8, 1000)
            End With

            vPrepararFlexGrid = True

        Catch ex As Exception
            Exit Sub
        End Try

    End Sub

    Public Sub SetaParametros(ByRef frmOld As System.Windows.Forms.Form)

        Try

            vfrmOld = frmOld
            vfrmOld.Enabled = False

        Catch ex As Exception
            Exit Sub
        End Try

    End Sub

    Private Sub AtualizaValorGrade(ByRef mfgAux As AxMSFlexGridLib.AxMSFlexGrid, ByRef txtAux As System.Windows.Forms.TextBox)

        Try

            With mfgAux
                .set_TextMatrix(.Row, .Col, Format(Convert.ToDouble(IIf(IsNumeric(txtAux.Text), txtAux.Text, 0)), "#,#####0.00000"))
                If .get_TextMatrix(0, .Col) = "Perdas" Then
                    If IsNumeric(.get_TextMatrix(.Row, 1)) And IsNumeric(.get_TextMatrix(.Row, .Col)) Then
                        .set_TextMatrix(.Row, 1, Format(Convert.ToDouble(Replace(.get_TextMatrix(.Row, 2), ".", "")) - Convert.ToDouble(Replace(.get_TextMatrix(.Row, .Col), ".", "")), "#,#####0.00000"))
                    End If
                ElseIf .get_TextMatrix(0, .Col) = "Energia" Then
                    If IsNumeric(.get_TextMatrix(.Row, 6)) And IsNumeric(.get_TextMatrix(.Row, .Col)) Then
                        .set_TextMatrix(.Row, 1, Format(Convert.ToDouble(Replace(.get_TextMatrix(.Row, .Col), ".", "")) - Convert.ToDouble(Replace(.get_TextMatrix(.Row, 6), ".", "")), "#,#####0.00000"))
                    End If
                End If
                .set_TextMatrix(.Row, 0, Format(Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 1)), .get_TextMatrix(.Row, 1), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 3)), .get_TextMatrix(.Row, 3), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 4)), .get_TextMatrix(.Row, 4), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 5)), .get_TextMatrix(.Row, 5), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 6)), .get_TextMatrix(.Row, 6), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 7)), .get_TextMatrix(.Row, 7), 0)) + Convert.ToDouble(IIf(IsNumeric(.get_TextMatrix(.Row, 8)), .get_TextMatrix(.Row, 8), 0)), "#,#####0.00000"))
            End With

        Catch ex As Exception
            Exit Sub
        End Try

    End Sub

    Private Sub PreencheCombobox()

        Try
            PreencherTarifaComposicao(cmbData)
        Catch ex As Exception
            Exit Sub
        End Try

    End Sub

    Private Sub lClose()

        Try

            Close()

        Catch ex As Exception
            Exit Sub
        End Try

    End Sub

    Private Function lInsert(ByRef objTarifaComposicao As entidadeTarifaComposicao) As Boolean
        Dim repositorioTarifaComposicao As New repositorioTarifaComposicao
        Try

            repositorioTarifaComposicao.Insert(objTarifaComposicao)

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

    Private Function lDelete(ByRef objTarifaComposicao As entidadeTarifaComposicao) As Boolean
        Dim repositorioTarifaComposicao As New repositorioTarifaComposicao
        Try

            repositorioTarifaComposicao.Delete(objTarifaComposicao)

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function

#End Region


End Class