コード例 #1
0
        public List<Expense> Convert(string testString)
        {
            var result = new List<Expense>();
            char[] delimiterChars = { '\n', '\t' };
            var splitList = testString.Split(delimiterChars).ToList();
            for (var i = 0; i < splitList.Count-4; i++)
            {
                var newExpense = new Expense();
                var actualDateTime = splitList[i++].Trim();
                var ignoreExpenseCode = splitList[i++].Trim();
                var actualDescription = splitList[i++].Trim();
                var actualDebit = splitList[i++].Trim();
                var actualCredit = splitList[i].Trim();

                newExpense.Time = System.Convert.ToDateTime(actualDateTime);
                newExpense.Description = actualDescription;
                if (actualDebit != "")
                {
                    ExtractExpenseValue(newExpense, actualDebit, true);
                }
                else
                {
                    ExtractExpenseValue(newExpense, actualCredit, false);
                }
                result.Add(newExpense);
            }
            return result;
        }
コード例 #2
0
 private static void AssertExpenseDetail(Expense expense,DateTime time, String description, double value, bool isExpense)
 {
     Assert.AreEqual(time, expense.Time);
     Assert.AreEqual(description, expense.Description);
     Assert.AreEqual(value, expense.Value);
     Assert.AreEqual(isExpense,expense.IsExpense);
 }
コード例 #3
0
        public List<Expense> Convert(string testString)
        {
            var result = new List<Expense>();
            char[] delimiterChars = {'\n', '\t'};
            var splitList = testString.Split(delimiterChars).ToList();
            var index = 0;

            while(index<splitList.Count-2){
                var expense = new Expense();
                DateTime datetime1;
                DateTime.TryParseExact(splitList[index++], _format, System.Globalization.CultureInfo.InvariantCulture,
                                       System.Globalization.DateTimeStyles.NoCurrentDateDefault, out datetime1);

                expense.Time = datetime1;
                var tempIndex = SearchForTheNextDateTimeValue(++index, splitList);
                if (tempIndex >= splitList.Count) tempIndex = splitList.Count - 1;

                if(splitList[tempIndex].Trim() == "-")
                {
                    expense.IsExpense = true;
                    expense.Value = System.Convert.ToDouble((splitList[tempIndex-1].Trim()));
                }
                else
                {
                    expense.IsExpense = false;
                    expense.Value = System.Convert.ToDouble((splitList[tempIndex].Trim()));
                }

                expense.Description = JoinDescriptionFromArray(splitList, index, tempIndex - 2);
                index = tempIndex+1;
                result.Add(expense);
            }
            return result;
        }
コード例 #4
0
 public NewExpenseView(Expense row)
     : this(new NewExpenseController())
 {
     _currentEditExpense = row;
     fieldDropDown.Text = row.Field;
     descriptionText.Text = row.Description;
     valueText.Text = row.Value.ToString();
     expenseCheck.Checked =row.IsExpense;
     dateText.EditValue = row.Time;
 }
コード例 #5
0
 public void AddExpense(Expense expense)
 {
     _gridData.Add(expense);
 }
コード例 #6
0
 private static void ExtractExpenseValue(Expense newExpense, string stringValue, bool isExpense)
 {
     var removeSingaporeDollarSymbol = stringValue.Substring(1, stringValue.Length - 1);
     newExpense.IsExpense = isExpense;
     newExpense.Value = Double.Parse(removeSingaporeDollarSymbol, NumberStyles.Currency);
 }
コード例 #7
0
 public void AddExpense(Expense expense)
 {
     _controller.AddExpense(expense);
 }