예제 #1
0
 public AdaugaProd(Produse param)
 {
     InitializeComponent();
     a            = param;
     tb_nume.Text = a.Nume;
     tb_pret.Text = a.Pret.ToString();
     tb_stoc.Text = a.Cantitate.ToString();
 }
예제 #2
0
        public int CompareTo(object obj)
        {
            Produse p = (Produse)obj;

            if (this.cantitate < p.cantitate)
            {
                return(-1);
            }
            else if (this.cantitate > p.cantitate)
            {
                return(1);
            }
            else
            {
                return(string.Compare(this.nume, p.nume));
            }
        }
예제 #3
0
        private void SAlvareXMLToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            MemoryStream  memStream = new MemoryStream();
            XmlTextWriter writer    = new XmlTextWriter(memStream, Encoding.UTF8);

            writer.Formatting = Formatting.Indented;

            writer.WriteStartDocument();
            writer.WriteStartElement("Lista-persoane");

            foreach (ListViewItem lvi in listView1.Items)
            {
                Produse plocal = (Produse)lvi.Tag;
                writer.WriteStartElement("Produs");

                writer.WriteStartElement("nume");
                writer.WriteValue(plocal.Nume);
                writer.WriteEndElement();


                writer.WriteStartElement("Pret");
                writer.WriteValue(plocal.Pret);
                writer.WriteEndElement();

                writer.WriteStartElement("Cantitate");
                writer.WriteValue(plocal.Cantitate);
                writer.WriteEndElement();

                writer.WriteEndElement();
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();

            string xmlString = Encoding.UTF8.GetString(memStream.ToArray());

            memStream.Close();
            memStream.Dispose();
            StreamWriter sw = new StreamWriter("fisier.xml");

            sw.WriteLine(xmlString);
            sw.Close();
            MessageBox.Show("Fisier generat cu succes!", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #4
0
        private void UpdateList()
        {
            listView1.Items.Clear();
            OleDbConnection conexiune = new OleDbConnection(Provider);
            string          sql       = "SELECT * FROM  produs";
            OleDbCommand    comanda   = new OleDbCommand(sql, conexiune);

            try
            {
                conexiune.Open();
                OleDbDataReader reader = comanda.ExecuteReader();

                while (reader.Read())
                {
                    ListViewItem itm = new ListViewItem(reader["nume"].ToString());
                    itm.SubItems.Add(reader["pret"].ToString());
                    itm.SubItems.Add(reader["cantitate"].ToString());

                    Produse p = new Produse
                    {
                        Nume      = reader["nume"].ToString(),
                        Pret      = Convert.ToDouble(reader["pret"].ToString()),
                        Cantitate = Convert.ToInt32(reader["cantitate"].ToString()),
                    };

                    itm.Tag = p;
                    listView1.Items.Add(itm);
                }
                reader.Close();
            }
            catch (OleDbException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conexiune.Close();
            }
        }