void refreshTable(Object sender, EventArgs e) { List <FlightCards> cards2 = new List <FlightCards>(); if (Reachability.IsHostReachable("http://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updateLeaseFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); cards2 = db.LoadArray(startRange); } else { cards2 = db.LoadArray(startRange); Reachability.InternetConnectionStatus(); Reachability.LocalWifiConnectionStatus(); Reachability.RemoteHostStatus(); try{ Reachability.ReachabilityChanged += delegate { if (Reachability.IsHostReachable("http://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updateLeaseFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); cards2 = db.LoadArray(startRange); } }; }catch (Exception ex) { Console.Out.WriteLine(ex.ToString()); } } ToastIOS.Toast.MakeText("Refreshing"); FlightTableView.Source = new FlightTVS(cards2, this); FlightTableView.RowHeight = 150f; FlightTableView.EstimatedRowHeight = 150f; refreshControl.EndRefreshing(); FlightTableView.ReloadData(); }
partial void SaveButton2_TouchUpInside(UIButton sender) { List <string> passengers = new List <string>(); var update = DataManip.GetIsUpdate(); if ((HobbsInTextField.Text != "") && (HobbsOutTextField.Text != "")) { var number = (double.Parse(HobbsOutTextField.Text) - double.Parse(HobbsInTextField.Text)).ToString("F1"); HobbsTotalTextField.Text = number; } passengers = DataManip.returnPassengerList(); if (passengers.Count != 24) { for (int i = passengers.Count; i < 24; i++) { passengers.Add(""); } } string destination = DestinationTextField.Text.Replace(',', '.'); var dateOutFromTextField = DateTime.Parse(DateOutTextField.Text); var dateOut = dateOutFromTextField.Add(DateTime.Now.TimeOfDay); var newCard = new FlightCards( dateOut, DateInTextField.Text, destination, HobbsInTextField.Text, HobbsOutTextField.Text, HobbsTotalTextField.Text, CashSpentTextField.Text, FlightTypeTextField.Text, pilotTextField.Text, PlaneTypeTextField.Text, leaseTextField.Text, passengers[0], passengers[1], passengers[2], passengers[3], passengers[4], passengers[5], passengers[6], passengers[7], passengers[8], passengers[9], passengers[10], passengers[11], passengers[12], passengers[13], passengers[14], passengers[15], passengers[16], passengers[17], passengers[18], passengers[19], passengers[20], passengers[21], passengers[22], passengers[23]); if (update) { FlightCards old = DataManip.GetEditCard(); newCard.dateOut = old.dateOut; if (Reachability.IsHostReachable("https://www.google.com")) { Toast.MakeText("Flight Card Saved!", Toast.LENGTH_LONG).Show(); dm.updateFlightCardTable(newCard); ws.updateFlightCard(newCard); } else { dm.updateFlightCardTable(newCard); dm.AddtoUpdateTable(newCard); } } else { if (Reachability.IsHostReachable("https://www.google.com")) { ws.SaveToServiceAsync(newCard); } else { dm.AddToAddTable(newCard); dm.SaveFlightCard(newCard); dm.saveAll(); } } DataManip.clearPassengerList(); DataManip.SetIsUpdate(false); UIStoryboard board = UIStoryboard.FromName("Main", null); UIViewController ctrl = (UIViewController)board.InstantiateViewController("TableController"); ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; this.PresentViewController(ctrl, true, null); }
public override void ViewDidAppear(bool animated) { db = new DataManip(); var cards = new List <FlightCards>(); vc = this; var tapOutside = new UITapGestureRecognizer(() => View.EndEditing(true)); tapOutside.CancelsTouchesInView = false; View.AddGestureRecognizer(tapOutside); Picker(StartRangeTextField); if (Reachability.IsHostReachable("http://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); db.updateLeaseFromRemote(); cards = db.LoadArray(startRange); } else { cards = db.LoadArray(startRange); try { Reachability.ReachabilityChanged += delegate { if (Reachability.IsHostReachable("https://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); db.updateLeaseFromRemote(); cards = db.LoadArray(startRange); ToastIOS.Toast.MakeText("Host online, Syncing with remote database", ToastIOS.Toast.LENGTH_LONG).Show(); } }; } catch (Exception e) { Console.Out.WriteLine(e.ToString()); } } db = new DataManip(); FlightTableView.Source = new FlightTVS(cards, this); FlightTableView.RowHeight = 150f; FlightTableView.EstimatedRowHeight = 150f; FlightTableView.ReloadData(); refreshControl = new UIRefreshControl(); FlightTableView.AddSubview(refreshControl); refreshControl.ValueChanged += refreshTable; }