private void LoadL() { ExpenseManagementEntities DBE = new ExpenseManagementEntities(); SpendMoney Money = new SpendMoney(); lstSatistics.DataSource = DBE.SpendMoney.ToList(); }
/// <summary> /// Create a new SpendMoney object. /// </summary> /// <param name="iDExpense">Initial value of the IDExpense property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="money">Initial value of the Money property.</param> public static SpendMoney CreateSpendMoney(global::System.DateTime iDExpense, global::System.String name, global::System.DateTime date, global::System.Int32 money) { SpendMoney spendMoney = new SpendMoney(); spendMoney.IDExpense = iDExpense; spendMoney.Name = name; spendMoney.Date = date; spendMoney.Money = money; return(spendMoney); }
private void btnDelete_Click(object sender, EventArgs e) { if (lstSatistics.SelectedRows.Count == 1) { var row = lstSatistics.SelectedRows[0]; var cell = row.Cells["IDExpense"]; DateTime ID = (DateTime)cell.Value; ExpenseManagementEntities db = new ExpenseManagementEntities(); SpendMoney Money = db.SpendMoney.Single(st => st.IDExpense == ID); db.SpendMoney.DeleteObject(Money); db.SaveChanges(); this.LoadL(); } else { MessageBox.Show("You should select a month!"); } }
private void btnSave_Click(object sender, EventArgs e) { Menu MN = new Menu(); try { int money = int.Parse(txtMoney.Text); int MoneyTotal = MN.MAvailable() - MN.MoSpend() - MN.MFSaving(); if ((MoneyTotal - money) < 0 || (MoneyTotal - money) <= MN.MFSaving()) { MessageBox.Show("Out of money"); } else { try { DateTime Date = DateTime.Now; string Name = txtName.Text; DateTime datepick = DTPDate.Value; ExpenseManagementEntities DBE = new ExpenseManagementEntities(); SpendMoney SpendMoney = new SpendMoney(); Money Money = new Money(); SpendMoney.IDExpense = Date; SpendMoney.Name = Name; SpendMoney.Date = datepick; SpendMoney.Money = money; DBE.SpendMoney.AddObject(SpendMoney); DBE.SaveChanges(); MessageBox.Show("Add sucesscesful"); this.Close(); } catch { MessageBox.Show("Invalid Input"); } } } catch { MessageBox.Show("Invalid Input"); } }
/// <summary> /// Deprecated Method for adding a new object to the SpendMoney EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSpendMoney(SpendMoney spendMoney) { base.AddObject("SpendMoney", spendMoney); }