Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions CS/SimpleCustomFields/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
using DevExpress.XtraScheduler;
#endregion #usings

namespace SimpleCustomFields
{
public partial class Form1 : Form
{
public Form1()
{
namespace SimpleCustomFields {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();

schedulerDataStorage1.AppointmentInserting += SchedulerStorage1_AppointmentInserting;
Expand All @@ -27,8 +24,7 @@ public Form1()
this.schedulerControl1.Start = new DateTime(2010, 07, 01);
}

private void Form1_Load(object sender, EventArgs e)
{
private void Form1_Load(object sender, EventArgs e) {
// TODO: This line of code loads data into the 'carsDBDataSet.Cars' table. You can move, or remove it, as needed.
this.carsTableAdapter.Fill(this.carsDBDataSet.Cars);
// TODO: This line of code loads data into the 'carsDBDataSet.CarScheduling' table. You can move, or remove it, as needed.
Expand All @@ -37,44 +33,35 @@ private void Form1_Load(object sender, EventArgs e)

}

private void OnApptChangedInsertedDeleted(object sender, PersistentObjectsEventArgs e)
{
private void OnApptChangedInsertedDeleted(object sender, PersistentObjectsEventArgs e) {
carSchedulingTableAdapter.Update(carsDBDataSet);
carsDBDataSet.AcceptChanges();
}

private void carSchedulingTableAdapter_RowUpdated(object sender, OleDbRowUpdatedEventArgs e)
{
if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert)
{
private void carSchedulingTableAdapter_RowUpdated(object sender, OleDbRowUpdatedEventArgs e) {
if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert) {
int id = 0;
using (OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY",
carSchedulingTableAdapter.Connection))
{
carSchedulingTableAdapter.Connection)) {
id = (int)cmd.ExecuteScalar();
}
e.Row["ID"] = id;
}
}
#region #EditAppointmentFormShowing
private void schedulerControl1_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
{
private void schedulerControl1_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e) {
MyAppointmentForm form = new MyAppointmentForm(sender as SchedulerControl, e.Appointment, e.OpenRecurrenceForm);
try
{
try {
e.DialogResult = form.ShowDialog();
e.Handled = true;
}
finally
{
} finally {
form.Dispose();
}
}
#endregion #EditAppointmentFormShowing

#region #InitNewAppointment
private void schedulerControl1_InitNewAppointment(object sender, DevExpress.XtraScheduler.AppointmentEventArgs e)
{
private void schedulerControl1_InitNewAppointment(object sender, DevExpress.XtraScheduler.AppointmentEventArgs e) {
e.Appointment.Description += "Created at runtime at " + String.Format("{0:g}", DateTime.Now);
e.Appointment.CustomFields["Amount"] = 00.01d;
e.Appointment.CustomFields["ContactInfo"] = "someone@somecompany.com";
Expand All @@ -87,8 +74,11 @@ private void SchedulerStorage1_AppointmentInserting(object sender, PersistentObj
#endregion #AppointmentInserting
#region #AppointmentChanging
private void SchedulerStorage1_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e) {
if (((DevExpress.XtraScheduler.AdvPersistentObjectCancelEventArgs)e).PropertyName == "StatusKey") {
return;
}
object busyKey = schedulerDataStorage1.Appointments.Statuses.GetByType(AppointmentStatusType.Busy).Id;
if (((Appointment)e.Object).StatusKey == busyKey) e.Cancel = true;
if (((Appointment)e.Object).StatusKey.Equals(busyKey)) e.Cancel = true;
}
#endregion #AppointmentChanging
}
Expand Down
25 changes: 14 additions & 11 deletions VB/SimpleCustomFields/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Namespace SimpleCustomFields
AddHandler schedulerDataStorage1.AppointmentsChanged, AddressOf OnApptChangedInsertedDeleted
AddHandler schedulerDataStorage1.AppointmentsDeleted, AddressOf OnApptChangedInsertedDeleted

Me.schedulerControl1.Start = New Date(2010, 07, 01)
Me.schedulerControl1.Start = New Date(2010, 7, 1)
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Expand All @@ -49,7 +49,7 @@ Namespace SimpleCustomFields
e.Row("ID") = id
End If
End Sub
#Region "#EditAppointmentFormShowing"
#Region "#EditAppointmentFormShowing"
Private Sub schedulerControl1_EditAppointmentFormShowing(ByVal sender As Object, ByVal e As AppointmentFormEventArgs) Handles schedulerControl1.EditAppointmentFormShowing
Dim form As New MyAppointmentForm(TryCast(sender, SchedulerControl), e.Appointment, e.OpenRecurrenceForm)
Try
Expand All @@ -59,29 +59,32 @@ Namespace SimpleCustomFields
form.Dispose()
End Try
End Sub
#End Region ' #EditAppointmentFormShowing
#End Region ' #EditAppointmentFormShowing

#Region "#InitNewAppointment"
#Region "#InitNewAppointment"
Private Sub schedulerControl1_InitNewAppointment(ByVal sender As Object, ByVal e As DevExpress.XtraScheduler.AppointmentEventArgs) Handles schedulerControl1.InitNewAppointment
e.Appointment.Description &= "Created at runtime at " & String.Format("{0:g}", Date.Now)
e.Appointment.CustomFields("Amount") = 00.01R
e.Appointment.CustomFields("Amount") = 0.01R
e.Appointment.CustomFields("ContactInfo") = "someone@somecompany.com"
End Sub
#End Region ' #InitNewAppointment
#Region "#AppointmentInserting"
#End Region ' #InitNewAppointment
#Region "#AppointmentInserting"
Private Sub SchedulerStorage1_AppointmentInserting(ByVal sender As Object, ByVal e As PersistentObjectCancelEventArgs)
If CType(e.Object, Appointment).Start < Date.Now Then
e.Cancel = True
End If
End Sub
#End Region ' #AppointmentInserting
#Region "#AppointmentChanging"
#End Region ' #AppointmentInserting
#Region "#AppointmentChanging"
Private Sub SchedulerStorage1_AppointmentChanging(ByVal sender As Object, ByVal e As PersistentObjectCancelEventArgs)
If CType(e, DevExpress.XtraScheduler.AdvPersistentObjectCancelEventArgs).PropertyName = "StatusKey" Then
Return
End If
Dim busyKey As Object = schedulerDataStorage1.Appointments.Statuses.GetByType(AppointmentStatusType.Busy).Id
If CType(e.Object, Appointment).StatusKey Is busyKey Then
If CType(e.Object, Appointment).StatusKey.Equals(busyKey) Then
e.Cancel = True
End If
End Sub
#End Region ' #AppointmentChanging
#End Region ' #AppointmentChanging
End Class
End Namespace