Ejemplo n.º 1
0
        public ClientiForm()
        {
            InitializeComponent();
            foreach (string cat in Enum.GetNames(typeof(Categoria)))
            {
                CheckBox cb = new CheckBox();
                cb.Name            = "_" + cat + "CheckBox";
                cb.Text            = cat;
                cb.Tag             = Enum.Parse(typeof(Categoria), cat);
                cb.Checked         = true;
                cb.CheckedChanged += Cb_CheckedChanged;
                _categorieFlowLayoutPanel.Controls.Add(cb);
            }
            foreach (Allergene all in LocaleRistorazione.GetInstance().Allergeni)
            {
                CheckBox cb = new CheckBox();
                cb.Name            = "_" + all.Nome + "CheckBox";
                cb.Text            = all.Nome;
                cb.Tag             = all;
                cb.CheckedChanged += Cb_CheckedChanged;
                _allergeniFlowLayoutPanel.Controls.Add(cb);
            }

            MenuDataGridView.ShowCellToolTips       = true;
            MenuDataGridView.CellToolTipTextNeeded += MenuDataGridView_CellToolTipTextNeeded;

            //PanelAttesaPers1.BackColor = Color.LightGreen;
            //LabelAttesaPers1.Text = "12 minuti";

            //PanelAttesaPers3.BackColor = Color.Orange;
            //LabelAttesaPers3.Text = "1 ora e 12 minuti";

            Control.CheckForIllegalCrossThreadCalls = false;
        }
Ejemplo n.º 2
0
        public CaposalaFormPresenter(CaposalaForm target)
        {
            _target             = target;
            _localeRistorazione = LocaleRistorazione.GetInstance();
            _localeRistorazione.ListaPrenotazioni.CollectionChanged += RefreshPrenotazioni;

            foreach (Tavolo t in _localeRistorazione.Tavoli)
            {
                t.StatoChanged += RefreshTavoli;
            }

            //Se per errore si chiude la finestra alla riapertura si hanno le prenotazioni di prima, idem per i tavoli
            RefreshPrenotazioni(this, EventArgs.Empty);
            RefreshTavoli(this, EventArgs.Empty);

            _modifierForm          = new ModifierForm();
            _modifierFormPresenter = new ModifierFormPresenter(_modifierForm);


            _target.PrenotazioniListView.MouseClick                   += _prenotazioniListView_MouseClick;
            _target.PrenotazioniListView.MouseDown                    += _prenotazioniListView_MouseDown;
            _target.TavoliListView.MouseClick                         += _tavoliListView_MouseClick;
            _target.OccupaTavoloToolStripMenuItem.Click               += occupaTavoloToolStripMenuItem_Click;
            _target.LiberaTavoloToolStripMenuItem.Click               += liberaTavoloToolStripMenuItem_Click;
            _target.ModificaPrenotazioneToolStripMenuItem.Click       += modificaPrenotazioneToolStripMenuItem_Click;
            _target.EliminaPrenotazioneToolStripMenuItem.Click        += eliminaPrenotazioneToolStripMenuItem_Click;
            _target.InserisciNuovaPrenotazioneToolStripMenuItem.Click += inserisciNuovaPrenotazioneToolStripMenuItem_Click;

            _target.FineSerataButton.Click += FineSerataButton_Click;
        }
Ejemplo n.º 3
0
        //unico handler per occupa e libera tavolo, differenzio il cambio in base allo stato del tavolo cliccato
        private void occupaTavoloToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem  t   = (ToolStripMenuItem)sender;
            ListViewItem       lvi = (ListViewItem)t.GetCurrentParent().Tag;
            LocaleRistorazione r   = LocaleRistorazione.GetInstance();
            Tavolo             tav = (Tavolo)lvi.Tag;

            int index = lvi.ListView.Items.IndexOf(lvi);

            Prenotazione first = getPrenotazione();
            bool         vuota = false;

            if (first == null)
            {
                vuota = true;
            }

            if (!vuota && first.NumeroCoperti <= tav.PostiMax)
            {
                r.Tavoli.ElementAt(index).Stato   = StatoTavolo.Occupato;
                r.Tavoli.ElementAt(index).Numero  = r.Tavoli.IndexOf(r.Tavoli.ElementAt(index)) + 1;
                r.Tavoli.ElementAt(index).Coperti = first.NumeroCoperti;
                r.Tavoli.ElementAt(index).CalcolaTempo.OccupaTavolo();
                r.ListaPrenotazioni.Remove(first);

                MessageBox.Show("Cliente " + first.ToString() + " al " + r.Tavoli.ElementAt(index));
            }
        }
Ejemplo n.º 4
0
 private void DrawPietanze()
 {
     Target.TableLayoutPanel.Controls.Clear();
     foreach (Pietanza p in LocaleRistorazione.GetInstance().Menu)
     {
         InsertPietanza(p);
     }
 }
Ejemplo n.º 5
0
        private void eliminaPrenotazioneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem t   = (ToolStripMenuItem)sender;
            ListViewItem      lvi = (ListViewItem)t.GetCurrentParent().Tag;
            Prenotazione      p   = (Prenotazione)lvi.Tag;

            LocaleRistorazione.GetInstance().ListaPrenotazioni.Remove(p);
            MessageBox.Show("Cancellazione Effettuata", "Elimina");
        }
Ejemplo n.º 6
0
        public ClientiFormTempiAttesaPresenter(ClientiForm target)
        {
            _target = target;

            LocaleRistorazione.GetInstance().ListaPrenotazioniChanged += RefreshListaPrenotazioni;
            Target.AggiungiPrenotazioneButton.Click += AggiungiPrenotazioneButton_Click;

            System.Timers.Timer timer = new System.Timers.Timer(1000);
            timer.Elapsed += Timer_Elapsed;
            timer.Start();
        }
Ejemplo n.º 7
0
        private void buttonNuovaPietanza_Click(object sender, EventArgs e)
        {
            Pietanza newPietanza = new Pietanza("", 0m, Categoria.Antipasto, new List <Allergene>());

            _modifierFormPresenter.SetEditableObject(newPietanza);
            if (_modifierForm.ShowDialog() == DialogResult.OK)
            {
                InsertPietanza(newPietanza);
                LocaleRistorazione.GetInstance().Menu.Add(newPietanza);
            }
        }
Ejemplo n.º 8
0
        private void liberaTavoloToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem  t   = (ToolStripMenuItem)sender;
            ListViewItem       lvi = (ListViewItem)t.GetCurrentParent().Tag;
            LocaleRistorazione r   = LocaleRistorazione.GetInstance();
            Tavolo             tav = (Tavolo)lvi.Tag;

            tav.CalcolaTempo.LiberaTavolo();
            tav.Stato  = StatoTavolo.Libero;
            tav.Numero = r.Tavoli.IndexOf(tav) + 1;
            MessageBox.Show(tav.ToString());
        }
Ejemplo n.º 9
0
        private void buttonIndietro_Click(object sender, EventArgs e)
        {
            if (LocaleRistorazione.GetInstance().Menu.Where(p => p.Disponibile == true).ToList().Count == 0)
            {
                MessageBox.Show(
                    "Il menu non contiene pietanze disponibili, non sarà possibile avviare il totem clienti",
                    "Nessuna Pietanza",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }

            Target.Close();
        }
Ejemplo n.º 10
0
 public AllergeniModifier()
 {
     InitializeComponent();
     foreach (Allergene all in LocaleRistorazione.GetInstance().Allergeni)
     {
         CheckBox cb = new CheckBox();
         cb.Name = "_" + all.Nome + "CheckBox";
         cb.Text = all.Nome;
         cb.Tag  = all;
         tableLayoutPanel1.Controls.Add(cb);
         tableLayoutPanel1.RowCount++;
     }
 }
Ejemplo n.º 11
0
 private Prenotazione getPrenotazione()
 {
     //return (Ristorante.GetInstance().ListaPrenotazioni.Count != 0) ? Ristorante.GetInstance().ListaPrenotazioni.First() : null;
     if (LocaleRistorazione.GetInstance().ListaPrenotazioni.Count == 0)
     {
         MessageBox.Show("Nessuna voce nella lista prenotazioni");
         return(null);
     }
     if (_target.PrenotazioniListView.SelectedItems.Count != 1)
     {
         MessageBox.Show("Seleziona una voce dalla lista di prenotazione");
         return(null);
     }
     return((Prenotazione)_target.PrenotazioniListView.SelectedItems[0].Tag);
 }
Ejemplo n.º 12
0
        private void buttonElimina_Click(object sender, EventArgs e)
        {
            Pietanza     toDelete = (Pietanza)((ToolStripMenuItem)sender).Tag;
            DialogResult dr       = MessageBox.Show(
                "Sei sicuro di voler eliminare la pietanza " + toDelete.Titolo + "?",
                "Conferma Eliminazione",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning,
                MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.Yes)
            {
                LocaleRistorazione.GetInstance().Menu.Remove(toDelete);
            }
            DrawPietanze();
        }
Ejemplo n.º 13
0
        private TimeSpan GetTempoAttesaMinimo(int nroPersone)
        {
            List <TimeSpan> tempi = new List <TimeSpan>();

            LocaleRistorazione.GetInstance().Tavoli.Where(t => t.PostiMax >= nroPersone && t.PostiMax <= (nroPersone + 1)).ToList()
            .ForEach(t => tempi.Add(t.CalcolaTempo.TempoRimanente));
            tempi.Sort();
            if (tempi.Count == 0 || localeVuoto())
            {
                return(TimeSpan.Zero);
            }
            int index = 0;

            LocaleRistorazione.GetInstance().ListaPrenotazioni.Where(p => p.NumeroCoperti >= nroPersone && p.NumeroCoperti <= (nroPersone + 1)).ToList()
            .ForEach(p => tempi[index % tempi.Count] = tempi[index++ % tempi.Count] + Previsione.GetInstance().OttieniPrevisione(nroPersone));
            return(tempi.Count != 0 ? tempi.Min() : TimeSpan.Zero);
        }
Ejemplo n.º 14
0
        private void modificaPrenotazioneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem t   = (ToolStripMenuItem)sender;
            ListViewItem      lvi = (ListViewItem)t.GetCurrentParent().Tag;
            Prenotazione      p   = (Prenotazione)lvi.Tag;
            ObservableCollection <Prenotazione> lista = LocaleRistorazione.GetInstance().ListaPrenotazioni;


            int index = lvi.ListView.Items.IndexOf(lvi);

            _modifierFormPresenter.SetEditableObject(p);

            if (_modifierForm.ShowDialog() == DialogResult.OK)
            {
                lista.RemoveAt(index);
                lista.Insert(index, p);
            }
        }
        public InserimentoPrenotazioneForm()
        {
            InitializeComponent();

            // Setto il componente per i coperti
            _numericUpDownNumeroPosti.Minimum = 1;
            List <Tavolo> tavoli   = LocaleRistorazione.GetInstance().Tavoli;
            int           maxPosti = 2;

            foreach (Tavolo t in tavoli)
            {
                if (t.PostiMax > maxPosti)
                {
                    maxPosti = t.PostiMax;
                }
            }
            _numericUpDownNumeroPosti.Maximum  = maxPosti;
            _numericUpDownNumeroPosti.ReadOnly = true;
        }
Ejemplo n.º 16
0
        private void ConfermaButton_onClick(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show(
                "Sei sicuro di voler salvare questo Layout?",
                "Conferma Layout",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Information,
                MessageBoxDefaultButton.Button2);

            if (dr == DialogResult.Yes)
            {
                LocaleRistorazione          ristorante = LocaleRistorazione.GetInstance();
                Dictionary <String, Tavolo> tavoli     = new Dictionary <string, Tavolo>();

                IEnumerable <PictureBox> layoutBox = Target.TableLayoutPanel2.Controls.OfType <PictureBox>();

                foreach (PictureBox pb in layoutBox)
                {
                    if (pb.Tag != null)
                    {
                        String name = pb.Name;
                        // Ricavo le coordinate dal nome della PictureBox
                        String coordinate = name.Substring(name.Length - 2);
                        tavoli.Add(coordinate, new Tavolo(int.Parse(pb.Tag.ToString()), StatoTavolo.Libero));
                    }
                }
                ristorante.Tavoli = tavoli.Values.ToList();

                LayoutPersisterFactory.GetLayoutSaver("SimpleJsonLayoutSaver").Save(tavoli);
                if (tavoli.Count == 0)
                {
                    MessageBox.Show(
                        "Il layout non contiene tavoli, non sarà possibile avviare il totem clienti",
                        "Nessun Tavolo",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                }

                Target.Close();
            }
        }
Ejemplo n.º 17
0
        public static void Test()
        {
            LocaleRistorazione rist             = LocaleRistorazione.GetInstance();
            List <Allergene>   allergeniLasagne = new List <Allergene>();

            allergeniLasagne.Add(new Allergene("Latticini"));
            rist.Menu.Add(new Pietanza("Lasagna alla bolognese", 7.5m, Categoria.Primo, allergeniLasagne));

            rist.Menu.Add(new Pietanza("Prosciutto e melone", 5.0m, Categoria.Antipasto, null, "Un antipasto fresco", false));

            rist.Menu.Add(new Pietanza("Arrosto di lonza di maiale al latte", 8.0m, Categoria.Secondo, allergeniLasagne, "Un secondo classico"));

            rist.Menu.Add(new Pietanza("Pignoletto bottiglia", 5.0m, Categoria.Bevanda, null));

            Console.WriteLine("---------- CRITERI DI SELEZIONE TEST ----------");

            Console.WriteLine("---------- MENU COMPLETO ----------");
            rist.Menu.ForEach(p => Console.WriteLine(p + Environment.NewLine));

            Console.WriteLine("---------- MENU NO LATTICINI ----------");
            new CriterioDiSelezioneByNotContainsAllergene(new Allergene("Latticini"))
            .GetPietanze()
            .ForEach(p => Console.WriteLine(p + Environment.NewLine));

            Console.WriteLine("---------- MENU SOLO PRIMI E SECONDI ----------");
            new CriterioDiSelezioneByCategoria(Categoria.Primo | Categoria.Secondo)
            .GetPietanze()
            .ForEach(p => Console.WriteLine(p + Environment.NewLine));

            Console.WriteLine("---------- MENU SOLO DISPONIBILI ----------");
            new CriterioDiSelezioneByDisp()
            .GetPietanze()
            .ForEach(p => Console.WriteLine(p + Environment.NewLine));

            Console.WriteLine("---------- MENU SOLO PRIMI NO LATTICINI ----------");
            new CriterioDiSelezioneByCategoria(Categoria.Primo,
                                               new CriterioDiSelezioneByNotContainsAllergene(new Allergene("Latticini")))
            .GetPietanze()
            .ForEach(p => Console.WriteLine(p + Environment.NewLine));
            Console.WriteLine("--------------------------------");
        }
Ejemplo n.º 18
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new LayoutForm());
            //(new Test()).Show();

            //Tests();

            //ModifierForm f = new ModifierForm();
            //ModifierFormPresenter mfp = new ModifierFormPresenter(f);
            //Pietanza piet = new Pietanza("primissimo piatto",
            //    4.5m, Categoria.Antipasto,new List<Allergene>());
            //mfp.SetEditableObject(piet);
            //Application.Run(f);
            //Application.Run(new Test());
            //f.ShowDialog();

            //Ristorante.GetInstance().Menu = InitMenu();
            //MenuForm mf = new MenuForm();
            //MenuFormPresenter mfp = new MenuFormPresenter(mf);
            //Application.Run(mf);

            //Application.Run(new LayoutForm());

            LocaleRistorazione.GetInstance().Menu = InitMenu();
            SetDefaultLayout();
            FirstWindowForm f = new FirstWindowForm();

            new FirstWindowFormPresenter(f);
            Application.Run(f);

            //ClientiForm cf = new ClientiForm();
            //new ClientiFormSelezioneMenuPresenter(cf);

            //Application.Run(cf);
        }
 private void _buttonOK_Click(object sender, EventArgs e)
 {
     if (_textBoxNome.Text == "" || _textBoxNumeroTel.Text == "" || !telefonoValido(_textBoxNumeroTel.Text))
     {
         MessageBox.Show(
             "Uno o più campi sono errati. Impossibile inserire prenotazione",
             "Errore",
             MessageBoxButtons.OK,
             MessageBoxIcon.Warning,
             MessageBoxDefaultButton.Button1);
     }
     else
     {
         LocaleRistorazione.GetInstance().ListaPrenotazioni.Add(
             new Prenotazione(_textBoxNome.Text, _textBoxNumeroTel.Text, (int)_numericUpDownNumeroPosti.Value));
         MessageBox.Show(
             "Prenotazione inserita con successo",
             "Prenotazione inserita",
             MessageBoxButtons.OK,
             MessageBoxIcon.Information,
             MessageBoxDefaultButton.Button1);
         Close();
     }
 }
Ejemplo n.º 20
0
 private bool localeVuoto()
 {
     return((LocaleRistorazione.GetInstance().ListaPrenotazioni.Count == 0) && (LocaleRistorazione.GetInstance().Tavoli.Where(t => t.Stato.Equals(StatoTavolo.Occupato)).Count() == 0));
 }
Ejemplo n.º 21
0
 private void Application_Idle(object sender, EventArgs e)
 {
     Target.AvvioTotemClientiButton.Enabled =
         LocaleRistorazione.GetInstance().Menu.Where(p => p.Disponibile).Count() != 0 &&
         LocaleRistorazione.GetInstance().Tavoli.Count != 0;
 }