Esempio n. 1
0
        public static List <SaleOption> ReadSaleOptions()
        {
            List <SaleOption> result = null;
            string            dbPath = ServerClientViewController.dbFilePath;

            try {
                // read sale options data here
                using (var dbConnection = new SqliteConnection("Data Source = " + dbPath))
                {
                    dbConnection.Open();
                    using (var dbCommand = dbConnection.CreateCommand())
                    {
                        string sql = "SELECT * FROM OPTIONS_REF ";                         // WHERE OPTION_ACTIVE=1";
                        dbCommand.CommandText = sql;
                        using (var reader = dbCommand.ExecuteReader())
                        {
                            result = new List <SaleOption>();
                            while (reader.Read())
                            {
                                SaleOption option = new SaleOption()
                                {
                                    Active            = Convert.ToBoolean((byte)reader["option_active"]),
                                    ID                = (long)reader["option_id"],
                                    Name              = (string)reader["option_desc"],
                                    Type              = (string)reader["option_type"],
                                    CustomerSurcharge = Convert.ToDouble(reader["surcharge"]),
                                    ExtraFee          = Convert.ToDouble(reader["extra_fee"]),
                                    Image             = UIImage.LoadFromData(NSData.FromArray((byte[])reader["picture"])),
                                    PartLink          = (reader["partno_oid"] == DBNull.Value) ? -1 : (long)reader["partno_oid"]
                                };
                                if (option.Image == null)
                                {
                                    // using (var image = UIImage.FromBundle ("/Images/puratap-logo"))
                                    if (MyConstants.iOSVersion > 7)
                                    {
                                        option.Image = UIImage.FromBundle("Images/puratap-logo.png");
                                    }
                                    else
                                    {
                                        option.Image = UIImage.FromBundle("/Images/puratap-logo");                                       // image;
                                    }
                                }

                                result.Add(option);
                            }
                            if (!reader.IsClosed)
                            {
                                reader.Close();
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception e) {
                return(null);
            }
        }
Esempio n. 2
0
 public SaleOptionBadgeElement(SaleOption option, Action tapped) : base(option.Image, option.Name, tapped)
 {
     ThisOption = option;
 }
Esempio n. 3
0
        public override void Selected(NSIndexPath indexPath)
        {
            if (indexPath.Section == 0)
            {
                SaveSaleOptionsToDatabase();
                jivc.InstallDataGathered();
            }
            else
            {
                SaleOptionBadgeElement element = (this.Root[indexPath.Section].Elements[indexPath.Row] as SaleOptionBadgeElement);
                SaleOption             option  = element.ThisOption;
                if (indexPath.Section == 1)
                {
                    // A tap model is selected

                    // Tap models act as a radiogroup, this means we will have to find the option that was selected previously and "unselect" it
                    foreach (SaleOptionBadgeElement _element in Root[indexPath.Section])
                    {
                        if (_element.Accessory != UITableViewCellAccessory.None)
                        {
                            // exclude the part(s) associated with this option from the parts list
                            SaleOption _option = _element.ThisOption;
                            if (_option.PartLink != 0)
                            {
                                jivc.PartRemoved(Convert.ToInt32(_option.PartLink));
                            }

                            // remove the "tick" from the element
                            _element.Accessory = UITableViewCellAccessory.None;

                            // invoke the routines to remove customer surcharge and extra fee
                            RemoveSurchargeForSaleOption(_option.ID);
                            RemoveExtraFeeForSaleOption(_option.ID);
                        }
                    }

                    // add the part(s) associated with the option selected by user to the list
                    jivc.PartChosen(Convert.ToInt32(option.PartLink));
                    jivc.ReloadData();
                    // "tick" the chosen element
                    element.Accessory = UITableViewCellAccessory.Checkmark;

                    // invoke the routines to apply customer surcharge and extra fee
                    ApplySurchargeForSaleOption(option.ID);
                    ApplyExtraFeeForSaleOption(option.ID);
                }
                else                 // non-tap option was selected
                {
                    // check if it was selected already
                    if (element.Accessory != UITableViewCellAccessory.None)
                    {
                        // the option was selected previously, it must be "unselected" now
                        element.Accessory = UITableViewCellAccessory.None;
                        if (option.PartLink != 0)
                        {
                            jivc.RemovePartsRangeFromList(option.PartLink);
                        }

                        RemoveSurchargeForSaleOption(option.ID);
                        RemoveExtraFeeForSaleOption(option.ID);
                    }
                    else
                    {
                        // the option was not selected, apply the appropriate changes
                        element.Accessory = UITableViewCellAccessory.Checkmark;
                        if (option.PartLink != 0)
                        {
                            jivc.AddPartsRangeToList(option.PartLink);
                        }

                        ApplySurchargeForSaleOption(option.ID);
                        ApplyExtraFeeForSaleOption(option.ID);

                        // Console.WriteLine (String.Format ("Fee: {0}, Price: {1}", SaleOptionsDVC.jrt.CurrentJob.EmployeeFee, SaleOptionsDVC.jrt.CurrentJob.MoneyToCollect));
                    }
                }
            }
            this.ReloadData();
            base.Selected(indexPath);
        }