예제 #1
0
        private void CheckInputIsValid()
        {
            //qui verifico l'inoput preventivamente.
            //non lascio la validazione finale all'oggetto di dominio per come è costruita la gui
            //di devexpress

            //verifica delle date
            if (this.dtpOut.DateTime.Date <= this.dtpIn.DateTime.Date)
            {
                throw new Exception("L'intervallo date inserito non è valido");
            }
            //verifico la possibilità di aggiungere una nuova assegnazione oppure
            //se la modifica di una assegnazione può essere fatta
            AssignmentHandler h = new AssignmentHandler();

            int assignmentID = -1;

            if (!_isCreationOp)
            {
                Assignment a = _apt.GetSourceObject(_control.Storage) as Assignment;
                if (a == null)
                {
                    throw new Exception("Impossibile otttenere il source object dall'appuntamento!! Contattare la noesis per la risoluzione del bug");
                }
                assignmentID = a.Id;
            }


            FreeRoomCheck cc = h.IsRoomFree(this.dtpIn.DateTime.Date, this.dtpOut.DateTime.Date, chkResources.EditValue as WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource, assignmentID);

            if (!cc.IsFree)
            {
                throw new Exception(cc.Message);
            }
        }
예제 #2
0
        private void schedulerStorage1_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e)
        {
            try
            {
                Nested_CheckSecurityForChanging();

                //qui verifico che l'appuntamento può essere cambiato
                Appointment app = e.Object as Appointment;

                BookingResourceHandler bc  = new BookingResourceHandler();
                BookingResource        res = bc.GetElementById(app.ResourceId.ToString()) as BookingResource;

                Assignment ass = app.GetSourceObject(schedulerStorage1) as Assignment;

                AssignmentHandler hh = new AssignmentHandler();

                FreeRoomCheck cc = hh.IsRoomFree(app.Start, app.End, res, ass.Id);
                if (!cc.IsFree)
                {
                    XtraMessageBox.Show(cc.Message, "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    e.Cancel = true;
                }


                //if (XtraMessageBox.Show("Il prezzo verra' cambiato di conseguenza. Continuare?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                //{
                //    e.Cancel = true;
                //    return;
                //}

                //Appointment app1 = e.Object as Appointment;
                //Assignment aas1 = app1.GetSourceObject(schedulerStorage1) as Assignment;

                //if (aas1.Booking.Confirmed)
                //{


                //    aas1.Booking.Payment.Total = aas1.Booking.Payment.Total + 10;
                //}
            }
            catch (AccessDeniedException)
            {
                ErrorHandler.Show("Impossibile accedere alla funzionalità richiesta. Accesso negato");
                e.Cancel = true;
            }
            catch (Exception ex)
            {
                ErrorHandler.Show(ex);
                e.Cancel = true;
            }
        }