private void AddButton_Click(object sender, RoutedEventArgs e) { if (!Validation.Validation.StringNotNull(NameBox.Text)) { MessageBox.Show("Uzupełnij nazwy kategorii"); return; } if (!Validation.Validation.NotLongerThen(NameBox.Text, 100)) { MessageBox.Show("Nazwa kategorii może mieć do 100 znaków"); return; } if (!Validation.Validation.IsGreaterOrEqualThenZero(Validation.Validation.GetDecimal(AmountBox.Text))) { MessageBox.Show("Kwota musi być większa lub równa zero"); return; } DB db = new Models.DB(); if (!db.InsertIrregularBudget(UserId, NameBox.Text, AmountBox.Text)) { MessageBox.Show("Ups... coś poszło nie tak :("); return; } else { this.NavigationService.Navigate(new IrregularBudgetPanel(UserId)); } }
public static bool IsValid(string username, string password) { using (DB db = new Models.DB()) { return(db.Users.Any(u => u.Username == username && u.Password == password)); } }
private void Button_Click(object sender, RoutedEventArgs e) { Expenses ex = (Expenses)ExpensesGrid.SelectedItem; if (MessageBox.Show("Czy na pewno chcesz usunąć wydatek \"" + ex.Name + "\"?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } else { DB db = new Models.DB(); db.DeleteteExpenditure(ex.ExpRecid); this.NavigationService.Navigate(new AllExpenses(UserId)); } }
protected void ProductDetail(string productId) { DataTable product = new Models.DB().ReadTable("Product Table", "select * from products where id= '" + productId + "'"); if (product.Rows.Count > 0) { productName = product.Rows[0]["product_name"].ToString(); productImage = "../images/" + productName + ".png"; productPrice = "₦" + string.Format("{0:#,0.00}", double.Parse(product.Rows[0]["Selling_Price"].ToString())); qtyOnHand = double.Parse(product.Rows[0]["QtyonHand"].ToString()); } else { Response.Redirect("../404.aspx"); } }
public ActionResult Index() { DB db = new Models.DB(); if (db.tBooks.Count() > 0) { var BookList = (from item in db.tBooks orderby item.Title select item).ToList(); return(View(BookList)); } else { return(View()); } }
private void Delete_Click(object sender, RoutedEventArgs e) { IrregularBudget ex = (IrregularBudget)IrregularExpensesGrid.SelectedItem; if (MessageBox.Show("Czy na pewno chcesz usunąć wydatek \"" + ex.Name + "\"?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } else { DB db = new Models.DB(); if (!db.DeleteteIrregularBudget(ex.__recid)) { MessageBox.Show("Ups... Coś poszło nie tak"); return; } this.NavigationService.Navigate(new IrregularBudgetPanel(UserId)); } }
public HttpResponseMessage ConvertCurrency(string currency1, string currency2, float amount) { var database = new Models.DB(); /* * CurrencyDTO c1; * foreach(var c in database.Currencies) * { * if (c.Name == currency1) * { * c1 = c; * break; * } * } */ var c1 = database.Currencies.First(c => c.Name == currency1); var c2 = database.Currencies.First(c => c.Name == currency2); return(Request.CreateResponse(HttpStatusCode.OK, CurrencyConverter.Convert(c1, c2, amount))); }
private void DeleteCategory_Click(object sender, RoutedEventArgs e) { //MessageBox.Show("TODO. Brak możliwości usunięcia rekordu"); Categories ex = (Categories)CategoryGrid.SelectedItem; DB db = new Models.DB(); string count = db.GetNumberExpensesInCaterory(UserId.ToString(), ex.Name); if (count != "0") { MessageBox.Show("Nie można usuwać kategorii dla których istnieją wydatki."); return; } else { if (db.GetNumberCategoryPlansWithCategory(UserId.ToString(), ex.Name) != "0") { MessageBox.Show("Nie można usuwać kategorii dla których zaplanowany jest już budżet."); return; } List <Categories> cat = db.GetAllFromCategories(UserId); if (cat.Count <= 5) { MessageBox.Show("Musisz mieć przynajmniej pięć kategorii wydatków."); return; } if (db.DeleteteCategory(UserId.ToString(), ex.Name)) { MessageBox.Show("Usunięto kategorię."); this.NavigationService.Navigate(new CategoriesPanel(UserId)); } else { MessageBox.Show("Nie udało się usunąć kategorii."); return; } } }
private void UpdateButton_Click(object sender, RoutedEventArgs e) { if (settings[0].HaveChanged(StartsSavingBox.Text, EarningsBox.Text, CategoryComboBox.SelectedItem.ToString())) { DB db = new Models.DB(); if (db.UpdateSettings(UserId, StartsSavingBox.Text.Replace(',', '.'), EarningsBox.Text.Replace(',', '.'), CategoryComboBox.SelectedItem.ToString())) { settings.Clear(); settings.Add(new Settings(StartsSavingBox.Text, EarningsBox.Text, CategoryComboBox.SelectedItem.ToString())); MessageBox.Show("Modyfikacja zakończona"); } else { MessageBox.Show("Ups. Coś poszło nie tak."); } } else { MessageBox.Show("Modyfikacja zakończona"); } }
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; } }
public HttpResponseMessage ListCurrencies() { var database = new Models.DB(); //connecting to the database return(Request.CreateResponse(HttpStatusCode.OK, database.Currencies.ToList())); // return the list of currencies }