私は (しようとして) DevExpress XtraScheduler を使用して - (理由は聞かないでください) 実際にスケジューラ コントロールを使用せずに予定を作成するために、このようにしようとしました...
conn = new SqlConnection("connectionstring");
conn.Open();
int ResourceId = 18;
AppointmentsAdapter = new SqlDataAdapter();
AppointmentsAdapter.SelectCommand = new SqlCommand("spGetAppointmentsForResourceById", conn);
AppointmentsAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
AppointmentsAdapter.SelectCommand.Parameters.AddWithValue("@ResourceID", ResourceID);
DataSet ds = new DataSet();
AppointmentsAdapter.Fill(ds);
SchedulerStorage store = new SchedulerStorage();
store.Appointments.DataSource = ds.Tables[0];
store.Appointments.Mappings.Start = "StartDate";
store.Appointments.Mappings.End = "EndDate";
//etc etc
store.Appointments.CustomFieldMappings.Add(new AppointmentCustomFieldMapping("fkcase", "fkcase"));
//.. etc etc
AppointmentBaseCollection appts = store.GetAppointments(dateFrom, dateTo);
これは正常に機能しています-つまり。それは日付間の予定を返します..素晴らしい..しかし、私が実際にやろうとしているのは、特定の日時に新しい予定を追加できるかどうかを判断できるように、すべての予定を照会することです。
できるようになりたい
AppointmentsAdapter.InsertCommand = new SqlCommand("spInsertAppointment", conn);
AppointmentsAdapter.InsertCommand.Parameters.Add("@Type", SqlDbType.Int);
AppointmentsAdapter.InsertCommand.Parameters.Add("@StartDate", SqlDbType.DateTime);
AppointmentsAdapter.InsertCommand.Parameters.Add("@EndDate", SqlDbType.DateTime);
//...etc etc
そして、する
Appointment apt = store.CreateAppointment(DevExpress.XtraScheduler.AppointmentType.Normal);
apt.Start = DateTime.Today.AddHours(8);
apt.Duration = TimeSpan.FromHours(1);
apt.Subject = "Subject";
apt.Description = "Description";
store.Appointments.Add(apt);
しかし、ストアのように見えます-マッピングなどを設定し、アダプターが実際に新しい予定を追加することを拒否しているにもかかわらず。私は何か間違ったことをしているだけだと思いますが、この方法ではできないのでしょうか? 確認するために、私は実際にはフォームにスケジューラ コントロールを持っておらず、望んでいません。
特定のリソース/日付範囲の可能な予定のリストをユーザーに提供しようとしているだけで、ユーザーが1つを選択したら、選択した予定を実際に保存します。