CodeWare

.Net

Converting your Barcode to BarCode Text for EAN13 true font

by Bruno Rebelo on Feb.10, 2009, under .Net, C#

?View Code CSHARP
public string EAN13(string chaine)
        {
 
            int i;
            int first;
            int checksum = 0;
            string CodeBarre = "";
            bool tableA;
            if (Regex.IsMatch(chaine, "^\\d{12}$"))
            {
 
                for (i = 1; i < 12; i += 2)
                {
                    System.Diagnostics.Debug.WriteLine(chaine.Substring(i, 1));
                    checksum += Convert.ToInt32(chaine.Substring(i, 1));
                }
                checksum *= 3;
                for (i = 0; i < 12; i += 2)
                {
                    checksum += Convert.ToInt32(chaine.Substring(i, 1));
                }
 
                chaine += (10 - checksum % 10) % 10;
                CodeBarre = chaine.Substring(0, 1) + (char)(65 + Convert.ToInt32(chaine.Substring(1, 1)));
                first = Convert.ToInt32(chaine.Substring(0, 1));
                for (i = 2; i <= 6; i++)
                {
                    tableA = false;
                    switch (i)
                    {
                        case 2:
                            if (first >= 0 && first <= 3) tableA = true;
                            break;
                        case 3:
                            if (first == 0 || first == 4 || first == 7 || first == 8) tableA = true;
                            break;
                        case 4:
                            if (first == 0 || first == 1 || first == 4 || first == 5 || first == 9) tableA = true;
                            break;
                        case 5:
                            if (first == 0 || first == 2 || first == 5 || first == 6 || first == 7) tableA = true;
                            break;
                        case 6:
                            if (first == 0 || first == 3 || first == 6 || first == 8 || first == 9) tableA = true;
                            break;
                    }
 
                    if (tableA)
                        CodeBarre += (char)(65 + Convert.ToInt32(chaine.Substring(i, 1)));
                    else
                        CodeBarre += (char)(75 + Convert.ToInt32(chaine.Substring(i, 1)));
                }
                CodeBarre += "*"; 
 
                for (i = 7; i <= 12; i++)
                {
                    CodeBarre += (char)(97 + Convert.ToInt32(chaine.Substring(i, 1)));
                }
                CodeBarre += "+"; 
            }
            return CodeBarre;
        }
2 Comments more...

Criar uma dal

by pedro on Jan.18, 2009, under .Net, C#

?View Code CSHARP
public class DALCON
{
    SqlConnection connection;
    public DALCON()
    {
        string connectionString = ConfigurationManager.ConnectionStrings["aero"].ConnectionString;
        connection = new SqlConnection(connectionString);
        connection.Open();
    }
 
    public void CloseCON()
    {
        connection.Close();
    }
}

para utilizar

?View Code CSHARP
DALCON DalObj = new DALCON();
 
aux = dalobj.CloseCON;
Leave a Comment :, more...

Connection String no Web.config

by pedro on Jan.18, 2009, under .Net, SQL

Colocar a connection string no web.config do asp.net para SQL

<connectionStrings>
    <add name="intranet" 
         providerName="System.Data.SqlClient"
         connectionString="server=SERVER;database=database;;uid=sa;pwd=pass"/>
</connectionStrings>
Leave a Comment :, , more...

Procurando algum código?

Utilize o formulário para procurar:

Não encontrou o que queria? Deixe um comentário num CODE ou contacte-nos para encontrar-mos solução!

Visit our friends!

A few highly recommended friends...