You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
161 lines
3.9 KiB
161 lines
3.9 KiB
using System;
|
|
using System.Windows.Input;
|
|
|
|
namespace GummingCommon
|
|
{
|
|
public class DateRangeViewModule : ViewModelBase
|
|
{
|
|
#region base parameters
|
|
public DateRangeView View { get; set; }
|
|
public bool IsConfirm;
|
|
#endregion
|
|
|
|
#region constructor
|
|
public DateRangeViewModule()
|
|
{
|
|
View = new DateRangeView();
|
|
View.DataContext = this;
|
|
|
|
InitializeCommands();
|
|
InitializeParameters();
|
|
|
|
}
|
|
|
|
public void ShowDialog(string datefield)
|
|
{
|
|
HeaderTitle = string.Format("Please select data ranage for the filter field of {0}", datefield);
|
|
if (SelectStartTime == null || SelectStartTime.Equals(DateTime.MinValue))
|
|
SelectStartTime = DateTime.Now;
|
|
if (SelectEndTime == null || SelectEndTime.Equals(DateTime.MinValue))
|
|
SelectEndTime = DateTime.Now;
|
|
View.ShowDialog();
|
|
}
|
|
|
|
private void InitializeCommands()
|
|
{
|
|
|
|
CancelCommand = new DelegateCommand(OnCancelCommand);
|
|
AddCommand = new DelegateCommand(OnAddCommand);
|
|
}
|
|
|
|
public override void InitializeParameters(object content = null)
|
|
{
|
|
IsConfirm = false;
|
|
WindowTitle = "";
|
|
}
|
|
|
|
~DateRangeViewModule()
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Binding Properties
|
|
public string WindowTitle { get; private set; }
|
|
|
|
private string _HeaderTitle;
|
|
public string HeaderTitle
|
|
{
|
|
get
|
|
{
|
|
return _HeaderTitle;
|
|
}
|
|
set
|
|
{
|
|
_HeaderTitle = value;
|
|
OnPropertyChanged("HeaderTitle");
|
|
}
|
|
}
|
|
|
|
private DateTime _SelectStartTime;
|
|
public DateTime SelectStartTime
|
|
{
|
|
get
|
|
{
|
|
return _SelectStartTime;
|
|
}
|
|
set
|
|
{
|
|
_SelectStartTime = value;
|
|
OnPropertyChanged("SelectStartTime");
|
|
}
|
|
}
|
|
|
|
private DateTime _SelectEndTime;
|
|
public DateTime SelectEndTime
|
|
{
|
|
get
|
|
{
|
|
return _SelectEndTime;
|
|
}
|
|
set
|
|
{
|
|
_SelectEndTime = value;
|
|
OnPropertyChanged("SelectEndTime");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Binding Commands
|
|
|
|
private ICommand _AddCommand;
|
|
public ICommand AddCommand
|
|
{
|
|
get
|
|
{
|
|
return _AddCommand;
|
|
}
|
|
set
|
|
{
|
|
_AddCommand = value;
|
|
OnPropertyChanged("AddCommand");
|
|
}
|
|
}
|
|
|
|
private ICommand _CancelCommand;
|
|
public ICommand CancelCommand
|
|
{
|
|
get
|
|
{
|
|
return _CancelCommand;
|
|
}
|
|
set
|
|
{
|
|
_CancelCommand = value;
|
|
OnPropertyChanged("CancelCommand");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Private Methods
|
|
private void OnCancelCommand(object sender)
|
|
{
|
|
View.DialogResult = true;
|
|
}
|
|
|
|
private void OnAddCommand(Object sender)
|
|
{
|
|
if (SelectStartTime == null)
|
|
{
|
|
ShowMessageBox("Please select start date.");
|
|
return;
|
|
}
|
|
if (SelectEndTime == null)
|
|
{
|
|
ShowMessageBox("Please select end date.");
|
|
return;
|
|
}
|
|
if (SelectStartTime > SelectEndTime)
|
|
{
|
|
ShowMessageBox("The start date should less than end date.");
|
|
return;
|
|
}
|
|
|
|
IsConfirm = true;
|
|
View.DialogResult = true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|