Exemplo n.º 1
0
        public void AddEntry(String investmentTypeID, String entryName, int calculateType, int compoundingType, int calendarType, double initialPayment, double futurePayment, double rate, String timetoGet, String startTimeToGet, String endTimeToGet, int depositFlag, double depositPayment)
        {
            Guid     newId   = Guid.NewGuid();
            TblEntry newItem = new TblEntry {
                InvestmentTypeID = investmentTypeID, EntryName = entryName, CalculateType = calculateType, CompoundingType = compoundingType, CalendarType = calendarType, InitialPayment = (float)initialPayment, FuturePayment = (float)futurePayment, Rate = (float)rate, TimeToGet = timetoGet, StartTimeToGet = startTimeToGet, EndTimeToGet = endTimeToGet, DepositFlag = depositFlag, DepositPayment = (float)depositPayment, Deleted = 0
            };

            Insert(newItem);
        }
Exemplo n.º 2
0
        public TblEntry GetEntryWithId(int uid)
        {
            try{
                TblEntry entry = (from s in Table <TblEntry>() where s.ID == uid select s).FirstOrDefault();

                return(entry);
            }
            catch (Exception ex) {
            }

            return(null);
        }
Exemplo n.º 3
0
 public void UpdateEntryWithId(TblEntry entryItem)
 {
     Update(entryItem);
 }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.AddEntry);

            _dateStart = _dateEnd = DateTime.Today;

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

            imgBack.Click += imgBack_Click;

            ImageView imgCalculate = FindViewById <ImageView>(Resource.Id.imgCalculate);

            imgCalculate.Click += imgCalculate_Click;

            ImageView imgSave = FindViewById <ImageView>(Resource.Id.imgSave);

            imgSave.Click += imgSave_Click;

            ImageButton imgSelectStartDate = FindViewById <ImageButton>(Resource.Id.imgSelectStartDate);

            imgSelectStartDate.Click += imgSelectStartDate_Click;

            ImageButton imgSelectEndDate = FindViewById <ImageButton>(Resource.Id.imgSelectEndDate);

            imgSelectEndDate.Click += imgSelectEndDate_Click;

            linearMuchInvesting  = FindViewById <LinearLayout>(Resource.Id.linearMuchInvesting);
            linearMuchFuture     = FindViewById <LinearLayout>(Resource.Id.linearMuchFuture);
            linearSelectCalendar = FindViewById <LinearLayout>(Resource.Id.linearSelectCalendar);
            linearPeriod         = FindViewById <LinearLayout>(Resource.Id.linearPeriod);
            linearRate           = FindViewById <LinearLayout>(Resource.Id.linearRate);

            spinnerType        = FindViewById <Spinner>(Resource.Id.spinnerInvestType);
            spinnerCalculate   = FindViewById <Spinner>(Resource.Id.spinnerCalculate);
            spinnerCompounding = FindViewById <Spinner>(Resource.Id.spinnerCompounding);
            spinnerCalendar    = FindViewById <Spinner>(Resource.Id.spinnerMonthYear);

            // Read Investment Types from table
            investTypeList = Util.GetDatabaseMgr().GetInvestmentTypes();
            String[] investTypesArr = new String[investTypeList.Count];
            for (int i = 0; i < investTypeList.Count; i++)
            {
                investTypesArr[i] = investTypeList[i].Name;
            }

            ArrayAdapter <String> adapter_type_group = new ArrayAdapter <String>(this, Resource.Layout.SpinnerText, investTypesArr);

            adapter_type_group.SetDropDownViewResource(Resource.Layout.SpinnerText);
            spinnerType.Adapter = adapter_type_group;

            spinnerType.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e)
            {
                if (e.Position != -1)                // && _selGroupId != e.Position)
                {
                    FindViewById <TextView>(Resource.Id.lblMuchInvesting).Text = investTypeList[e.Position].Present;
                    FindViewById <TextView>(Resource.Id.lblMuchFuture).Text    = investTypeList[e.Position].Future;
                    FindViewById <TextView>(Resource.Id.lblRate).Text          = investTypeList[e.Position].Rate;
                    FindViewById <TextView>(Resource.Id.lblGetDate).Text       = investTypeList[e.Position].TimetoGet;
                    FindViewById <TextView>(Resource.Id.lblDeposit).Text       = investTypeList[e.Position].Periodic;

                    if (String.IsNullOrEmpty(investTypeList[e.Position].Periodic) == false)
                    {
                        isPeriodic = true;
                    }
                    else
                    {
                        isPeriodic = false;
                    }

                    ChangeUILayout();
                }
            };

            ArrayAdapter <String> adapter_calculate_group = new ArrayAdapter <String>(this, Resource.Layout.SpinnerText, Util.CALCULATE_TYPES);

            adapter_calculate_group.SetDropDownViewResource(Resource.Layout.SpinnerText);
            spinnerCalculate.Adapter = adapter_calculate_group;

            spinnerCalculate.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e)
            {
                if (e.Position != -1)// && _selGroupId != e.Position)
                {
                    calculateOption = e.Position;
                    ChangeUILayout();
                }
            };

            ArrayAdapter <String> adapter_compounding_group = new ArrayAdapter <String>(this, Resource.Layout.SpinnerText, Util.COMPOUNDING_TYPES);

            adapter_compounding_group.SetDropDownViewResource(Resource.Layout.SpinnerText);
            spinnerCompounding.Adapter = adapter_compounding_group;

            spinnerCompounding.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e)
            {
                if (e.Position != -1)// && _selGroupId != e.Position)
                {
                    compoundOption = e.Position;
                    ChangeUILayout();
                }
            };

            ArrayAdapter <String> adapter_calendar_group = new ArrayAdapter <String>(this, Resource.Layout.SpinnerText, Util.CALENDAR_TYPES);

            adapter_calendar_group.SetDropDownViewResource(Resource.Layout.SpinnerText);
            spinnerCalendar.Adapter = adapter_calendar_group;

            spinnerCalendar.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs e)
            {
                if (e.Position != -1)// && _selGroupId != e.Position)
                {
                }
            };

            linearMuchInvesting.Visibility  = ViewStates.Invisible;
            linearMuchFuture.Visibility     = ViewStates.Invisible;
            linearSelectCalendar.Visibility = ViewStates.Invisible;
            linearPeriod.Visibility         = ViewStates.Invisible;

            curEntryItemId = -1;
            if (this.Intent != null)
            {
                int curId = this.Intent.GetIntExtra("UID", -1);
                if (curId != -1)
                {
                    TblEntry entryItem = Util.GetDatabaseMgr().GetEntryWithId(curId);
                    if (entryItem != null)
                    {
                        curEntryItemId = curId;
                        curEntryItem   = entryItem;

                        try{
                            spinnerType.SetSelection(GetIndexFromInvestTypeId(entryItem.InvestmentTypeID));
                            spinnerCalculate.SetSelection(entryItem.CalculateType);
                            spinnerCalendar.SetSelection(entryItem.CalendarType);
                            spinnerCompounding.SetSelection(entryItem.CompoundingType);

                            FindViewById <TextView>(Resource.Id.txtInvestName).Text    = entryItem.EntryName;
                            FindViewById <TextView>(Resource.Id.txtMuchInvesting).Text = "" + entryItem.InitialPayment;
                            FindViewById <TextView>(Resource.Id.txtMuchFuture).Text    = "" + entryItem.FuturePayment;
                            FindViewById <TextView>(Resource.Id.txtRate).Text          = "" + entryItem.Rate * 100;
                            FindViewById <TextView>(Resource.Id.txtGetDate).Text       = entryItem.TimeToGet;
                            FindViewById <CheckBox>(Resource.Id.chkAtPeriod).Checked   = (entryItem.DepositFlag == 1);
                            FindViewById <TextView>(Resource.Id.txtDeposit).Text       = "" + entryItem.DepositPayment;
                            FindViewById <TextView>(Resource.Id.txtStartDate).Text     = IsValidDateTime(entryItem.StartTimeToGet, true) ? _dateStart.ToString("d") : "";
                            FindViewById <TextView>(Resource.Id.txtEndDate).Text       = IsValidDateTime(entryItem.EndTimeToGet, false) ? _dateEnd.ToString("d") : "";
                        }
                        catch (Exception ex) {
                        }
                    }
                }
            }
        }