Esempio n. 1
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            ExpenseItem exp = (ExpenseItem)listExpense.SelectedItem;

            roster.Delete(exp);
            LoadExpensesList();
        }
Esempio n. 2
0
 public ExpenseItem(ExpenseItem exp) //Copy constructor
 {
     description   = exp.description;
     amount        = exp.amount;
     paymentMethod = exp.paymentMethod;
     trip          = exp.trip;
     note          = exp.note;
     date          = exp.date;
 }
Esempio n. 3
0
        public bool Equals(ExpenseItem exp) // Equals method
        {
            if (description == exp.description && date.Equals(exp.date) && amount == exp.amount && paymentMethod == exp.paymentMethod && trip == exp.trip && note == exp.note)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     textBoxTotalExepense.Clear();
     textBoxTotalExepense.Enabled  = false;
     dateTimePickerExpense.Value   = DateTime.Today;
     dateTimePickerExpense.Enabled = true;
     comboBoxTrip.ResetText();
     textBoxDescription.Clear();
     textBoxNote.Clear();
     textBoxAmount.Clear();
     comboBoxPayment.ResetText();
     comboBoxFilter.ResetText();
     comboBoxFilter.Enabled = true;
     textBoxAmount.Enabled  = true;
     selectedExpense        = new ExpenseItem();
 }
Esempio n. 5
0
        private void DeleteTrip()
        {
            ExpenseItem ext    = (ExpenseItem)listExpense.SelectedItem;
            var         DltTrp =
                from e in roster
                where e.Trip == ext.Trip
                orderby e.Trip
                select e;

            foreach (var e in DltTrp)
            {
                ExpenseItem emp2 = DltTrp.ElementAt(0);
                roster.Remove(emp2);
            }
            LoadExpensesList();
        }
Esempio n. 6
0
 private void listExpense_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         ExpenseItem exp = (ExpenseItem)listExpense.SelectedItem;
         selectedExpense               = roster.Find(exp);
         textBoxAmount.Text            = selectedExpense.Amount.ToString("C");
         comboBoxTrip.Text             = selectedExpense.Trip;
         textBoxDescription.Text       = selectedExpense.Description;
         textBoxNote.Text              = selectedExpense.Note;
         comboBoxPayment.Text          = selectedExpense.PaymentMethod;
         dateTimePickerExpense.Value   = selectedExpense.Date;
         dateTimePickerExpense.Enabled = true;
         textBoxTotalExepense.Enabled  = false;
         textBoxAmount.Enabled         = true;
         textBoxTotalExepense.Text     = roster.TotalAmount().ToString("C");
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Choose an expense item");
         return;
     }
 }
Esempio n. 7
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            string Trp = comboBoxTrip.Text;
            string desc;

            try
            {
                desc = textBoxDescription.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }
            string nte = textBoxNote.Text;
            string pay;

            try
            {
                pay = comboBoxPayment.Text;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }

            DateTime dt;

            try
            {
                dt = dateTimePickerExpense.Value;
            }

            catch (Exception)
            {
                MessageBox.Show(this, "Invalid Date");
                return;
            }
            decimal amot;

            try
            {
                amot = Convert.ToDecimal(textBoxAmount.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Invalid Amount | Remove the $ sign");
                return;
            }

            try
            {
                selectedExpense.Amount        = amot;
                selectedExpense.Description   = desc;
                selectedExpense.PaymentMethod = pay;
                selectedExpense.Trip          = Trp;
                selectedExpense.Note          = nte;
                selectedExpense.Date          = dt;
            }

            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }

            try
            {
                ExpenseItem exp3 = roster.Find(selectedExpense);
                if (exp3 == null)
                {
                    roster.Add(selectedExpense);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }
            LoadExpensesList();
            textBoxTotalExepense.Enabled  = false;
            dateTimePickerExpense.Value   = DateTime.Today;
            dateTimePickerExpense.Enabled = true;
            comboBoxTrip.ResetText();
            textBoxDescription.Clear();
            textBoxNote.Clear();
            textBoxAmount.Clear();
            comboBoxPayment.ResetText();
            comboBoxFilter.ResetText();
            comboBoxFilter.Enabled = true;
        }