Csharp/C#教程:XtraScheduler以编程方式创建约会分享


XtraScheduler以编程方式创建约会

我(尝试)使用DevExpress XtraScheduler – (不要问为什么)创建约会而不实际使用我试图这样做的forms的调度程序控件…

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); 

但它似乎是商店 – 即使我已经设置了映射等,并且适配器拒绝实际添加新约会。 我想我只是做错了什么,但也许我不能这样做? 只是为了确认,我实际上并没有表单中的调度程序控件,也不想要一个。

我只是试图给用户一个特定资源/日期范围的可能约会列表,然后一旦用户选择了一个,实际上保存所选择的约会。

我建议你订阅SchedulerStorage的AppointmentsChanged,AppointmentsInserted和AppointmentsDeleted事件,为所有这些事件实现一个处理程序,最后在这个事件处理程序中调用dataAdapter的Update方法:

上述就是C#学习教程:XtraScheduler以编程方式创建约会分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 void schedulerStorage_AppointmentsChanged(object sender, DevExpress.XtraScheduler.PersistentObjectsEventArgs e) { // the code below to apply changes. myTableAdapter.Update(this.myDBDataSet); myDBDataSet.AcceptChanges(); } 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1009615.html

(0)
上一篇 2021年12月29日
下一篇 2021年12月29日

精彩推荐