private void button4_Click(object sender, EventArgs e) { try { int incomingPrice = Convert.ToInt32(textBox2.Text); var data = (from currentPrice in expenseTracker.ExpenseIncomings select currentPrice.Price).ToList(); if (data.Count == 0) { expenseTracker.ExpenseIncomings.InsertOnSubmit(new ExpenseIncoming() { Price = incomingPrice }); expenseTracker.SubmitChanges(); LoadGridView(); } else { var updateData = (from currentPrice in expenseTracker.ExpenseIncomings select currentPrice.Price).FirstOrDefault(); ExpenseIncoming incoming = expenseTracker.ExpenseIncomings.Single(a => a.Price == updateData); incoming.Price = updateData + incomingPrice; expenseTracker.SubmitChanges(); LoadGridView(); } textBox2.Text = ""; MessageBox.Show("Incoming Price Added"); } catch (Exception ex) { MessageBox.Show("There are no records"); } }
private void UpdateTotalIncome(int finalAmount) { try { var updateData = (from currentPrice in expenseTracker.ExpenseIncomings select currentPrice.Price).FirstOrDefault(); ExpenseIncoming incoming = expenseTracker.ExpenseIncomings.Single(a => a.Price == updateData); incoming.Price = finalAmount; expenseTracker.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
partial void UpdateExpenseIncoming(ExpenseIncoming instance);
partial void DeleteExpenseIncoming(ExpenseIncoming instance);
partial void InsertExpenseIncoming(ExpenseIncoming instance);