public async System.Threading.Tasks.Task ListViewPopulate() { laborViews.Clear(); var groupOfPassedJobFunctions = App.JobFunctions.Where(u => u.JobID == passedJobFunctionView.JobID && u.DateScheduled == passedJobFunctionView.DateScheduled).ToList(); foreach (JobFunction item in groupOfPassedJobFunctions) { var linqQueriedLaborViews = App.Labors.Where(u => u.JobFunctionID == item.ID).ToList(); foreach (Labor labor in linqQueriedLaborViews) { var tempTask = App.Tasks.Where(u => u.ID == item.TaskID).FirstOrDefault(); var tempTool = App.Tools.Where(u => u.ID == labor.ToolID).FirstOrDefault(); LaborView laborView = new LaborView() { ID = labor.ID, EmployeeID = labor.EmployeeID, TimeDateEnd = labor.TimeDateEnd, TimeDateStart = labor.TimeDateStart, JobFunctionID = labor.JobFunctionID, TaskName = tempTask.TaskName, ToolName = tempTool.ToolName, ToolID = labor.ToolID }; laborViews.Add(laborView); } } LaborClockListView.ItemsSource = laborViews; LaborClockListView.DataSource.SortDescriptors.Clear(); LaborClockListView.DataSource.SortDescriptors.Add(new SortDescriptor { PropertyName = "TimeDateStart", Direction = Syncfusion.DataSource.ListSortDirection.Ascending }); }
private async void sendHoursButton_Clicked(object sender, EventArgs e) { bool allRecordsClockedOut = true; foreach (LaborView item in laborViews) { if (item.TimeDateEnd == null && item.TimeDateStart != null) { allRecordsClockedOut = false; } } if (!allRecordsClockedOut) { await Application.Current.MainPage.DisplayAlert("Alert", "Please clock out of all active" + " tasks first.", "Ok."); } else { bool check = await Application.Current.MainPage.DisplayAlert("Query", "Send notice of completed job" + " to supervisors?", "Yes.", "Cancel."); if (check) { DateTime todaysDate = DateTime.Today; long min = Math.Abs(todaysDate.Ticks - laborViews[0].TimeDateStart.Value.Ticks); long max = Math.Abs(todaysDate.Ticks - laborViews[0].TimeDateStart.Value.Ticks); LaborView firstJob = laborViews[0]; LaborView lastJob = laborViews[0]; foreach (LaborView item in laborViews) { long diff = Math.Abs(todaysDate.Ticks - item.TimeDateStart.Value.Ticks); if (diff < min) { min = diff; firstJob = item; } if (diff > min) { max = diff; lastJob = item; } } var jobCompleted = App.Jobs.Where(u => u.ID == passedJobFunctionView.JobID).FirstOrDefault(); string datesToPass = $"Hours for {jobCompleted.JobName}. Start Time:{firstJob.TimeDateStart.Value}" + $" End Time:{lastJob.TimeDateStart.Value}"; Message message = new Message() { OwnerID = App.boss.ID, SenderID = App.user.ID, DateTimeSent = DateTime.Now, TextMessage = datesToPass, ToSupervisors = true }; try { await App.mobileService.GetTable <Message>().InsertAsync(message); await Navigation.PopAsync(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", $"{ex}", "OK"); } } } }
public TimeClockEditPage(LaborView selectedLabor) { InitializeComponent(); this.selectedLabor = selectedLabor; datePicker.HeaderText = "Start Date"; }