Syrve POS API SDK

Date and time pop ups

Date and time request windows

While the plugin is running, it may be needed to require the user to request the date and time. For this, the dialog windows can be shown using IViewManager.ShowDateNumpadPopup, IViewManager.ShowDateTimePopup and IViewManager.ShowCalendarPopup.

How does it look in Syrve POS?

In some cases, an instance of the IViewManager class is available to the plugin. It is available, for example, during the processing of a button click:

PluginContext.Operations.AddButtonToPluginsMenu("Sample Plugin", x =>
{
    var viewManager = x.vm;
});

or the triggering of some events:

PluginContext.Notifications.BeforeOrderBill.Subscribe(x =>
{
	var viewManager = x.vm;
});

For more details about this class, check the article Dialog windows. In these cases, the IViewManager can be used to show dialog windows. Consider all methods for requesting the date and time from a user. As an example, create a button using the IOperationService.AddButtonToPluginsMenu method, as shown above, and show dialogs when it is clicked.

Option 1: Date Numpad Popup

A simple dialog with the number keypad can be used to request a date only:

{
    var dateNumpadPopupResult = x.vm.ShowDateNumpadPopup(DateTime.Today, "Date Numpad");
});

This way, when you click on the button, the date selection window will be shown

date-numpad-popup

Method IViewManager.ShowDateNumpadPopup(DateTime selectedDate, string title) accepts 2 arguments:

The method will return the date selected by the user if he presses «OK», or null, if he presses «Cancel».

Option 2: Date-Time Popup

A date and time can be requested through a dialog:

PluginContext.Operations.AddButtonToPluginsMenu("Sample Plugin", x =>
{
    var dateTimePopupResult = x.vm.ShowDateTimePopup(DateTime.Now, "Date-Time", DateTime.Today, DateTime.Today.AddMonths(6));
});

Pressing the button will display the date and time selection window:

date-numpad-popup

By clicking on the current date, the calendar is shown, with which a quick switch to another day can be made:

date-numpad-popup

The method IViewManager.ShowDateTimePopup(DateTime selectedDate, [CanBeNull] string title, DateTime minDate, DateTime maxDate) accepts 4 arguments:

The method will return the date and time selected by the user if he presses «OK», or null if he presses «Cancel».

Option 3: Calendar Popup

For selecting a date, it is possible to use the window with the calendar:

PluginContext.Operations.AddButtonToPluginsMenu("Sample Plugin", x =>
{
    var dateCalendarPopupResult = x.vm.ShowCalendarPopup(DateTime.Today, "Calendar", DateTime.Today, DateTime.Today.AddMonths(6));
});

By clicking on the button, the window will be shown:

date-numpad-popup

The method IViewManager.ShowCalendarPopup(DateTime selectedDate, [CanBeNull] string title, DateTime minDate, DateTime maxDate) accepts 4 arguments for input:

The method will return the date selected by the user if he presses «OK» or null, if he presses «Cancel».