Files
LogisticsMgr-Mobile/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetMovement.cs
T
2019-08-05 09:02:30 +01:00

214 lines
9.2 KiB
C#

using Sarand.Core.Base;
using Sarand.Core.Mobile.Forms.Utils;
using Sarand.LogisticsMgr.Core.App;
using Sarand.LogisticsMgr.Core.Bus;
using Sarand.LogisticsMgr.Mobile.App;
using Sarand.LogisticsMgr.Mobile.Core.App;
using Sarand.LogisticsMgr.Mobile.Core.Forms.Base;
using Sarand.LogisticsMgr.Mobile.Core.Forms.Controls;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
namespace Sarand.LogisticsMgr.Mobile.Forms.Components
{
//=======================================================================
public class SlmComponents_AssetMovement : SlmComponents
{
//-------------------------------------------------------------------
// Data members.
private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile;
private readonly List<TypeCodeDesc> movementTypes = new List<TypeCodeDesc>();
//-------------------------------------------------------------------
// Construction.
public SlmComponents_AssetMovement ()
{
movementTypes.AddRange(SlmSystem.GetCodesOfType(Slm.SystemCode.AssetMovementType));
InitialiseComponents();
}
//-------------------------------------------------------------------
// Properties.
public String MessageTitle { get; set; } = "Asset Movement";
// Asset Code.
public SlmLabel LabelAssetCode { get; } = new SlmLabel() { Text = "Container no." };
public SlmEntryView EntryAssetCode { get; } = new SlmEntryView();
// Asset Size.
public SlmLabel LabelAssetSize { get; } = new SlmLabel() { Text = "Size" };
public SlmPickerView_CodeType PickerAssetSize { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.ContainerSize };
// Movement type.
public SlmLabel LabelMovementType { get; } = new SlmLabel() { Text = "Movement type" };
public SlmPickerView_SystemCodes PickerMovementType { get; } = new SlmPickerView_SystemCodes(Slm.SystemCode.AssetMovementType) { };
// Reference.
public SlmLabel LabelReference { get; } = new SlmLabel() { Text = "Reference" };
public SlmEntryView EntryReference { get; } = new SlmEntryView();
// Movement date.
public SlmLabel LabelMovementDate { get; } = new SlmLabel() { Text = "Movement date" };
public SlmDatePickerView DatePickerMovementDate { get; } = new SlmDatePickerView();
// Customer.
public SlmLabel LabelCustomer { get; } = new SlmLabel() { Text = "Customer" };
public SlmEntryView EntryCustomer { get; } = new SlmEntryView();
// Customer reference.
public SlmLabel LabelCustomerReference { get; } = new SlmLabel() { Text = "Customer ref" };
public SlmEntryView EntryCustomerReference { get; } = new SlmEntryView();
// Location - start.
public SlmLabel LabelLocationStart { get; } = new SlmLabel() { Text = "Location - start" };
public SlmEntryView EntryLocationStart { get; } = new SlmEntryView();
// Location - current.
public SlmLabel LabelLocationCurrent { get; } = new SlmLabel() { Text = "Location - current" };
public SlmEntryView EntryLocationCurrent { get; } = new SlmEntryView();
// Location - finish.
public SlmLabel LabelLocationFinish { get; } = new SlmLabel() { Text = "Location - finish" };
public SlmEntryView EntryLocationFinish { get; } = new SlmEntryView();
// Haulier - initial.
public SlmLabel LabelHaulierInitial { get; } = new SlmLabel() { Text = "Haulier - initial" };
public SlmEntryView EntryHaulierInitial { get; } = new SlmEntryView();
// Registration - initial.
public SlmLabel LabelRegistrationInitial { get; } = new SlmLabel() { Text = "Registration - initial" };
public SlmEntryView EntryRegistrationInitial { get; } = new SlmEntryView();
// Haulier - final.
public SlmLabel LabelHaulierFinal { get; } = new SlmLabel() { Text = "Haulier - final" };
public SlmEntryView EntryHaulierFinal { get; } = new SlmEntryView();
// Registration - final.
public SlmLabel LabelRegistrationFinal { get; } = new SlmLabel() { Text = "Registration - final" };
public SlmEntryView EntryRegistrationFinal { get; } = new SlmEntryView();
// Pin number.
public SlmLabel LabelPinNumber { get; } = new SlmLabel() { Text = "PIN" };
public SlmEntryView EntryPinNumber { get; } = new SlmEntryView();
// Seal number.
public SlmLabel LabelSealNumber { get; } = new SlmLabel() { Text = "Seal number" };
public SlmEntryView EntrySealNumber { get; } = new SlmEntryView();
// Status.
public SlmLabel LabelStatus { get; } = new SlmLabel() { Text = "Status" };
public SlmEntryView EntryStatus { get; } = new SlmEntryView();
// InProgress date.
public SlmLabel LabelInProgressDate { get; } = new SlmLabel() { Text = "In progress" };
public SlmDatePickerView DatePickerInProgressDate { get; } = new SlmDatePickerView();
// Completed date.
public SlmLabel LabelCompletedDate { get; } = new SlmLabel() { Text = "Completed" };
public SlmDatePickerView DatePickerCompletedDate { get; } = new SlmDatePickerView();
// Notes.
public SlmLabel LabelNotes { get; } = new SlmLabel() { Text = "Notes" };
public SlmEditorView EntryNotes { get; } = new SlmEditorView();
//-------------------------------------------------------------------
// Utilities.
//-------------------------------------------------------------------
// I n i t i a l i s e
//-------------------------------------------------------------------
private void InitialiseComponents ()
{
// Asset code.
EntryAssetCode.MaxLength = 12;
EntryAssetCode.TextChanged += EntryAssetCode_TextChanged;
EntryAssetCode.Completed += EntryAssetCode_Completed;
// Size.
PickerAssetSize.SelectedIndexChanged += PickerAssetSize_SelectedIndexChanged;
// Movement type.
Changed = false;
}
//-------------------------------------------------------------------
// P o p u l a t i o n
//-------------------------------------------------------------------
public void PopulateToControls (SlmContainer.Data data)
{
EntryAssetCode.Text = data.Code;
PickerAssetSize.SelectedCode= data.SizeCode;
Changed = false;
}
public void PopulateToControls (SlmAssetMovement.Data data)
{
PickerAssetSize.SelectedCode = data.AssetSizeCode;
PickerMovementType.SelectedCode = movementTypes.GetCodeForType((int)data.MovementType);
EntryReference.Text = data.MovementRef;
DatePickerMovementDate.Date = data.MovementAt;
EntryCustomer.Text = data.Customer;
EntryCustomerReference.Text = data.CustomerRef;
EntryLocationStart.Text = data.LocationStart;
EntryLocationCurrent.Text = data.LocationCurrent;
EntryLocationFinish.Text = data.LocationFinish;
EntryHaulierInitial.Text = data.HaulierInitial;
EntryRegistrationInitial.Text = data.RegistrationInitial;
EntryHaulierFinal.Text = data.HaulierFinal;
EntryRegistrationFinal.Text = data.RegistrationFinal;
EntryPinNumber.Text = data.PinNumber;
EntrySealNumber.Text = data.SealNumber;
EntryStatus.Text = SlmSystem.GetStatusDesc(data.Status);
EntryReference.Text = data.MovementRef;
DatePickerInProgressDate.Date = data.InProgressAt;
DatePickerCompletedDate.Date = data.CompletedAt;
EntryNotes.Text = data.Notes;
Changed = false;
}
//-------------------------------------------------------------------
public bool IsDataValid (SlmAssetMovement.Data data)
{
return true;
}
//-------------------------------------------------------------------
public void PopulateFromControls (SlmAssetMovement.Data data)
{
}
//-------------------------------------------------------------------
// C o n t r o l A c t i v i t y
//-------------------------------------------------------------------
protected override void SetControlActivity ()
{
SetControlsReadOnly();
}
protected override void SetControlsReadOnly ()
{
EntryAssetCode.ReadOnly = ReadOnly;
PickerAssetSize.ReadOnly = ReadOnly;
PickerMovementType.ReadOnly = ReadOnly;
EntryReference.ReadOnly = ReadOnly;
DatePickerMovementDate.ReadOnly = ReadOnly;
EntryCustomer.ReadOnly = ReadOnly;
EntryCustomerReference.ReadOnly = ReadOnly;
EntryLocationStart.ReadOnly = ReadOnly;
EntryLocationCurrent.ReadOnly = ReadOnly;
EntryLocationFinish.ReadOnly = ReadOnly;
EntryHaulierInitial.ReadOnly = ReadOnly;
EntryRegistrationInitial.ReadOnly = ReadOnly;
EntryHaulierFinal.ReadOnly = ReadOnly;
EntryRegistrationFinal.ReadOnly = ReadOnly;
EntryPinNumber.ReadOnly = ReadOnly;
EntrySealNumber.ReadOnly = ReadOnly;
EntryStatus.ReadOnly = ReadOnly;
EntryStatus.ReadOnly = ReadOnly;
DatePickerInProgressDate.ReadOnly = ReadOnly;
DatePickerCompletedDate.ReadOnly = ReadOnly;
EntryNotes.ReadOnly = ReadOnly;
}
//-------------------------------------------------------------------
// C o n t r o l E v e n t s
//-------------------------------------------------------------------
// Asset Code.
private void EntryAssetCode_TextChanged (object sender, TextChangedEventArgs e)
{
Changed = true;
}
private void EntryAssetCode_Completed (object sender, EventArgs e)
{
}
//-------------------------------------------------------------------
// Asset Size.
private void PickerAssetSize_SelectedIndexChanged (object sender, EventArgs e)
{
Changed = true;
}
//-------------------------------------------------------------------
}
//=======================================================================
}