コード例 #1
0
        //write record to record.txt
        public void WriteRecordToFile()
        {
            StreamWriter streamWriter = new StreamWriter(RECORD_FILE_NAME);

            foreach (Record record in _records)
            {
                streamWriter.Write(record.Date.ToString(DATE_FORMAT + " "));
                streamWriter.Write(_categoryModel.GetCategoryIndex(record.Category) + " ");
                streamWriter.WriteLine(record.Amount.ToString());
            }
            streamWriter.Close();
        }
コード例 #2
0
 //select a record
 public void SelectRecord(int recordIndex)
 {
     RecordIndex = recordIndex;
     if (recordIndex >= 0)
     {
         IsSelectionMode      = true;
         IsAddEnable          = false;
         IsModifyEnable       = true;
         IsDeleteEnable       = true;
         IsCancelEnable       = true;
         ErrorProviderMessage = String.Empty;
         Record record = _recordModel.Records[recordIndex];
         CategoryIndex = _categoryModel.GetCategoryIndex(record.Category);
         SetAmountAndIncome(record);
         RecordDate = record.Date;
     }
     else
     {
         InitializeState();
     }
     RaiseUpdateEvent();
 }
コード例 #3
0
ファイル: EZMoneyModel.cs プロジェクト: housemeow/ezMoney
 //get category index from category name
 public int GetCategoryIndex(Category category)
 {
     return(_categoryModel.GetCategoryIndex(category));
 }
コード例 #4
0
 public void TestGetCategoryIndex()
 {
     CategoryModel categoryModel = new CategoryModel();
     Category categoryMovie = new Category(CATEGORY_NAME_MOVIE);
     Category categoryWork = new Category(CATEGORY_NAME_WORK);
     categoryModel.AddCategory(categoryMovie);
     categoryModel.AddCategory(categoryWork);
     Assert.AreEqual(0, categoryModel.GetCategoryIndex(categoryMovie));
     Assert.AreEqual(1, categoryModel.GetCategoryIndex(categoryWork));
 }