Exemplo n.º 1
0
        /// <summary>
        /// Constructorul
        /// </summary>
        /// <param name="x">pozitia pe x in panel</param>
        /// <param name="y">pozitia pe y in panel</param>
        /// <param name="_products">tipul de produs ce urmeaza a fi afisat pe interfata</param>
        /// <param name="panel">Panel-ul din interfata pe care vor fi adaugate controalele</param>
        /// <param name="listBoxProducts">Lista de produse, unde se vor adauga produsele atunci cand se apasa pe butoanele 'Adauga'.</param>
        public ComboboxProducts(int x, int y, TipProdus _products, Panel panel, ListBox listBoxProducts)
        {
            _listBoxProducts = listBoxProducts;
            //Se creaza un label pentru a afisa pe interfata denumirea tipului de produse
            _productTypeName          = new Label();
            _productTypeName.AutoSize = true;                                          //Controlul isi va lua singur dimensiunile in funtie de lungimea sirului de caractere care contine denumirea
            _productTypeName.Location = new System.Drawing.Point(x * 10, y * 50 + 25); // Seteaza pozitia label-ului in panel.
            _productTypeName.Text     = _products.Name;                                //Seteaza textul label-ului

            //Se creaza un combobox din care se poate alege un produs de tipul respectiv de produs.
            _comboboxProducts          = new ComboBox();
            _comboboxProducts.AutoSize = true;
            _comboboxProducts.Location = new System.Drawing.Point(x * 10 + 100, y * 50 + 25);
            List <Produs> productList = _products.GetProducts;

            for (int i = 0; i < productList.Count; i++)
            {
                _comboboxProducts.Items.Add(productList[i].Nume);//Se adauga in ComboBox optiunile, acestea find produsele de acel tip.
            }

            //Se creaza un buton pentru a adauga produsul ales din combobox in lista de produse.
            _buttonAdd          = new Button();
            _buttonAdd.Text     = "Adauga";
            _buttonAdd.AutoSize = true;
            _buttonAdd.Location = new System.Drawing.Point(x * 10 + 270, y * 50 + 25);
            _buttonAdd.Click   += new System.EventHandler(this.buttonAdd_Click);// Seteaza handler-ul care este apelat atunci cand se apasa Click pe acest buton.
            panel.Controls.Add(_productTypeName);
            panel.Controls.Add(_comboboxProducts);
            panel.Controls.Add(_buttonAdd);
            //Controalele sunt adaugate in panel
        }
Exemplo n.º 2
0
 private void initControls()
 {
     //Implementare Heghea Mihail-Cristian
     for (int i = 0; i < _meniu.ProductList.Count; i++)
     {// se parcurge lista de tipuri de produse si se creaza un obiect ComboboxProducts folosit pentru a afisa tipurile de prosuse impreuna cu
         // produsele in panel-ul de meniu.
         TipProdus        productsType    = _meniu.ProductList[i];
         ComboboxProducts comboboxProduct = new ComboboxProducts(1, i, productsType, panelMeniu, listBoxComenzi);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Constructorul este privat pentru ca implementeaza sablonul de proiectare Singleton.
        /// </summary>
        private Meniu()
        {
            //Se creaza fabrica si se initializeaza lista de tipuri de produse
            _creator     = new CreatorProduct();
            _productList = new List <TipProdus>();
            //Se creaza fiecare tip de produse si se adauga produsele in listele cu fiecare tip de produs
            //Gustari reci
            TipProdus gustariReci = new TipProdus("Gustari Reci");

            gustariReci.AddProduct(_creator.CreateProduct(ProductName.PSalataCaesar));
            gustariReci.AddProduct(_creator.CreateProduct(ProductName.PSalataBulgareasca));
            gustariReci.AddProduct(_creator.CreateProduct(ProductName.PSalataGreceasca));
            gustariReci.AddProduct(_creator.CreateProduct(ProductName.PSalatCapresse));
            _productList.Add(gustariReci);

            //Paste
            TipProdus paste = new TipProdus("Paste");

            paste.AddProduct(_creator.CreateProduct(ProductName.PSpaghettiCarbonara));
            paste.AddProduct(_creator.CreateProduct(ProductName.PSpaghettiBolognese));
            paste.AddProduct(_creator.CreateProduct(ProductName.PLinguiniConFrttiDiMare));
            paste.AddProduct(_creator.CreateProduct(ProductName.PPennQuattroFormaggi));
            paste.AddProduct(_creator.CreateProduct(ProductName.PLasagna));
            _productList.Add(paste);

            //Supe/Ciorbe
            TipProdus supe = new TipProdus("Supe/Ciorbe");

            supe.AddProduct(_creator.CreateProduct(ProductName.PCiorbaRadauteana));
            supe.AddProduct(_creator.CreateProduct(ProductName.PCiorbaBurta));
            supe.AddProduct(_creator.CreateProduct(ProductName.PCiorbaPerisoare));
            supe.AddProduct(_creator.CreateProduct(ProductName.PCiorbaDeVacuta));
            supe.AddProduct(_creator.CreateProduct(ProductName.PCiorbaDeFasole));
            _productList.Add(supe);

            //Preparate Pui
            TipProdus preparatePui = new TipProdus("Preparate Pui");

            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PPieptDePuiLaGratar));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PPieptDePuiCuSosGrogonzola));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PFicateiPasare));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PAripioarePicante));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PCiulamaDePuiCuBranzaSiMamaliguta));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PPuiShanghai));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PPiFteluteMoldovenesti));
            preparatePui.AddProduct(_creator.CreateProduct(ProductName.PCordonBleu));
            _productList.Add(preparatePui);

            //Preparate Porc
            TipProdus preparatePorc = new TipProdus("Preparate Porc");

            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PCeafaLaGratar));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PCotletLaGratar));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PFrigaruiDePorcCuLegume));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PSnitelPorc));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PCiolanDePorcCuVarzaCalita));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PTochituraMoldoveneasca));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PMici));
            preparatePorc.AddProduct(_creator.CreateProduct(ProductName.PFasoleCuCiolan));
            _productList.Add(preparatePorc);

            //Desterturi
            TipProdus deserturi = new TipProdus("Deserturi");

            deserturi.AddProduct(_creator.CreateProduct(ProductName.PClatiteCuGem));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PClatiteCuFinetti));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PClatiteCuInghetataTopingSiFrisca));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PPapanasi));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PInghetataAsortata));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PTiramisu));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PBaclava));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PCheeseCake));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PTortCuFructe));
            deserturi.AddProduct(_creator.CreateProduct(ProductName.PTortCuCiocolata));
            _productList.Add(deserturi);
        }