Beispiel #1
0
        private void btn_aggiorna_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();



            if (radioButton5.Checked == false && radioButton6.Checked == false && radioButton7.Checked == false && radioButton8.Checked == false)
            {
                int x = default(int);
                while (x < num)
                {
                    var row      = new string[] { ele[x].nome, ele[x].autore, ele[x].prezzo.ToString(), ele[x].codice, ele[x].quantita.ToString(), ele[x].tipo };
                    var listrow4 = new ListViewItem(row);
                    listView1.Items.Add(listrow4);
                    x++;
                }
                return;
            }


            articolo[] elef = new articolo[num];
            int        numf = 0;

            if (radioButton5.Checked == true)
            {
                string filtro = "rivista";
                Class1.Filtra(ele, elef, num, ref numf, filtro);
            }

            if (radioButton6.Checked == true)
            {
                string filtro = "giornale";
                Class1.Filtra(ele, elef, num, ref numf, filtro);
            }

            if (radioButton7.Checked == true)
            {
                string filtro = "libro";
                Class1.Filtra(ele, elef, num, ref numf, filtro);
            }

            if (radioButton8.Checked == true)
            {
                string filtro = "materiale";
                Class1.Filtra(ele, elef, num, ref numf, filtro);
            }

            int y = default(int);

            while (y < numf)
            {
                var row      = new string[] { elef[y].nome, elef[y].autore, elef[y].prezzo.ToString(), elef[y].codice, elef[y].quantita.ToString(), elef[y].tipo };
                var listrow4 = new ListViewItem(row);
                listView1.Items.Add(listrow4);
                y++;
            }

            numf = 0;
        }
Beispiel #2
0
        private void btn_modi_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBox5.Text) == true || string.IsNullOrEmpty(textBox7.Text) == true || string.IsNullOrEmpty(textBox8.Text) == true || string.IsNullOrEmpty(textBox9.Text) == true || string.IsNullOrEmpty(textBox10.Text) == true) //|| string.IsNullOrEmpty(textBox11.Text) == true
            {
                MessageBox.Show("completare tutti i campi");
                return;
            }
            articolo k = default(articolo);

            k.nome     = textBox5.Text;
            k.autore   = textBox7.Text;
            k.prezzo   = decimal.Parse(textBox8.Text);
            k.codice   = textBox9.Text;
            k.quantita = int.Parse(textBox10.Text);
            //k.tipo ="libro";
            if (radioButton10.Checked == true)
            {
                k.tipo = "rivista";
            }

            if (radioButton9.Checked == true)
            {
                k.tipo = "materiale";
            }

            if (radioButton11.Checked == true)
            {
                k.tipo = "libro";
            }

            if (radioButton12.Checked == true)
            {
                k.tipo = "giornale";
            }


            try
            {
                k.prezzo   = decimal.Parse(textBox8.Text);
                k.quantita = int.Parse(textBox10.Text);
            }
            catch
            {
                MessageBox.Show("dati inseriti scorretti");
                return;
            }

            int x = listView1.SelectedIndices.Count;

            if (x == 0)
            {
                return;
            }
            int pos = Class1.cerca(ele, num, listView1.SelectedItems[0].SubItems[0].Text);

            ele[pos] = k;

            textBox5.Clear();
            textBox7.Clear();
            textBox8.Clear();
            textBox9.Clear();
            textBox10.Clear();
            //textBox11.Clear();
            MessageBox.Show("dati modificati correttamente");
            btn_aggiorna.PerformClick();
        }