using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Comal.Classes; using InABox.Clients; using InABox.Core; using InABox.Mobile; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace PRS.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class ManufacturingPacketEditDetailsView { public ManufacturingPacketEditDetailsView() { InitializeComponent(); } public override void Refresh() { LoadIssues(); LoadStages(); LoadOrders(); } private void LoadOrders() { var poitem = ViewModel.OrderItems.FirstOrDefault(); ETAFrame.IsVisible = poitem != null; if (poitem != null) { if (!poitem.ReceivedDate.IsEmpty()) ETALbl.Text = $"Item received from {poitem.SupplierName} on {poitem.ReceivedDate:dd MMM yy}"; else if (!poitem.EstimatedWarehouseArrival.IsEmpty()) ETALbl.Text = $"Item on order from {poitem.SupplierName} (ETA: {poitem.EstimatedWarehouseArrival:dd MMM yy})"; else ETALbl.Text = $"Item on order from {poitem.SupplierName} (unknown ETA)"; } } private void LoadStages() { _stages.Columns .BeginUpdate() .Clear() .Add(new MobileGridTextColumn() { Column = x => x.ManufacturingSectionLinkName, Width = GridLength.Star, Caption = "Section Name" }) .Add(new MobileGridDateColumn() { Column = x => x.Started, Width = GridLength.Auto }) .Add(new MobileGridDateColumn() { Column = x => x.Completed, Width = GridLength.Auto }) .Add(new MobileGridDoubleColumn() { Column = x => x.PercentageComplete, Width = GridLength.Auto, Caption = "%" }) .EndUpdate(); _stages.ItemsSource = ViewModel.Stages.Items; } private void LoadIssues() { IssuesFrame.IsVisible = !String.IsNullOrWhiteSpace(ViewModel.Item.Issues); IssuesLbl.Text = ViewModel.Item.Issues; IssuesTitle.IsVisible = IssuesFrame.IsVisible; } } }