Ejemplo n.º 1
0
        private void Buy_Click(object sender, EventArgs e)
        {
            Bilet b = view.getBilet();

            if (b == null)
            {
                view.showMessage("NU mai sunt bilete disponibile pentru acest spectacol");
            }
            else
            {
                spectacolRepo.insertBilet(b);

                List <Spectacol> ls = spectacolRepo.getSpectacole();
                Spectacol        s  = new Spectacol();
                int index           = -1;

                //cautam spectacolul cu id-ul de la bilet deoarece in UI se preia id-ul de la lista de spectacole returnata (spectacolele sunt in ord alfabetica si id-urile nu sunt in ordine)
                for (int i = 0; i < ls.Count && index == -1; i++)
                {
                    if (ls[i].IdSpectacol == b.IdSpectacol)
                    {
                        s     = ls[i];
                        index = i;
                    }
                }

                view.setMatriceLocuri(index, spectacolRepo.getBileteBySpectacol(s), MoveMatrice_Event, MatriceLeave_Event, Matrice_Click);
                view.showMessage("Biletul a fost inregistrat");
            }
        }