示例#1
0
        public void ResetToDefaults(bool resetFee)
        {
            ClearPartsList();
            this.DeactivateEditingMode();

            if (resetFee)
            {
                SetCurrentJobFeeToDefault();
            }

            EntryElement pressureElement = (this.Root[0].Elements[0] as EntryElement);

            pressureElement.Value = String.Empty;
            dvcSO = new SaleOptionsDVC(null, false, true, this.NavUsedParts.Tabs._jobRunTable, this);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        public JobReinstallViewController(RootElement root, WorkflowNavigationController nav, UsedPartsNavigationController upnav, bool pushing) : base(root, pushing)
        {
            NavUsedParts = upnav;
            NavWorkflow  = nav;
            DBParts      = new List <Part>();
            DBAssemblies = new List <Assembly> ();
            dvcSO        = new SaleOptionsDVC(null, false, true, this.NavUsedParts.Tabs._jobRunTable, this);
            DeactivateEditingMode();

            Section      OptionsSection  = new Section("");
            EntryElement pressureElement = new EntryElement("Pressure", "Value", "", false);

            pressureElement.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            OptionsSection.Add(pressureElement);
            OptionsSection.EntryAlignment = new CGSize(565, 20);

            Root.Add(OptionsSection);

            Section InstallationTypeSection = new Section("Installation information");

            var img = UIImage.FromBundle("Images/181-hammer");

            InstallationTypeSection.Add(new BadgeElement(img, "Enter info", delegate {
                GoChooseProduct();
            }));
            img.Dispose();

            Root.Add(InstallationTypeSection);

            PartsSection UsedPartsSection = new PartsSection("Parts used", this);

            UsedPartsSection.Add(new StyledStringElement("Tap here to add a part"));
            Root.Add(UsedPartsSection);

            this.Title = "Re-installation";
            using (var image = UIImage.FromBundle("Images/181-hammer")) this.TabBarItem.Image = image;

            ToolbarItems = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Reply),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Clear parts list", UIBarButtonItemStyle.Bordered, delegate { ClearPartsList(); }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Action)
            };

            ToolbarItems[0].Clicked += delegate {
                if (NavUsedParts.Tabs._jobRunTable.CurrentJob.HasParent())                      // for child jobs, we jump to payment screen
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                }
                else                 // for main jobs we jump to pre-plumbing check
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[0];
                }
            };

            ToolbarItems[4].Clicked += delegate {
                // pressure has to be entered and correct, check if parts list is empty
                if (PressureValueOK())
                {
                    SavePressureValueToDatabase();

                    if (PartsListNotEmpty())
                    {
                        // all good, jump to payment
                        NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                        NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                    }
                    else
                    {
                        // alert the user that parts list is empty
                        var partsEmpty = new UIAlertView("", "Parts list is empty, are you sure?", null, "No", "Yes");
                        partsEmpty.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                            if (e.ButtonIndex != partsEmpty.CancelButtonIndex)
                            {
                                // jump to payment
                                NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                                NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                            }
                        };
                        partsEmpty.Show();
                    }
                }
                else
                {
                    // alert the user that pressure value must be entered
                    var pressureNotEntered = new UIAlertView("", "Cannot parse pressure value. Please enter a number.", null, "OK");
                    pressureNotEntered.Show();
                    this.Root[0].Elements[0].Selected(this, this.TableView, NSIndexPath.FromRowSection(0, 0));
                }
            };
        }
示例#4
0
        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);
            }
        }
示例#5
0
        public JobInstallationViewController(RootElement root, WorkflowNavigationController nav, UsedPartsNavigationController upnav, bool pushing) : base(root, pushing)
        {
            NavUsedParts = upnav;
            NavWorkflow  = nav;
            DBParts      = new List <Part>();
            DBAssemblies = new List <Assembly> ();
            dvcSO        = new SaleOptionsDVC(null, false, true, this.NavUsedParts.Tabs._jobRunTable, this);
            DeactivateEditingMode();

            Section      OptionsSection  = new Section("");
            EntryElement pressureElement = new EntryElement("Pressure", "Value", "", false);

            pressureElement.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            OptionsSection.Add(pressureElement);
            OptionsSection.EntryAlignment = new CGSize(565, 20);

            /*
             * CheckboxElement drillElement = new CheckboxElement("Drilling", false);
             * drillElement.Tapped += delegate {
             *      Job currentJob = NavWorkflow._tabs._jobRunTable.CurrentJob;
             *      if (drillElement.Value == true)
             *      {
             *              // increase the job price by 40
             *              currentJob.MoneyToCollect += 40;
             *              Console.WriteLine (String.Format ("CurrentJob.TotalToCollect = {0}", currentJob.TotalToCollect ()));
             *              NavWorkflow._tabs._customersView.UpdateCustomerInfo (CustomerDetailsUpdatableField.JobPriceTotal,
             *                                                                   (currentJob.MoneyToCollect-40).ToString (), currentJob.MoneyToCollect.ToString (), currentJob.CustomerNumber, currentJob.JobBookingNumber);
             *
             *              // if current fee value is 0, set it to standard fee for the job type
             *              if (currentJob.EmployeeFee < 1 ||
             *                  currentJob.EmployeeFee > currentJob.Type.EmployeeFee)
             *              {
             *                      currentJob.EmployeeFee = currentJob.Type.EmployeeFee;
             *              }
             *              // increase the fee by 49.5
             *              currentJob.EmployeeFee += 49.5;
             *
             *              Console.WriteLine (String.Format ("Job fee: {0}, job type (standard fee): {1}", NavWorkflow._tabs._jobRunTable.CurrentJob.EmployeeFee, NavWorkflow._tabs._jobRunTable.CurrentJob.Type.EmployeeFee));
             *      }
             *      else
             *      {
             *              // decrease the fee if it's exceeding the standard fee for the job by 49.5
             *
             *              if (currentJob.EmployeeFee - currentJob.Type.EmployeeFee > 49)
             *                      currentJob.EmployeeFee -= 49.5;
             *
             *              Console.WriteLine (String.Format ("Job fee: {0}, job type (standard fee): {1}", currentJob.EmployeeFee, currentJob.Type.EmployeeFee));
             *      }
             * }; */
            // OptionsSection.Add (drillElement);

            Root.Add(OptionsSection);

            Section InstallationTypeSection = new Section("Installation information");

            var img = UIImage.FromBundle("Images/181-hammer");

            InstallationTypeSection.Add(new BadgeElement(img, "Enter info", delegate {
                GoChooseProduct();
            }));
            img.Dispose();

            Root.Add(InstallationTypeSection);

            PartsSection UsedPartsSection = new PartsSection("Parts used", this);

            UsedPartsSection.Add(new StyledStringElement("Tap here to add a part"));
            Root.Add(UsedPartsSection);

            this.Title = "Installation";
            using (var image = UIImage.FromBundle("Images/181-hammer")) this.TabBarItem.Image = image;

            ToolbarItems = new UIBarButtonItem[] {
                new UIBarButtonItem(UIBarButtonSystemItem.Reply),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Clear parts list", UIBarButtonItemStyle.Bordered, delegate { ClearPartsList(); }),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Action)
            };

            ToolbarItems[0].Clicked += delegate {
                if (NavUsedParts.Tabs._jobRunTable.CurrentJob.HasParent())                      // for child jobs, we jump to payment screen
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];
                }
                else                 // for main jobs we jump to pre-plumbing check
                {
                    NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[0];
                }
            };

            ToolbarItems[4].Clicked += delegate {
                // various checks here: pressure has to be entered and correct, parts list must not be empty
                if (PressureValueOK())
                {
                    SavePressureValueToDatabase();

                    if (PartsListNotEmpty())
                    {
                        // all good, jump to payment
                        NavUsedParts.Tabs.LastSelectedTab        = NavUsedParts.Tabs.SelectedIndex;
                        NavUsedParts.Tabs.SelectedViewController = NavUsedParts.Tabs.ViewControllers[3];                         // jump to payment
                    }
                    else
                    {
                        // alert the user that install data must be entered
                        var enterInstallData = new UIAlertView("", "Parts list is empty, how come?", null, "OK");
                        enterInstallData.Show();
                    }
                }
                else
                {
                    // alert the user that pressure value must be entered
                    var pressureNotEntered = new UIAlertView("", "Cannot parse pressure value. Please enter a number.", null, "OK");
                    pressureNotEntered.Show();
                    this.Root[0].Elements[0].Selected(this, this.TableView, NSIndexPath.FromRowSection(0, 0));
                }
            };
        }