internal static ComboBox UpdateComboBoxAddAccumulation(ComboBox cb, int id) { if (cb.Name == "comboBoxEnterNameAccumulation") { int tempId = id; cb.Items.Clear(); // Combobox filling try { using (ApplicationContext db = new ApplicationContext()) { Accumulation accumulation = db.Accumulations.FirstOrDefault(a => a.UserId == tempId); cb.SelectedItem = accumulation.AccumulationName; foreach (var item in db.Accumulations) { cb.Items.Add(item.AccumulationName); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } return(cb); }
private void TabMenu_Activated(object sender, EventArgs e) { user = new User(); Accumulation accumulation = new Accumulation(); // Getting User Id try { using (ApplicationContext db = new ApplicationContext()) { user = db.Users.FirstOrDefault(u => u.Id == _idUserForTabMenu); accumulation = db.Accumulations.FirstOrDefault(a => a.UserId == _idUserForTabMenu); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } // DataGrid Update Functions.UpdateDataGridsTabMenu(dataGridCosts, user); Functions.UpdateDataGridsTabMenu(dataGridIncomes, user); Functions.UpdateDataGridsTabMenu(dataGridDebts, user); Functions.UpdateDataGridsTabMenu(dataGridAccumulation, user); }
private void DeleteAccumulationItem(Accumulation a) { using (PFContext db = new PFContext()) { try { foreach (AccumulationOperation ao in db.AccumulationOperation) { if (ao.AccumulationId == a.Id) { db.AccumulationOperation.Remove(ao); } } db.Accumulation.Remove(a); db.SaveChanges(); accumulationCollection = new ObservableCollection <Accumulation>(db.Accumulation .Include(x => x.Currency).ToList()); accumulationList.ItemsSource = accumulationCollection; } catch { errorText.Text = "Не возможно удалить цель. Попробуйте позже."; } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { id = (int)e.Parameter; using (PFContext db = new PFContext()) { accumulation = db.Accumulation.FirstOrDefault(a => a.Id == id); curObjForCurAbrevv = db.Currency.FirstOrDefault(c => c.Id == accumulation.CurrencyId); purseCollection = new ObservableCollection <Purse>(db.Purse.Where(p => p.CurrencyId == accumulation.CurrencyId).ToList()); } } if (accumulation != null) { if (purseCollection.Count == 0) { errorText.Text = "Нет доступных счетов"; } else { purseListCB.ItemsSource = purseCollection; } curAbbrev.Text = curObjForCurAbrevv.Abbreviation; } else { GoToPreviousPage(); } }
private void accumulationList_RightTapped(object sender, RightTappedRoutedEventArgs e) { ListView listView = (ListView)sender; accumulationFlyoutMenu.ShowAt(listView, e.GetPosition(listView)); accumulationElement = ((FrameworkElement)e.OriginalSource).DataContext as Accumulation; }
/// <summary> /// </summary> /// <typeparam name="AccumulationT"></typeparam> /// <typeparam name="AccumulatedT"></typeparam> /// <typeparam name="SharedT"></typeparam> /// <param name="SourceCandidate"></param> /// <param name="InstantToFit"></param> /// <param name="Other"></param> /// <returns>best fit according to method "Score" of element in <paramref name="SourceCandidate"/></returns> static public AccumulationT BestFitFromSet <AccumulationT, AccumulatedT, SharedT>( this IEnumerable <AccumulationT> SourceCandidate, AccumulatedT InstantToFit, SharedT Other = default(SharedT)) where AccumulationT : class, Accumulation.IEntityScoring <AccumulatedT, SharedT> => SourceCandidate?.Select(Accumulation => new { Accumulation, Score = Accumulation?.Score(InstantToFit, Other) ?? int.MinValue }) ?.Where(scored => 0 < scored.Score) ?.OrderByDescending(scored => scored.Score) ?.FirstOrDefault()?.Accumulation;
private IEnumerable <double> GetCurrencyReturn(double[] simReturns, Accumulation accumulation) { for (int i = 0; i < MaxHorizon; i++) { double cumulativeCurrencyReturn = _currentExchangeRate / simReturns[i]; yield return(accumulation == Accumulation.Cumulative ? cumulativeCurrencyReturn - 1 : Math.Pow(cumulativeCurrencyReturn, 1d / (i + 1)) - 1); } }
private void BtnOk_Click(object sender, RoutedEventArgs e) { string currentSum = ConvertToStringFormat(accumCurrentSum.Text); string finalSum = ConvertToStringFormat(accumFinalSum.Text); Currency cur = currencyList.SelectedItem as Currency; double cSumm; double fSumm; if (accumNameBox.Text.Length == 0) { errorText.Text = "Введите имя"; return; } if (!Double.TryParse(currentSum, out cSumm) || !Double.TryParse(finalSum, out fSumm)) { errorText.Text = "Некоректная сумма"; return; } if (cur == null) { errorText.Text = "Выберите валюту"; return; } using (PFContext db = new PFContext()) { if (accumulation != null) { accumulation.Name = accumNameBox.Text; accumulation.CurrentSumma = cSumm; accumulation.FinalSumma = fSumm; accumulation.Currency = cur; accumulation.CurrencyId = cur.Id; db.Accumulation.Update(accumulation); } else { Accumulation accumulationNew = new Accumulation { Name = accumNameBox.Text, CurrentSumma = cSumm, FinalSumma = fSumm, CurrencyId = cur.Id, Currency = cur }; db.Currency.Attach(cur); db.Accumulation.Add(accumulationNew); } db.SaveChanges(); } GoToPreviousPage(); }
public ActionResult Create(String studentId, String clubId, int point) { try { DateTime now = DateTime.Now; int currentMonth = now.Month; string currentSemester; switch (currentMonth) { case 1: case 2: case 3: case 4: currentSemester = "spring"; break; case 5: case 6: case 7: case 8: currentSemester = "summer"; break; default: currentSemester = "fall"; break; } Accumulation acc = AccumulationService.Get(_ => _.clubId.Equals(clubId) && _.studentId.Equals(studentId) && _.semester.Equals(currentSemester)); if (acc != null) { return(StatusCode(400)); } Accumulation accumulation = new Accumulation { studentId = studentId, point = point, clubId = clubId, semester = currentSemester, year = now.Year, }; AccumulationService.Add(accumulation); AccumulationService.SaveChanges(); return(Ok(accumulation.accumulationId)); } catch (Exception e) { return(BadRequest(e)); } }
public ActionResult UpdatePointMember(int accumulationId, int point) { try { Accumulation accumulation = AccumulationService.Get(_ => _.accumulationId.Equals(accumulationId)); accumulation.point = point; AccumulationService.Update(accumulation); AccumulationService.SaveChanges(); return(StatusCode(204)); } catch (Exception e) { return(BadRequest(e.Message)); } }
private void currency_returns_equal_EXPECTATION(Accumulation accumulation, double[][] expectation) { var currencyReturns = _fxArray.GetCurrencyReturns(accumulation); int maxSim = currencyReturns.MaxSim; int maxHor = currencyReturns.MaxHorizon; for (int i = 0; i < maxSim; i++) { for (int j = 0; j < maxHor; j++) { currencyReturns.Values[i][j].ShouldBe(expectation[i][j], 1E-5); } } }
/// <summary> /// Accumulates the return in the stoch array across time, for each sim /// </summary> /// <param name="year">The year up to which the accumulation will proceed</param> /// <param name="accumulation">Whether the accumualtion result should be <see cref="Accumulation.Annualised"/>or <see cref="Accumulation.Cumulative"/></param> /// <returns>The accumulated stocharray returned as a sample</returns> public Sample Accumulate(int year, Accumulation accumulation) { var values = Enumerable.Repeat(1d, MaxSim).ToArray(); for (int i = 0; i < MaxSim; i++) { for (int j = 0; j < year; j++) { values[i] *= (1 + _values[i][j]); } values[i] = accumulation == Accumulation.Annualised ? values[i] = Math.Pow(values[i], 1d / year) - 1 : values[i] - 1; } return(new Sample(values)); }
public ActionResult GetConclusion(string action, string file, params string [] valueLv) { if (action == "RedyForms") { Phasing.StartPhasing(FKB, valueLv); Agregation.AgregationStart(FKB); Term result = Accumulation.AccumulationStart(FKB); Defuzzication.DefuzzicationStart(result); return(View(result)); } else { Phasing.PhasingLv(FKB, valueLv); return(View("GetVievPhasing", FKB)); } }
private void btnAddSummAccumulation_Click(object sender, RoutedEventArgs e) { string tempAccumulationName; double tempsumm; // Format the cost if (textBoxAddSummAccumulation.Text == "") { tempsumm = 0.0; } else { tempsumm = Convert.ToDouble(textBoxAddSummAccumulation.Text); } try { using (ApplicationContext db = new ApplicationContext()) { tempAccumulationName = comboBoxEnterNameAccumulation.SelectedItem.ToString(); Accumulation accumulation = db.Accumulations.FirstOrDefault(a => a.AccumulationName == tempAccumulationName); if (accumulation != null) { accumulation.AccumulationName = tempAccumulationName; accumulation.Contributed = tempsumm; accumulation.Accumulated += tempsumm; accumulation.UserId = _idUserForAddSummAccumulation; db.SaveChanges(); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } this.Close(); }
private void btnRemoveAccumulation_Click(object sender, RoutedEventArgs e) { // Removing an operation from the Accumulation list try { using (ApplicationContext db = new ApplicationContext()) { Accumulation temp = dataGridAccumulation.SelectedItem as Accumulation; _accumulationForRemove = new Accumulation(); foreach (var item in db.Accumulations) { if (item.UserId == _idUserForTabMenu && item.DateTimeAccumulation == temp.DateTimeAccumulation && item.SummofAccumulation == temp.SummofAccumulation && item.AccumulationName == temp.AccumulationName && item.Accumulated == temp.Accumulated) { _accumulationForRemove = item; } } db.Accumulations.Remove(_accumulationForRemove); db.SaveChanges(); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } // DataGrid Update Functions.UpdateDataGridsTabMenu(dataGridAccumulation, user); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { id = (int)e.Parameter; using (PFContext db = new PFContext()) { accumulation = db.Accumulation.FirstOrDefault(a => a.Id == id); } } if (accumulation != null) { headerBlock.Text = "Редатировать цель"; accumNameBox.Text = accumulation.Name; accumCurrentSum.Text = accumulation.CurrentSumma.ToString(); accumFinalSum.Text = accumulation.FinalSumma.ToString(); using (PFContext db = new PFContext()) { curSealed = db.Currency.FirstOrDefault(c => c.Id == accumulation.CurrencyId); } } }
public StochArray GetCurrencyReturns(Accumulation accumulation) { return(new StochArray( Values.Select(simReturns => GetCurrencyReturn(simReturns, accumulation).ToArray()).ToArray())); }
private void calculated_accumulation_is_correct(int year, Accumulation accum, double[] expectation) { _stochArray.Accumulate(year, accum).Values.ShouldBe(expectation, 1E-06); }
public void UpdateDisplay() => Display = Accumulation.ToString();
public void Accumulation_is_calculated_correctly_test(double[][] values, int year, Accumulation accum, double[] expectation) { Runner.RunScenario( Given => a_valid_stochArray(values), Then => calculated_accumulation_is_correct(year, accum, expectation)); }
public void GetCurrencyReturns_is_performed_correctly_test(double[][] rates, double currentFx, Accumulation accumulation, double[][] expectation) { Runner.RunScenario( Given => a_valid_fxArray(rates, currentFx), Then => currency_returns_equal_EXPECTATION(accumulation, expectation)); }
public ActionResult GetVievDefuzzication() { result = Accumulation.AccumulationStart(FKB); Defuzzication.DefuzzicationStart(result); return(View(result)); }