-1
I have this code in Vb, I need it in c#. In Vb create a new code each time it is executed, in c# always puts the same code "000011".
Public Function CalculaNovoCodBarras() As String
Dim lista As New StdBELista
Dim res As String
Dim flag As Boolean
Dim MaxArt As String
MaxArt = "00001"
flag = False
On Error GoTo erro
Do
Set lista = BSO.Consulta("Select substring(Artigo.codbarras,8,5) as MaxArtigo FROM ARTIGO where substring(Artigo.codbarras,8,5) = '" & MaxArt & "'")
If lista.NoFim Then
res = GetCodPaisEmpresa & MaxArt
res = res & CalculaDigitoEAN13(res)
flag = True
Else
MaxArt = Format(MaxArt + 1, "00000")
End If
Loop While flag = False
CalculaNovoCodBarras = res
Exit Function
erro:
MsgBox Err.Description
End Function
C#
public string CalculaNovoCodBarras()
{
StdBELista lista = new StdBELista();
string res = "";
bool flag = false;
string MaxArt = "00001";
// MaxArt = "00001";
//flag = false;
do
{
lista = BSO.Consulta("Select substring(Artigo.codbarras,8,5) as MaxArtigo FROM ARTIGO where substring(Artigo.codbarras,8,5) = '" + MaxArt + "'");
if (lista.NoFim())
{
res = GetCodPaisEmpresa() + MaxArt;
res = res + CalculaDigitoEAN13();
flag = true;
}
else
MaxArt = String.Format(MaxArt + 1, "00000");
}
while (flag == false);
return res;
}
Always report the error and which line the error occurs :)
– Ronaldo Araújo Alves
Not giving error , in Vb is generating a new code, sequential with 5 digit format each time it is running in c# this giving the same code with 6 digits.
– Aliona
What is your question? You want to increase
MaxArt
and fill in with0
– Leandro Angelo