private void editRecord(int recordID) { if (recordID < 0 || m_mainDiary.RecordsCount <= recordID) { return; } Record recordToChange = m_mainDiary.GetRecord(recordID); if (recordToChange == null) { return; } inoutParentForm form; if (recordToChange.Type == Record.RecordType.Income) { form = new incomeForm(recordToChange, this); } else { form = new outcomeForm(recordToChange); } form.ShowDialog(); if (form.Result != inoutParentForm.InOutFormResult.Cancel) { m_mainDiary.ReplaceRecord(recordID, recordToChange); } UpdateCurrentPage(); }
private void insertOutcomeForm(object o, EventArgs ea) { Record newRecord = new Record(); initRecord(ref newRecord, m_mainDiary); int curRecord = contextMenuRowIndex; int curNumber = -1; while (curRecord >= 0) { Record rec = m_mainDiary.GetRecord(curRecord); if (rec.Type == Record.RecordType.Expense) { curNumber = rec.TypeID; break; } curRecord--; } if (curNumber == -1) { curNumber = m_mainDiary.InitTypeCounts[(int)Record.RecordType.Expense] + 1; } newRecord.TypeID = curNumber + 1; outcomeForm oForm = new outcomeForm(newRecord); oForm.ShowDialog(); if (oForm.Result == inoutParentForm.InOutFormResult.OK) { m_mainDiary.InsertRecord(contextMenuRowIndex, newRecord); } UpdateCurrentPage(); }
private void btnExpense_Click(object sender, EventArgs e) { Record newRecord = new Record(); //todo kdo nastavi defaulty? initRecord(ref newRecord, m_mainDiary); newRecord.TypeID = m_mainDiary.TypeCounts[(int)Record.RecordType.Expense] + 1; outcomeForm oform = new outcomeForm(newRecord); oform.ShowDialog(); if (oform.Result != inoutParentForm.InOutFormResult.Cancel) { m_mainDiary.AppendRecord(newRecord); EnsureRecordVisibility(m_mainDiary.RecordsCount - 1); UpdateCurrentPage(); } }