private void SaveOrUpdate() { if (_current == null) { return; } //inserisco i parametri abituali _current.Subject = txtSub.Text; _current.Resource = cboZon.SelectedItem as Resource; _current.Customer = txtCust.EditValue as Customer; _current.Location = txtLoc.Text; _current.Label = cboCaus.SelectedItem as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Label; _current.Operator = cboOp.SelectedItem as Operator; _current.StartDate = dtpIni.DateTime.Date + timini.Time.TimeOfDay; _current.EndDate = dtpFin.DateTime.Date + timfin.Time.TimeOfDay; _current.Description = txtNote.Text; if (dtpOut.EditValue == null) { _current.OutcomeDate = DateTime.MinValue; } else { _current.OutcomeDate = dtpOut.DateTime; } _current.Outcome = cboOut.SelectedItem as Outcome; _current.OutcomeDescription = txtNoteRapp.Text; _current.IsClosed = chkClosed.Checked; //imposto i parametri di base _current.AppointmentType = 0; _current.AllDay = false; _current.StatusId = 0; _current.LabelId = 0; _current.ResourceId = 0; _current.RecurrenceInfo = ""; _current.ReminderInfo = ""; AppointmentHandler h = new AppointmentHandler(); h.SaveOrUpdate(_current); _current.CalculateAppointmentInfo(Properties.Settings.Default.Main_DeadlineDaysBefore); }
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 false; app.AllDay = false; MyAppointment a = app.GetSourceObject(schedulerStorage1) as MyAppointment; //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) { ResourceHandler h1 = new ResourceHandler(); WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource res = h1.GetElementById(a.ResourceId.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource; a.Resource = res; app.SetValue(schedulerStorage1, "Resource", res); } ////i save on my db AppointmentHandler h = new AppointmentHandler(); try { h.SaveOrUpdate(a); } catch (Exception ex) { WIN.SCHEDULING_APP.GUI.Utility.ErrorHandler.Show(ex); } } }
private void schedulerStorage1_AppointmentsInserted(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e) { //gets the newly created Devexpress appointment; DevExpress.XtraScheduler.Appointment app = e.Objects[0] as DevExpress.XtraScheduler.Appointment; //********************************************************* //questo codice è inserito per risolvere il problema dell'assegnazione della risorsa //dopo il grag drop DevExpress.XtraScheduler.Resource ee = app.ResourceId as DevExpress.XtraScheduler.Resource; //questa situazione si verifica quando lo scheduler non è stato in grado //di assegnare una risorsa all'appuntamento creato nella funzione GetDragData //e pertanto assegna la risorsa "All" all'appuntamento if (ee != null) { Customer ccc = app.GetValue(schedulerStorage1, "Customer") as Customer; if (ccc != null) { app.SetValue(schedulerStorage1, "Resource", ccc.Resource); app.ResourceId = ccc.Resource.Id; } else { WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource t = new ResourceHandler().GetAll()[0] as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource; app.SetValue(schedulerStorage1, "Resource", t); app.ResourceId = t.Id; } } else { app.SetValue(schedulerStorage1, "Resource", new ResourceHandler().GetElementById(app.ResourceId.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.ComboElements.Resource); } //****************************************************************++ //imposto per sicurezza il campo allday a false; app.AllDay = false; ////i get my custom object MyAppointment a = app.GetSourceObject(schedulerStorage1) as MyAppointment; ////i save on my db AppointmentHandler h = new AppointmentHandler(); try { h.SaveOrUpdate(a); } catch (Exception ex) { WIN.SCHEDULING_APP.GUI.Utility.ErrorHandler.Show(ex); return; } //notifico l'id all'oggetto appena creato Key newId = a.Key; app.SetValue(schedulerStorage1, "Key", newId); //Appointment app1 = app.Copy(); //app1.Start = DateTime.Now.AddHours(2); //schedulerStorage1.Appointments.Add(app1); //foreach (Appointment item in schedulerStorage1 .Appointments.Items ) //{ // MyAppointment a1 = app.GetSourceObject(schedulerStorage1) as MyAppointment; //} }