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); } }
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; } } }
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))); }