private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string Money = txtMoney.Text;
         IC.MoneyFSaving = int.Parse(Money);
         EME.SaveChanges();
         MessageBox.Show("Saved");
         this.Close();
     }
     catch
     {
         MessageBox.Show("Invalid Input");
     }
 }
Exemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (lstIncome.SelectedRows.Count == 1)
     {
         var      row  = lstIncome.SelectedRows[0];
         var      cell = row.Cells["ID"];
         DateTime ID   = (DateTime)cell.Value;
         ExpenseManagementEntities db    = new ExpenseManagementEntities();
         MoneyForSavings           Money = db.MoneyForSavings.Single(st => st.IDSaving == ID);
         db.MoneyForSavings.DeleteObject(Money);
         db.SaveChanges();
         this.LoadMoneyList();
     }
     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");
            }
        }