Example #1
0
        public static void LeggiDaFile(Form1.articolo[] elep, ref int num, string nomefile)    //Leggi da file
        {
            Form1.articolo newprod = default(Form1.articolo);
            StreamReader   miofile;

            miofile = new StreamReader(nomefile);
            while (miofile.EndOfStream == false)
            {
                newprod.nome     = miofile.ReadLine();
                newprod.autore   = miofile.ReadLine();
                newprod.prezzo   = decimal.Parse(miofile.ReadLine());
                newprod.codice   = miofile.ReadLine();
                newprod.quantita = int.Parse(miofile.ReadLine());
                newprod.tipo     = miofile.ReadLine();
                elep[num]        = newprod;
                num++;
            }
            miofile.Close();
        }
Example #2
0
        public static void ordinaprezzo(Form1.articolo[] elep, int num)        //ordina per prezzo
        {
            Form1.articolo temp = default(Form1.articolo);
            int            x    = 0;
            int            y    = 0;

            while (x < num)
            {
                y = x + 1;
                while (y < num)
                {
                    if (elep[x].prezzo > elep[y].prezzo)
                    {
                        temp    = elep[x];
                        elep[x] = elep[y];
                        elep[y] = temp;
                    }
                    y++;
                }
                x++;
            }
        }
Example #3
0
        public static void ordinatipo(Form1.articolo[] elep, int num)   //ordina per tipo
        {
            Form1.articolo temp = default(Form1.articolo);
            int            x    = 0;
            int            y    = 0;

            while (x < num)
            {
                y = x + 1;
                while (y < num)
                {
                    if (string.Compare(elep[x].tipo, elep[y].tipo) > 0)
                    {
                        temp    = elep[x];
                        elep[x] = elep[y];
                        elep[y] = temp;
                    }
                    y++;
                }
                x++;
            }
        }