XtraScheduler创建约会编程 [英] XtraScheduler create appointment programatically
问题描述
我(想)使用DevEx preSS XtraScheduler为 - (不要问为什么),以创建约会实际上并没有使用调度控制形式 我试图做这样的...
I am (trying) to use the DevExpress XtraScheduler to - (dont ask why) to create an appointment without actually using the scheduler control in the form i have attempted to do that like this...
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);
这是工作的罚款 - 即。它返回我的日期之间的约会......伟大的.. 但其实我试图做的是查询所有的约会,这样我可以工作,如果新人们可以在特定日期时间进行添加。
this is working fine - ie. it returns me the appointments between the dates.. great.. but what i am actually trying to do is query all the appointments so that i can work out if a new one can be added at a particular datetime.
我还想能够做到
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);
但现在看来,实体店 - 尽管我已成立了映射等和适配器拒绝实际添加了新的任命。 我想我只是做错了什么,BUIT也许我不能做这种方式? 只是为了确认,我不居然有形式的调度控制,并且不想要一个。
but it appears that the store - even though i have set up the mappings etc and the adapter refuses to actually add the new appointment. i imagine i am just doing something wrong, buit maybe i cannot do it this way ? just to confirm, i dont actually have a scheduler control in the form, and dont want one.
我只是想给用户的可能的预约名单特定资源/ DATERANGE,然后一旦用户已经挑了一张,真正保存挑约会了。
i am just trying to give the user a list of possible appointments for a particular resource/daterange and then once the user has picked one, actually save the picked appointment away.
任何帮助,非常高兴地接受。
any help very happily received.
感谢
NAT
推荐答案
我建议你订阅SchedulerStorage的AppointmentsChanged,AppointmentsInserted和AppointmentsDeleted活动,实行单一的处理程序为所有这些事件最后调用DataAdapter的更新方法此事件处理程序:
I suggest that you subscribe to the AppointmentsChanged, AppointmentsInserted and AppointmentsDeleted events of the SchedulerStorage, implement a single handler for all these events and finally call the dataAdapter's Update method in this event handler:
void schedulerStorage_AppointmentsChanged(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e) {
// the code below to apply changes.
myTableAdapter.Update(this.myDBDataSet);
myDBDataSet.AcceptChanges();
}
这篇关于XtraScheduler创建约会编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!