private void buttonConfirm_Click(object sender, EventArgs e)
        {
            var ammount = decimal.Parse(boxMoney.Text);
            var comment = boxComment.Text;
            var date    = DateTime.Parse(dateTimePicker1.Text);

            Expense expense = null;


            switch (dropTypes.Text)
            {
            case "Irregular":
                expense = new IrregularExpense(new TransactionData(ammount, date), comment);
                break;

            case "Regular":
                expense = new RegularExpense(new TransactionData(ammount, date), comment);
                break;

            default:
                break;
            }

            // You can change the logic from here.
            // Only instantiate new JsonExporter/ExcelExporter or anything that implements IExporter
            var exporter = new ExcelExporter();

            if (ammount < AmmountMinimumValue)
            {
                MessageBox.Show(GlobalMessages.NonNegativeInput, GlobalMessages.ExpenseTitle);

                boxMoney.Clear();
            }
            else if (comment == string.Empty)
            {
                MessageBox.Show(GlobalMessages.CommentFieldErrorMessage, GlobalMessages.ExpenseTitle);
            }
            else
            {
                ExportInFile.SaveExpenseData(exporter, expense);

                MessageBox.Show(GlobalMessages.ExpenseAdded, GlobalMessages.ExpenseTitle);

                boxMoney.Clear();
                boxComment.Clear();
                dropTypes.ResetText();
                dateTimePicker1.ResetText();
            }

            //Old way printing with json serializer
            //ExportInFile.SaveExpenseData(expense);
        }
Esempio n. 2
0
    private void DefaultPhysicalConditionConfiguration()
    {
        C_CurrentPosition = 0;
        C_CurrentTime     = 0;
        C_Wealth          = 0;

        C_IncomeType       = 1;
        C_IncomeMoney      = 1;
        C_IncomeFrequency  = 1;
        C_IncomeTimeLeft   = 1;
        C_ExpenseType      = 1;
        C_ExpenseMoney     = 1;
        C_ExpenseFrequency = 1;
        C_ExpenseTimeLeft  = 1;
        C_Income           = new RegularIncome(C_IncomeType, C_IncomeMoney, C_IncomeFrequency, C_IncomeTimeLeft);
        C_Expense          = new RegularExpense(C_ExpenseType, C_ExpenseMoney, C_ExpenseFrequency, C_ExpenseTimeLeft);
        C_Incomes          = new List <RegularIncome> ();
        C_Expenses         = new List <RegularExpense> ();
        C_Incomes.Add(C_Income);
        C_Expenses.Add(C_Expense);

        C_DayRoutineTime           = 1;
        C_DayRoutinePlace          = 1;
        C_DayRoutineTimesPerformed = 0;
        C_DayRoutineHowUsedTo      = 0;
        C_DayRoutineTimeDuration   = 1;
        C_DayRoutineState          = 1;
        C_ActionType       = 1;
        C_ActionTarget     = 1;
        C_DayRoutineAction = new CharacterAction(C_ActionType, C_ActionTarget);
        C_DayRoutine       = new DayRoutine(C_DayRoutineTime, C_DayRoutinePlace, C_DayRoutineTimesPerformed, C_DayRoutineHowUsedTo, C_DayRoutineTimeDuration, C_DayRoutineState, C_DayRoutineAction);
        C_MondayRoutine    = new List <DayRoutine> ();
        C_TuesdayRoutine   = new List <DayRoutine> ();
        C_WednesdayRoutine = new List <DayRoutine> ();
        C_ThursdayRoutine  = new List <DayRoutine> ();
        C_FridayRoutine    = new List <DayRoutine> ();
        C_SaturdayRoutine  = new List <DayRoutine> ();
        C_SundayRoutine    = new List <DayRoutine> ();
        C_MondayRoutine.Add(C_DayRoutine);
    }