Example #1
0
        private void timerTick_Tick(object sender, EventArgs e)
        {
            tick++;

            if (GestoreCalendario.Dump(ref info) || tick > 20)
            {
                CorreggiTimeScale();

                tick = 0;
                this.schedulerControlPrenotazioni.Focus();
                this.schedulerControlPrenotazioni.Refresh();
            }

            this.barStaticItemInfo3.Caption =
                info.ElencoRichiesteEvase + " / " +
                info.ElencoRichiesteAttive + " / " +
                info.ElencoNuoveRichieste;

            if (info.ElencoRichiesteAttive > 0)
            {
                this.barStaticItemInfo3.Glyph = Properties.Resources.bullet_ball_red;
            }
            else
            {
                this.barStaticItemInfo3.Glyph = Properties.Resources.bullet_ball_green;
            }

            foreach (Exception item in info.ErroriWeb)
            {
                DevExpress.XtraBars.Alerter.AlertInfo ainfo = new DevExpress.XtraBars.Alerter.AlertInfo("ERRORE Query Calendario", string.Format("Errore {0}", item.Message), Properties.Resources.delete);
                this.alertControl1.Show(this, ainfo);
            }
        }
Example #2
0
        private void schedulerControlPrenotazioni_CustomDrawDayViewAllDayArea(object sender, CustomDrawObjectEventArgs e)
        {
            AllDayAreaCell cell = (AllDayAreaCell)e.ObjectInfo;

            RisultatoCalendario ris = GestoreCalendario.GeneraRichiesta(cell.Interval.Start, m_ActiveControl.Ingresso.CodicePrevent);

            if (ris != null)
            {
                if (!string.IsNullOrEmpty(ris.InfoGiornata))
                {
                    if (cell.Selected)
                    {
                        e.Cache.FillRectangle(Brushes.LightCyan, e.Bounds);
                    }
                    else
                    {
                        e.Cache.FillRectangle(Brushes.Yellow, e.Bounds);
                    }

                    e.Cache.DrawString(ris.InfoGiornata, cell.Appearance.Font, Brushes.Black, e.Bounds, cell.Appearance.TextOptions.GetStringFormat());

                    cell.ToolTipText = String.Format("{0} : {1}", cell.Interval.Start.ToShortDateString(), ris.InfoGiornata);

                    e.Handled = true;
                }
            }
        }
Example #3
0
        private void CorreggiTimeScale()
        {
            int timespan = GestoreCalendario.GetTimeSpan();

            if (this.schedulerControlPrenotazioni.DayView.TimeScale.TotalMinutes != timespan)
            {
                this.schedulerControlPrenotazioni.DayView.TimeScale      = new TimeSpan(0, timespan, 0);
                this.schedulerControlPrenotazioni.WorkWeekView.TimeScale = new TimeSpan(0, timespan, 0);
            }
        }
        public void CreaPrenotazione(bool manuale)
        {
            // cancello se presenti nel calendario
            foreach (Prenotazione item in this.m_CollectionMySet)
            {
                this.m_CollectionPrenotazioni.Remove(item);
            }

            this.m_CollectionMySet = new XPCollection <Prenotazione>(m_UnitOfWork, false);

            m_Ingresso = m_UnitOfWork.GetObjectByKey <Ingresso>(m_Prenotazione.Ingresso.Oid);

            if (manuale)
            {
                m_Prenotazione.Init(this.m_CollectionPrenotazioni, this.m_Scheduler.SelectedInterval.Start, GestoreCalendario.TipoGS);
            }

            foreach (SingolaPrenotazione singolaPrenotazione in m_Prenotazione.Prenotazioni)
            {
                Prenotazione pren = new Prenotazione(m_UnitOfWork);
                //pren.DurataSlot = m_Ingresso.DurataSlot(GestoreCalendario.TipoGS);
                pren.DurataSlot = GestoreCalendario.GetTimeSpan(m_Ingresso.CodicePrevent);
                pren.StartDate  = singolaPrenotazione.Orario;
                pren.EndDate    = singolaPrenotazione.Orario + new TimeSpan(0, GestoreCalendario.GetTimeSpan(m_Ingresso.CodicePrevent), 0);
                //new TimeSpan(0, m_Ingresso.DurataSlot(GestoreCalendario.TipoGS), 0);
                pren.Subject = singolaPrenotazione.Descrizione;
                //"Squadra " + nomegruppo[this.m_CollectionMySet.Count % nomegruppo.Length]; // +" (" + singolaPrenotazione.NumeroPersone.ToString() + " persone)";
                pren.Ingresso         = m_Ingresso;
                pren.Description      = m_Ingresso.Descrizione;
                pren.NumeroPersone    = singolaPrenotazione.NumeroPersone;
                pren.OriginataPrevent = singolaPrenotazione.OriginataPrevent;
                pren.PreventStartDate = pren.StartDate;
                pren.SetLabel(m_PaginaAttiva);

                pren.Save();

                this.m_CollectionMySet.Add(pren);
                this.m_CollectionPrenotazioni.Add(pren);
            }

            VerificaStato();

            this.m_Scheduler.RefreshData();

            this.gridControlPrenotazioni.DataSource = this.m_CollectionMySet;
            this.gridViewPrenotazioni.BestFitColumns();
        }
        private void gridControlPrenotazioni_EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType == NavigatorButtonType.Append)
            {
                e.Handled = true;

                Prenotazione prenotazione = new Prenotazione(m_UnitOfWork);
                prenotazione.Ingresso    = m_Ingresso;
                prenotazione.Description = m_Ingresso.Descrizione;
                prenotazione.Subject     = PrenotazioneComplessiva.RiferimentoGlobale;
                // "nuova squadra";
                //prenotazione.DurataSlot = m_Ingresso.DurataSlot(GestoreCalendario.TipoGS);
                prenotazione.DurataSlot = GestoreCalendario.GetTimeSpan(m_Ingresso.CodicePrevent);
                prenotazione.StartDate  = this.m_Scheduler.SelectedInterval.Start;
                prenotazione.StartDate  = prenotazione.FixStartDate();

                using (XtraFormEditPrenotazione formpre = new XtraFormEditPrenotazione())
                {
                    formpre.Init(prenotazione);
                    if (formpre.ShowDialog(this) == DialogResult.OK)
                    {
                        prenotazione.Save();
                        this.m_CollectionMySet.Add(prenotazione);
                        this.m_CollectionPrenotazioni.Add(prenotazione);
                        VerificaStato();
                    }
                }
            }

            if (e.Button.ButtonType == NavigatorButtonType.Remove)
            {
                e.Handled = true;

                Prenotazione prenotazione = this.gridViewPrenotazioni.GetRow(this.gridViewPrenotazioni.FocusedRowHandle) as Prenotazione;
                if (prenotazione != null)
                {
                    prenotazione.Delete();
                    VerificaStato();
                }
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (GestoreCalendario.RichiesteInCoda() == 0)
            {
                this.simpleButtonOk.Enabled = true;
                this.simpleButtonOk.Text    = "Conferma";

                if (!layoutControlItemProgress.IsHidden)
                {
                    this.layoutControlItemProgress.HideToCustomization();
                }
            }
            else
            {
                this.simpleButtonOk.Enabled = false;
                this.simpleButtonOk.Text    = String.Format("Attendere {0}", GestoreCalendario.RichiesteInCoda());

                if (layoutControlItemProgress.IsHidden)
                {
                    this.layoutControlItemProgress.RestoreFromCustomization(emptySpaceItem2, DevExpress.XtraLayout.Utils.InsertType.Left);
                }
            }
        }
Example #7
0
        private void schedulerControlPrenotazioni_CustomDrawTimeCell(object sender, CustomDrawObjectEventArgs e)
        {
            SelectableIntervalViewInfo obj = e.ObjectInfo as DevExpress.XtraScheduler.Drawing.SelectableIntervalViewInfo;

            if (obj != null)
            {
                e.DrawDefault();

                if (m_ActiveControl != null && m_ActiveControl.Ingresso.CodicePrevent > 0 && m_ActiveControl.Ingresso.Prenotazione != EnumPrenotazioneIngresso.NonGestita)
                {
                    RisultatoCalendario ris = GestoreCalendario.GeneraRichiesta(obj.Interval.Start, m_ActiveControl.Ingresso.CodicePrevent);

                    if (ris != null)
                    {
                        int numero = ris.PostiDisponibili;

                        if (obj.Selected)
                        {
                            e.Graphics.DrawString(numero.ToString(), font, brush_white, e.Bounds);
                        }
                        else
                        {
                            e.Graphics.DrawString(numero.ToString(), font, brush_green, e.Bounds);
                        }

                        if (numero > 0)
                        {
                            // int massimo = Math.Max(numero, m_ActiveControl.Ingresso.CapacitaSlot(GestoreCalendario.TipoGS));
                            int massimo = Math.Max(numero, ris.MaxPostiDisponibili);
                            e.Graphics.DrawLine(pen_green, e.Bounds.X + 1, e.Bounds.Y + 16, e.Bounds.X + e.Bounds.Width * numero / massimo - 1, e.Bounds.Y + 16);
                        }
                    }
                }

                e.Handled = true;
            }
        }
Example #8
0
        public void SistemaPrenotazione()
        {
            int numeroGiusto = this.GestoreProfili.TotalePersone();

            foreach (PrenotazioneIngresso prenotazioneIngresso in this.Prenotazioni)
            {
                if (prenotazioneIngresso.Attivo)
                {
                    prenotazioneIngresso.NumeroPersone = numeroGiusto;

                    int attuale = 0;
                    foreach (SingolaPrenotazione singolaPrenotazione in prenotazioneIngresso.Prenotazioni)
                    {
                        attuale += singolaPrenotazione.NumeroPersone;
                    }

                    if (attuale == numeroGiusto)
                    {
                        continue;
                    }

                    DateTime doinizio = new DateTime(1900, 1, 1);
                    foreach (SingolaPrenotazione item in prenotazioneIngresso.Prenotazioni)
                    {
                        if (item.Orario > doinizio)
                        {
                            doinizio = item.Orario;
                        }
                    }

                    //int ingressoCapacitaSlot = prenotazioneIngresso.Ingresso.CapacitaSlot(TipoGS());
                    int ingressoCapacitaSlot = GestoreCalendario.Capacita(prenotazioneIngresso.Ingresso.CodicePrevent, doinizio);

                    //MessageBox.Show(ingressoCapacitaSlot.ToString());

                    int slot  = numeroGiusto / ingressoCapacitaSlot;
                    int resto = numeroGiusto - ingressoCapacitaSlot * slot;
                    if (resto > 0)
                    {
                        slot++;
                    }
                    int media = numeroGiusto / slot;
                    resto = numeroGiusto - media * slot;

                    if (prenotazioneIngresso.Prenotazioni.Count < slot)
                    {
                        // creo i nuovi slot se sono necessari
                        DateTime inizio     = new DateTime(1900, 1, 1);
                        int      durataSlot = GestoreCalendario.GetTimeSpan(prenotazioneIngresso.Ingresso.CodicePrevent);
                        //int durataSlot = prenotazioneIngresso.Ingresso.DurataSlot(TipoGS());
                        //if (durataSlot == 0)
                        //    durataSlot = 60;

                        foreach (SingolaPrenotazione item in prenotazioneIngresso.Prenotazioni)
                        {
                            item.NumeroPersone = media;
                            if (item.Orario > inizio)
                            {
                                inizio = item.Orario;
                            }
                        }

                        inizio = inizio + new TimeSpan(0, durataSlot, 0);

                        for (int i = prenotazioneIngresso.Prenotazioni.Count; i < slot; i++)
                        {
                            SingolaPrenotazione nuova = new SingolaPrenotazione();

                            nuova.NumeroPersone    = media;
                            nuova.Orario           = inizio;
                            nuova.OrarioFine       = inizio + new TimeSpan(0, durataSlot, 0);
                            nuova.Descrizione      = PrenotazioneComplessiva.RiferimentoGlobale;
                            nuova.OriginataPrevent = !string.IsNullOrEmpty(this.PrenotazionePrevent);

                            prenotazioneIngresso.Prenotazioni.Add(nuova);

                            inizio = inizio + new TimeSpan(0, durataSlot, 0);
                        }

                        attuale = media * slot;
                    }
                    else if (prenotazioneIngresso.Prenotazioni.Count > slot)
                    {
                        // devo togliere degli slot ...
                        while (prenotazioneIngresso.Prenotazioni.Count > slot)
                        {
                            prenotazioneIngresso.Prenotazioni.Remove(prenotazioneIngresso.Prenotazioni[prenotazioneIngresso.Prenotazioni.Count - 1]);
                        }

                        foreach (SingolaPrenotazione item in prenotazioneIngresso.Prenotazioni)
                        {
                            item.NumeroPersone = media;
                        }

                        attuale = media * slot;
                    }

                    // raggiungo il numero corretto di persone
                    while (attuale != numeroGiusto)
                    {
                        if (attuale > numeroGiusto)
                        {
                            int pos = prenotazioneIngresso.SlotMaggiore();
                            prenotazioneIngresso.Prenotazioni[pos].NumeroPersone--;
                            attuale--;
                        }
                        else if (attuale < numeroGiusto)
                        {
                            int pos = prenotazioneIngresso.SlotMinore();
                            prenotazioneIngresso.Prenotazioni[pos].NumeroPersone++;
                            attuale++;
                        }
                    }
                }
            }
        }
Example #9
0
        //private bool fattoPrevent = false;
        private bool CreaSlotPrevent()
        {
            //string nomegruppo = "ABCDEFGHIJKLMNOPQRSTUWXYZ";

            if (PreventObj == null)
            {
                return(false);
            }
            //if (fattoPrevent) return false;

            // costruisce la prenotazione prevent
            foreach (PrenotazioneIngresso prenotazioneIngresso in this.Prenotazioni)
            {
                if (Esiste(PreventObj, prenotazioneIngresso.Ingresso.CodicePrevent))
                {
                    prenotazioneIngresso.Prenotazioni.Clear();
                    prenotazioneIngresso.ForzaturaPrevent = true;
                    foreach (prevent.get.OutRigaPercorsoVisita item in PreventObj.RigaPercorsoVisita)
                    {
                        if (item.IdMostra == prenotazioneIngresso.Ingresso.CodicePrevent.ToString())
                        {
                            SingolaPrenotazione prenotazione = new SingolaPrenotazione();
                            prenotazione.NumeroPersone = int.Parse(item.PaxVisita);
                            prenotazione.Orario        = item.DataVisita.Date + item.OraVisita.TimeOfDay;
                            prenotazione.OrarioFine    = prenotazione.Orario + new TimeSpan(0, GestoreCalendario.GetTimeSpan(prenotazioneIngresso.Ingresso.CodicePrevent), 0);
                            //prenotazioneIngresso.Ingresso.DurataSlot(PreventObj.TipoGS), 0);
                            //new TimeSpan(0, prenotazioneIngresso.Ingresso.DurataSlot(PreventObj.TipoGS), 0);
                            prenotazione.OriginataPrevent = true;
                            prenotazione.OrarioPrevent    = prenotazione.Orario;
                            prenotazione.Descrizione      = RiferimentoVendita;
                            // "Squadra " + nomegruppo[prenotazioneIngresso.Prenotazioni.Count % nomegruppo.Length];

                            prenotazioneIngresso.Prenotazioni.Add(prenotazione);

                            //Console.WriteLine("Prenotazione " + prenotazione.Orario);
                        }
                    }
                }
            }

            //fattoPrevent = true;

            return(true);
        }
Example #10
0
        public void Init(List <Ingresso> elenco, PrenotazioneComplessiva prenotazione)
        {
            CorreggiTimeScale();

            saved = false;

            //this.xpCollectionPrenotazioni = new DevExpress.Xpo.XPCollection(this.unitOfWork1, typeof(Prenotazione));
            for (int i = this.xpCollectionPrenotazioni.Count - 1; i >= 0; i--)
            {
                this.xpCollectionPrenotazioni.Remove(this.xpCollectionPrenotazioni[i]);
            }

            m_Elenco       = elenco;
            m_Prenotazione = prenotazione;
            m_Prenotazione.CollectionPrenotazione = this.xpCollectionPrenotazioni;

            GestoreCalendario.Clear(m_Prenotazione.TipoGS(), m_Prenotazione.TipoScuola(), false);

            //if (string.IsNullOrEmpty(m_Prenotazione.RiferimentoVendita))
            //{
            //    XtraFormAskInfoPrenotazione info = new XtraFormAskInfoPrenotazione();
            //    info.Init(m_Prenotazione);
            //    info.ShowDialog();
            //}

            this.xtraTabControlIngressi.BeginUpdate();
            this.xtraTabControlIngressi.TabPages.Clear();
            //int timespan = 60;

            m_Prenotazione.InitRefreshPrenotazione(m_Elenco);

            foreach (Ingresso item in m_Elenco)
            {
                XtraTabPage pagina = new XtraTabPage();
                pagina.Text = item.DescrizioneBreve;

                PrenotazioneIngresso newPrenotazioneIngresso = null;
                foreach (PrenotazioneIngresso prenotazioneIngresso in m_Prenotazione.Prenotazioni)
                {
                    if (prenotazioneIngresso.Ingresso.Oid == item.Oid)
                    {
                        newPrenotazioneIngresso = prenotazioneIngresso;
                    }
                }

                switch (item.Prenotazione)
                {
                case EnumPrenotazioneIngresso.NonGestita:
                    pagina.Text += ": NG";
                    //pagina.ImageIndex = 0;
                    break;

                case EnumPrenotazioneIngresso.Facoltativa:
                    pagina.Text      += ": FAC";
                    pagina.ImageIndex = 1;
                    break;

                case EnumPrenotazioneIngresso.Consigliata:
                    pagina.Text      += ": CON";
                    pagina.ImageIndex = 2;
                    break;

                case EnumPrenotazioneIngresso.Obbligatoria:
                    pagina.Text      += ": OBL";
                    pagina.ImageIndex = 3;
                    break;
                }

                pagina.Tag = newPrenotazioneIngresso;
                this.xtraTabControlIngressi.TabPages.Add(pagina);

                XtraUserControlCalendario2 ucal = new XtraUserControlCalendario2();
                ucal.Init(newPrenotazioneIngresso, pagina, this.xpCollectionPrenotazioni, this.schedulerControlPrenotazioni, m_Prenotazione);
                ucal.Dock = DockStyle.Fill;
                pagina.Controls.Add(ucal);

                //if (item.DurataSlot(GestoreCalendario.TipoGS) > 0)
                //    timespan = gcd(timespan, item.DurataSlot(GestoreCalendario.TipoGS));
            }

            // attivo la tab relativa alle prenotazioni prevent
            //foreach (XtraTabPage xtraTabPage in this.xtraTabControlIngressi.TabPages)
            //{
            //    m_ActiveControl = xtraTabPage.Controls[0] as XtraUserControlCalendario2;
            //    m_ActiveControl.CreaPrenotazione(false);
            //}

            this.xtraTabControlIngressi.EndUpdate();

            this.xtraTabControlIngressi.SelectedTabPage = this.xtraTabControlIngressi.TabPages[0];
            xtraTabControlIngressi_SelectedPageChanged(null, new TabPageChangedEventArgs(null, this.xtraTabControlIngressi.TabPages[0]));

            this.barStaticItemInfo1.Caption = string.Format("{0} persone per un totale di {1:c}", m_Prenotazione.GestoreProfili.TotalePersone(), m_Prenotazione.GestoreProfili.TotaleImporto());
            this.barStaticItemInfo2.Caption = m_Prenotazione.RiferimentoVendita;
            this.barStaticItemInfoG.Caption = string.Format("TipoGS: {0}", GestoreCalendario.TipoGS);
            this.barStaticItemInfoS.Caption = string.Format("Scuola: {0}", GestoreCalendario.TipoScuola);

            // Imposta la griglia temporale
            //this.schedulerControlPrenotazioni.DayView.TimeSlots.Clear();
            //this.schedulerControlPrenotazioni.WorkWeekView.TimeSlots.Clear();

            //int durata = timespan;
            //while (durata <= 60)
            //{
            //    this.schedulerControlPrenotazioni.DayView.TimeSlots.Add(new DevExpress.XtraScheduler.TimeSlot(new TimeSpan(0, durata, 0), "slotx1"));
            //    this.schedulerControlPrenotazioni.WorkWeekView.TimeSlots.Add(new DevExpress.XtraScheduler.TimeSlot(new TimeSpan(0, durata, 0), "slotx1"));
            //    durata += timespan;
            //}

            //this.schedulerControlPrenotazioni.DayView.TimeScale = new TimeSpan(0, timespan, 0);
            //this.schedulerControlPrenotazioni.WorkWeekView.TimeScale = new TimeSpan(0, timespan, 0);

            this.schedulerControlPrenotazioni.Start = DateTime.Now.Date.AddDays(-1);
            this.schedulerControlPrenotazioni.GoToToday();

            this.schedulerControlPrenotazioni.LimitInterval.Start = DateTime.Now.Date.AddDays(-1);
            this.schedulerControlPrenotazioni.LimitInterval.End   = DateTime.Now.Date.AddDays(20);

            this.schedulerControlPrenotazioni.Refresh();
        }
        public void Init(DevExpress.Xpo.XPCollection xPCollection, DateTime inizio, string tipoGS)
        {
            if (ForzaturaPrevent)
            {
                return;
            }

            RisultatoCalendario risultato = GestoreCalendario.GeneraRichiesta(inizio, Ingresso.CodicePrevent);

            if (risultato == null)
            {
                return;
            }

            int ingressoCapacitaSlot = risultato.MaxPostiDisponibili;

            if (ingressoCapacitaSlot <= 0)
            {
                ingressoCapacitaSlot = NumeroPersone;
            }

            //int durataSlot = Ingresso.DurataSlot(tipoGS);
            int durataSlot = GestoreCalendario.GetTimeSpan(Ingresso.CodicePrevent);

            DateTime origine = inizio;

            int slot  = NumeroPersone / ingressoCapacitaSlot;
            int resto = NumeroPersone - ingressoCapacitaSlot * slot;

            if (resto > 0)
            {
                slot++;
            }
            int media = NumeroPersone / slot;

            resto = NumeroPersone - media * slot;

            int persone = NumeroPersone;
            List <SingolaPrenotazione> ListaTemp = new List <SingolaPrenotazione>();

            while (persone > 0)
            {
                while (Occupato(xPCollection, inizio, durataSlot) || risultato == null)
                {
                    inizio   += new TimeSpan(0, durataSlot, 0);
                    risultato = GestoreCalendario.GeneraRichiesta(inizio, Ingresso.CodicePrevent);
                    TimeSpan tempo = inizio - origine;
                    if (tempo.TotalDays > 3)
                    {
                        return;
                    }
                }

                int nump = media;
                if (persone >= media)
                {
                    if (resto > 0 && risultato.MaxPostiDisponibili > media)
                    {
                        nump++;
                        resto--;
                    }
                }
                else
                {
                    nump = resto;
                }

                SingolaPrenotazione pre = new SingolaPrenotazione();

                pre.NumeroPersone    = nump;
                pre.Orario           = inizio;
                pre.OrarioFine       = inizio + new TimeSpan(0, durataSlot, 0);
                pre.Descrizione      = PrenotazioneComplessiva.RiferimentoGlobale;
                pre.OriginataPrevent = false;

                ListaTemp.Add(pre);

                persone -= nump;

                inizio   += new TimeSpan(0, durataSlot, 0);
                risultato = GestoreCalendario.GeneraRichiesta(inizio, Ingresso.CodicePrevent);
            }

            if (persone == 0)
            {
                Prenotazioni = ListaTemp;
            }
        }