Exemplo n.º 1
0
 private async void addCrewToTheJobButton_Clicked(object sender, EventArgs e)
 {
     if (selectedCrewWorkerBottom != null)
     {
         foreach (CrewWorker item in CWUnaddedList)
         {
             if (selectedCrewWorkerBottom.CrewName != null && item.CrewName != null)
             {
                 if (item.CrewName == selectedCrewWorkerBottom.CrewName)
                 {
                     bool checkExistingAlreadyInJob = crewWorkersAddedList.Where(u => u.WorkerID == item.WorkerID).Any();
                     if (!checkExistingAlreadyInJob)
                     {
                         crewWorkersAddedList.Add(item);
                     }
                 }
             }
         }
         CrewWorkerListViewPopulate();
         selectedCrewWorkerBottom            = null;
         allWorkersCrewListView.SelectedItem = null;
     }
     else
     {
         await Application.Current.MainPage.DisplayAlert("Alert", "Select a worker of a crew below to add to the job.", "Yes");
     }
 }
Exemplo n.º 2
0
 private async void removeWorkerFromJobButton_Clicked(object sender, EventArgs e)
 {
     if (selectedCrewWorkerTop != null)
     {
         crewWorkersAddedList.Remove(selectedCrewWorkerTop);
         CrewWorkerListViewPopulate();
         selectedCrewWorkerTop             = null;
         WorkersLaborListView.SelectedItem = null;
     }
     else
     {
         await Application.Current.MainPage.DisplayAlert("Alert", "Select a worker above to remove from the job.", "Ok");
     }
 }
Exemplo n.º 3
0
 private async void addWorkerToTheJobButton_Clicked(object sender, EventArgs e)
 {
     if (selectedCrewWorkerBottom != null)
     {
         bool checkExistingAlreadyInJob = crewWorkersAddedList.Where(u => u.WorkerID == selectedCrewWorkerBottom.WorkerID).Any();
         if (!checkExistingAlreadyInJob)
         {
             crewWorkersAddedList.Add(selectedCrewWorkerBottom);
             CrewWorkerListViewPopulate();
             selectedCrewWorkerBottom            = null;
             allWorkersCrewListView.SelectedItem = null;
         }
     }
     else
     {
         await Application.Current.MainPage.DisplayAlert("Alert", "Select a worker below to add to the job above.", "Ok");
     }
 }
Exemplo n.º 4
0
 private async void removeCrewFromJobButton_Clicked(object sender, EventArgs e)
 {
     if (selectedCrewWorkerTop != null)
     {
         foreach (CrewWorker item in crewWorkersAddedList.ToList())
         {
             if (selectedCrewWorkerTop.CrewName != null && item.CrewName != null)
             {
                 if (item.CrewName == selectedCrewWorkerTop.CrewName)
                 {
                     crewWorkersAddedList.Remove(item);
                 }
             }
         }
         CrewWorkerListViewPopulate();
         selectedCrewWorkerTop             = null;
         WorkersLaborListView.SelectedItem = null;
     }
     else
     {
         await Application.Current.MainPage.DisplayAlert("Alert", "Select a worker of a crew above to remove from the job.", "Yes");
     }
 }
Exemplo n.º 5
0
        private void CrewWorkerListViewPopulate()
        {
            List <Worker> workers = new List <Worker> {
            };
            List <Crew> crewList  = new List <Crew> {
            };
            List <Labor> tempListOfMatchedLabor = new List <Labor>()
            {
            };


            using (SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation))
            {
                allWorkersCrewListView.ItemsSource = null;
                WorkersLaborListView.ItemsSource   = null;

                //makes a table of just crew without workers
                conn.CreateTable <Crew>();
                crewList = conn.Table <Crew>().ToList();

                //seperate table of workers
                conn.CreateTable <Worker>();
                workers = conn.Table <Worker>().ToList();

                if (workers != null)
                {
                    //had to create a class crewworkers that inherits from crew in order to use filtering/querying with linq queries
                    //left outer join was easier with a fill linq query with no lambdas

                    CWUnaddedList = (from Worker in App.WorkerList
                                     join Crew in crewList on Worker.ID equals Crew.WorkerID
                                     into CrewWorker
                                     from subcrew in CrewWorker.DefaultIfEmpty()
                                     select new CrewWorker()
                    {
                        ID = subcrew?.ID ?? null, WorkerID = Worker.ID, CrewName = subcrew?.CrewName ?? string.Empty, WorkerLastName = Worker.WorkerLastName, IsSupervisor = Worker.IsSupervisor
                    }).ToList();

                    if (CWUnaddedList != null)
                    {
                        allWorkersCrewListView.ItemsSource = CWUnaddedList;
                    }
                }

                //finds the jobfunctions created for this job based on the one jobfunction that was passed
                matchedJobFunctionList = App.JobFunctions.Where(u => u.JobID == passedJobFunctionView.JobID && u.DateScheduled == passedJobFunctionView.DateScheduled).ToList();

                if (matchedJobFunctionList.Count > 0)
                {
                    //go through each jobfunction
                    foreach (JobFunction jobFunction in matchedJobFunctionList)
                    {
                        if (App.Labors.Count > 0)
                        {
                            //get the labor list that is for this job function
                            var tempToAdd = App.Labors.Where(u => u.JobFunctionID == jobFunction.ID).ToList();
                            if (tempToAdd.Count > 0)
                            {
                                tempListOfMatchedLabor.AddRange(tempToAdd);
                            }
                        }
                    }
                    //go through each labor that was returned from this function
                    foreach (Labor item in tempListOfMatchedLabor)
                    {
                        if (CWUnaddedList != null)
                        {
                            //get the workers that are paired with this labor //should be only 1, foreach here and linq query might be unnecessary
                            bool alreadyPresent = false;
                            var  tempCrewWorker = CWUnaddedList.Where(u => u.WorkerID == item.EmployeeID).FirstOrDefault();

                            //Check to see if the worker for this labor is already present in the top group and if it isnt add them.

                            alreadyPresent = crewWorkersAddedList.Where(u => u.WorkerID == tempCrewWorker.WorkerID).Any();
                            if (!alreadyPresent)
                            {
                                crewWorkersAddedList.Add(tempCrewWorker);
                            }
                        }
                    }
                }

                WorkersLaborListView.ItemsSource = crewWorkersAddedList;

                allWorkersCrewListView.DataSource.SortDescriptors.Clear();
                allWorkersCrewListView.DataSource.SortDescriptors.Add(new SortDescriptor()
                {
                    PropertyName = "CrewName",
                    Direction    = ListSortDirection.Ascending
                });

                WorkersLaborListView.DataSource.SortDescriptors.Clear();
                WorkersLaborListView.DataSource.SortDescriptors.Add(new SortDescriptor()
                {
                    PropertyName = "IsSupervisor",
                    Direction    = ListSortDirection.Ascending
                });

                WorkersLaborListView.RefreshView();
                allWorkersCrewListView.RefreshView();
            }
        }
Exemplo n.º 6
0
 private void allWorkersCrewListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
 {
     selectedCrewWorkerBottom = e.ItemData as CrewWorker;
 }
Exemplo n.º 7
0
 private void WorkersLaborListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
 {
     selectedCrewWorkerTop = e.ItemData as CrewWorker;
 }