protected override void Nested_LoadDataFromDataSource() { BookingResourceHandler h = new BookingResourceHandler(); _current = h.GetElementById(m_IdShowedObject.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource; if (_current == null) { throw new Exception("Elemento non trovato"); } }
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; } }
private void schedulerStorage1_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) { try { Nested_CheckSecurityForChanging(); } catch (Exception ex) { ErrorHandler.Show(ex); return; } foreach (DevExpress.XtraScheduler.Appointment app in e.Objects) { // DevExpress.XtraScheduler.Appointment app = e.Objects[0] as DevExpress.XtraScheduler.Appointment; //imposto per sicurezza il campo allday a true; app.AllDay = true; Assignment a = app.GetSourceObject(schedulerStorage1) as Assignment; //se ho cambiato risorsa dal calendario e non dal form //(il form tiene i valori sincronizzati) recupero la risorsa e la setto if (a.ResourceId != a.Resource.Id) { BookingResourceHandler h1 = new BookingResourceHandler(); WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource res = h1.GetElementById(a.ResourceId.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource; a.Resource = res; app.SetValue(schedulerStorage1, "Resource", res); } ////i save on my db AssignmentHandler h = new AssignmentHandler(); try { h.SaveOrUpdate(a); } catch (Exception ex) { WIN.SCHEDULING_APP.GUI.Utility.ErrorHandler.Show(ex); } } }