using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using InABox.Mobile; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace PRS.Mobile { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class ConsignmentEditDetailsView { public ConsignmentEditDetailsView() { InitializeComponent(); } public override void Refresh() { } private void SelectSupplier_Clicked(object sender, MobileButtonClickEventArgs args) { ShowPopup(() => SelectionView.Execute( (columns) => { columns.Add(new MobileGridTextColumn() { Column = x => x.Name, Width = GridLength.Star, Caption = "Select Supplier", Alignment = TextAlignment.Start }); }, (refresh) => App.Data.Suppliers.Refresh(false), (suppliers) => { ViewModel.Item.SupplierID = suppliers.FirstOrDefault()?.ID ?? Guid.Empty; ViewModel.Item.SupplierName = suppliers.FirstOrDefault()?.Name ?? string.Empty; DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.SupplierName)); DismissPopup(); })); } private void SelectType_Clicked(object sender, MobileButtonClickEventArgs args) { ShowPopup(() => SelectionView.Execute( (columns) => { columns.Add(new MobileGridTextColumn() { Column = x => x.Description, Width = GridLength.Star, Caption = "Select Type", Alignment = TextAlignment.Start }); }, (refresh) => App.Data.ConsignmentTypes.Refresh(false), (types) => { ViewModel.Item.TypeID = types.FirstOrDefault()?.ID ?? Guid.Empty; ViewModel.Item.TypeDescription = types.FirstOrDefault()?.Description ?? string.Empty; DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.TypeDescription)); DismissPopup(); })); } private void SelectETA_Clicked(object sender, MobileButtonClickEventArgs args) { ShowPopup( () => { var selector = new MobileDateSelector(); selector.Date = ViewModel.Item.EstimatedWarehouseArrival; selector.Changed += (o, changedArgs) => { ViewModel.Item.EstimatedWarehouseArrival = changedArgs.Date; DismissPopup(); }; selector.Cancelled += (o, eventArgs) => DismissPopup(); return selector; }, new PopupManagerConfiguration() { Modal = true } ); } private void Number_Changed(object sender, TextChangedEventArgs e) { DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.Number)); } private void Description_Changed(object sender, TextChangedEventArgs e) { DoChanged(nameof(ViewModel.Item), nameof(ConsignmentShell.Description)); } private void SelectATA_Clicked(object sender, MobileButtonClickEventArgs args) { ShowPopup( () => { var selector = new MobileDateSelector(); selector.Date = ViewModel.Item.ActualWarehouseArrival; selector.Changed += (o, changedArgs) => { ViewModel.Item.ActualWarehouseArrival = changedArgs.Date; DismissPopup(); }; selector.Cancelled += (o, eventArgs) => DismissPopup(); return selector; }, new PopupManagerConfiguration() { Modal = true } ); } } }