Ejemplo n.º 1
0
        void generareID()
        {
            SingletonNrRandom rand = SingletonNrRandom.Instance;

            for (int i = 0; i < 5; i++)
            {
                clientID += rand.getRandom();
            }
            clientID += nume[0].ToString() + prenume[0].ToString();
        }
Ejemplo n.º 2
0
        public long generareEAN_13()
        {
            SingletonNrRandom rnd = SingletonNrRandom.Instance;

            int[] EAN_13 = new int[14];
            long  code   = 0;

            int sp13 = 0, si13 = 0, s13 = 0;

            for (int i = 1; i < 14; i++)
            {
                EAN_13[i] = rnd.getRandom();
                if (i % 2 == 0)
                {
                    sp13 += EAN_13[i];
                }
                else
                {
                    si13 += EAN_13[i];
                }
            }
            if (EAN_13[1] == 0)
            {
                while (EAN_13[1] == 0)
                {
                    EAN_13[1] = rnd.getRandom();
                }
                si13 += EAN_13[1];
            }
            s13 = si13 + 3 * sp13;
            if (s13 % 10 == 0)
            {
                EAN_13[13] = 0;
            }
            else
            {
                EAN_13[13] = 10 - s13 % 10;
            }
            for (int i = 1; i < 14; i++)
            {
                code = code * 10 + EAN_13[i];
            }
            return(code);
        }
Ejemplo n.º 3
0
        public int generareEAN_8()
        {
            SingletonNrRandom rnd = SingletonNrRandom.Instance;

            int[] EAN_8 = new int[9];
            int   code = 0;
            int   sp8 = 0, si8 = 0, s8 = 0;

            for (int i = 1; i < 9; i++)
            {
                EAN_8[i] = rnd.getRandom();
                if (i % 2 == 0)
                {
                    sp8 += EAN_8[i];
                }
                else
                {
                    si8 += EAN_8[i];
                }
            }
            if (EAN_8[1] == 0)
            {
                while (EAN_8[1] == 0)
                {
                    EAN_8[1] = rnd.getRandom();
                }
                si8 += EAN_8[1];
            }
            s8 = 3 * si8 + sp8;
            if (s8 % 10 == 0)
            {
                EAN_8[8] = 0;
            }
            else
            {
                EAN_8[8] = 10 - s8 % 10;
            }
            for (int i = 1; i < 9; i++)
            {
                code = code * 10 + EAN_8[i];
            }
            return(code);
        }