Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem itm = listView1.SelectedItems[0];
                Produs       p   = (Produs)itm.Tag;

                MessageBox.Show("totalul este " + (decimal)p);
            }
        }
Exemple #2
0
 private void editareToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         ListViewItem itm     = listView1.SelectedItems[0];
         Produs       p       = (Produs)itm.Tag;
         Form2        editare = new Form2(p);
         editare.ShowDialog();
         incarcaDatele();
     }
 }
Exemple #3
0
 public Form2(Produs produs)
 {
     preluare_furnizori();
     this.produs = produs;
     InitializeComponent();
     this.connString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=firma.accdb";
     if (this.produs != null)
     {
         adaugaDate();
         this.buttonEditare.Text = "Editare";
     }
 }
Exemple #4
0
        public int CompareTo(object obj)
        {
            Produs p = (Produs)obj;

            if (this.pret > p.pret)
            {
                return(1);
            }
            else if (this.pret < p.pret)
            {
                return(-1);
            }
            return(0);
        }
Exemple #5
0
        private void incarcaDatele()
        {
            listView1.Items.Clear();

            List <Produs> produse = new List <Produs>();

            OleDbConnection connection = new OleDbConnection(this.connString);
            OleDbCommand    command    = new OleDbCommand("SELECT * FROM produse", connection);

            try
            {
                connection.Open();

                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    int     id         = Convert.ToInt32(reader["ID"].ToString());
                    string  nume       = reader["nume"].ToString();
                    int     unitati    = Convert.ToInt32(reader["unitati"].ToString());
                    decimal pret       = Convert.ToDecimal(reader["pret"].ToString());
                    int     idFurnizor = Convert.ToInt32(reader["idFurnizor"].ToString());

                    Produs p = new Produs(id, nume, unitati, pret, idFurnizor);
                    produse.Add(p);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connection.Close();
            }

            produse.Sort();
            foreach (Produs p in produse)
            {
                ListViewItem item = new ListViewItem(p.Id.ToString());
                item.SubItems.Add(p.Nume);
                item.SubItems.Add(p.Unitati.ToString());
                item.SubItems.Add(p.Pret.ToString());
                item.SubItems.Add(p.IdFurnizor.ToString());
                item.Tag = p;
                listView1.Items.Add(item);
            }
        }