public virtual void UpdateUserIncome(User user, int currencyId, int income) { UserIncome userIncome = this.GetUserIncome(user.Id, currencyId); userIncome.Income += income; this.UpdateUserIncome(userIncome); }
private async void OnDeleteTransaction(object sender, EventArgs e) { var item = (MenuItem)sender; var itemToDelete = (IncomeTransaction)item.CommandParameter; await App.Database.DeleteItemAsync(itemToDelete); UserIncome.Remove(itemToDelete); }
private void insertInitIncome(User user, ICurrency c) { UserIncome income = new UserIncome(); income.UserId = user.Id; income.CurrencyId = c.Id; income.Income = c.InitValue; InsertIncome(income); }
public virtual UserIncome GetUserIncome(int userId, int currencyId) { UserIncome income = db.find <UserIncome>("UserId=" + userId + " and CurrencyId=" + currencyId).first(); if (income == null) { income = new UserIncome(); income.UserId = userId; income.CurrencyId = currencyId; db.insert(income); } return(income); }
private UserIncome getIncomeFromList(int userId, ICurrency c, IList incomeList) { foreach (UserIncome income in incomeList) { if ((income.UserId == userId) && (income.CurrencyId == c.Id)) { return(income); } } UserIncome results = new UserIncome(); results.UserId = userId; results.CurrencyId = c.Id; results.Income = 0; return(results); }
// 用户持有的下载币 private int getUserDownloadMoney(User user) { if (user == null || user.Id <= 0) { return(0); } int currencyId = getDownloadCurrency(); if (currencyId <= 0) { return(0); } UserIncome income = incomeService.GetUserIncome(user.Id, currencyId); return(income == null ? 0 : income.Income); }
public virtual int UpdateUserIncome(User user, long currencyId, int income, string msg) { UserIncome userIncome = this.GetUserIncome(user.Id, currencyId); userIncome.Income += income; this.UpdateUserIncome(userIncome); // save log UserIncomeLog incomeLog = new UserIncomeLog(); incomeLog.UserId = user.Id; incomeLog.CurrencyId = currencyId; incomeLog.Income = income; incomeLog.Note = msg; incomeLog.insert(); return(userIncome.Income); // return total income }
private void insertInitIncome(User user, ICurrency c) { UserIncome income = new UserIncome(); income.UserId = user.Id; income.CurrencyId = c.Id; income.Income = c.InitValue; InsertIncome(income); // save log UserIncomeLog incomeLog = new UserIncomeLog(); incomeLog.UserId = user.Id; incomeLog.CurrencyId = c.Id; incomeLog.Income = c.InitValue; incomeLog.Note = "注册奖励"; incomeLog.insert(); }
//-------------------------------------- tools ----------------------------------------- public virtual void UpdateUserIncome( UserIncome userIncome ) { db.update( userIncome, "Income" ); }
public virtual void InsertIncome( UserIncome income ) { db.insert( income ); }
public virtual UserIncome GetUserIncome( long userId, long currencyId ) { UserIncome income = db.find<UserIncome>( "UserId=" + userId + " and CurrencyId=" + currencyId ).first(); if (income == null) { income = new UserIncome(); income.UserId = userId; income.CurrencyId = currencyId; db.insert( income ); } return income; }
//-------------------------------------- tools ----------------------------------------- public virtual void UpdateUserIncome(UserIncome userIncome) { db.update(userIncome, "Income"); }
//-------------------------------- 增加收入 -------------------------------------- public virtual bool HasEnoughKeyIncome(long userId, int income) { UserIncome keyIncome = GetUserIncome(userId, KeyCurrency.Instance.Id); return(keyIncome.Income >= income); }
private void insertInitIncome( User user, ICurrency c ) { UserIncome income = new UserIncome(); income.UserId = user.Id; income.CurrencyId = c.Id; income.Income = c.InitValue; InsertIncome( income ); }
private UserIncome getIncomeFromList( int userId, ICurrency c, IList incomeList ) { foreach (UserIncome income in incomeList) { if ((income.UserId == userId) && (income.CurrencyId == c.Id)) { return income; } } UserIncome results = new UserIncome(); results.UserId = userId; results.CurrencyId = c.Id; results.Income = 0; return results; }
private void insertInitIncome( User user, ICurrency c ) { UserIncome income = new UserIncome(); income.UserId = user.Id; income.CurrencyId = c.Id; income.Income = c.InitValue; InsertIncome( income ); // save log UserIncomeLog incomeLog = new UserIncomeLog(); incomeLog.UserId = user.Id; incomeLog.CurrencyId = c.Id; incomeLog.Income = c.InitValue; incomeLog.Note = "注册奖励"; incomeLog.insert(); }
public virtual void InsertIncome(UserIncome income) { db.insert(income); }
public UserIncomeView() { App.Database.GetItems <IncomeTransaction>().ForEach(x => UserIncome.Add(x)); InitializeComponent(); }
private void Button_Send(object sender, RoutedEventArgs e) { double amountSpent; if (textBoxForSpent.Text != "") { amountSpent = Convert.ToDouble(textBoxForSpent.Text.Trim()); } else { MessageBox.Show("Введите сумму!"); return; } string getCategoryId; if (listOfCategories.SelectedIndex > -1) { getCategoryId = listOfCategories.SelectedItems[0].ToString(); } else { MessageBox.Show("Выберите категорию!"); return; } string getComment = textBoxForComments.Text.Trim(); string getBill = listOfUsers.Text.ToString(); UserIncome userIncome = new UserIncome(amountSpent, Convert.ToInt32(getCategoryId), getComment); using (ApplicationContext context = new ApplicationContext()) { DB db = new DB(); SQLiteCommand command = new SQLiteCommand("UPDATE Totals SET totalMoney = totalMoney + @amountSpent WHERE billName = @billName", db.getConnection()); command.Parameters.Add("@amountSpent", DbType.Double).Value = amountSpent; command.Parameters.Add("@billName", DbType.String).Value = getBill; db.openConnection(); command.ExecuteNonQuery(); int index = listOfUsers.SelectedIndex; List <Total> total = context.Totals.ToList(); listOfUsers.ItemsSource = total; listOfUsers.SelectedIndex = index; context.UserIncomes.Add(userIncome); context.SaveChanges(); textBoxForSpent.Clear(); listOfCategories.UnselectAll(); textBoxForComments.Clear(); } using (ApplicationContext context = new ApplicationContext()) { List <UserIncome> userIncomes = context.UserIncomes .Include(c => c.IncomeCategory) .ToList(); historySpend.ItemsSource = userIncomes; new Sorting().SortDesc(historySpend); } }