using System;
using System.Drawing;
using System.ComponentModel;
using System.Reflection;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Localization;
using DevExpress.XtraScheduler.Native;
using DevExpress.XtraScheduler.UI;
using DevExpress.Utils;
using DevExpress.Utils.Menu;
using DevExpress.Utils.Internal;
using System.Collections.Generic;
using Common;
namespace Erp
{
public partial class FrmEditSchedulInfo : XtraForm, IDXManagerPopupMenu
{
private UserRight UserRight;
public string Sid = string.Empty;
bool openRecurrenceForm;
readonly ISchedulerStorage storage;
readonly SchedulerControl control;
Icon recurringIcon;
Icon normalIcon;
readonly AppointmentFormController controller;
IDXMenuManager menuManager;
[EditorBrowsable(EditorBrowsableState.Never)]
public FrmEditSchedulInfo()
{
InitializeComponent();
}
public FrmEditSchedulInfo(SchedulerControl control, Appointment apt)
: this(control, apt, false)
{
}
public FrmEditSchedulInfo(SchedulerControl control, Appointment apt, bool openRecurrenceForm)
{
Guard.ArgumentNotNull(control, "control");
Guard.ArgumentNotNull(control.DataStorage, "control.DataStorage");
Guard.ArgumentNotNull(apt, "apt");
this.openRecurrenceForm = openRecurrenceForm;
this.controller = CreateController(control, apt);
InitializeComponent();
SetupPredefinedConstraints();
LoadIcons();
this.control = control;
this.storage = control.DataStorage;
SubscribeControllerEvents(Controller);
BindControllerToControls();
if (apt != null && apt.Id != null)
{
this.Sid = apt.Id.ToString();
}
}
[Browsable(false)]
public IDXMenuManager MenuManager { get { return this.menuManager; } private set { this.menuManager = value; } }
protected internal AppointmentFormController Controller { get { return this.controller; } }
protected internal SchedulerControl Control { get { return this.control; } }
protected internal bool IsNewAppointment { get { return this.controller != null ? this.controller.IsNewAppointment : true; } }
protected internal Icon RecurringIcon { get { return this.recurringIcon; } }
protected internal Icon NormalIcon { get { return this.normalIcon; } }
protected internal bool OpenRecurrenceForm { get { return this.openRecurrenceForm; } }
[DXDescription("DevExpress.XtraScheduler.UI.AppointmentForm,ReadOnly")]
[DXCategory(CategoryName.Behavior)]
[DefaultValue(false)]
/// <summary>
/// 载入数据
/// </summary>
public virtual void LoadFormData(Appointment appointment)
{
this.Text = "排课信息";
if (!string.IsNullOrEmpty(Sid))
{
Model.SchedulInfo model = Repository.SchedulInfo.Get(new Model.SchedulInfo { Id = Sid });
if (model != null)
{
this.dtStartTime.Text = model.StartTime.HasValue ? model.StartTime.Value.ToString("mm:ss") : null;