using System; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using Comal.Classes; using InABox.Clients; using InABox.Core; using Xamarin.Forms; using Xamarin.Forms.Xaml; namespace comal.timesheets { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class AssignmentEdit : ContentPage { public AssignmentEdit(Guid assignmentid) { InitializeComponent(); DataModel.Load(assignmentid); } public AssignmentEdit(Assignment assignment) { InitializeComponent(); DataModel.Load(assignment); } private void Save_Tapped(object sender, EventArgs e) { DataModel.Save("Saved by PRS Mobile"); } private async void Activity_Clicked(object sender, EventArgs e) { try { GenericSelectionPage page = new GenericSelectionPage( "Select Activity", new SelectionViewModel( new Filter(x => x.Employee.ID).IsEqualTo(App.Data.Employee.ID), new Expression>[] { x => x.Activity.Code, x => x.Activity.Description }, new Expression>[] { x => x.Activity.ID }, new SortOrder(x => x.Activity.Code) ) ); page.OnItemSelected += (row) => { Device.BeginInvokeOnMainThread(() => { DataModel.Item.ActivityID = row.Get(c => c.Activity.ID); DataModel.Item.ActivityCode = row.Get(c => c.Activity.Code); DataModel.Item.ActivityDescription = row.Get(c => c.Activity.Description); }); }; Navigation.PushAsync(page); } catch { } } private void Job_Clicked(object sender, EventArgs e) { try { GenericSelectionPage page = new GenericSelectionPage( "Select Job", new SelectionViewModel( new Filter(x => x.JobStatus.Active).IsEqualTo(true), new Expression>[] { x => x.JobNumber, x => x.Name }, new Expression>[] { x => x.ID }, new SortOrder(x => x.JobNumber,SortDirection.Descending) ) ); page.OnItemSelected += (row) => { Device.BeginInvokeOnMainThread(() => { DataModel.Item.JobID = row.Get(c => c.ID); DataModel.Item.JobNumber = row.Get(c => c.JobNumber); DataModel.Item.JobName = row.Get(c => c.Name); }); }; Navigation.PushAsync(page); } catch { } } } }