private void GridCellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { if (!isManualEditCommit) { isManualEditCommit = true; DataGridRow row = e.Row; DataRowView row_items = (DataRowView)row.Item; if (e.Column.Header.ToString() == "Category") { ComboBox cb = e.EditingElement as ComboBox; string t = Convert.ToString(cb.SelectedItem); InvestmentCategory new_category = new InvestmentCategory(); new_category.Category = t; new_category.Keyword = row_items.Row.ItemArray[1].ToString().Replace("'", "''"); new_category.UpdateDefinition(new_category.Keyword, row_items.Row.ItemArray[1] != DBNull.Value && !string.IsNullOrWhiteSpace(t)); FillDataGrid(null); } else { DataGridInvestments.CommitEdit(); DataGridInvestments.CommitEdit(); } isManualEditCommit = false; } }
public void AddEdit(InvestmentCategory investmentCategory, User user) { DynamicParameters spParams = new DynamicParameters(); spParams.Add("Id", investmentCategory.Id); spParams.Add("Name", investmentCategory.Name); spParams.Add("Description", investmentCategory.Description); spParams.Add("UserId", user.Id); DapperORM.ExecuteWithoutReturn("AddEditProductCategory", spParams); }
public void Stacked_Chart(bool change) { DateTime from_month = new DateTime(); DateTime to_month = new DateTime(); string selected_person = ""; Dispatcher.Invoke(() => { from_month = new DateTime(Convert.ToDateTime(date_month_from.SelectedDate).Year, Convert.ToDateTime(date_month_from.SelectedDate).Month, 1); to_month = Convert.ToDateTime(date_month_to.SelectedDate); selected_person = HoldersItems.Where(r => r.IsChecked == true).Select(x => x.HolderName).First(); StackedSeriesCollection.Clear(); }); DataTable dt = BrokerageAsset.GetHistoricalInvestments(selected_person, null, null, from_month, to_month); IEnumerable <string> selectcategories = InvestmentCategory.Getcategories(); Brush[] colors = { Brushes.DarkGreen, Brushes.ForestGreen, Brushes.Gainsboro, Brushes.DimGray, Brushes.Gold, Brushes.Orange, Brushes.DarkBlue }; Dispatcher.Invoke(() => { int count = 0; foreach (string category in selectcategories) { ChartValues <DateModel> chartvalues = new ChartValues <DateModel>(dt.AsEnumerable().Where(r => r["category"].ToString() == category) .Select(r => new DateModel { DateTime = r.Field <DateTime>("date"), Value = r.Field <double?>("ending_mkt_value") ?? 0 })); if (chartvalues.Count != 0) { StackedSeriesCollection.Add(new StackedColumnSeries { Values = chartvalues, StackMode = StackMode.Values, Title = category, Fill = colors[count], DataLabels = true, LabelPoint = point => (point.Y / 1000).ToString("C1") + "k", LabelsPosition = BarLabelPosition.Perpendicular, Foreground = Brushes.Black }); count++; } } }); if (!change) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.DataBind, (Action)(() => { DataContext = this; })); } }
public Investments() { InitializeComponent(); HoldersItems = Helpers.Initializer.SetHolders(comboFor, this); date_month_to.SelectedDateChanged -= SelectionChanged; date_month_from.SelectedDateChanged -= SelectionChanged; Helpers.Initializer.SetDates(date_month_from, date_month_to); date_month_to.SelectedDateChanged += SelectionChanged; date_month_from.SelectedDateChanged += SelectionChanged; Categories.ItemsSource = InvestmentCategory.Getcategories(); var dateConfig = Mappers.Xy <DateModel>() .X(dateModel => dateModel.DateTime.AddDays(-13).Ticks / (TimeSpan.FromDays(1).Ticks * 30.44)) .Y(dateModel => dateModel.Value); //save the mapper globally. Charting.For <DateModel>(dateConfig); GainFormatter = value => value.ToString(gainformatter); CurrencyFormatter = value => value.ToString("C0"); CurrencyFormatter2 = value => value.ToString(order_history_formatter); MonthFormatter = value => new DateTime((long)((value < 0 ? 0 : value) * TimeSpan.FromDays(1).Ticks * 30.44)).AddDays(13).ToString("MMM yy"); DayFormatter = value => new DateTime((long)((value < 0 ? 0 : value) * TimeSpan.FromDays(1).Ticks * 30.44)).AddDays(13).ToString("M/d/yy"); Task.Factory.StartNew(() => { DataGridInvestments.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged; FillDataGrid(null); }); Task.Factory.StartNew(() => { Gains_Chart(); }); Task.Factory.StartNew(() => { Stacked_Chart(); }); Task.Factory.StartNew(() => { StackedAsset_Chart(); }); Task.Factory.StartNew(() => { PriceAsset_Chart(); }); }
/// <summary> /// Match investment into /// </summary> /// <param name="investmentCategory"></param> /// <param name="interestRate"></param> /// <returns></returns> protected bool MatchCategory(InvestmentCategory investmentCategory, double interestRate) { // i => c.InvestmentCategory.InterestRateFrom <= i.InterestRate && c.InvestmentCategory.InterestRateTo > i.InterestRate) return(investmentCategory.InterestRateFrom <= interestRate && investmentCategory.InterestRateTo > interestRate); }
public InvestmentProductManagerViewModel() { InvestmentCategory = new InvestmentCategory(); }