void mmAttachmentDialog::AddAttachment() { const wxString attachmentFilePath = wxFileSelector(_("Import attachment:") , wxEmptyString, wxEmptyString, wxEmptyString , "All Files |*.*" , wxFD_FILE_MUST_EXIST); if (attachmentFilePath.empty()) return; const wxString attachmentFileName = wxFileName(attachmentFilePath).GetName(); const wxString attachmentFileExtension = wxFileName(attachmentFilePath).GetExt().MakeLower(); const wxString attachmentDescription = wxGetTextFromUser(_("Enter a description for the new attachment:") , _("Organize Attachments: Add Attachment"), attachmentFileName); wxString AttachmentsFolder = mmex::getPathAttachment(mmAttachmentManage::InfotablePathSetting()); wxString attachmentNumberString = Model_Attachment::LastAttachmentFileName(m_RefType, m_RefId); attachmentNumberString = attachmentNumberString.SubString(attachmentNumberString.Find("Attach")+6, attachmentNumberString.Find(".")-1); int attachmentNumber = wxAtoi(attachmentNumberString); wxString importedFileName = m_RefType + "_" + wxString::Format("%i", m_RefId) + "_Attach" + wxString::Format("%i", attachmentNumber+1) + "." + attachmentFileExtension; if (mmAttachmentManage::CopyAttachment(attachmentFilePath, AttachmentsFolder + m_PathSep + m_RefType + m_PathSep + importedFileName)) { Model_Attachment::Data* NewAttachment = Model_Attachment::instance().create(); NewAttachment->REFTYPE = m_RefType; NewAttachment->REFID = m_RefId; NewAttachment->DESCRIPTION = attachmentDescription; NewAttachment->FILENAME = importedFileName; m_attachment_id = Model_Attachment::instance().save(NewAttachment); m_attachment_id = NewAttachment->ATTACHMENTID; } fillControls(); }
void mmMainCurrencyDialog::OnBtnEdit(wxCommandEvent& /*event*/) { Model_Currency::Data *currency = Model_Currency::instance().get(currencyID_); if (currency) mmCurrencyDialog(this, currency).ShowModal(); fillControls(); }
void mmCategDialog::OnMenuSelected(wxCommandEvent& event) { int id = event.GetId(); const wxString index = wxString::Format("*%i:%i*", m_categ_id, m_subcateg_id); if (id == MENU_ITEM_HIDE) { m_treeCtrl->SetItemTextColour(selectedItemId_, wxColour("GREY")); if (m_hidden_categs.Index(index) == wxNOT_FOUND) m_hidden_categs.Add(index); } else if (id == MENU_ITEM_UNHIDE) { m_treeCtrl->SetItemTextColour(selectedItemId_, NormalColor_); m_hidden_categs.Remove(index); } else if (id == MENU_ITEM_CLEAR) { m_hidden_categs.Clear(); } wxString sSettings = ""; for (const auto& item : m_hidden_categs) { sSettings.Append(item + ";"); } sSettings.RemoveLast(1); Model_Infotable::instance().Set("HIDDEN_CATEGS_ID", sSettings); fillControls(); }
void mmPayeeDialog::OnDataChanged(wxDataViewEvent& event) { int row = payeeListBox_->ItemToRow(event.GetItem()); wxVariant var; payeeListBox_->GetValue(var, row, event.GetColumn()); const wxString value = var.GetString(); auto payee = Model_Payee::instance().get(m_payee_rename); if (!payee || value == payee->PAYEENAME) return; const auto payees = Model_Payee::instance().find(Model_Payee::PAYEENAME(value)); if (payees.empty()) { if (payee) { payee->PAYEENAME = value; Model_Payee::instance().save(payee); mmWebApp::MMEX_WebApp_UpdatePayee(); refreshRequested_ = true; } } else { wxMessageBox(_("Payee with same name exists") , _("Organize Payees: Add Payee"), wxOK | wxICON_ERROR); } fillControls(); }
bool mmCurrencyDialog::Create(wxWindow* parent, wxWindowID id , const wxString& caption, const wxPoint& pos , const wxSize& size, long style) { SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); wxDialog::Create(parent, id, caption, pos, size, style); CreateControls(); if (!m_currency) { mmSingleChoiceDialog select_currency_name(this, _("Currency name") , _("Select Currency"), Model_Currency::instance().all_currency_names()); if (select_currency_name.ShowModal() == wxID_OK) { const wxString currencyname = select_currency_name.GetStringSelection(); m_currency = Model_Currency::instance().get_one(Model_Currency::CURRENCYNAME(currencyname)); } } SetEvtHandlerEnabled(false); fillControls(); SetEvtHandlerEnabled(true); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); this->SetInitialSize(); SetIcon(mmex::getProgramIcon()); Centre(); return TRUE; }
void mmPayeeDialog::EditPayee() { Model_Payee::Data *payee = Model_Payee::instance().get(m_payee_id); if (payee) { const wxString name = wxGetTextFromUser(_("Modify the name for the payee:") , _("Organize Payees: Edit Payee"), payee->PAYEENAME); if (name.IsEmpty()) return; if (name == payee->PAYEENAME) return; Model_Payee::Data_Set payees = Model_Payee::instance().find(Model_Payee::PAYEENAME(name)); if (payees.empty()) { payee->PAYEENAME = name; m_payee_id = Model_Payee::instance().save(payee); mmWebApp::MMEX_WebApp_UpdatePayee(); m_payee_id = payee->PAYEEID; refreshRequested_ = true; } else { wxMessageBox(_("Payee with same name exists"), _("Organize Payees: Edit Payee"), wxOK | wxICON_ERROR); } fillControls(); } }
void mmMainCurrencyDialog::OnHistoryDeleteUnused(wxCommandEvent& /*event*/) { Model_CurrencyHistory::instance().Savepoint(); auto currencies = Model_Currency::instance().all(); for (auto ¤cy : currencies) { if (!Model_Account::is_used(currency)) { for (const auto& r : Model_CurrencyHistory::instance().find(Model_CurrencyHistory::CURRENCYID(currency.CURRENCYID))) Model_CurrencyHistory::instance().remove(r.id()); } else { std::map<wxDateTime, int> DatesList = Model_Currency::DateUsed(currency.CURRENCYID); wxDateTime CurrDate; for (const auto& r : Model_CurrencyHistory::instance().find(Model_CurrencyHistory::CURRENCYID(currency.CURRENCYID))) { CurrDate.ParseDate(r.CURRDATE); if (DatesList.find(CurrDate) == DatesList.end()) Model_CurrencyHistory::instance().remove(r.id()); } } } Model_CurrencyHistory::instance().ReleaseSavepoint(); fillControls(); ShowCurrencyHistory(); }
void mmCustomFieldListDialog::AddField() { mmCustomFieldEditDialog dlg(this, (Model_CustomField::Data*)nullptr, m_RefType); if (dlg.ShowModal() != wxID_OK) return; fillControls(); }
void mmAttachmentDialog::do_create(wxWindow* parent) { SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); long style = wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER; wxString WindowTitle; if (m_RefId != 0) WindowTitle = wxString::Format(_("Organize Attachments | %s %i"), m_RefType, m_RefId); else WindowTitle = wxString::Format(_("Organize Attachments | New %s"), m_RefType); if (!wxDialog::Create(parent, wxID_ANY, WindowTitle, wxDefaultPosition, wxDefaultSize, style)) return; CreateControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); SetIcon(mmex::getProgramIcon()); fillControls(); Centre(); }
void mmBudgetYearDialog::OnDelete(wxCommandEvent& /*event*/) { wxString budgetYearString = m_listBox->GetStringSelection(); int budgetYearID = Model_Budgetyear::instance().Get(budgetYearString); Model_Budgetyear::instance().remove(budgetYearID); m_listBox->Clear(); fillControls(); }
void mmCustomFieldListDialog::Create(wxWindow* parent) { SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); long style = wxCAPTION | wxCLOSE_BOX | wxRESIZE_BORDER; wxString WindowTitle = wxString::Format(_("Personalize custom fields | %s"), m_RefType); if (!wxDialog::Create(parent, wxID_ANY, WindowTitle, wxDefaultPosition, wxDefaultSize, style)) return; CreateControls(); fillControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); fillControls(); SetIcon(mmex::getProgramIcon()); Centre(); }
void mmBudgetYearDialog::OnAddMonth(wxCommandEvent& /*event*/) { mmBudgetYearEntryDialog dlg(this, true); if ( dlg.ShowModal() == wxID_OK ) { m_listBox->Clear(); fillControls(); } }
void mmMainCurrencyDialog::OnBtnAdd(wxCommandEvent& /*event*/) { mmCurrencyDialog dlg(this, 0); if (dlg.ShowModal() == wxID_OK) { currencyID_ = dlg.getCurrencyID(); selectedIndex_ = -1; } fillControls(); }
void mmCustomFieldListDialog::EditField() { Model_CustomField::Data *field = Model_CustomField::instance().get(m_field_id); if (field) { mmCustomFieldEditDialog dlg(this, field, m_RefType); if (dlg.ShowModal() != wxID_OK) return; fillControls(); } }
void mmWebAppDialog::OnListItemActivated(wxDataViewEvent& event) { wxDataViewItem item = event.GetItem(); int selected_index = webtranListBox_->ItemToRow(item); if (selected_index >= 0) { int WebTrID = (int)webtranListBox_->GetItemData(item); mmWebAppDialog::ImportWebTr(WebTrID, true); fillControls(); } }
void mmCategDialog::OnCategoryRelocation(wxCommandEvent& /*event*/) { relocateCategoryDialog dlg(this, m_categ_id, m_subcateg_id); if (dlg.ShowModal() == wxID_OK) { wxString msgStr; msgStr << _("Category Relocation Completed.") << "\n\n" << wxString::Format(_("Records have been updated in the database: %i"), dlg.updatedCategoriesCount()); wxMessageBox(msgStr, _("Category Relocation Result")); m_refresh_requested = true; fillControls(); } }
void mmMainCurrencyDialog::OnMenuSelected(wxCommandEvent& event) { switch (event.GetId()) { case MENU_ITEM1: { if (!SetBaseCurrency(currencyID_)) mmErrorDialogs::MessageError(this, "Unable to update history currency rates. Please update them manually!", "Currency history error"); itemButtonDelete_->Disable(); fillControls(); ShowCurrencyHistory(); } break; case MENU_ITEM2: OnlineUpdateCurRate(currencyID_,false); break; } }
void mmMainCurrencyDialog::OnBtnDelete(wxCommandEvent& /*event*/) { if (selectedIndex_ < 0) return; Model_Currency::Data* currency = Model_Currency::instance().get(currencyID_); if (!currency) return; if (wxMessageBox(_("Do you really want to delete the selected Currency?") , _("Currency Dialog") , wxYES_NO | wxNO_DEFAULT | wxICON_ERROR) == wxYES) { Model_Currency::instance().remove(currencyID_); selectedIndex_ = -1; currencyID_ = -1; fillControls(); } }
mmNewAcctDialog::mmNewAcctDialog(Model_Account::Data* account, wxWindow* parent) : m_account(account) , m_currencyID(-1) , m_textAccountName() , m_notesCtrl() , m_itemInitValue() , m_imageList() , m_bitmapButtons() { m_imageList = navtree_images_list(); long style = wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX; Create(parent, wxID_ANY, _("New Account"), wxDefaultPosition, wxSize(550, 300), style); fillControls(); this->Connect(wxID_ANY, wxEVT_CHILD_FOCUS, wxChildFocusEventHandler(mmNewAcctDialog::changeFocus), nullptr, this); }
void mmMainCurrencyDialog::OnHistoryAdd(wxCommandEvent& /*event*/) { if (currencyID_ <= 0) return; wxString listStr; wxDateTime dt; double dPrice = 0.0; Model_Currency::Data* currency = Model_Currency::instance().get(currencyID_); wxString currentPriceStr = valueTextBox_->GetValue().Trim(); if (!Model_Currency::fromString(currentPriceStr, dPrice, currency) || (dPrice < 0.0)) return; Model_CurrencyHistory::instance().addUpdate(currencyID_, valueDatePicker_->GetValue(), dPrice, Model_CurrencyHistory::MANUAL); fillControls(); ShowCurrencyHistory(); }
void mmPayeeDialog::DefineDefaultCategory() { Model_Payee::Data *payee = Model_Payee::instance().get(m_payee_id); if (payee) { mmCategDialog dlg(this, payee->CATEGID, payee->SUBCATEGID, false); if (dlg.ShowModal() == wxID_OK) { payee->CATEGID = dlg.getCategId(); payee->SUBCATEGID = dlg.getSubCategId(); refreshRequested_ = true; Model_Payee::instance().save(payee); mmWebApp::MMEX_WebApp_UpdatePayee(); fillControls(); } } }
void mmCustomFieldListDialog::DeleteField() { Model_CustomField::Data *field = Model_CustomField::instance().get(m_field_id); if (field) { int DeleteResponse = wxMessageBox( _("Do you really want to delete this custom field and all its data?") , _("Confirm Custom Field Deletion") , wxYES_NO | wxNO_DEFAULT | wxICON_ERROR); if (DeleteResponse == wxYES) { Model_CustomField::instance().Delete(m_field_id); m_field_id = -1; fillControls(); } } }
bool mmMainCurrencyDialog::Create(wxWindow* parent , wxWindowID id , const wxString& caption , const wxPoint& pos , const wxSize& size , long style) { SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); wxDialog::Create(parent, id, caption, pos, size, style); CreateControls(); SetIcon(mmex::getProgramIcon()); fillControls(); Centre(); return TRUE; }
bool mmCategDialog::Create(wxWindow* parent, wxWindowID id , const wxString& caption, const wxPoint& pos , const wxSize& size, long style) { SetExtraStyle(GetExtraStyle() | wxWS_EX_BLOCK_EVENTS); wxDialog::Create(parent, id, caption, pos, size, style); CreateControls(); fillControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); this->SetInitialSize(); SetIcon(mmex::getProgramIcon()); SetMinSize(wxSize(316, 316)); Centre(); return TRUE; }
void mmWebAppDialog::DeleteWebTr() { wxDataViewItemArray Selected; webtranListBox_->GetSelections(Selected); if (Selected.size() == 0) return; for (wxDataViewItem Item : Selected) { int selectedIndex_ = webtranListBox_->ItemToRow(Item); if (selectedIndex_ >= 0) { mmWebApp::WebApp_DeleteOneTransaction((int)webtranListBox_->GetItemData(Item)); } } fillControls(); }
void mmAttachmentDialog::EditAttachment() { Model_Attachment::Data *attachment = Model_Attachment::instance().get(m_attachment_id); if (attachment) { const wxString description = wxGetTextFromUser(_("Modify the description for the attachment:") , _("Organize Attachments: Edit Attachment"), attachment->DESCRIPTION); if (description.IsEmpty()) return; if (description == attachment->DESCRIPTION) return; attachment->DESCRIPTION = description; m_attachment_id = Model_Attachment::instance().save(attachment); m_attachment_id = attachment->ATTACHMENTID; fillControls(); } }
void mmWebAppDialog::ImportWebTrSelected() { wxDataViewItemArray Selected; webtranListBox_->GetSelections(Selected); if (Selected.size() == 0) return; for (wxDataViewItem Item : Selected) { int selectedIndex_ = webtranListBox_->ItemToRow(Item); if (selectedIndex_ >= 0) { int WebTrID = (int)webtranListBox_->GetItemData(Item); mmWebAppDialog::ImportWebTr(WebTrID, true); } } fillControls(); }
void mmMainCurrencyDialog::OnHistoryDelete(wxCommandEvent& /*event*/) { if (valueListBox_->GetSelectedItemCount() <= 0) return; long item = -1; Model_CurrencyHistory::instance().Savepoint(); for (;;) { item = valueListBox_->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (item == -1) break; Model_CurrencyHistory::instance().remove((int)valueListBox_->GetItemData(item)); } Model_CurrencyHistory::instance().ReleaseSavepoint(); fillControls(); ShowCurrencyHistory(); }
void mmAttachmentDialog::DeleteAttachment() { Model_Attachment::Data *attachment = Model_Attachment::instance().get(m_attachment_id); if (attachment) { int DeleteResponse = wxMessageBox( _("Do you really want to delete this attachment?") , _("Confirm Attachment Deletion") , wxYES_NO | wxNO_DEFAULT | wxICON_ERROR); if (DeleteResponse == wxYES) { wxString AttachmentsFolder = mmex::getPathAttachment(mmAttachmentManage::InfotablePathSetting()) + m_PathSep + attachment->REFTYPE; if (mmAttachmentManage::DeleteAttachment(AttachmentsFolder + m_PathSep + attachment->FILENAME)) { Model_Attachment::instance().remove(m_attachment_id); } m_attachment_id = -1; fillControls(); } } }
void mmAttachmentDialog::EditAttachment() { Model_Attachment::Data *attachment = Model_Attachment::instance().get(m_attachment_id); if (attachment) { mmDialogComboBoxAutocomplete dlg(this, _("Enter a new description for the attachment:"), _("Organize Attachments: Edit Attachment"), attachment->DESCRIPTION, Model_Attachment::instance().allDescriptions()); if (dlg.ShowModal() != wxID_OK) return; const wxString description = dlg.getText(); if (description == attachment->DESCRIPTION) return; attachment->DESCRIPTION = description; m_attachment_id = Model_Attachment::instance().save(attachment); fillControls(); } }