private void MonthBudgetGrid_CellEditEnding_1(object sender, DataGridCellEditEndingEventArgs e) { var el = e.EditingElement as TextBox; CategoryPlan ex = (CategoryPlan)MonthBudgetGrid.SelectedItem; if (Validation.Validation.GetNumberWithDot(el.Text) == "0,0") { valid = true; MonthPlanExist(); } else { if (!Validation.Validation.IsGreaterOrEqualThenZero(Convert.ToDecimal(el.Text))) { valid = true; MonthPlanExist(); } else { foreach (CategoryPlan c in cat) { if (c.CatRecid == ex.CatRecid) { c.Value = Validation.Validation.GetNumberWithDot(el.Text); el.Text = c.Value; } } } } }
private void MonthBudgetGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { CategoryPlan ex = (CategoryPlan)MonthBudgetGrid.SelectedItem; string temp = Validation.Validation.GetNumberWithDot(ex.Value.Trim()); foreach (CategoryPlan c in cat) { if (c.Name == ex.Name) { c.Value = temp; } } MonthBudgetGrid.Items.Clear(); MonthBudgetGrid.ItemsSource = cat; }
private void GetMaxCat() { DB db = new Models.DB(); string maxrecid = ""; string midrecid = ""; decimal max = -1; CategoryPlan maxCP = new CategoryPlan("", "0", "0,0"); foreach (CategoryPlan cp in cat) { if (cp.Percent > max) { max = cp.Percent; maxCP = cp; } } maxrecid = maxCP.CatRecid; MaxCatLabel.Content = maxCP.Name; Color color = (Color)ColorConverter.ConvertFromString(db.GetCategoryColor(maxCP.CatRecid)); MaxCatPB.Foreground = new System.Windows.Media.SolidColorBrush(color); MaxCatPB.Value = Convert.ToDouble(maxCP.Percent); MaxCatText.Text = maxCP.Sum + "zł /" + maxCP.Value + "zł"; if (maxCP.Percent < 1) { Interjection1.Visibility = Visibility.Hidden; } else { Interjection1.Visibility = Visibility.Visible; } max = -1; CategoryPlan midCP = new CategoryPlan("", "0", "0,0"); foreach (CategoryPlan cp in cat) { if ((cp.Percent > max) && (maxrecid != cp.CatRecid)) { max = cp.Percent; midCP = cp; } } midrecid = midCP.CatRecid; MidCatLabel.Content = midCP.Name; color = (Color)ColorConverter.ConvertFromString(db.GetCategoryColor(midCP.CatRecid)); MidCatPB.Foreground = new System.Windows.Media.SolidColorBrush(color); MidCatPB.Value = Convert.ToDouble(midCP.Percent); MidCatText.Text = midCP.Sum + "zł /" + midCP.Value + "zł"; if (midCP.Percent < 1) { Interjection2.Visibility = Visibility.Hidden; } else { Interjection2.Visibility = Visibility.Visible; } max = -1; CategoryPlan lowCP = new CategoryPlan("", "0", "0,0"); foreach (CategoryPlan cp in cat) { if ((cp.Percent > max) && (maxrecid != cp.CatRecid) && (midrecid != cp.CatRecid)) { max = cp.Percent; lowCP = cp; } } LowCatLabel.Content = lowCP.Name; color = (Color)ColorConverter.ConvertFromString(db.GetCategoryColor(lowCP.CatRecid)); LowCatPB.Foreground = new System.Windows.Media.SolidColorBrush(color); LowCatPB.Value = Convert.ToDouble(lowCP.Percent); LowCatText.Text = lowCP.Sum + "zł /" + lowCP.Value + "zł"; if (lowCP.Percent < 1) { Interjection3.Visibility = Visibility.Hidden; } else { Interjection3.Visibility = Visibility.Visible; } }