/
Calendar.aspx.cs
77 lines (68 loc) · 3.51 KB
/
Calendar.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using DevExpress.Web.ASPxScheduler;
using DevExpress.XtraScheduler;
namespace SchedulerReportPreviewTest {
public partial class Calendar : System.Web.UI.Page {
#region #calendarpageload
protected void Page_Load(object sender, EventArgs e) {
if (Session["Loaded"] != null) {
PrepareReportPreview(PreviewPanel);
}
}
#endregion #calendarpageload
int lastInsertedAppointmentId;
// DXCOMMENT: This handler is called when a datasource insert operation has been completed
protected void SchedulingDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e) {
// DXCOMMENT: This method saves the last inserted appointment's unique identifier
SqlConnection connection = (SqlConnection)e.Command.Connection;
using (SqlCommand cmd = new SqlCommand("SELECT IDENT_CURRENT('Appointments')", connection)) {
this.lastInsertedAppointmentId = Convert.ToInt32(cmd.ExecuteScalar());
}
}
// DXCOMMENT: This handler is called before appointment data is posted to the datasource for insertion
protected void Scheduler_AppointmentRowInserting(object sender, ASPxSchedulerDataInsertingEventArgs e) {
// DXCOMMENT: This method removes the ID field from the row insert query
e.NewValues.Remove("ID");
}
// DXCOMMENT: This handler is called after a new record that contains appointment information has been inserted into the datasource
protected void Scheduler_AppointmentRowInserted(object sender, ASPxSchedulerDataInsertedEventArgs e) {
// DXCOMMENT: This method sets the value of the key field for the appointment's data record
e.KeyFieldValue = this.lastInsertedAppointmentId;
}
// DXCOMMENT: This handler is called after appointments are added to the collection
protected void Scheduler_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) {
// DXCOMMENT: This method sets unique identifiers for new appointments
((ASPxSchedulerStorage)sender).SetAppointmentId((Appointment)e.Objects[0], lastInsertedAppointmentId);
}
#region #callbackpanel
protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
if (e.Parameter == "Show") {
PreviewPanel.Visible = true;
Session["Loaded"] = true;
PrepareReportPreview(PreviewPanel);
}
else {
PreviewPanel.Visible = false;
Session.Remove("Loaded");
}
}
#endregion #callbackpanel
#region #preparereportpreview
void PrepareReportPreview(Control cp) {
ASPxSchedulerControlPrintAdapter1.TimeInterval =
Scheduler.ActiveView.GetVisibleIntervals().Interval;
ASPxSchedulerControlPrintAdapter1.WorkTime =
new TimeOfDayInterval(TimeSpan.FromHours(9), TimeSpan.FromHours(18));
Reports.ReportPreview reportPreview =
(Reports.ReportPreview)Page.LoadControl("Reports/ReportPreview.ascx");
reportPreview.ControlAdapter = ASPxSchedulerControlPrintAdapter1;
cp.Controls.Clear();
cp.Controls.Add(reportPreview);
}
#endregion #preparereportpreview
}
}