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 override void Selected(Foundation.NSIndexPath indexPath) { if (indexPath.Section == 1 && indexPath.Row == 0) { List <SaleOption> saleOptions = new List <SaleOption>(); saleOptions = SaleOptionsDVC.ReadSaleOptions(); var ac = new UIActionSheet("Please choose a tap"); foreach (SaleOption so in saleOptions) { if (so.Type == "Taps") { ac.AddButton(so.Name); } } ac.Style = UIActionSheetStyle.BlackTranslucent; ac.Dismissed += delegate(object sender, UIButtonEventArgs e) { this.TableView.DeselectRow(indexPath, true); if (e.ButtonIndex != ac.CancelButtonIndex) { ClearPartsList(); PartsSection.ReadPartsFromDatabase(ServerClientViewController.dbFilePath); string chosenButton = ac.ButtonTitle(e.ButtonIndex); foreach (SaleOption so in saleOptions) { if (so.Name == chosenButton) { // putting the appropriate part into the list of stock used foreach (Part prt in DBParts) { if (prt.PartNo == so.PartLink) { PartChosen(prt, false); break; } } // adjusting the fee if the chosen tap model attracts something on top of the standard fee if (so.ExtraFee > 0) { ThisJob.EmployeeFee = so.ExtraFee; } else { ThisJob.EmployeeFee = ThisJob.Type.EmployeeFee; } break; } } } }; ac.ShowInView(this.View); } else { base.Selected(indexPath); } }