private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { JobCell _job = new JobCell(); _job = e.SelectedItem as JobCell; go(_job); }
public JobSpecific(Connection cnx, JobCell job, bool comingFromSubjob) { InitializeComponent(); BackgroundColor = Color.FromHex("#B80000"); _comingFromSubjob = comingFromSubjob; jx = job; updateView(job); MainCnx = cnx; _jobcell = job; loaded = true; if (job.Status == "Completed") { SendPDFButton.IsEnabled = true; SendPDFButton.IsVisible = true; } else { SendPDFButton.IsEnabled = false; SendPDFButton.IsVisible = false; AbsoluteLayout.SetLayoutBounds(CallUsButton, new Rectangle(.5, .975, .25, .1)); } }
private void updateView(JobCell job) { if (job.Status != "Sent") { SendPDFButton.IsEnabled = false; } _JobNumber = job.job.job.ToString(); IDLabel.Text = string.Format("Job: {0}", job.job.job.ToString()); SJLabel.Text = string.Format("Subjob: {0}", job.SubJobNumber); Add1.Text = job.job.add1; Add2.Text = job.job.add2; Add3.Text = job.job.add3; Add4.Text = job.job.add4; AddPC.Text = job.job.addpc; Notes.Text = job.Notes; Description.Text = job.Description; Total = job.GrossValue; Price = job.NetValue; VatVal = job.VatValue; var awarded = job.job.awarded; switch (awarded) { case "Won": { AwardedPicker.SelectedIndex = 0; AwardedPicker.TextColor = Color.Green; break; } case "Lost": { AwardedPicker.SelectedIndex = 1; AwardedPicker.TextColor = Color.Red; break; } default: { AwardedPicker.SelectedIndex = -1; break; } } Status.Text = job.Status; Status.TextColor = job.StatusColor; PayButton.IsEnabled = false; PayButton.Text = "No Payment Due"; if (Total != 0) { PayButton.IsEnabled = true; PayButton.Text = String.Format("Pay: £{0}", Total); } }
public async void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e) { var cnx = Maincnx; var item = e.SelectedItem as JobCell; Job _item = new Job(); _item = item.job; string jobKey = String.Format("/api/api/5?id=id$~{0}~cmd$~getjobdetails~{1}", cnx.ID, item.JobNumber); //List<MegaParser.groupitem> groupitems = MegaParser.ParseJobs(await GetJob(jobKey, cnx.Token)); string rawJson = await GetJob(jobKey, cnx.Token); if (connected == false) { return; } if (rawJson == "no jobs" || string.IsNullOrEmpty(rawJson)) { await DisplayAlert("No Info", "No Further Information", "ok"); Console.WriteLine("RETURNED: no jobs"); updateList(Maincnx, null); } else if (rawJson[0] != '[') { await DisplayAlert("No Info", "No Further Information", "ok"); Console.WriteLine("RETURNED: Improper Format"); updateList(Maincnx, null); } else { var x = JobsFromJson.FromJson(rawJson); List <SubJob> _subJobs = new List <SubJob>(); foreach (Dictionary <string, string> i in x) { SubJob sj = new SubJob(); if (i["subjob"] == "") { sj.Subjob = 0; } else { sj.Subjob = Convert.ToInt32(i["subjob"]); } if (i["esent"] == "") { sj.Sent = 0; } else { sj.Sent = Convert.ToInt32(i["esent"]); } sj.Status = i["status"]; sj.Created = i["created"]; sj.Description = i["description"]; sj.GrossValue = i["grossValue"]; sj.NetValue = i["netValue"]; sj.VatValue = i["vatValue"]; sj.Notes = i["notes"]; _subJobs.Add(sj); } List <Job> subjobs = new List <Job>(); foreach (SubJob _sj in _subJobs) { Job job = new Job(); if (_sj.Description == "none") { _sj.Description = ""; } if (_sj.GrossValue == null || _sj.GrossValue == "") { if (_item.grossValue == null || _item.grossValue == 0) { _sj.GrossValue = "0.00"; job.grossValue = Convert.ToDouble(_sj.GrossValue); } else if (_sj.Subjob == 0) { job.grossValue = _item.grossValue; } } else { job.grossValue = Convert.ToDouble(_sj.GrossValue); } if (_sj.NetValue == null || _sj.NetValue == "") { if (_item.netValue == null || _item.netValue == 0) { _sj.NetValue = "0.00"; job.netValue = Convert.ToDouble(_sj.NetValue); } else if (_sj.Subjob == 0) { job.netValue = _item.netValue; } } else { job.netValue = Convert.ToDouble(_sj.NetValue); } if (_sj.VatValue == null || _sj.VatValue == "") { if (_item.vatValue == null || _item.vatValue == 0) { _sj.VatValue = "0.00"; job.vatValue = Convert.ToDouble(_sj.VatValue); } else if (_sj.Subjob == 0) { job.vatValue = _item.vatValue; } } else { job.vatValue = Convert.ToDouble(_sj.VatValue); } job.job = _item.job; job.subjob = _sj.Subjob; job.status = _sj.Status; job.created = Convert.ToDateTime(_sj.Created, System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")); job.add1 = _item.add1; job.add2 = _item.add2; job.add3 = _item.add3; job.add4 = _item.add4; job.addpc = _item.addpc; job.awarded = _item.awarded; job.buildername = _item.buildername; job.description = _sj.Description; job.sentcount = _sj.Sent; job.Notes = _sj.Notes; subjobs.Add(job); } if (subjobs.Count == 1) { JobCell _job = new JobCell { JobColor = StatusSorter.JobNumberColor(subjobs[0]), Status = StatusSorter.StatusText(subjobs[0]), StatusColor = StatusSorter.StatusColor(subjobs[0]), CellColor = StatusSorter.CellColor(subjobs[0]), Add1 = subjobs[0].add1, Add2 = subjobs[0].add2, Add3 = subjobs[0].add3, Add4 = subjobs[0].add4, AddPC = subjobs[0].addpc, Awarded = subjobs[0].awarded, Builder = subjobs[0].buildername, Created = subjobs[0].created, Description = subjobs[0].description, JobNumber = subjobs[0].job.ToString(), SentCount = subjobs[0].sentcount, GrossValue = subjobs[0].grossValue, NetValue = subjobs[0].netValue, VatValue = subjobs[0].vatValue, Notes = subjobs[0].Notes, noSubs = true, job = _item }; await Navigation.PushAsync(new JobSpecific(cnx, _job, false)); } else { await Navigation.PushAsync(new Subjobs_List(cnx, subjobs, _item)); } } }
public List <JobCell> FormListFromText(string Text) { //Could also index origional list of jobs and use that to decide which to display, instead of creating another temp list. if (!string.IsNullOrEmpty(Text) && !string.IsNullOrWhiteSpace(Text)) { string _text = ""; try { searchBarText = Text; _text = Text.ToLower(); } catch (NullReferenceException) { Console.WriteLine("CAUGHT THE EXCEPTION 1"); } int indexer = 0; List <int> indexerList = new List <int>(); List <JobCell> List = new List <JobCell>(); foreach (JobCell cell in _Cells) { bool addToList = false; JobCell x = cell; if (!string.IsNullOrEmpty(x.Add1) && !string.IsNullOrWhiteSpace(x.Add1)) { indexer++; string y = ""; try { y = x.Add1.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.Add2) && !string.IsNullOrWhiteSpace(x.Add2)) { indexer++; string y = ""; try { y = x.Add2.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.Add3) && !string.IsNullOrWhiteSpace(x.Add3)) { indexer++; string y = ""; try { y = x.Add3.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.Add4) && !string.IsNullOrWhiteSpace(x.Add4)) { indexer++; string y = ""; try { y = x.Add4.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.AddPC) && !string.IsNullOrWhiteSpace(x.AddPC)) { indexer++; string y = ""; try { y = x.AddPC.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.Description) && !string.IsNullOrWhiteSpace(x.Description)) { indexer++; string y = ""; try { y = x.Description.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (!string.IsNullOrEmpty(x.JobNumber) && !string.IsNullOrWhiteSpace(x.JobNumber)) { indexer++; string y = ""; try { y = x.JobNumber.ToLower(); } catch (NullReferenceException) { indexerList.Add(indexer); Console.WriteLine("CAUGHT AT " + indexer); } Console.WriteLine(indexer + " " + "Add1" + " " + y + "\n"); if (y.Contains(_text)) { addToList = true; } } if (addToList == true) { try { List.Add(cell); } catch (NullReferenceException) { Console.WriteLine("Found Putting in Cell"); } } } var osf = List; return(List); } else { updateList(Maincnx, null); return(null); } }
async Task updateList(Connection cnx, List <JobCell> JOBCELLS) { this.BarBackgroundColor = Color.FromHex("#B80000"); settingsButton.BackgroundColor = Color.FromHex("#B80000"); materialsButton.BackgroundColor = Color.FromHex("#B80000"); contactButton.BackgroundColor = Color.FromHex("#B80000"); passwordButton.BackgroundColor = Color.FromHex("#B80000"); List <Job> Jobs = new List <Job>();; List <JobCell> Cells = new List <JobCell>(); if (JOBCELLS == null) { JobAmounts jobamounts = await GetAmounts(cnx); if (!string.IsNullOrEmpty(jobamounts.jobs)) { int endNumber = Int32.Parse(jobamounts.jobs); Jobs = await GetContent(0, endNumber, cnx); if (Jobs == null) { await DisplayAlert("Error", "There has been an issue retreiving your jobs. Please try again.\n\nIf this keeps happening please restart the app.", "Ok"); return; } } else { await DisplayAlert("Error", "There has been an issue retreiving your job count. Please try again.\n\nIf this keeps happening please restart the app.", "Ok"); } foreach (Job job in Jobs) { JobCell cell = new JobCell { JobNumber = job.job.ToString(), Add1 = job.add1, JobColor = StatusSorter.JobNumberColor(job), Status = StatusSorter.StatusText(job), StatusColor = StatusSorter.StatusColor(job), CellColor = StatusSorter.CellColor(job), job = job }; Cells.Add(cell); _Cells = Cells; } } else { Cells = JOBCELLS; } Label jobHeader = new Label { Text = Maincnx.Name, TextColor = Color.Black, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center }; searchbar = new SearchBar() { Placeholder = "Search:", Text = searchBarText, CancelButtonColor = Color.Red }; searchbar.SearchButtonPressed += SearchBarButtonPressedChanged; searchbar.TextChanged += Searchbar_TextChanged; listView = new ListView() { HasUnevenRows = true, BackgroundColor = Color.White, ItemsSource = Cells, ItemTemplate = new DataTemplate(() => { //create views with bindings for displaying each property. Label JobNumber = new Label() { FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), FontAttributes = FontAttributes.Bold }; JobNumber.SetBinding(Label.TextProperty, "JobNumber"); JobNumber.SetBinding(Label.TextColorProperty, "JobColor"); Label JobAddress = new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontAttributes = FontAttributes.Italic }; JobAddress.SetBinding(Label.TextProperty, "Add1"); JobAddress.TextColor = Color.Black; Label Status = new Label(); Status.SetBinding(Label.TextProperty, "Status"); Status.SetBinding(Label.TextColorProperty, "StatusColor"); return(new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Orientation = StackOrientation.Horizontal, Children = { JobNumber, //stick in an image here for whatever you want. new StackLayout { VerticalOptions = LayoutOptions.CenterAndExpand, Spacing = 0, Children = { JobAddress, Status } } } } }); }) }; listView.ItemSelected += ListView_ItemSelected; this.Padding = new Thickness(10, 20, 10, 5); Tab1.Content = new StackLayout { Children = { jobHeader, searchbar, listView, } }; }
void updateList(Connection cnx, List <Job> subjobs, Job item) { Job JR = item; List <JobCell> Cells = new List <JobCell>(); foreach (Job job in subjobs) { JobCell cell = new JobCell(); cell.Add1 = JR.add1; cell.Add2 = JR.add2; cell.Add3 = JR.add3; cell.Add4 = JR.add4; cell.AddPC = JR.addpc; cell.Builder = JR.buildername; cell.JobNumber = JR.job.ToString(); cell.Awarded = JR.awarded; cell.subjob = job; cell.Notes = job.Notes; cell.SubJobNumber = job.subjob.ToString(); cell.Created = job.created; cell.Description = job.description; cell.SentCount = job.sentcount; cell.GrossValue = job.grossValue; cell.NetValue = job.netValue; cell.VatValue = job.vatValue; cell.JobColor = StatusSorter.JobNumberColor(subjobs[0]); cell.Status = StatusSorter.StatusText(subjobs[0]); cell.StatusColor = StatusSorter.StatusColor(subjobs[0]); cell.CellColor = StatusSorter.CellColor(subjobs[0]); //switch (job.status) //{ // case "S20": // cell.JobColor = Color.Green; // cell.StatusColor = Color.Green; // cell.Status = "Sent"; // break; // case "S00": // cell.Status = "Awaiting Appraisal"; // break; // case "S02": // cell.CellColor = Color.LightPink; // cell.JobColor = Color.Red; // cell.StatusColor = Color.Red; // cell.Status = "Awaiting Documentation"; // break; // case "S03": // cell.Status = "Adjudication Issue"; // cell.StatusColor = Color.Purple; // break; // case "S99": // cell.Status = "Cancelled"; // cell.CellColor = Color.LightGray; // break; // default: // cell.Status = job.status; // break; //} cell.job = JR; Cells.Add(cell); } Label jobHeader = new Label { Text = Cells[0].Add1, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), TextColor = Color.Black, HorizontalOptions = LayoutOptions.Center }; ListView listView = new ListView() { BackgroundColor = Color.White, HasUnevenRows = true, ItemsSource = Cells, ItemTemplate = new DataTemplate(() => { //create views with bindings for displaying each property. Label JobNumber = new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)) }; JobNumber.SetBinding(Label.TextProperty, "JobNumber"); JobNumber.SetBinding(Label.TextColorProperty, "JobColor"); Label SubJob = new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), }; SubJob.SetBinding(Label.TextProperty, "SubJobNumber"); Label JobDiscription = new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontAttributes = FontAttributes.Bold }; JobDiscription.SetBinding(Label.TextProperty, "Description"); Label JobAddress = new Label() { FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontAttributes = FontAttributes.Italic }; JobAddress.SetBinding(Label.TextProperty, "Add1"); Label Status = new Label(); Status.SetBinding(Label.TextProperty, "Status"); Status.SetBinding(Label.TextColorProperty, "StatusColor"); return(new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Children = { new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { JobNumber } }, new StackLayout { Orientation = StackOrientation.Vertical, Children = { Status } } } }, new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.StartAndExpand, Children = { JobDiscription } }, new StackLayout { Orientation = StackOrientation.Vertical, Children = { SubJob } } } } } } }); }) }; listView.ItemSelected += ListView_ItemSelected; this.Padding = new Thickness(10, 20, 10, 5); this.Content = new StackLayout { Children = { jobHeader, listView } }; }
private async void go(JobCell _job) { await Navigation.PushAsync(new JobSpecific(MainCnx, _job, true)); }