using System; using System.Collections.Generic; using System.Threading.Tasks; using Comal.Classes; using InABox.Clients; using InABox.Core; using Xamarin.Forms; using XF.Material.Forms.UI.Dialogs; namespace comal.timesheets { public partial class Purchases { private Employee _employee = null; public Purchases(Employee employee) { _employee = employee; InitializeComponent(); NavigationPage.SetHasBackButton(this, false); ToolbarItems.Clear(); ToolbarItems.Add( new ToolbarItem("Back", "", () => { Navigation.PopAsync(); }) ); Title = "Purchase Orders"; } protected override async void OnAppearing() { base.OnAppearing(); await LoadData(); } private async Task LoadData() { Device.BeginInvokeOnMainThread(() => NewPurch.IsVisible = false); using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading Data")) { CoreTable orders = new Client().Query( new Filter(x => x.IssuedBy.ID).IsEqualTo(_employee.ID).And(X => X.ClosedDate).IsEqualTo(DateTime.MinValue), new Columns(X => X.ID, X => X.PONumber, X => X.SupplierLink.Name, X => X.ExTax, X => X.IssuedDate), new SortOrder(x => x.PONumber) ); Device.BeginInvokeOnMainThread(() => { foreach (var row in orders.Rows) { PurchaseOrder order = row.ToObject(); PurchaseCard card = new PurchaseCard(order); Cards.Children.Add(card); } NewPurch.IsVisible = true; }); } } void NewPurchase_Clicked(System.Object sender, System.EventArgs e) { NewPurch.IsVisible = false; NewPurchase purchase = new NewPurchase(); Navigation.PushAsync(purchase); } } }