Guest User

Devexpress scheduler mapping

a guest
Jan 13th, 2015
1,682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. #region Load tabels
  2.  
  3. SqlConnection cnn = new SqlConnection(functionsClass.GetConnectionString());
  4. SqlCommand cmd = new SqlCommand() { CommandText = "prepareAppointmentsTbl", CommandType = CommandType.StoredProcedure, Connection = cnn };
  5.  
  6. //SqlCommand cmd2 = new SqlCommand("select * from Doctors", cnn);
  7. SqlCommand cmd2 = new SqlCommand() { CommandText = "newSelectDoctors", CommandType = CommandType.StoredProcedure, Connection = cnn };
  8.  
  9.  
  10. cnn.Open();
  11. try
  12. {
  13. cmd.Parameters.Clear();
  14. cmd.Parameters.AddWithValue("@month_count", mont_count);
  15. cmd.Parameters.AddWithValue("@all", all);
  16.  
  17.  
  18. dt.Load(cmd.ExecuteReader());
  19. dt2.Load(cmd2.ExecuteReader());
  20.  
  21. }
  22. catch (Exception ex)
  23. {
  24. XtraMessageBox.Show(ex.Message);
  25. return;
  26. }
  27. finally
  28. {
  29. cnn.Close();
  30.  
  31. }
  32. #endregion
  33.  
  34. #region bind and mapping fields
  35. // bind the schedular to datatables
  36. schedulerStorage1.Appointments.DataSource = dt;
  37. schedulerStorage1.Resources.DataSource = dt2;
  38.  
  39. SchedulerStorage schedulerStorage = schedulerControl1.Storage;
  40. ResourceMappingInfo resourceMappings = schedulerStorage.Resources.Mappings;
  41. AppointmentDependencyMappingInfo appointmentDependencyMappings = schedulerStorage.AppointmentDependencies.Mappings;
  42. AppointmentMappingInfo appointmentMappings = schedulerStorage.Appointments.Mappings;
  43.  
  44. resourceMappings.Id = "doc_ID";
  45. resourceMappings.Caption = "doc_name";
  46.  
  47. appointmentMappings.AppointmentId = "app_code";
  48. appointmentMappings.Start = "start_date";
  49. appointmentMappings.End = "end_date";
  50. appointmentMappings.Subject = "pname";
  51. appointmentMappings.Description = "notes";
  52. appointmentMappings.Location = "cat_name";
  53. appointmentMappings.Label = "color";
  54. appointmentMappings.Status = "showAs";
  55. appointmentMappings.AllDay = "allDay";
  56. //appointmentMappings.ReminderInfo = "ReminderInfo";
  57. //appointmentMappings.RecurrenceInfo = "RecurrenceInfo";
  58. //appointmentMappings.Type = "EventType";
  59. //appointmentMappings.ResourceId = "ResourceID";
  60.  
  61.  
  62. schedulerStorage.Appointments.CommitIdToDataSource = false;
  63. schedulerStorage.Appointments.ResourceSharing = true;
  64. schedulerControl1.GroupType = SchedulerGroupType.Resource;
  65. schedulerControl1.ActiveViewType = SchedulerViewType.Day;
  66.  
  67. schedulerStorage.Resources.DataSource = dt2;
  68. // schedulerStorage.AppointmentDependencies.DataSource = dataSet.Tables["AppointmentDependencies"];
  69. schedulerStorage.Appointments.DataSource = dt;
  70.  
  71. schedulerStorage.AppointmentsInserted += delegate(object s, PersistentObjectsEventArgs ea)
  72. {
  73. DataTable dtAppointments = (DataTable)schedulerStorage.Appointments.DataSource;
  74.  
  75. schedulerStorage.SetAppointmentId((Appointment)ea.Objects[0],
  76. Convert.ToInt32(dtAppointments.Rows[dtAppointments.Rows.Count - 1][appointmentMappings.AppointmentId]));
  77. };
  78.  
  79.  
  80. #endregion
Advertisement
Add Comment
Please, Sign In to add comment