Exemple #1
0
        private void btnSalvareProdus_Click(object sender, EventArgs e)
        {
            Random        rnd             = new Random();
            List <Produs> produseDeSalvat = new List <Produs>();

            foreach (DataGridViewRow row in dataGridViewProduse.Rows)
            {
                string nume = row.Cells[0].Value == null ?
                              string.Empty : row.Cells[0].Value.ToString();
                string codIntern = row.Cells[1].Value == null ?
                                   string.Empty : row.Cells[1].Value.ToString();
                int pret = row.Cells[2].Value == null ?
                           0 : int.Parse(row.Cells[2].Value.ToString());
                string categorie = row.Cells[3].Value == null ?
                                   string.Empty : row.Cells[3].Value.ToString();
                string producator = row.Cells[3].Value == null ?
                                    string.Empty : row.Cells[4].Value.ToString();
                int id = rnd.Next(1, 1000);

                if (nume == null || nume == "")
                {
                }
                else
                {
                    produseDeSalvat.Add(new Produs(id, nume, codIntern, pret, categorie, producator));
                }
            }


            ProduseMgr prod = new ProduseMgr();

            prod.WriteListToXML(produseDeSalvat);
        }
Exemple #2
0
        private List <ProdusAbstract> produse()
        {
            ProduseMgr produse = new ProduseMgr();

            produse.InitListafromXML();
            List <ProdusAbstract> produces = produse.elems();

            return(produces);
        }
Exemple #3
0
        public void InitListafromXML()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load("D:\\Anul II\\OOP\\labs\\lab-6\\POS\\app1\\Pachete.xml");
            XmlNodeList lista_noduri = doc.SelectNodes("/pachete/Pachet");

            foreach (XmlNode nod in lista_noduri)
            {
                string nume       = nod["Nume"].InnerText;
                string codIntern  = nod["CodIntern"].InnerText;
                int    nrProduse  = int.Parse(nod["Produse"].InnerText);
                int    nrServicii = int.Parse(nod["Servicii"].InnerText);
                string categorie  = nod["Categorie"].InnerText;
                Pachet pachet     = new Pachet(elemente.Count + 1, nume, codIntern, categorie, nrServicii, nrProduse);

                ProduseMgr  produse  = new ProduseMgr();
                ServiciuMgr servicii = new ServiciuMgr();
                produse.Init(pachet);
                servicii.Init(pachet);
                elemente.Add(pachet);
            }
        }