Пример #1
0
        partial void CancelButton2_TouchUpInside(UIButton sender)
        {
            DataManip.clearPassengerList();
            DataManip.SetIsUpdate(false);
            var              update = DataManip.GetIsUpdate();
            UIStoryboard     board  = UIStoryboard.FromName("Main", null);
            UIViewController ctrl   = (UIViewController)board.InstantiateViewController("TableController");

            ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
            this.PresentViewController(ctrl, true, null);
        }
Пример #2
0
        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);
        }
Пример #3
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
        {
            switch (editingStyle)
            {
            case UITableViewCellEditingStyle.Delete:

                UIAlertController actionSheetAlert = UIAlertController.Create(
                    "Menu", "Select An Action", UIAlertControllerStyle.ActionSheet);
                actionSheetAlert.AddAction(UIAlertAction.Create("Email", UIAlertActionStyle.Default, (obj) =>
                {
                    if (MFMailComposeViewController.CanSendMail)
                    {
                        var passengers = cards[indexPath.Row].getPassengers();
                        List <String> actualPassengers = new List <string>();
                        foreach (var person in passengers)
                        {
                            if (person != "")
                            {
                                actualPassengers.Add(person);
                            }
                        }
                        String passString = "Passengers: \n";
                        foreach (var passenger in actualPassengers)
                        {
                            passString += passenger + "\n";
                        }
                        var dateOut     = cards[indexPath.Row].dateOut;
                        var dateIn      = cards[indexPath.Row].dateOut;
                        var destination = cards[indexPath.Row].destination;
                        var hobbsIn     = cards[indexPath.Row].hobbsIn;
                        var hobbsOut    = cards[indexPath.Row].hobbsOut;
                        var hobbsTotal  = cards[indexPath.Row].totalHobbs;
                        var cash        = cards[indexPath.Row].cashSpent;
                        var flighttype  = cards[indexPath.Row].flightType;
                        var pilot       = cards[indexPath.Row].pilot;
                        var plane       = cards[indexPath.Row].planeType;
                        var lease       = cards[indexPath.Row].leaseName;

                        String message = string.Format("Date Out =    {0} \n " +
                                                       "Date In =     {1} \n" +
                                                       "Destination = {2} \n" +
                                                       "Hobbs In =    {3} \n" +
                                                       "Hobbs Out =   {4} \n" +
                                                       "Total Hobbs = {5}\n " +
                                                       "Cash Spent =  {6} \n" +
                                                       "Flight Type = {7} \n" +
                                                       "Pilot =       {8}\n" +
                                                       "Plane =       {9}\n" +
                                                       "Lease =       {10} \n", dateOut, dateIn,
                                                       destination, hobbsIn, hobbsOut, hobbsTotal,
                                                       cash, flighttype, pilot, plane, lease);
                        String body    = message + passString;
                        mailController = new MFMailComposeViewController();
                        mailController.SetToRecipients(new string[] { "*****@*****.**" });
                        mailController.SetSubject("Flight Card");
                        mailController.SetMessageBody("Flight card information:  \n " + body, false);
                        mailController.Finished += (object s,
                                                    MFComposeResultEventArgs args) =>
                        {
                            Console.WriteLine(args.Result.ToString());
                            args.Controller.DismissViewController(true, null);
                        };
                        vc.PresentViewController(mailController, true, null);
                    }
                }));
                actionSheetAlert.AddAction(UIAlertAction.Create("Edit", UIAlertActionStyle.Default, (obj) =>
                {
                    DataManip.SetIsUpdate(true);
                    DataManip.SetEditCard(cards[indexPath.Row]);

                    UIStoryboard board        = UIStoryboard.FromName("Main", null);
                    UIViewController ctrl     = (UIViewController)board.InstantiateViewController("Add");
                    ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
                    vc.PresentViewController(ctrl, true, null);
                }));
                actionSheetAlert.AddAction(UIAlertAction.Create("Delete", UIAlertActionStyle.Default, (obj) =>
                {
                    DataManip.deleteRecordFromFlightCards(cards[indexPath.Row]);
                    cards.RemoveAt(indexPath.Row);
                    tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
                }));

                actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (obj) => {}));
                vc.PresentViewController(actionSheetAlert, true, null);
                tableView.DeselectRow(indexPath, true);
                break;

            case UITableViewCellEditingStyle.None:
                Console.WriteLine("commit editing style none called");
                break;
            }
        }