119 lines
4.9 KiB
C#
119 lines
4.9 KiB
C#
using Sarand.Core.Base;
|
|
using Sarand.BusinessMgr.Mobile.App.Commands;
|
|
using Sarand.BusinessMgr.Mobile.Core.App;
|
|
using Sarand.BusinessMgr.Mobile.Forms.Views;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Xamarin.Essentials;
|
|
using Xamarin.Forms;
|
|
using Sarand.BusinessMgr.Mobile.Forms.Pages.Config;
|
|
|
|
namespace Sarand.BusinessMgr.Mobile.App
|
|
{
|
|
//=======================================================================
|
|
public class SbmMenu : SbmMenuView
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private readonly List<OptionData> menuOptions = new List<OptionData>();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SbmMenu ()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
public SbmMainPage MainPage { get; set; }
|
|
public INavigation MainViewNavigation { get { return MainPage.Navigation; } }
|
|
|
|
//-------------------------------------------------------------------
|
|
// M e n u O p t i o n s
|
|
//-------------------------------------------------------------------
|
|
public override List<OptionData> MenuOptions
|
|
{
|
|
get
|
|
{
|
|
ClearMenuOptions();
|
|
if (menuOptions.Count < 1)
|
|
{
|
|
// Home.
|
|
SacsCommand homeCommand = new SbmCommand_Home();
|
|
if (homeCommand.CanExecute(null))
|
|
menuOptions.Add(new OptionData() { Caption = "Home", Command = homeCommand });
|
|
// Accounts.
|
|
List<OptionData> accountsCommands = new List<OptionData>();
|
|
accountsCommands.Add(new OptionData() { Caption = "Customer", Command = new SbmCommand_Accounts_Customer() });
|
|
accountsCommands.Add(new OptionData() { Caption = "Supplier", Command = new SbmCommand_Accounts_Supplier() });
|
|
if (accountsCommands.Exists(item => item.Command.CanExecute(null)))
|
|
{
|
|
menuOptions.Add(new OptionData() { Caption = "Accounts", Heading = true });
|
|
menuOptions.AddRange(accountsCommands);
|
|
}
|
|
// Transactions.
|
|
List<OptionData> transactionCommands = new List<OptionData>();
|
|
transactionCommands.Add(new OptionData() { Caption = "Sales order", Command = new SbmCommand_Transaction_SalesOrder() });
|
|
if (transactionCommands.Exists(item => item.Command.CanExecute(null)))
|
|
{
|
|
menuOptions.Add(new OptionData() { Caption = "Transactions", Heading = true });
|
|
menuOptions.AddRange(transactionCommands);
|
|
}
|
|
// Commodities.
|
|
List<OptionData> commodityCommands = new List<OptionData>();
|
|
commodityCommands.Add(new OptionData() { Caption = "Commodities", Command = new SbmCommand_Commodity() });
|
|
if (commodityCommands.Exists(item => item.Command.CanExecute(null)))
|
|
{
|
|
menuOptions.Add(new OptionData() { Caption = "Commodity", Heading = true });
|
|
menuOptions.AddRange(commodityCommands);
|
|
}
|
|
// Config.
|
|
menuOptions.Add(new OptionData() { Caption = "Config", Heading = true });
|
|
//menuOptions.Add(new OptionData() { Caption = "Options", Command = new SbmCommand_Mobile(OnConfig_OptionsClicked) });
|
|
menuOptions.Add(new OptionData() { Caption = "System", Command = new SbmCommand_Mobile(OnConfig_SystemClicked) });
|
|
menuOptions.Add(new OptionData() { Caption = "Update", Command = new SbmCommand_Mobile(OnConfig_UpdateClicked) });
|
|
// Logout.
|
|
SacsCommand logoutCommand = new SbmCommand_Logout();
|
|
if (logoutCommand.CanExecute(null))
|
|
menuOptions.Add(new OptionData() { Caption = "Logout", Command = logoutCommand });
|
|
}
|
|
return menuOptions;
|
|
}
|
|
}
|
|
public void ClearMenuOptions ()
|
|
{
|
|
menuOptions.Clear();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n f i g
|
|
//-------------------------------------------------------------------
|
|
private async void OnConfig_OptionsClicked (object commandParam)
|
|
{
|
|
InvokeMenuOptionClicked();
|
|
SbmPage_Config_Options.Config pageConfig = new SbmPage_Config_Options.Config();
|
|
await MainViewNavigation.PushModalAsync(new SbmPage_Config_Options(pageConfig), false);
|
|
}
|
|
//-------------------------------------------------------------------
|
|
private async void OnConfig_SystemClicked (object commandParam)
|
|
{
|
|
InvokeMenuOptionClicked();
|
|
SbmPage_Config_System.Config pageConfig = new SbmPage_Config_System.Config();
|
|
await MainViewNavigation.PushModalAsync(new SbmPage_Config_System(pageConfig), false);
|
|
}
|
|
//-------------------------------------------------------------------
|
|
private async void OnConfig_UpdateClicked (object commandParam)
|
|
{
|
|
InvokeMenuOptionClicked();
|
|
await Browser.OpenAsync("http://www.sarand.com/Android/BusinessMgrMobile.apk", BrowserLaunchMode.SystemPreferred);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|