public SaleOptionsDVC(RootElement root, bool pushing, bool filling, JobRunTable JRT, JobInstallationViewController JIVC) : base(root, pushing) { jrt = JRT; jivc = JIVC; if (SaleOptionsDVC.dbSaleOptions == null || SaleOptionsDVC.dbSaleOptions.Count == 0) { dbSaleOptions = SaleOptionsDVC.ReadSaleOptions(); } if (filling) { this.Root = new RootElement("Choose install options"); Section scAllDone = new Section(""); var allDone = new StringElement("Finished choosing options", ""); scAllDone.Add(allDone); this.Root.Add(scAllDone); // fill the Tap Models section Section scTapModels = new Section("Tap models"); if (dbSaleOptions != null) { foreach (SaleOption option in dbSaleOptions) { if (option.Type == "Taps" && option.Active) { scTapModels.Add(new SaleOptionBadgeElement(option, null)); } } } this.Root.Add(scTapModels); // fill the Extras section Section scExtras = new Section("Extras"); if (dbSaleOptions != null) { foreach (SaleOption option in dbSaleOptions) { if (option.Type != "Taps" && option.Active) { scExtras.Add(new SaleOptionBadgeElement(option, null)); } } } this.Root.Add(scExtras); } }
public InstallTypesDVC(RootElement root, bool pushing, bool filling, JobRunTable JRT, JobInstallationViewController JIVC) : base(root, pushing) { jrt = JRT; jivc = JIVC; if (InstallTypesDVC.dbInstallTypes == null || InstallTypesDVC.dbInstallTypes.Count == 0) { dbInstallTypes = InstallTypesDVC.ReadInstallTypes(); } if (filling) { this.Root = new RootElement("Choose install type"); Root.Add(new Section("Install types")); foreach (InstallationType installType in dbInstallTypes) { Root[0].Add(new InstallTypeBadgeElement(installType, null)); } } }
public ProductsDVC(RootElement root, bool pushing, bool filling, JobRunTable JRT, JobInstallationViewController JIVC) : base(root, pushing) { jivc = JIVC; // jrt = JRT; if (ProductsDVC.dbProducts == null || ProductsDVC.dbProducts.Count == 0) { dbProducts = ProductsDVC.ReadProducts(); } if (filling) { this.Root = new RootElement("Choose product"); Root.Add(new Section("Products")); foreach (Product product in dbProducts) { Root[0].Add(new ProductBadgeElement(product, null)); } } }
public PaymentsSummary(RootElement root, PaymentsSummaryNavigationController pnav, JobRunTable JRT) : base(root) { SummaryMode = SummaryModes.Money; jrt = JRT; Nav = pnav; Root.Caption = "Daily payments summary"; Root.Add(new Section("Customer# Type To collect Received")); Root.Add(new Section("Totals")); Root[0].Footer = ""; // Payments = new List<JobPayment>(); SummaryData = new List <string>(); JobsByType = new Dictionary <string, int>(); PrintDailySummary = delegate { if (this.View != null) { // exception handling here string pdfFileName = MyConstants.PreparePDFFileForPrintingAView(this.TableView); if (pdfFileName != "") { BeginPrintingDailySummary(pdfFileName); } else { var savingError = new UIAlertView("Failed to generate a summary file for printing.", "", null, "Sad times..."); savingError.Show(); } } }; EmailDailySummary = delegate { if (MFMailComposeViewController.CanSendMail) { string dailySummaryType = (this.SummaryMode == SummaryModes.Money)? "Payments" : "Stock"; string dailySummaryPath = (this.SummaryMode == SummaryModes.Money)? GeneratePaymentsSummaryFile() : GenerateStockSummaryFile(); NSData fileContents = NSData.FromFile(dailySummaryPath); mail = new MFMailComposeViewController(); if (fileContents != null) { mail.AddAttachmentData(fileContents, "text/plain", String.Format("{0} {1}.txt", MyConstants.DEBUG_TODAY.Substring(2, 10), dailySummaryType)); } Action act = delegate { }; mail.SetSubject(String.Format("{0} summary {1}", dailySummaryType, MyConstants.DEBUG_TODAY.Substring(2, 10))); mail.SetToRecipients(new string[] { "*****@*****.**" }); mail.Finished += delegate(object sender, MFComposeResultEventArgs e) { if (e.Result == MFMailComposeResult.Sent) { var alert = new UIAlertView("", "Email sent.", null, "OK"); alert.Show(); } else { var alert = new UIAlertView(e.Result.ToString(), "Email has not been sent.", null, "OK"); alert.Show(); } this.DismissViewController(true, act); }; this.PresentViewController(mail, true, act); // this.PresentModalViewController (mail, true); } else { var alert = new UIAlertView("", "It seems like this iPad cannot send e-mails at the time. Please check the network settings and try again", null, "OK"); alert.Show(); } }; WeeklySummaryMail = delegate { if (MFMailComposeViewController.CanSendMail) { UIAlertView notYet = new UIAlertView("Not implemented yet...", "", null, "OK"); notYet.Show(); } else { var alert = new UIAlertView("", "It seems like this iPad cannot send e-mails at the time. Please check the network settings and try again", null, "OK"); alert.Show(); } }; SwitchToMoney = delegate { UIView.BeginAnimations(null); // UIView.SetAnimationDuration (0.3f); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Bordered, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Bordered, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to stock", UIBarButtonItemStyle.Bordered, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Money; this.ViewDidAppear(false); UIView.CommitAnimations(); }; SwitchToStock = delegate { UIView.BeginAnimations(null); // UIView.SetAnimationDuration (0.5f); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Bordered, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Bordered, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("View stock float", UIBarButtonItemStyle.Bordered, SwitchToStockFloat), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to money", UIBarButtonItemStyle.Bordered, SwitchToMoney), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Stock; this.ViewDidAppear(false); this.ReloadData(); UIView.CommitAnimations(); }; SwitchToStockFloat = delegate { UIView.BeginAnimations(null); ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("View stock used", UIBarButtonItemStyle.Bordered, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to money", UIBarButtonItemStyle.Bordered, SwitchToMoney), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; this.SummaryMode = SummaryModes.Float; this.ViewDidAppear(false); this.ReloadData(); UIView.CommitAnimations(); }; ToolbarItems = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Print this summary", UIBarButtonItemStyle.Plain, PrintDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Email this summary", UIBarButtonItemStyle.Plain, EmailDailySummary), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), new UIBarButtonItem("Switch to stock", UIBarButtonItemStyle.Plain, SwitchToStock), new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), }; }
void HandleEditingDidEnd(object sender, EventArgs e) { JobRunTable jrt = _tabs._jobRunTable; if (jrt.CurrentCustomer != null) { if (jrt.Customers.IndexOf(jrt.CurrentCustomer) != -1) { jrt.CurrentJob = jrt.MainJobList[jrt.Customers.IndexOf(jrt.CurrentCustomer)]; } else { jrt.CurrentJob = jrt.UserCreatedJobs[jrt.UserAddedCustomers.IndexOf(jrt.CurrentCustomer)]; } CustomerDetailsUpdatableField field = CustomerDetailsUpdatableField.None; if (sender is UITextField) { field = (CustomerDetailsUpdatableField)Convert.ToInt32((sender as UITextField).Tag); } else if (sender is UITextView) { field = (CustomerDetailsUpdatableField)Convert.ToInt32((sender as UIView).Tag); } string OldValue; switch (field) { case CustomerDetailsUpdatableField.FirstName: OldValue = jrt.CurrentCustomer.FirstName; jrt.CurrentCustomer.FirstName = cFirstName.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.FirstName, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set First Name to {1}", jrt.CurrentCustomer.CustomerNumber, cFirstName.Text)); break; case CustomerDetailsUpdatableField.LastName: OldValue = jrt.CurrentCustomer.LastName; jrt.CurrentCustomer.LastName = cLastName.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.LastName, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Last Name to {1}", jrt.CurrentCustomer.CustomerNumber, cLastName.Text)); break; case CustomerDetailsUpdatableField.Address: OldValue = jrt.CurrentCustomer.Address; jrt.CurrentCustomer.Address = cAddress.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.Address, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Address to {1}", jrt.CurrentCustomer.CustomerNumber, cAddress.Text)); break; case CustomerDetailsUpdatableField.Suburb: OldValue = jrt.CurrentCustomer.Suburb; jrt.CurrentCustomer.Suburb = cSuburb.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.Suburb, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Suburb to {1}", jrt.CurrentCustomer.CustomerNumber, cSuburb.Text)); break; case CustomerDetailsUpdatableField.Phone: OldValue = jrt.CurrentCustomer.PhoneNumber; string newPhoneValue = String.Empty; for (int i = 0; i < cPhoneNumber.Text.Length; i++) { char c = cPhoneNumber.Text[i]; if (char.IsDigit(c) || char.IsWhiteSpace(c)) { newPhoneValue += c; } } jrt.CurrentCustomer.PhoneNumber = newPhoneValue; cPhoneNumber.Text = newPhoneValue; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.PhoneNumber, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Phone Number to {1}", jrt.CurrentCustomer.CustomerNumber, cPhoneNumber.Text)); break; case CustomerDetailsUpdatableField.MobilePhone: OldValue = jrt.CurrentCustomer.MobileNumber; string newMobileValue = String.Empty; for (int i = 0; i < cMobileNumber.Text.Length; i++) { char c = cMobileNumber.Text[i]; if (char.IsDigit(c) || char.IsWhiteSpace(c)) { newMobileValue += c; } } jrt.CurrentCustomer.MobileNumber = newMobileValue; cMobileNumber.Text = newMobileValue; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.MobileNumber, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Mobile Phone Number to {1}", jrt.CurrentCustomer.CustomerNumber, cMobileNumber.Text)); break; case CustomerDetailsUpdatableField.FallbackContact: OldValue = jrt.CurrentCustomer.FallbackContact; jrt.CurrentCustomer.FallbackContact = cFallbackContact.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.FallbackContact, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Fallback Contact to {1}", jrt.CurrentCustomer.CustomerNumber, cFallbackContact.Text)); break; case CustomerDetailsUpdatableField.FallbackPhone: OldValue = jrt.CurrentCustomer.FallbackPhoneNumber; string newFallbackPhoneValue = String.Empty; for (int i = 0; i < cFallbackPhone.Text.Length; i++) { char c = cFallbackPhone.Text[i]; if (char.IsDigit(c) || char.IsWhiteSpace(c)) { newFallbackPhoneValue += c; } } jrt.CurrentCustomer.FallbackPhoneNumber = newFallbackPhoneValue; cFallbackPhone.Text = newFallbackPhoneValue; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.FallbackPhoneNumber, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Fallback Phone to {1}", jrt.CurrentCustomer.CustomerNumber, cFallbackPhone.Text)); break; case CustomerDetailsUpdatableField.CompanyName: OldValue = jrt.CurrentCustomer.CompanyName; jrt.CurrentCustomer.CompanyName = cCompanyName.Text; UpdateCustomerInfo(field, OldValue, jrt.CurrentCustomer.CompanyName, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); _tabs._scView.Log(String.Format("Database updated for Customer #{0} : Set Company Name to {1}", jrt.CurrentCustomer.CustomerNumber, cCompanyName.Text)); break; case CustomerDetailsUpdatableField.SpecialComments: OldValue = (jrt.CurrentJob.HasParent()) ? jrt.FindParentJob(jrt.CurrentJob).JobSpecialInstructions : jrt.CurrentJob.JobSpecialInstructions; if (jrt.CurrentJob.HasParent()) { jrt.FindParentJob(jrt.CurrentJob).JobSpecialInstructions = cSpecialInstructions.Text; UpdateCustomerInfo(field, OldValue, this.cSpecialInstructions.Text, jrt.CurrentCustomer.CustomerNumber, jrt.FindParentJob(jrt.CurrentJob).JobBookingNumber); } else { jrt.CurrentJob.JobSpecialInstructions = cSpecialInstructions.Text; UpdateCustomerInfo(field, OldValue, this.cSpecialInstructions.Text, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); } break; case CustomerDetailsUpdatableField.AttentionReason: OldValue = (jrt.CurrentJob.HasParent()) ? jrt.FindParentJob(jrt.CurrentJob).AttentionReason : jrt.CurrentJob.AttentionReason; if (jrt.CurrentJob.HasParent()) { jrt.FindParentJob(jrt.CurrentJob).AttentionReason = cAttentionReason.Text; UpdateCustomerInfo(field, OldValue, this.cAttentionReason.Text, jrt.CurrentCustomer.CustomerNumber, jrt.FindParentJob(jrt.CurrentJob).JobBookingNumber); } else { jrt.CurrentJob.AttentionReason = cAttentionReason.Text; UpdateCustomerInfo(field, OldValue, this.cAttentionReason.Text, jrt.CurrentCustomer.CustomerNumber, jrt.CurrentJob.JobBookingNumber); } break; default: if (_tabs._scView != null) { _tabs._scView.Log(String.Format("HandleEditingDidEnd: Attempt to update unknown field: Tag {0}", field)); } break; } // jrt.CurrentJob = null; if (jrt.HighlightedMode) { jrt.HighlightedMode = false; } if (jrt.LastSelectedRowPath != null) { jrt.TableView.ReloadRows(new NSIndexPath[] { jrt.LastSelectedRowPath }, UITableViewRowAnimation.Automatic); for (int i = 0; i < jrt.TableView.NumberOfRowsInSection(0); i++) { if (jrt.Customers[i].HighLighted) { jrt.TableView.ReloadRows(new NSIndexPath[] { NSIndexPath.FromRowSection(i, 0) }, UITableViewRowAnimation.Automatic); } } if (jrt.TableView.NumberOfRowsInSection(1) > 0) { for (int i = 0; i < jrt.TableView.NumberOfRowsInSection(1); i++) { if (jrt.UserAddedCustomers[i].HighLighted) { jrt.TableView.ReloadRows(new NSIndexPath[] { NSIndexPath.FromRowSection(i, 1) }, UITableViewRowAnimation.Automatic); } } } // jrt.TableView.CellAt (jrt.LastSelectedRowPath).Selected = true ; jrt.TableView.SelectRow(jrt.LastSelectedRowPath, true, UITableViewScrollPosition.None); } } }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have approximately 17 seconds to return from this method, or iOS will terminate your application. public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Xamarin.Insights.Initialize("20b7565ad9a4eee1d56492b26841b0bf70fbb5ed"); Xamarin.Insights.Identify(MyConstants.DeviceID, MyConstants.EmployeeID.ToString(), MyConstants.EmployeeName); // MonoTouch.TestFlight.TestFlight.TakeOffThreadSafe("f1e1ead5-5ee8-4a3c-a52b-a18e7919b06d"); InitializeLocationObjects(); // if database file does not exist, copy test database from app bundle to /Documents folder so that we can edit it // DEBUG :: if (! File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "NEWTESTDB.sqlite")) ) { File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "NEWTESTDB.sqlite")); string _from = Path.Combine(NSBundle.MainBundle.BundlePath, "NEWTESTDB.sqlite"); string _to = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "NEWTESTDB.sqlite"); File.Copy(_from, _to); if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Franchisee Training Manual.pdf"))) { File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Franchisee Training Manual.pdf")); } _from = Path.Combine(NSBundle.MainBundle.BundlePath, "Franchisee Training Manual.pdf"); _to = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Franchisee Training Manual.pdf"); File.Copy(_from, _to); } // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); // create a tableview that will contain the jobs (left side) _jobs = new JobRunTable(UITableViewStyle.Grouped); // create the tabcontroller that defines and handles the tabs (rightside) _tabs = new DetailedTabs(_jobs, this); _tabs.Title = "Puratap " + MyConstants.AppVersion; // link the two above controllers _jobs._tabs = _tabs; _tabs._jobRunTable = _jobs; _navTabs = new UINavigationController(_tabs); _navTabs.NavigationBar.BarStyle = UIBarStyle.Black; _navTabs.NavigationBar.Translucent = true; // create a split controller that will hold the two above controllers _split = new UISplitViewController(); // add _jobs and _tabs to split view controller _split.ViewControllers = new UIViewController[] { _jobs, _navTabs // _tabs }; _split.Delegate = new SplitDelegate(); // make the split controller the root (main) application controller window.RootViewController = _split; // ?? DEBUG // try { // NSUrl url = (NSUrl) options.ValueForKey (UIApplication.LaunchOptionsUrlKey); // if (url != null) // { // // Console.WriteLine (url.Path); // } // } // catch {} // if database file exists, check its integrity try { if (File.Exists(MyConstants.DBReceivedFromServer)) { if (_tabs._jobRunTable._ds.TestDBIntegrity()) { // HACK temporary transitional code for updating from version 1.3c to 1.3d // 1.3d requires IPAD_ORDERING field in PL_RECOR table // some of the databases may not contain it if they were exported before the change was implemented // check if "IPAD_ORDERING" field exists in database string dbPath = MyConstants.DBReceivedFromServer; using (var dbCon = new SqliteConnection("Data Source=" + dbPath)) { dbCon.Open(); using (var cmd = dbCon.CreateCommand()) { string sql = " SELECT IPAD_ORDERING FROM PL_RECOR "; cmd.CommandText = sql; try { using (var reader = cmd.ExecuteReader()) { if (reader.HasRows) { // db is good, the IPAD_ORDERING field exists } } } catch { // IPAD_ORDERING field does not exists, we need to add it cmd.Parameters.Clear(); cmd.CommandText = "ALTER TABLE PL_RECOR ADD COLUMN IPAD_ORDERING INTEGER NULL DEFAULT 9999"; cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE PL_RECOR SET IPAD_ORDERING = 9999"; cmd.ExecuteNonQuery(); } } // end using dbCommand } // end using dbConnection // END HACK this code should be removed on 08.11.2013 // if database integrity check went ok, load customers and jobs from it _tabs._jobRunTable._ds.LoadJobRun(1); } else { var integrityCheckFailedAlert = new UIAlertView("Database integrity check failed", "Try loading the data anyway? (App may crash if you choose 'Yes')", null, "No", "Yes"); integrityCheckFailedAlert.Dismissed += delegate(object sender, UIButtonEventArgs e) { if (e.ButtonIndex != integrityCheckFailedAlert.CancelButtonIndex) { _tabs._jobRunTable._ds.LoadJobRun(1); } }; this.InvokeOnMainThread(delegate { integrityCheckFailedAlert.Show(); }); } } else { // db file does not exist var dbNotfound = new UIAlertView("Database file not found", "Please complete the data exchange with the server.", null, "OK"); this.InvokeOnMainThread(delegate { dbNotfound.Show(); }); } } finally { window.MakeKeyAndVisible(); } return(true); }