Exemple #1
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            try
            {
                //string date = ""+Expense_Date.Value.ToOADate();
                string date = "" + Expense_Date.Value.Date.ToOADate();

                //MessageBox.Show("Date: " + date + "\nDate1: " +date1);
                if (expense.AddExpense(Expense_Name.Text, Convert.ToInt32(Expense_Amount.Text), date, Expense_Comment.Text))
                {
                    ClearData();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something went wrong Please try again later.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ValidateInput())
            {
                double cost = Convert.ToDouble(txtCost.Text);
                exp = new Expense(exp.Id, txtDesc.Text, ddlCat.Text, cost, now.Date, Session["email"].ToString());

                int result = exp.AddExpense(Session["email"].ToString());
                if (result == 1)
                {
                    lblError.Text      = "Record added successfully!";
                    lblError.ForeColor = Color.Green;
                    txtDesc.Text       = "";
                    txtCost.Text       = "";
                    RefreshGridView();
                }
                else
                {
                    lblError.Text      = "Error Adding into the System!";
                    lblError.ForeColor = Color.Red;
                }
            }
        }
Exemple #3
0
        public void AddExpense_ParticipantAndSpenderInList_BothShouldBeEqual()
        {
            var particpant1 = new Person();
            var particpant2 = new Person();

            var spender = new Person();

            var expenseModel = new Expense
            {
                AmountSpent  = 10,
                SpentBy      = spender,
                Participants = new List <Person> {
                    particpant1, particpant2, spender
                }
            };

            //Act
            var exp = new Expense();

            exp.AddExpense(expenseModel);

            //Assert
            Assert.IsTrue(exp.SpentBy.Amount.Equals(expenseModel.Participants.Sum(h => - h.Amount)));
        }