Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagevb
titleOriginal VB code
Public Function GetLessee(Acct As String) As String
    'Returns name of accountholder, if no last name then use company name.
    If gbErrorTrapOn Then On Error GoTo ErrorTrap
    Dim rs As ADODB.Recordset
    If ExecProc("cash", "cash_GetLessee", rs, -1, Acct, gsCountry) Then
        If Not rs.EOF Then
            If Len(Trim(rs!last_nme)) > 0 Then
                GetLessee = IIf(IsNull(rs!first_nme), "", Trim(rs!first_nme)) & " " & _
                IIf(IsNull(rs!last_nme), "", Trim(rs!last_nme))
     Else   GetLessee = IIf(IsNull(   Else
                GetLessee = IIf(IsNull(rs!company_nme), "", Trim(rs!company_nme))
            End If
        End If
    Else
        GetLessee = "Unavailable"
    End If
    Exit Function

 ErrorTrap:
  ShowError  "GetLessee",     ShowError("GetLessee", Err.Number, Err.Description)

End Function
Code Block
languagecpp
titleGenerated C# code
public static string GetLessee(string Acct)
{
 {   string GetLessee = "";
    // Returns name of accountholder, if no last name then use company name.
    SqlParameter[] sqlParms = new SqlParameter[2];
    try
    {
        SqlDataReader rs = null;
        sqlParms[0] = DesktopDataMeister.SetProcParameter("@account_no",
        ParameterDirection.Input, false, Acct.ToString(), 10);
        sqlParms[1] = DesktopDataMeister.SetProcParameter("@country_cde",
        ParameterDirection.Input, false, Cash_Globals.gsCountry.ToString(), 3);
        rs = DesktopDataMeister.ExecuteReader(DesktopConfigurator.EDBServer,
        CommandType.StoredProcedure, "Cash.dbo.cash_GetLessee", sqlParms);
 if (rs       if (rs.Read())
        {
            if ((rs["last_nme"].ToString().Trim()).Length > 0)
            {
                GetLessee = (VBNET.Information.IsDBNull(rs["first_nme"]) ? "" : 
 rs["first_nme"].ToString().Trim()) + " " 
+
                rs["first_nme"].ToString().Trim()) + " "
                + (VBNET.Information.IsDBNull(rs["last_nme"]) ? "" :
                rs["last_nme"].ToString().Trim());
            }
            else
            {
                GetLessee = (VBNET.Information.IsDBNull(rs["lastcompany_nme"]) ? "" :
                rs["lastcompany_nme"].ToString().Trim());
            }
 else    {   GetLessee}
= (VBNET.Information.IsDBNull(rs["company_nme"]) ? "" :   rs["company_nme"].ToString().Trim());  else
 }   }  else  {
            GetLessee = "Unavailable";
        }
        return GetLessee;
    }
    catch (Exception exc)
    {
        ShowError("GetLessee", ABCFSException.MapExceptionToErrNumber(exc),
        exc.Message);
    }
}

Listing 1. Sample Translation produced by the Promula VB-to-C# Translation System

...