242 lines
9.3 KiB
C#
242 lines
9.3 KiB
C#
using Sarand.Core.Base;
|
|
using Sarand.Core.Mobile.Forms.Controls;
|
|
using Sarand.LogisticsMgr.Core.App;
|
|
using Sarand.LogisticsMgr.Core.Bus;
|
|
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_AssetRepairJob : SlmComponents
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile;
|
|
private static readonly int codeEntryWidth = 48;
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SlmComponents_AssetRepairJob()
|
|
{
|
|
InitialiseComponents();
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
// Location code.
|
|
public SlmLabel LabelLocation { get; } = new SlmLabel() { Text = "Location" };
|
|
public SlmEntryView EntryLocation { get; } = new SlmEntryView();
|
|
public SlmPickerView_CodeType PickerLocation { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Location };
|
|
// Component code.
|
|
public SlmLabel LabelComponent { get; } = new SlmLabel() { Text = "Component" };
|
|
public SlmEntryView EntryComponent { get; } = new SlmEntryView();
|
|
public SlmPickerView_CodeType PickerComponent { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Component };
|
|
// Damage code.
|
|
public SlmLabel LabelDamage { get; } = new SlmLabel() { Text = "Damage" };
|
|
public SlmEntryView EntryDamage { get; } = new SlmEntryView();
|
|
public SlmPickerView_CodeType PickerDamage { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Damage };
|
|
// Repair code.
|
|
public SlmLabel LabelRepair { get; } = new SlmLabel() { Text = "Repair" };
|
|
public SlmEntryView EntryRepair { get; } = new SlmEntryView();
|
|
public SlmPickerView_CodeType PickerRepair { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Repair };
|
|
// Quantity.
|
|
public SlmLabel LabelQuantity { get; } = new SlmLabel() { Text = "Quantity" };
|
|
public SlmEntryView EntryQuantity { get; } = new SlmEntryView();
|
|
|
|
//-------------------------------------------------------------------
|
|
// Utilities.
|
|
|
|
//-------------------------------------------------------------------
|
|
// I n i t i a l i s e
|
|
//-------------------------------------------------------------------
|
|
private void InitialiseComponents ()
|
|
{
|
|
// Location.
|
|
EntryLocation.HorizontalOptions = LayoutOptions.Start;
|
|
EntryLocation.WidthRequest = codeEntryWidth;
|
|
EntryLocation.TextCase = SaxEntry.TextCaseType.Upper;
|
|
EntryLocation.MaxLength = 4;
|
|
EntryLocation.TextChanged += EntryLocation_TextChanged;
|
|
EntryLocation.Completed += EntryLocation_Completed;
|
|
PickerLocation.SelectedIndexChanged += PickerLocation_SelectedIndexChanged;
|
|
PickerLocation.Populated += PickerLocation_Populated;
|
|
|
|
// Component.
|
|
EntryComponent.HorizontalOptions = LayoutOptions.Start;
|
|
EntryComponent.WidthRequest = codeEntryWidth;
|
|
EntryComponent.TextCase = SaxEntry.TextCaseType.Upper;
|
|
EntryComponent.MaxLength = 3;
|
|
EntryComponent.TextChanged += EntryComponent_TextChanged;
|
|
EntryComponent.Completed += EntryComponent_Completed;
|
|
PickerComponent.SelectedIndexChanged += PickerComponent_SelectedIndexChanged;
|
|
PickerComponent.Populated += PickerComponent_Populated;
|
|
|
|
// Damage.
|
|
EntryDamage.HorizontalOptions = LayoutOptions.Start;
|
|
EntryDamage.WidthRequest = codeEntryWidth;
|
|
EntryDamage.TextCase = SaxEntry.TextCaseType.Upper;
|
|
EntryDamage.MaxLength = 2;
|
|
EntryDamage.TextChanged += EntryDamage_TextChanged;
|
|
EntryDamage.Completed += EntryDamage_Completed;
|
|
PickerDamage.SelectedIndexChanged += PickerDamage_SelectedIndexChanged;
|
|
PickerDamage.Populated += PickerDamage_Populated;
|
|
|
|
// Repair.
|
|
EntryRepair.HorizontalOptions = LayoutOptions.Start;
|
|
EntryRepair.WidthRequest = codeEntryWidth;
|
|
EntryRepair.TextCase = SaxEntry.TextCaseType.Upper;
|
|
EntryRepair.MaxLength = 2;
|
|
EntryRepair.TextChanged += EntryRepair_TextChanged;
|
|
EntryRepair.Completed += EntryRepair_Completed;
|
|
PickerRepair.SelectedIndexChanged += PickerRepair_SelectedIndexChanged;
|
|
PickerRepair.Populated += PickerRepair_Populated;
|
|
|
|
// Quantity.
|
|
EntryQuantity.Text = "1";
|
|
EntryQuantity.HorizontalOptions = LayoutOptions.Start;
|
|
EntryQuantity.WidthRequest = codeEntryWidth;
|
|
EntryQuantity.NumericOnly = true;
|
|
EntryQuantity.MaxLength = 2;
|
|
EntryQuantity.TextChanged += EntryQuantity_TextChanged;
|
|
EntryQuantity.Completed += EntryQuantity_Completed;
|
|
|
|
Changed = false;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// P o p u l a t i o n
|
|
//-------------------------------------------------------------------
|
|
public void PopulateToControls (SlmAssetRepairJob.Data data)
|
|
{
|
|
EntryLocation.Text = data.LocationCode;
|
|
EntryComponent.Text = data.ComponentCode;
|
|
EntryDamage.Text = data.DamageCode;
|
|
EntryRepair.Text = data.RepairCode;
|
|
EntryQuantity.Text = data.Quantity.ToString();
|
|
Changed = false;
|
|
}
|
|
public bool IsDataValid (SlmAssetRepairJob.Data data)
|
|
{
|
|
return true;
|
|
}
|
|
public void PopulateFromControls (SlmAssetRepairJob.Data data)
|
|
{
|
|
data.LocationCode = EntryLocation.Text;
|
|
data.ComponentCode = EntryComponent.Text;
|
|
data.DamageCode = EntryDamage.Text;
|
|
data.RepairCode = EntryRepair.Text;
|
|
data.Quantity= StringUtil.ToShort(EntryQuantity.Text);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n t r o l A c t i v i t y
|
|
//-------------------------------------------------------------------
|
|
protected override void SetControlActivity ()
|
|
{
|
|
SetControlsReadOnly();
|
|
}
|
|
protected override void SetControlsReadOnly ()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// C o n t r o l E v e n t s
|
|
//-------------------------------------------------------------------
|
|
// Location.
|
|
private void EntryLocation_TextChanged (object sender, Xamarin.Forms.TextChangedEventArgs e)
|
|
{
|
|
if (PickerLocation.ContainsCode(e.NewTextValue))
|
|
PickerLocation.SelectedCode = e.NewTextValue;
|
|
}
|
|
private void EntryLocation_Completed (object sender, EventArgs e)
|
|
{
|
|
}
|
|
private void PickerLocation_Populated (object sender, SaxPicker.PopulatedEventArgs e)
|
|
{
|
|
if (PickerLocation.ContainsCode(EntryLocation.Text))
|
|
PickerLocation.SelectedCode = EntryLocation.Text;
|
|
}
|
|
private void PickerLocation_SelectedIndexChanged (object sender, EventArgs e)
|
|
{
|
|
EntryLocation.Text = PickerLocation.SelectedCode;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Component.
|
|
private void EntryComponent_TextChanged (object sender, Xamarin.Forms.TextChangedEventArgs e)
|
|
{
|
|
if (PickerComponent.ContainsCode(e.NewTextValue))
|
|
PickerComponent.SelectedCode = e.NewTextValue;
|
|
}
|
|
private void EntryComponent_Completed (object sender, EventArgs e)
|
|
{
|
|
}
|
|
private void PickerComponent_Populated (object sender, SaxPicker.PopulatedEventArgs e)
|
|
{
|
|
if (PickerComponent.ContainsCode(EntryComponent.Text))
|
|
PickerComponent.SelectedCode = EntryComponent.Text;
|
|
}
|
|
private void PickerComponent_SelectedIndexChanged (object sender, EventArgs e)
|
|
{
|
|
EntryComponent.Text = PickerComponent.SelectedCode;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Damage.
|
|
private void EntryDamage_TextChanged (object sender, Xamarin.Forms.TextChangedEventArgs e)
|
|
{
|
|
if (PickerDamage.ContainsCode(e.NewTextValue))
|
|
PickerDamage.SelectedCode = e.NewTextValue;
|
|
}
|
|
private void EntryDamage_Completed (object sender, EventArgs e)
|
|
{
|
|
}
|
|
private void PickerDamage_Populated (object sender, SaxPicker.PopulatedEventArgs e)
|
|
{
|
|
if (PickerDamage.ContainsCode(EntryDamage.Text))
|
|
PickerDamage.SelectedCode = EntryDamage.Text;
|
|
}
|
|
private void PickerDamage_SelectedIndexChanged (object sender, EventArgs e)
|
|
{
|
|
EntryDamage.Text = PickerDamage.SelectedCode;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Repair.
|
|
private void EntryRepair_TextChanged (object sender, Xamarin.Forms.TextChangedEventArgs e)
|
|
{
|
|
if (PickerRepair.ContainsCode(e.NewTextValue))
|
|
PickerRepair.SelectedCode = e.NewTextValue;
|
|
}
|
|
private void EntryRepair_Completed (object sender, EventArgs e)
|
|
{
|
|
}
|
|
private void PickerRepair_Populated (object sender, SaxPicker.PopulatedEventArgs e)
|
|
{
|
|
if (PickerRepair.ContainsCode(EntryRepair.Text))
|
|
PickerRepair.SelectedCode = EntryRepair.Text;
|
|
}
|
|
private void PickerRepair_SelectedIndexChanged (object sender, EventArgs e)
|
|
{
|
|
EntryRepair.Text = PickerRepair.SelectedCode;
|
|
}
|
|
//-------------------------------------------------------------------
|
|
// Quantity.
|
|
private void EntryQuantity_TextChanged (object sender, TextChangedEventArgs e)
|
|
{
|
|
}
|
|
private void EntryQuantity_Completed (object sender, EventArgs e)
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|