TS - Added transaction and commodity panels
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\Commands\SbmCommand_Commodity.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\Commands\SbmCommand_Transaction_SalesOrder.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\Commands\SbmCommand_Accounts_Supplier.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\Commands\SbmCommand_Accounts_Customer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\App\Commands\SbmCommand_Home.cs" />
|
||||
@@ -33,9 +35,11 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\Accounts\SbmMainPanel_Association_Supplier.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\Accounts\SbmMainPanel_Association_Customer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\Accounts\SbmMainPanel_Association.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\Commodities\SbmMainPanel_Commodity.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\SbmMainPanel_ItemList.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\SbmMainPanel_Home.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\SbmMainPanel_Login.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Panels\Main\Transactions\SbmMainPanel_Transaction.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Mobile\Forms\Views\SbmMenuView.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using Sarand.BusinessMgr.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Pages.Templates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.BusinessMgr.Mobile.App.Commands
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmCommand_Commodity : SbmCommand_Mobile
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCommand_Commodity () : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public override bool CanExecute (object commandParam)
|
||||
{
|
||||
//if (!SecurityProfile.Accounts.CanView) return false;
|
||||
if (!SbmAppConsole.IsViewApplicable(UserContext, Sbm.View.Commodities)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Execute command.</summary>
|
||||
public override void Execute (object commandParam)
|
||||
{
|
||||
if (!CanExecute(commandParam)) return;
|
||||
App.GetInstance().SbmMainPage.SwitchView(SbmMobile.MainView.Commodity, Page_Template_Main.PageBodyMode.SelfScrolling);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
using Sarand.BusinessMgr.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Pages.Templates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Sarand.BusinessMgr.Mobile.App.Commands
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmCommand_Transaction_SalesOrder : SbmCommand_Mobile
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmCommand_Transaction_SalesOrder () : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
public override bool CanExecute (object commandParam)
|
||||
{
|
||||
//if (!SecurityProfile.Accounts.CanView) return false;
|
||||
if (!SbmAppConsole.IsViewApplicable(UserContext, Sbm.View.Contacts_Associations_Supplier)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Execute command.</summary>
|
||||
public override void Execute (object commandParam)
|
||||
{
|
||||
if (!CanExecute(commandParam)) return;
|
||||
App.GetInstance().SbmMainPage.SwitchView(SbmMobile.MainView.Transaction, Page_Template_Main.PageBodyMode.SelfScrolling);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -12,6 +12,8 @@ using Xamarin.Forms;
|
||||
using Sarand.BusinessMgr.Mobile.Core.Forms.Base;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Panels.Main;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Panels.Main.Accounts;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Panels.Main.Transactions;
|
||||
using Sarand.BusinessMgr.Mobile.Forms.Panels.Main.Commodities;
|
||||
|
||||
namespace Sarand.BusinessMgr.Mobile.App
|
||||
{
|
||||
@@ -102,6 +104,24 @@ namespace Sarand.BusinessMgr.Mobile.App
|
||||
break;
|
||||
}
|
||||
//-------------------------------------------------------
|
||||
// Transaction.
|
||||
case SbmMobile.MainView.Transaction:
|
||||
{
|
||||
SbmMainPanel_Transaction.Config panelConfig = new SbmMainPanel_Transaction.Config();
|
||||
SbmMainPanel_Transaction loginPanel = new SbmMainPanel_Transaction(panelConfig);
|
||||
mainPanel = loginPanel;
|
||||
break;
|
||||
}
|
||||
//-------------------------------------------------------
|
||||
// Commodity.
|
||||
case SbmMobile.MainView.Commodity:
|
||||
{
|
||||
SbmMainPanel_Commodity.Config panelConfig = new SbmMainPanel_Commodity.Config();
|
||||
SbmMainPanel_Commodity loginPanel = new SbmMainPanel_Commodity(panelConfig);
|
||||
mainPanel = loginPanel;
|
||||
break;
|
||||
}
|
||||
//-------------------------------------------------------
|
||||
}
|
||||
}
|
||||
catch (Exception exc) { Logger.Warn(fn + " " + exc.GetLogMessage(6)); }
|
||||
|
||||
@@ -47,12 +47,28 @@ namespace Sarand.BusinessMgr.Mobile.App
|
||||
if (homeCommand.CanExecute(null))
|
||||
menuOptions.Add(new OptionData() { Caption = "Home", Command = homeCommand });
|
||||
// Accounts.
|
||||
List<OptionData> commodityCommands = new List<OptionData>();
|
||||
commodityCommands.Add(new OptionData() { Caption = "Customer", Command = new SbmCommand_Accounts_Customer() });
|
||||
commodityCommands.Add(new OptionData() { Caption = "Supplier", Command = new SbmCommand_Accounts_Supplier() });
|
||||
if (commodityCommands.Exists(item => item.Command.CanExecute(null)))
|
||||
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.
|
||||
|
||||
+335
@@ -0,0 +1,335 @@
|
||||
using Sarand.Core.App;
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Mobile.Forms.Controls;
|
||||
using Sarand.Core.Mobile.Forms.Panels;
|
||||
using Sarand.Core.Tasks;
|
||||
using Sarand.BusinessMgr.Core.App;
|
||||
using Sarand.BusinessMgr.Core.Bus;
|
||||
using Sarand.BusinessMgr.Core.WebService;
|
||||
using Sarand.BusinessMgr.Mobile.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Core.Forms.Pages;
|
||||
using Sarand.BusinessMgr.Mobile.Core.Mgr;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Sarand.BusinessMgr.Mobile.Forms.Panels.Main.Commodities
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmMainPanel_Commodity : SbmMainPanel_ItemList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum FilterProperty
|
||||
{
|
||||
Code,
|
||||
Description,
|
||||
}
|
||||
public enum PanelMode
|
||||
{
|
||||
InProgress,
|
||||
}
|
||||
public new class Config : SbmMainPanel_ItemList.Config
|
||||
{
|
||||
public PanelMode Mode { get; set; } = PanelMode.InProgress;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config;
|
||||
private class Columns
|
||||
{
|
||||
public ColumnDfn Id { get; set; }
|
||||
public ColumnDfn Name { get; set; }
|
||||
public ColumnDfn DescBrief { get; set; }
|
||||
public ColumnDfn Code { get; set; }
|
||||
public ColumnDfn Status { get; set; }
|
||||
}
|
||||
private Columns cols = new Columns();
|
||||
private String commodityDoubleClickedPrefix = "CommodityDblClick#";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmMainPanel_Commodity (Config config) :
|
||||
base(config)
|
||||
{
|
||||
this.config = config;
|
||||
// Columns.
|
||||
cols.Id = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Id);
|
||||
cols.Name = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Supplier_Name);
|
||||
cols.DescBrief = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.DescBrief);
|
||||
cols.Code = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Code);
|
||||
cols.Status = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Status);
|
||||
// Initialise components.
|
||||
InitialiseComponents();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected override String HeaderCaption { get { return "Commodities"; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// I n i t i l i a s e C o m p o n e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Control initialisation on construction.</summary>
|
||||
protected override void InitialiseComponents ()
|
||||
{
|
||||
base.InitialiseComponents();
|
||||
|
||||
ConfigureComponents();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n f i g u r e C o m p o n e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Control configuration that can be changed dynamically.</summary>
|
||||
protected override void ConfigureComponents ()
|
||||
{
|
||||
base.ConfigureComponents();
|
||||
|
||||
// Initial population.
|
||||
RefreshItemList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a n e l A c t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l A c t i v i t y
|
||||
//-------------------------------------------------------------------
|
||||
protected override void SetControlActivity ()
|
||||
{
|
||||
}
|
||||
protected override void SetControlsReadOnly ()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// I t e m L i s t
|
||||
//-------------------------------------------------------------------
|
||||
protected override List<SacsFilterPropertyType> GetFilterPropertyTypes ()
|
||||
{
|
||||
List<SacsFilterPropertyType> filterPropertyTypes = new List<SacsFilterPropertyType>();
|
||||
filterPropertyTypes.Add(new SacsFilterPropertyType((int)FilterProperty.Code, "Code") { Mode = SacsFilterPropertyType.FilterMode.Text });
|
||||
filterPropertyTypes.Add(new SacsFilterPropertyType((int)FilterProperty.Description, "Description") { Mode = SacsFilterPropertyType.FilterMode.Text });
|
||||
return filterPropertyTypes;
|
||||
}
|
||||
public SbmCommodity.Params GetCommodityParams (uint pageNo, ushort pageLength)
|
||||
{
|
||||
SbmCommodity.Params prmCommodity = new SbmCommodity.Params();
|
||||
// Filter.
|
||||
prmCommodity.CodePartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Code);
|
||||
prmCommodity.DescBriefPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Description);
|
||||
prmCommodity.StatusCat = SbmCommodity.StatusCat.NotDeleted;
|
||||
// Mode.
|
||||
if (config.Mode == PanelMode.InProgress)
|
||||
//prmCommodity.StatusCat = SbmCommodity.StatusCat.OnHold;
|
||||
// Paging.
|
||||
prmCommodity.ResultsPaging.PageNo = pageNo;
|
||||
prmCommodity.ResultsPaging.PageLength = pageLength;
|
||||
// Sort.
|
||||
prmCommodity.SortColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Id));
|
||||
return prmCommodity;
|
||||
}
|
||||
private SacsTaskData taskDataRefreshList = null;
|
||||
protected override void RefreshItemList (uint pageNo = 1)
|
||||
{
|
||||
String fn = GetType().Name + ".RefreshItemList";
|
||||
|
||||
// Kill previous request.
|
||||
if (taskDataRefreshList != null)
|
||||
{
|
||||
taskDataRefreshList.TriggerCancellation();
|
||||
taskDataRefreshList = null;
|
||||
}
|
||||
|
||||
// Clear existing list.
|
||||
DisplayItemList(null, "Refreshing list. Please wait...");
|
||||
|
||||
// Refresh the list.
|
||||
RefreshItemList(GetCommodityParams(pageNo, ItemsPerPage), taskDataRefreshList = new SacsTaskData(null));
|
||||
}
|
||||
private void RefreshItemList (SbmCommodity.Params commodityParams, SacsTaskData taskDataRefreshList_Local)
|
||||
{
|
||||
String fn = GetType().Name + ".RefreshItemList";
|
||||
|
||||
// Query data after delay.
|
||||
Device.StartTimer(TimeSpan.FromMilliseconds(250), () =>
|
||||
{
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Timer fired.");
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// Configure request.
|
||||
SbmWebServiceRequest.Config configRequest = new SbmWebServiceRequest.Config();
|
||||
configRequest.DataType = SbmWebServiceRequest.DataType.Commodity;
|
||||
configRequest.RequestType = SbmWebServiceRequest.RequestType.QueryList;
|
||||
configRequest.Context.InstanceDefinition = SbmGlobals_Mobile.SessionProfile.InstanceDefinition;
|
||||
configRequest.Context.Debug = SacsSystem.DebugMode;
|
||||
// Filter.
|
||||
Dictionary<String, String> filter = CommodityMgr.GetCommodityQueryFilter_Mobile(commodityParams);
|
||||
|
||||
// Columns.
|
||||
List<String> queryColumns = new List<String>()
|
||||
{
|
||||
cols.Id.DataName,
|
||||
cols.Name.DataName,
|
||||
cols.DescBrief.DataName,
|
||||
cols.Code.DataName,
|
||||
cols.Status.DataName,
|
||||
};
|
||||
// Request User profile.
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - START");
|
||||
configRequest.RequestType = SbmWebServiceRequest.RequestType.QueryList;
|
||||
SbmWebServiceClient.QueryListResponseData responseData =
|
||||
await new SbmWebServiceClient().RequestQueryList(configRequest, filter, queryColumns, CommodityMgr.GetSortColumns_Mobile<SbmCommodity.Column>(commodityParams), taskDataRefreshList_Local);
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - END Items: " + (responseData?.Items.Count.ToString() ?? "None") + (taskDataRefreshList_Local.IsCancellationRequested ? " [Cancelled]" : ""));
|
||||
|
||||
// Display item list.
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
DisplayItemList(responseData);
|
||||
});
|
||||
}
|
||||
catch (Exception exc) { if (SacsSystem.DebugMode) Logger.Warn(fn + " " + exc.GetLogMessage()); }
|
||||
}, taskDataRefreshList_Local.CancellationToken)
|
||||
.ContinueWith(task =>
|
||||
{
|
||||
taskDataRefreshList_Local.Dispose();
|
||||
if (taskDataRefreshList == taskDataRefreshList_Local)
|
||||
taskDataRefreshList = null;
|
||||
});
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Timer method complete.");
|
||||
// Kill timer with false response.
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override void DisplayItemList (SbmWebServiceClient.QueryListResponseData responseData, SacsMessage message = null)
|
||||
{
|
||||
// Refresh paging properties.
|
||||
if (responseData != null)
|
||||
HeaderPanel.SetPaging(responseData.PageNo, responseData.PageLength, responseData.Total > 0 ? responseData.Total : responseData.Count);
|
||||
else HeaderPanel.SetPaging(0, 0, 0);
|
||||
// Construct item list HTML.
|
||||
string html = "<html><head>" + GetCommodityListStyles().Concat("\n") + GetCommodityListScripts().Concat("\n") + "</head><body>";
|
||||
if (message != null)
|
||||
{
|
||||
String messageClass = "inf";
|
||||
switch (message.MessageLevel)
|
||||
{
|
||||
case SaMessageLevel.Fatal:
|
||||
case SaMessageLevel.Exception:
|
||||
case SaMessageLevel.Error:
|
||||
messageClass = "err";
|
||||
break;
|
||||
case SaMessageLevel.Warning:
|
||||
messageClass = "wrn";
|
||||
break;
|
||||
}
|
||||
html += "<div class='msg " + messageClass + "'>" + message.Message + "</div>";
|
||||
}
|
||||
if (responseData == null)
|
||||
{ }
|
||||
else if (responseData.Items.Count > 0)
|
||||
{
|
||||
html += "<div class='msg inf'>Commodities found: " + responseData.Items.Count + "</div>";
|
||||
int itemCount = 0;
|
||||
foreach (var item in responseData.Items)
|
||||
{
|
||||
itemCount++;
|
||||
html += "<div id='AssMov-" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + "' class='item' ondblclick='sbm.openCommodity(" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + ")'>";
|
||||
html += "<table class='fullwidth'>";
|
||||
html += " <tr><td style='width:10%'></td><td style='width:40%'></td><td style='width:10%'></td><td style='width:40%'></td></tr>";
|
||||
html += " <tr>";
|
||||
html += " <td class='label pt2'>Name</td><td class='value pt2'>" + item.GetValue(cols.Name.DataName) + "</td>";
|
||||
html += " <td class='label pt2'>Description</td><td class='value caption'>" + item.GetValue(cols.DescBrief.DataName) + "</td>";
|
||||
html += " </tr>";
|
||||
html += " <tr>";
|
||||
html += " <td class='label'>Code</td><td class='value'>" + item.GetValue(cols.Code.DataName) + "</td>";
|
||||
SaStatus commodityStatus = SacsSystem.GetStatusForCode(item.GetValue(cols.Status.DataName));
|
||||
html += " <td class='label'>Status</td><td class='value'>" + SacsSystem.GetStatusDesc(commodityStatus) + "</td>";
|
||||
html += " </tr>";
|
||||
if (SacsSystem.DebugMode)
|
||||
{
|
||||
html += " <tr>";
|
||||
html += " <td class='label'>Item</td><td class='value'>" + itemCount + "</td>";
|
||||
html += " <td class='label'>Id</td><td class='value'>" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + "</td>";
|
||||
html += " </tr>";
|
||||
}
|
||||
html += "</table>";
|
||||
html += "</div>";
|
||||
}
|
||||
}
|
||||
else html += "<div class='msg wrn'>No commodities found</div>";
|
||||
html += "</body></html>";
|
||||
ItemListWebView.Html = html;
|
||||
//Logger.Debug("HTML: " + html);
|
||||
}
|
||||
private List<String> GetCommodityListStyles ()
|
||||
{
|
||||
List<string> styles = new List<string>(GetItemListBaseStyles());
|
||||
styles.AddRange(new String[]
|
||||
{
|
||||
});
|
||||
return styles;
|
||||
}
|
||||
private List<String> GetCommodityListScripts ()
|
||||
{
|
||||
List<string> scripts = new List<string>(GetItemListBaseScripts());
|
||||
scripts.AddRange(new String[]
|
||||
{
|
||||
"<script>",
|
||||
"sbm.openCommodity=function(id)",
|
||||
"{",
|
||||
//" alert('sbm.openCommodity Id: '+id)",
|
||||
" document.location=\"" + SaxWebView.AppActionPrefix + commodityDoubleClickedPrefix + "\"+id;",
|
||||
"}",
|
||||
"$(function()",
|
||||
"{",
|
||||
" //$('html,body').scrollTop(0);",
|
||||
" $(window).scrollTop(0);",
|
||||
"});",
|
||||
"</script>"
|
||||
});
|
||||
return scripts;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a n e l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>'App' navigation events on Item List web view control.</summary>
|
||||
protected override void ItemListWebView_AppNavigating (object sender, SaxWebView.AppNavigatingEventArgs eventArgs)
|
||||
{
|
||||
String fn = GetType().Name + ".ItemListWebView_AppNavigating";
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " AppAction: " + eventArgs.AppAction);
|
||||
if (eventArgs.AppAction.StartsWithCI(commodityDoubleClickedPrefix))
|
||||
{
|
||||
SysId commodityId = new SysId(StringUtil.ToInt(eventArgs.AppAction.Right(eventArgs.AppAction.Length - commodityDoubleClickedPrefix.Length)));
|
||||
if (!SysId.IsValid(commodityId))
|
||||
{
|
||||
DisplayAlert(HeaderCaption, "Invalid commodity commodity selected.", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure Commodity Commodity page.
|
||||
// Data will be retrieved and validated by the page.
|
||||
//SbmFormPage_Commodities_Commodities.Config pageConfig = new SbmFormPage_Commodities_Commodities.Config();
|
||||
//pageConfig.CommodityIdToUpdate = commodityId;
|
||||
//pageConfig.ReadOnly = true;
|
||||
//if (pageConfig.ReadOnly) pageConfig.NavigationMode = SbmFormPage.NavigationMode.Close;
|
||||
//SbmFormPage_Commodities_Commodities commodityForm = new SbmFormPage_Commodities_Commodities(pageConfig);
|
||||
//commodityRepairForm.Disappearing += (sender2, e2) => { };
|
||||
//SbmGlobals_Mobile.Application.MainPage.Navigation.PushModalAsync(commodityForm, false);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
using Sarand.Core.App;
|
||||
using Sarand.Core.Base;
|
||||
using Sarand.Core.Bus;
|
||||
using Sarand.Core.Mobile.Forms.Controls;
|
||||
using Sarand.Core.Mobile.Forms.Panels;
|
||||
using Sarand.Core.Tasks;
|
||||
using Sarand.BusinessMgr.Core.App;
|
||||
using Sarand.BusinessMgr.Core.Bus;
|
||||
using Sarand.BusinessMgr.Core.WebService;
|
||||
using Sarand.BusinessMgr.Mobile.Core.App;
|
||||
using Sarand.BusinessMgr.Mobile.Core.Forms.Pages;
|
||||
using Sarand.BusinessMgr.Mobile.Core.Mgr;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Sarand.BusinessMgr.Mobile.Forms.Panels.Main.Transactions
|
||||
{
|
||||
//=======================================================================
|
||||
public class SbmMainPanel_Transaction : SbmMainPanel_ItemList
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Definitions.
|
||||
public enum FilterProperty
|
||||
{
|
||||
Ref,
|
||||
}
|
||||
public enum PanelMode
|
||||
{
|
||||
InProgress,
|
||||
}
|
||||
public new class Config : SbmMainPanel_ItemList.Config
|
||||
{
|
||||
public PanelMode Mode { get; set; } = PanelMode.InProgress;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
private Config config;
|
||||
private class Columns
|
||||
{
|
||||
public ColumnDfn Id { get; set; }
|
||||
public ColumnDfn Name { get; set; }
|
||||
public ColumnDfn AmountTot { get; set; }
|
||||
public ColumnDfn Ref { get; set; }
|
||||
public ColumnDfn Status { get; set; }
|
||||
}
|
||||
private Columns cols = new Columns();
|
||||
private String transactionDoubleClickedPrefix = "TransactionDblClick#";
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public SbmMainPanel_Transaction (Config config) :
|
||||
base(config)
|
||||
{
|
||||
this.config = config;
|
||||
// Columns.
|
||||
cols.Id = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Id);
|
||||
cols.Name = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.AssocTarget_Name);
|
||||
cols.AmountTot = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.AmountTot);
|
||||
cols.Ref = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Ref);
|
||||
cols.Status = TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Status);
|
||||
// Initialise components.
|
||||
InitialiseComponents();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
protected override String HeaderCaption { get { return "Transactions"; } }
|
||||
public virtual Sbm.TransactionType TransactionType { get; } = Sbm.TransactionType.SalesOrder;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// I n i t i l i a s e C o m p o n e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Control initialisation on construction.</summary>
|
||||
protected override void InitialiseComponents ()
|
||||
{
|
||||
base.InitialiseComponents();
|
||||
|
||||
ConfigureComponents();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n f i g u r e C o m p o n e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>Control configuration that can be changed dynamically.</summary>
|
||||
protected override void ConfigureComponents ()
|
||||
{
|
||||
base.ConfigureComponents();
|
||||
|
||||
// Initial population.
|
||||
RefreshItemList();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a n e l A c t i o n s
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// C o n t r o l A c t i v i t y
|
||||
//-------------------------------------------------------------------
|
||||
protected override void SetControlActivity ()
|
||||
{
|
||||
}
|
||||
protected override void SetControlsReadOnly ()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// I t e m L i s t
|
||||
//-------------------------------------------------------------------
|
||||
protected override List<SacsFilterPropertyType> GetFilterPropertyTypes ()
|
||||
{
|
||||
List<SacsFilterPropertyType> filterPropertyTypes = new List<SacsFilterPropertyType>();
|
||||
filterPropertyTypes.Add(new SacsFilterPropertyType((int)FilterProperty.Ref, "Ref") { Mode = SacsFilterPropertyType.FilterMode.Text });
|
||||
return filterPropertyTypes;
|
||||
}
|
||||
public SbmTransaction.Params GetTransactionParams (uint pageNo, ushort pageLength)
|
||||
{
|
||||
SbmTransaction.Params prmTransaction = new SbmTransaction.Params();
|
||||
// Filter.
|
||||
prmTransaction.TransactionType = TransactionType;
|
||||
prmTransaction.TransRefPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Ref);
|
||||
prmTransaction.StatusCat = SbmTransaction.StatusCat.NotDeleted;
|
||||
// Mode.
|
||||
if (config.Mode == PanelMode.InProgress)
|
||||
//prmTransaction.StatusCat = SbmTransaction.StatusCat.OnHold;
|
||||
// Paging.
|
||||
prmTransaction.ResultsPaging.PageNo = pageNo;
|
||||
prmTransaction.ResultsPaging.PageLength = pageLength;
|
||||
// Sort.
|
||||
prmTransaction.SortColumns.Add(TransactionMgr.GetTransactionColumnDfn(SbmTransaction.Column.Id));
|
||||
return prmTransaction;
|
||||
}
|
||||
private SacsTaskData taskDataRefreshList = null;
|
||||
protected override void RefreshItemList (uint pageNo = 1)
|
||||
{
|
||||
String fn = GetType().Name + ".RefreshItemList";
|
||||
|
||||
// Kill previous request.
|
||||
if (taskDataRefreshList != null)
|
||||
{
|
||||
taskDataRefreshList.TriggerCancellation();
|
||||
taskDataRefreshList = null;
|
||||
}
|
||||
|
||||
// Clear existing list.
|
||||
DisplayItemList(null, "Refreshing list. Please wait...");
|
||||
|
||||
// Refresh the list.
|
||||
RefreshItemList(GetTransactionParams(pageNo, ItemsPerPage), taskDataRefreshList = new SacsTaskData(null));
|
||||
}
|
||||
private void RefreshItemList (SbmTransaction.Params transactionParams, SacsTaskData taskDataRefreshList_Local)
|
||||
{
|
||||
String fn = GetType().Name + ".RefreshItemList";
|
||||
|
||||
// Query data after delay.
|
||||
Device.StartTimer(TimeSpan.FromMilliseconds(250), () =>
|
||||
{
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Timer fired.");
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// Configure request.
|
||||
SbmWebServiceRequest.Config configRequest = new SbmWebServiceRequest.Config();
|
||||
configRequest.DataType = SbmWebServiceRequest.DataType.Transaction;
|
||||
configRequest.RequestType = SbmWebServiceRequest.RequestType.QueryList;
|
||||
configRequest.Context.InstanceDefinition = SbmGlobals_Mobile.SessionProfile.InstanceDefinition;
|
||||
configRequest.Context.Debug = SacsSystem.DebugMode;
|
||||
// Filter.
|
||||
Dictionary<String, String> filter = TransactionMgr.GetTransactionQueryFilter_Mobile(transactionParams);
|
||||
|
||||
// Columns.
|
||||
List<String> queryColumns = new List<String>()
|
||||
{
|
||||
cols.Id.DataName,
|
||||
cols.Name.DataName,
|
||||
cols.AmountTot.DataName,
|
||||
cols.Ref.DataName,
|
||||
cols.Status.DataName,
|
||||
};
|
||||
// Request User profile.
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - START");
|
||||
configRequest.RequestType = SbmWebServiceRequest.RequestType.QueryList;
|
||||
SbmWebServiceClient.QueryListResponseData responseData =
|
||||
await new SbmWebServiceClient().RequestQueryList(configRequest, filter, queryColumns, TransactionMgr.GetSortColumns_Mobile<SbmTransaction.Column>(transactionParams), taskDataRefreshList_Local);
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - END Items: " + (responseData?.Items.Count.ToString() ?? "None") + (taskDataRefreshList_Local.IsCancellationRequested ? " [Cancelled]" : ""));
|
||||
|
||||
// Display item list.
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
DisplayItemList(responseData);
|
||||
});
|
||||
}
|
||||
catch (Exception exc) { if (SacsSystem.DebugMode) Logger.Warn(fn + " " + exc.GetLogMessage()); }
|
||||
}, taskDataRefreshList_Local.CancellationToken)
|
||||
.ContinueWith(task =>
|
||||
{
|
||||
taskDataRefreshList_Local.Dispose();
|
||||
if (taskDataRefreshList == taskDataRefreshList_Local)
|
||||
taskDataRefreshList = null;
|
||||
});
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " Timer method complete.");
|
||||
// Kill timer with false response.
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
protected override void DisplayItemList (SbmWebServiceClient.QueryListResponseData responseData, SacsMessage message = null)
|
||||
{
|
||||
// Refresh paging properties.
|
||||
if (responseData != null)
|
||||
HeaderPanel.SetPaging(responseData.PageNo, responseData.PageLength, responseData.Total > 0 ? responseData.Total : responseData.Count);
|
||||
else HeaderPanel.SetPaging(0, 0, 0);
|
||||
// Construct item list HTML.
|
||||
string html = "<html><head>" + GetTransactionListStyles().Concat("\n") + GetTransactionListScripts().Concat("\n") + "</head><body>";
|
||||
if (message != null)
|
||||
{
|
||||
String messageClass = "inf";
|
||||
switch (message.MessageLevel)
|
||||
{
|
||||
case SaMessageLevel.Fatal:
|
||||
case SaMessageLevel.Exception:
|
||||
case SaMessageLevel.Error:
|
||||
messageClass = "err";
|
||||
break;
|
||||
case SaMessageLevel.Warning:
|
||||
messageClass = "wrn";
|
||||
break;
|
||||
}
|
||||
html += "<div class='msg " + messageClass + "'>" + message.Message + "</div>";
|
||||
}
|
||||
if (responseData == null)
|
||||
{ }
|
||||
else if (responseData.Items.Count > 0)
|
||||
{
|
||||
html += "<div class='msg inf'>Transactions found: " + responseData.Items.Count + "</div>";
|
||||
int itemCount = 0;
|
||||
foreach (var item in responseData.Items)
|
||||
{
|
||||
itemCount++;
|
||||
html += "<div id='AssMov-" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + "' class='item' ondblclick='sbm.openTransaction(" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + ")'>";
|
||||
html += "<table class='fullwidth'>";
|
||||
html += " <tr><td style='width:10%'></td><td style='width:40%'></td><td style='width:10%'></td><td style='width:40%'></td></tr>";
|
||||
html += " <tr>";
|
||||
html += " <td class='label pt2'>Name</td><td class='value pt2'>" + item.GetValue(cols.Name.DataName) + "</td>";
|
||||
html += " <td class='label pt2'>Cost</td><td class='value caption'>" + item.GetValue(cols.AmountTot.DataName) + "</td>";
|
||||
html += " </tr>";
|
||||
html += " <tr>";
|
||||
html += " <td class='label'>Ref</td><td class='value'>" + item.GetValue(cols.Ref.DataName) + "</td>";
|
||||
SaStatus transactionStatus = SacsSystem.GetStatusForCode(item.GetValue(cols.Status.DataName));
|
||||
html += " <td class='label'>Status</td><td class='value'>" + SacsSystem.GetStatusDesc(transactionStatus) + "</td>";
|
||||
html += " </tr>";
|
||||
if (SacsSystem.DebugMode)
|
||||
{
|
||||
html += " <tr>";
|
||||
html += " <td class='label'>Item</td><td class='value'>" + itemCount + "</td>";
|
||||
html += " <td class='label'>Id</td><td class='value'>" + SysId.ToString(item.GetIdValue(cols.Id.DataName)) + "</td>";
|
||||
html += " </tr>";
|
||||
}
|
||||
html += "</table>";
|
||||
html += "</div>";
|
||||
}
|
||||
}
|
||||
else html += "<div class='msg wrn'>No transactions found</div>";
|
||||
html += "</body></html>";
|
||||
ItemListWebView.Html = html;
|
||||
//Logger.Debug("HTML: " + html);
|
||||
}
|
||||
private List<String> GetTransactionListStyles ()
|
||||
{
|
||||
List<string> styles = new List<string>(GetItemListBaseStyles());
|
||||
styles.AddRange(new String[]
|
||||
{
|
||||
});
|
||||
return styles;
|
||||
}
|
||||
private List<String> GetTransactionListScripts ()
|
||||
{
|
||||
List<string> scripts = new List<string>(GetItemListBaseScripts());
|
||||
scripts.AddRange(new String[]
|
||||
{
|
||||
"<script>",
|
||||
"sbm.openTransaction=function(id)",
|
||||
"{",
|
||||
//" alert('sbm.openTransaction Id: '+id)",
|
||||
" document.location=\"" + SaxWebView.AppActionPrefix + transactionDoubleClickedPrefix + "\"+id;",
|
||||
"}",
|
||||
"$(function()",
|
||||
"{",
|
||||
" //$('html,body').scrollTop(0);",
|
||||
" $(window).scrollTop(0);",
|
||||
"});",
|
||||
"</script>"
|
||||
});
|
||||
return scripts;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// P a n e l E v e n t s
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>'App' navigation events on Item List web view control.</summary>
|
||||
protected override void ItemListWebView_AppNavigating (object sender, SaxWebView.AppNavigatingEventArgs eventArgs)
|
||||
{
|
||||
String fn = GetType().Name + ".ItemListWebView_AppNavigating";
|
||||
if (SacsSystem.DebugMode) Logger.Debug(fn + " AppAction: " + eventArgs.AppAction);
|
||||
if (eventArgs.AppAction.StartsWithCI(transactionDoubleClickedPrefix))
|
||||
{
|
||||
SysId transactionId = new SysId(StringUtil.ToInt(eventArgs.AppAction.Right(eventArgs.AppAction.Length - transactionDoubleClickedPrefix.Length)));
|
||||
if (!SysId.IsValid(transactionId))
|
||||
{
|
||||
DisplayAlert(HeaderCaption, "Invalid transaction transaction selected.", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
// Configure Transaction Transaction page.
|
||||
// Data will be retrieved and validated by the page.
|
||||
//SbmFormPage_Transactions_Transactions.Config pageConfig = new SbmFormPage_Transactions_Transactions.Config();
|
||||
//pageConfig.TransactionIdToUpdate = transactionId;
|
||||
//pageConfig.ReadOnly = true;
|
||||
//if (pageConfig.ReadOnly) pageConfig.NavigationMode = SbmFormPage.NavigationMode.Close;
|
||||
//SbmFormPage_Transactions_Transactions transactionForm = new SbmFormPage_Transactions_Transactions(pageConfig);
|
||||
//transactionRepairForm.Disappearing += (sender2, e2) => { };
|
||||
//SbmGlobals_Mobile.Application.MainPage.Navigation.PushModalAsync(transactionForm, false);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -38,6 +38,10 @@ namespace Sarand.BusinessMgr.Mobile.Core.App
|
||||
// Accounts.
|
||||
Customer,
|
||||
Supplier,
|
||||
// Transactions.
|
||||
Transaction,
|
||||
// Commodities.
|
||||
Commodity
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Sarand.BusinessMgr.Mobile.Core.Forms.Views
|
||||
protected SbmDataItemMgr_Mobile DataItemMgr { get { if (dataItemMgr == null) dataItemMgr = new SbmDataItemMgr_Mobile(UserContext); return dataItemMgr; } }
|
||||
protected SbmProcessMgr_Mobile ProcessMgr { get { if (processMgr == null) processMgr = new SbmProcessMgr_Mobile(UserContext); return processMgr; } }
|
||||
protected SbmStockMgr_Mobile StockMgr { get { if (stockMgr == null) stockMgr = new SbmStockMgr_Mobile(UserContext); return stockMgr; } }
|
||||
protected SbmTransactionMgr_Mobile BerthingMgr { get { if (transactionMgr == null) transactionMgr = new SbmTransactionMgr_Mobile(UserContext); return transactionMgr; } }
|
||||
protected SbmTransactionMgr_Mobile TransactionMgr { get { if (transactionMgr == null) transactionMgr = new SbmTransactionMgr_Mobile(UserContext); return transactionMgr; } }
|
||||
public SbmWebServiceClient WebServiceClient { get { if (webServiceClient == null) webServiceClient = new SbmWebServiceClient(); return webServiceClient; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user