Exemple #1
0
        public void SyncInvestTypes(List <Investment.Portable.TblInvestmentType> result)
        {
            for (int i = 0; i < result.Count; i++)
            {
                try{
                    String            id   = result[i].ID.ToUpper();
                    TblInvestmentType item = (from s in Table <TblInvestmentType>() where s.FieldID.ToUpper().Equals(id) select s).FirstOrDefault();
                    if (item == null)
                    {
                        AddInvestType(result[i].Name, result[i].Present, result[i].Future, result[i].TimetoGet, result[i].Rate, result[i].Periodic, result[i].Icon);
                    }
                    else
                    {
                        item.Name      = result[i].Name;
                        item.Present   = result[i].Present;
                        item.Future    = result[i].Future;
                        item.TimetoGet = result[i].TimetoGet;
                        item.Rate      = result[i].Rate;
                        item.Periodic  = result[i].Periodic;
                        item.Icon      = result[i].Icon;

                        Update(item);
                    }
                }
                catch (Exception e) {
                }
            }
        }
Exemple #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.InvestmentTypeAdd);

            var imgBack = FindViewById <ImageView>(Resource.Id.imgBack);

            imgBack.Click += imgBack_Click;

            MyAdapter spinnerAdapter = new MyAdapter(this, Resource.Layout.spinner_iconrow, strings);
            Spinner   mySpinner      = FindViewById <Spinner>(Resource.Id.spinnerIcon);

            mySpinner.ItemSelected += mySpinner_ItemSelected;
            mySpinner.Adapter       = spinnerAdapter;

            var btnSave = FindViewById <Button>(Resource.Id.btnSave);

            btnSave.Click += btnSave_Click;

            itemId = Intent.GetIntExtra("itemid", -1);
            if (itemId != -1)
            {
                TblInvestmentType investTypeData = Util.GetDatabaseMgr().GetInvestmentTypeFromDBId(itemId);
                FindViewById <TextView>(Resource.Id.txtName).Text           = investTypeData.Name;
                FindViewById <TextView>(Resource.Id.txtPresentValue).Text   = investTypeData.Present;
                FindViewById <TextView>(Resource.Id.txtFutureValue).Text    = investTypeData.Future;
                FindViewById <TextView>(Resource.Id.txtTime).Text           = investTypeData.TimetoGet;
                FindViewById <TextView>(Resource.Id.txtRate).Text           = investTypeData.Rate;
                FindViewById <TextView>(Resource.Id.txtPeriodicAmount).Text = investTypeData.Periodic;

                iconIndex = GetIndexFromStringArray(arr_image_names, investTypeData.Icon);
                mySpinner.SetSelection(iconIndex);
            }
        }
Exemple #3
0
        public void AddInvestType(String name, String present, String future, String timetoget, String rate, String periodic, String icon)
        {
            TblInvestmentType newItem = new TblInvestmentType {
                Name = name, Present = present, Future = future, TimetoGet = timetoget, Rate = rate, Periodic = periodic, Icon = icon, Deleted = 0
            };

            Insert(newItem);
        }
Exemple #4
0
        public void UpdateInvestType(int itemId, String name, String present, String future, String timetoget, String rate, String periodic, String icon)
        {
            TblInvestmentType newItem = new TblInvestmentType {
                Name = name, Present = present, Future = future, TimetoGet = timetoget, Rate = rate, Periodic = periodic, Icon = icon, Deleted = 0
            };

            newItem.ID = itemId;
            Update(newItem);
        }
Exemple #5
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var item = items [position];

            View view = convertView;

            if (view == null)
            {
                view = ((Activity)context).LayoutInflater.Inflate(Resource.Layout.EntryItem, null);
            }

            var rootLinear = view.FindViewById <LinearLayout> (Resource.Id.linearRoot);

            rootLinear.SetTag(Resource.Uid.TAG_ITEM_ID, item.ID);
            if (position % 2 == 0)
            {
                view.FindViewById <LinearLayout>(Resource.Id.linearRoot).SetBackgroundColor(Android.Graphics.Color.Rgb(241, 243, 242));
            }
            else
            {
                view.FindViewById <LinearLayout>(Resource.Id.linearRoot).SetBackgroundColor(Android.Graphics.Color.Rgb(230, 230, 230));
            }

            int indexColor = position % Util.BAR_COLORS.Length;

            view.FindViewById <LinearLayout>(Resource.Id.linearColor).SetBackgroundColor(Util.BAR_COLORS[indexColor]);

            TblInvestmentType investmentType = Util.GetDatabaseMgr().GetInvestmentTypeFromId(item.InvestmentTypeID);

            view.FindViewById <ImageView>(Resource.Id.imgTypeIcon).SetImageResource(context.Resources.GetIdentifier(investmentType.Icon, "drawable", context.PackageName));

            double dAPY = Util.Effect(item.Rate, item.CompoundingType) * 100;

            view.FindViewById <TextView>(Resource.Id.txtName).Text            = item.EntryName;
            view.FindViewById <TextView>(Resource.Id.txtInitialPayment).Text  = "$" + Math.Round(item.InitialPayment, 2).ToString();
            view.FindViewById <TextView>(Resource.Id.txtFuturePayment).Text   = "$" + Math.Round(item.FuturePayment, 2).ToString();
            view.FindViewById <TextView>(Resource.Id.txtTime).Text            = String.Format("{0:0.00}", Util.GetTimeToGet(item.TimeToGet, item.CalendarType, item.StartTimeToGet, item.EndTimeToGet));//Math.Round(item.TimeToGet, 2).ToString();
            view.FindViewById <TextView>(Resource.Id.txtGrowthRate).Text      = Math.Round(dAPY, 2) + "%";
            view.FindViewById <CheckBox>(Resource.Id.chkPeriod).Checked       = (item.Selected == 1);
            view.FindViewById <TextView>(Resource.Id.txtPeriodicPayment).Text = Math.Round(item.DepositPayment, 2).ToString();
            view.FindViewById <TextView>(Resource.Id.txtCompounded).Text      = Util.COMPOUNDING_TYPES[item.CompoundingType];

            var CheckBoxPeriod = view.FindViewById <CheckBox> (Resource.Id.chkPeriod);

            CheckBoxPeriod.SetTag(Resource.Uid.TAG_ITEM_ID, item.ID);
            CheckBoxPeriod.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                bool isCheckedState = CheckBoxPeriod.Checked;

                if (parentInvestFragment != null)
                {
                    View root = sender as View;
                    int  Id   = (int)root.GetTag(Resource.Uid.TAG_ITEM_ID);
                    if (parentInvestFragment.ItemCheckChanged(Id, isCheckedState) == false)
                    {
                        CheckBoxPeriod.Checked = false;
                    }
                }
                else if (parentOverviewFragment != null)
                {
                    View root = sender as View;
                    int  Id   = (int)root.GetTag(Resource.Uid.TAG_ITEM_ID);
                    if (parentOverviewFragment.ItemCheckChanged(Id, isCheckedState) == false)
                    {
                        CheckBoxPeriod.Checked = false;
                    }
                }
            };

            /*
             * rootLinear.Clickable = true;
             * rootLinear.Click += (object sender, EventArgs e) => {
             *      if (parentInvestFragment != null)
             *      {
             *              View root = sender as View;
             *              int Id = (int)root.GetTag(Resource.Uid.TAG_ITEM_ID);
             *              parentInvestFragment.ItemSelected(Id);
             *      }
             *      else if (parentOverviewFragment != null)
             *      {
             *              View root = sender as View;
             *              int Id = (int)root.GetTag(Resource.Uid.TAG_ITEM_ID);
             *              parentOverviewFragment.ItemSelected(Id);
             *      }
             * };*/

            return(view);
        }