예제 #1
0
        private void btnSalvareServiciu_Click(object sender, EventArgs e)
        {
            Random          rnd = new Random();
            List <Serviciu> serviciiDeSalvat = new List <Serviciu>();

            foreach (DataGridViewRow row in dataGridViewServicii.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();
                int id = rnd.Next(1, 1000);

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


            ServiciuMgr serv = new ServiciuMgr();

            serv.WriteListToXML(serviciiDeSalvat);
        }
예제 #2
0
        private List <ProdusAbstract> servicii()
        {
            ServiciuMgr servicii = new ServiciuMgr();

            servicii.InitListafromXML();
            List <ProdusAbstract> services = servicii.elems();

            return(services);
        }
예제 #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);
            }
        }