Salary Simulation in . NET

Asked

Viewed 104 times

1

I am trying to perform a C# Salary Simulation by introducing a remuneration, but in the method INSERELINHAREMUNERACAO is going wrong.

The mistake is:

Invalid Procedure Call or Argument.

In VBA works well, but I’m not sure what I lack in C#.

Send down the code.

private void CalculaVencimento(int vPeriodo, int vAno, string vFuncionario, double vRemExtra, ref double vVencimento)
    {
        try
        {
            string strErro = "";
            string strRemuneracao = Txt01.Text;
            short Ano = Convert.ToInt16(vAno);
            short Periodo = Convert.ToInt16(vPeriodo);

            RhpBEFuncionario SimulaFuncionario = new RhpBEFuncionario();

            SimulaFuncionario = PriEngine.Aplicacao.RecursosHumanos.Funcionarios.Edita(vFuncionario);

            RhpBEProcessamento SimulaVencimento = new RhpBEProcessamento();
            SimulaVencimento.set_Funcionario(vFuncionario);
            SimulaVencimento.set_TipoProcessamento(TipoProc.tpVencimento);
            SimulaVencimento.set_Periodo("P01");
            SimulaVencimento.set_Ano((short)vAno);
            SimulaVencimento.set_NumPeriodoProcessado((short)vPeriodo);
            SimulaVencimento.set_DiasUteis(Convert.ToUInt16(PriEngine.Aplicacao.RecursosHumanos.Periodos.DaDiasUteis("P01", (short)vAno, (short)vPeriodo).ToString()));
            MotorBS.RecursosHumanos.Processamento.InsereLinhaRemuneracao(SimulaVencimento, SimulaFuncionario, strRemuneracao, strErro, 1, vRemExtra, 1, "EUR", Ano, Periodo);
            MotorBS.RecursosHumanos.Processamento.CalculaProcessamento(SimulaVencimento);
            vVencimento = SimulaVencimento.get_TotalLiquido();
            SimulaVencimento = null;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
  • I’ve seen the stacktrace to see if it has any more information?

  • Could you put this method here

  • The stacktrace has no relevant information. Removing the line from the INSERT will perform perfectly. I already put explicit values according to the types and it still doesn’t work.

1 answer

0

Good,

I did so and it is working. I’m just not able to simulate the Faults, but otherwise everything works.


                Try
                Dim NumFunc = CodFunc
                Dim strErro As String = ""
                Dim Remuneracao As String = Vencimento
                Dim Premio As String = Premios
                Dim Ano As Short = Now.Year
                Dim Periodo = motor.RecursosHumanos.Funcionarios.DaValorAtributo(NumFunc, "Periodo")
                Dim DiasUteis = Convert.ToUInt16(motor.RecursosHumanos.Periodos.DaDiasUteis(Periodo, CShort(Ano), CShort(Now.Month)).ToString())
                Dim SimulaFuncionario As RhpBEFuncionario = New RhpBEFuncionario()
                SimulaFuncionario = motor.RecursosHumanos.Funcionarios.Edita(NumFunc)

                Dim RemFunc As RhpBEProcRemuneracao = New RhpBEProcRemuneracao
                If CDbl(Premio) > 0 Then
                    RemFunc.Remuneracao = "R301"
                    RemFunc.Valor = CDbl(Premio)
                End If

                Dim SimulaVencimento As RhpBEProcessamento = New RhpBEProcessamento()
                SimulaVencimento.Funcionario = NumFunc
                SimulaVencimento.TipoProcessamento = TipoProc.tpVencimento
                SimulaVencimento.Periodo = Periodo
                SimulaVencimento.Ano = Ano
                SimulaVencimento.NumPeriodoProcessado = CShort(Now.Month)
                SimulaVencimento.DiasUteis = DiasUteis
                SimulaVencimento.DiasProc = DiasUteis - CInt(Flt)
                If CDbl(Premio) > 0 Then
                    SimulaVencimento.Remuneracoes.Insere(RemFunc)
                End If
                motor.RecursosHumanos.Processamento.InsereLinhaRemuneracao(SimulaVencimento, SimulaFuncionario, Remuneracao, strErro, 1, CDbl(Premios)), 1, "AKZ", Ano, CShort(Now.Month))
                motor.RecursosHumanos.Processamento.CalculaProcessamento(SimulaVencimento)
                Dim ValorPrevisto = SimulaVencimento.TotalLiquido()               
                SimulaVencimento = Nothing
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try

Browser other questions tagged

You are not signed in. Login or sign up in order to post.