⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdi.cpp

📁 理财小工具
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	}	totalValue+=db;	UpdateStatusBar();	int index=0;	gridobject.Insert(index,nodedata);	grid->InsertRows(1);	grid->SetCellAlignment(wxALIGN_LEFT,1,2);	grid->SetCellValue(thedate.FormatISODate(), 1, 0);	grid->SetCellValue(wxString::Format("%.2f",db), 1, 1);	grid->SetCellValue(s3, 1, 2);	}void MyGridFrame::AppendRecToGrid(xmlnodeGNode*nodedata, wxString s1,wxString s2,wxString s3){	wxDateTime thedate;	wxDouble db;	if ((NULL==thedate.ParseDate(s1.mb_str()))		||(!s2.ToDouble(&db))		||(s3.IsEmpty()))	{		wxLogError(_("The format of date or money is error in AppendRec!"));		return;	}	totalValue+=db;	UpdateStatusBar();	gridobject.Append(nodedata);	grid->AppendRows(1);	grid->SetCellAlignment(wxALIGN_LEFT,grid->GetRows()-1,2);	grid->SetCellValue(thedate.FormatISODate(), grid->GetRows()-1, 0);	grid->SetCellValue(wxString::Format("%.2f",db), grid->GetRows()-1, 1);	grid->SetCellValue(s3, grid->GetRows()-1, 2);	}void MyGridFrame::OnSize(wxSizeEvent& event){    wxSize size3 = GetClientSize();	ResetSize(size3);    event.Skip();}void MyGridFrame::ResetSize(wxSize clientSize){	UpdateUIBaseOnSize();/*	m_text3->SetSize(clientSize.x - colwidth[0]-colwidth[1]-30-10,recheight);	grid->SetColSize(2, clientSize.x - colwidth[0]-colwidth[1]-30-10);	grid->SetSize(clientSize.x,clientSize.y-recheight);	grid->ForceRefresh();*/}void MyGridFrame::OnCellRightClick( wxGridEvent& ev ){    wxMenu menu(_("Menu for Cell"));    menu.Append(POPUP_DELETEREC, _("&Delete Rec(s)"));    grid->PopupMenu(&menu, ev.GetPosition());    UpdateUIBaseOnSize();}void MyGridFrame::OnRowSize(wxGridSizeEvent& ev){	int row=ev.GetRowOrCol();	recheight=grid->GetRowSize(row);	UpdateUIBaseOnSize();	frame->stdata.recheight = recheight;	frame->SetAllConfig(&frame->stdata);}void MyGridFrame::OnColSize(wxGridSizeEvent& ev){	for (int i=0;i<3;i++)	{		colwidth[i] = grid->GetColSize(i);		frame->stdata.colswidth[i] = colwidth[i];	}	recheight = grid->GetDefaultRowSize();	UpdateUIBaseOnSize();	frame->SetAllConfig(&frame->stdata);}void MyGridFrame::OnUpKeyPress(wxCommandEvent& WXUNUSED(event) ){	wxTreeItemId selitem=frame->textWindow->GetSelection();	if (!selitem.IsOk()) return;	wxTreeItemId item=frame->textWindow->GetPrevVisible(selitem);	if ((selitem != item) &&(item.IsOk()))	{		frame->textWindow->SelectItem(item);	}}void MyGridFrame::OnTabKeyPress(wxCommandEvent& WXUNUSED(event) ){	if (m_text1 == FindFocus())	{		m_text2->SetFocus();		m_text2->SetSelection(-1, -1);	}	else if (m_text2 == FindFocus())	{		m_text3->SetFocus();		m_text3->SetSelection(-1, -1);	}	else	{			m_text1->SetFocus();		m_text1->SetSelection(-1, -1);	}}void MyGridFrame::OnDownKeyPress(wxCommandEvent& WXUNUSED(event) ){	wxTreeItemId selitem=frame->textWindow->GetSelection();	if (!selitem.IsOk()) return;	wxTreeItemId item=frame->textWindow->GetNextVisible(selitem);	if ((selitem != item) &&(item.IsOk()))	{		frame->textWindow->SelectItem(item);	}}	void MyGridFrame::OnCellValueChanged(wxGridEvent& ev ){	if (EnableAutoModify==FALSE) 	{	    ev.Skip();		return;	}	if (ev.GetRow()==0) return;	long index= ev.GetRow()-1;	if (frame->stdata.hintinmodify)	{		wxMessageDialog dialog( NULL, _("The value of one record has just been changed\n"			"If you want save the change and keep this hint next time, Please choose YES\n"			"If you want save the change and never show this hint, please choose No\n"			"If you do not want save the change please choose Cancel\n"			"Once you save the change,not the value,but the type of the record maybe changed!\n"			"So you should choose the suitable type one change record value,Pay Attention!!"),		  _("modify records confirm"), wxNO_DEFAULT|wxYES_NO|wxCANCEL|wxICON_INFORMATION);		switch ( dialog.ShowModal() )		{		  case wxID_YES:		    break;		  case wxID_NO:		  	frame->stdata.hintinmodify = FALSE;			frame->SetAllConfig(&frame->stdata);			break;		  case wxID_CANCEL:			  default:			xmlnodeGNode *dataitem = gridobject.Item(index)->GetData();			if (dataitem == NULL) 			{				wxLogError(_("should not be here,mail to wq1911@yahoo.com.cn please!"));				return;			}			xmlChar * desc=xmlNodeGetContent(dataitem->xmlNode);			wxString temp(wxConvUTF8.cMB2WC((const char *)desc),*wxConvCurrent);		  	grid->SetCellValue(ev.GetRow(),ev.GetCol(),temp);			xmlFree(desc);			return;		}			}		xmlnodeGNode *dataitem = gridobject.Item(index)->GetData();	if (dataitem == NULL) 	{		wxLogError(_("row %d col %d modify fail!"),ev.GetRow(),ev.GetCol());		return;	}	wxDateTime thedate;	wxDouble db;		if ((NULL==thedate.ParseDate(grid->GetCellValue(ev.GetRow(),0).mb_str()))		||(!grid->GetCellValue(ev.GetRow(),1).ToDouble(&db))		||(grid->GetCellValue(ev.GetRow(),2).IsEmpty()))	{		wxLogError(_("The format of date or money is error in ModifyRec!"));		return;	}	xmlNodePtr oldNode = dataitem->xmlNode;	if (frame->moneybook->ModifyMoneyRec(dataitem, &thedate, db, grid->GetCellValue(ev.GetRow(),2)))	{		wxLogStatus("Value %d,%d changed and saved!",ev.GetRow(),ev.GetCol());		gridobject.DeleteNode(gridobject.Item(index));		gridobject.Insert(index,dataitem);		totalValue = GetTotalFromUi();		UpdateStatusBar();				//TODO update performance		wxNode *node =my_children.GetFirst();		while (node)		{			MyGridFrame* peerframe = (MyGridFrame*)node->GetData();			if (peerframe==this) 			{				node = node->GetNext();				continue;			}			MyXmlNodeList::Node *wxxmlnode = peerframe->gridobject.GetFirst();			while (NULL!=wxxmlnode)			{				xmlnodeGNode *xmlnodec = wxxmlnode->GetData();				if (xmlnodec->xmlNode == oldNode)				{					xmlnodec->xmlNode = dataitem->xmlNode;					peerframe->grid->SetCellValue(peerframe->gridobject.IndexOf(xmlnodec)+1,0,grid->GetCellValue(ev.GetRow(),0));					peerframe->grid->SetCellValue(peerframe->gridobject.IndexOf(xmlnodec)+1,1,grid->GetCellValue(ev.GetRow(),1));					peerframe->grid->SetCellValue(peerframe->gridobject.IndexOf(xmlnodec)+1,2,grid->GetCellValue(ev.GetRow(),2));					peerframe->totalValue = peerframe->GetTotalFromUi();					peerframe->UpdateStatusBar();					break;				}				wxxmlnode =wxxmlnode->GetNext(); 			}			node = node->GetNext();		}			}	frame->UpdateStatusBar();    ev.Skip();}void MyGridFrame::OnKeyDown(wxKeyEvent& event){	if (m_text1 == FindFocus())	{		m_text2->SetFocus();		m_text2->SetSelection(-1, -1);	}	else if (m_text2 == FindFocus())	{		m_text3->SetFocus();		m_text3->SetValue("");	}	else if (m_text3 == FindFocus())	{			wxDateTime thedate;		wxDouble db;		if ((NULL==thedate.ParseDate(m_text1->GetValue().mb_str()))			||(!m_text2->GetValue().ToDouble(&db)))		{			wxLogError(_("The format of date or money is error in Format Check !"));			return;		}		if	(m_text3->GetValue().IsEmpty()) return;        xmlnodeGNode*dataitem = new xmlnodeGNode(NULL);		if (!frame->moneybook->AddMoneyRec(&thedate,db,m_text3->GetValue(),dataitem))		{			wxLogError(_("Please choose suitable type!"));			return;		}		AddRecToGrid(dataitem, m_text1->GetValue(), m_text2->GetValue(), m_text3->GetValue());		frame->UpdateStatusBar();				m_text1->SetFocus();		m_text1->SetSelection(-1, -1);		m_text3->SetValue("");	}		     event.Skip();}MyCalendarDialog::MyCalendarDialog(wxWindow *parent)             : wxDialog(parent, -1, wxString(_("Month Choose")),wxDefaultPosition,wxSize(450, 340)){	wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );    m_calendar = new wxCalendarCtrl(this, Calendar_CalCtrl,                                    wxDefaultDateTime,                                    wxPoint(0, 0),                                    wxDefaultSize,                                    wxCAL_MONDAY_FIRST |                                    wxCAL_SHOW_HOLIDAYS |                                    wxRAISED_BORDER);	topsizer->Add(m_calendar,1,wxEXPAND | wxALL, 10);    wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);    m_btnFocused = new wxButton(this, -1, _("Con&firm"));    wxButton *btnOk = new wxButton(this, wxID_CANCEL, _("&Cancel"));    sizerTop->Add(m_btnFocused, 0, wxALIGN_CENTER | wxALL, 5);    sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);    m_btnFocused->SetFocus();    m_btnFocused->SetDefault();	topsizer->Add(sizerTop,0,wxALIGN_CENTER);    topsizer->SetSizeHints(this);    topsizer->Fit(this);    SetAutoLayout(TRUE);    SetSizer(topsizer);	//SetClientSize(m_calendar->GetSize() + );	}void MyCalendarDialog::OnButton(wxCommandEvent& event){	if ( event.GetEventObject() == m_btnFocused )    {		wxTreeItemId treeitem = frame->textWindow->GetSelection();		if (treeitem.IsOk())		{			frame->CreateBrowserWindow(&treeitem,TRUE,m_calendar->GetDate());		}		Close();    }    else    {        event.Skip();    }}MyCalcHouseFeeDialog::MyCalcHouseFeeDialog(wxWindow *parent)             : wxDialog(parent, -1, wxString(_("Clac House Fee")),wxDefaultPosition,wxSize(450, 340)){	wxString choices[] =    {        _("Same Count Plus Tax"),        _("Same Count Only")    };	m_TotalCount = new wxTextCtrl(this, -1, _("220000"));	m_MonthRate = new wxTextCtrl(this, -1, _("0.042"));	m_Terms = new wxTextCtrl(this, -1, _("120"));	m_PayMethord = new wxRadioBox( this, -1, _("Pay Methord"), wxPoint(-1,-1), wxSize(-1,-1), 2, choices,1,wxRA_SPECIFY_COLS);	wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );    wxGridSizer *gridsizer = new wxGridSizer(2, 4, 6);    gridsizer->Add(new wxStaticText(this, -1, _("TotalCount:")), 0,                  wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);    gridsizer->Add(m_TotalCount, 1,                   wxGROW | wxALIGN_CENTER_VERTICAL);    gridsizer->Add(new wxStaticText(this, -1, _("Month Rate(%)")), 0,                   wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);    gridsizer->Add(m_MonthRate, 1,                   wxGROW | wxALIGN_CENTER_VERTICAL);    gridsizer->Add(new wxStaticText(this, -1, _("Terms:")), 0,                   wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL);    gridsizer->Add(m_Terms, 1,                   wxGROW | wxALIGN_CENTER_VERTICAL);	topsizer->Add(gridsizer,1,wxEXPAND | wxALL, 10);	topsizer->Add(m_PayMethord,1,                   wxEXPAND | wxALL,10);    wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);    m_btnSetDefault = new wxButton(this, -1, _("&Set As Mine"));    m_btnFocused = new wxButton(this, -1, _("Con&firm"));    wxButton *btnOk = new wxButton(this, wxID_CANCEL, _("&Close"));    sizerTop->Add(m_btnSetDefault, 0, wxALIGN_CENTER | wxALL, 5);    sizerTop->Add(m_btnFocused, 0, wxALIGN_CENTER | wxALL, 5);    sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);    m_btnFocused->SetFocus();    m_btnFocused->SetDefault();	topsizer->Add(sizerTop,0,wxALIGN_CENTER);    topsizer->SetSizeHints(this);    topsizer->Fit(this);    SetAutoLayout(TRUE);    SetSizer(topsizer);	//SetClientSize(m_calendar->GetSize() + );	}void MyCalcHouseFeeDialog::SetValue(wxDouble TotalCnt, wxDouble MonthRate, long terms, long PayMethod){	m_TotalCount->SetValue(wxString::Format("%.2f",TotalCnt));	m_MonthRate->SetValue(wxString::Format("%f",MonthRate));	m_Terms->SetValue(wxString::Format("%d",terms));	m_PayMethord->SetSelection(PayMethod);}void MyCalcHouseFeeDialog::OnButton(wxCommandEvent& event){	if ( event.GetEventObject() == m_btnFocused )    {		wxDouble totalcnt;		m_TotalCount->GetValue().ToDouble(&totalcnt);		wxDouble monthrate;		m_MonthRate->GetValue().ToDouble(&monthrate);		monthrate /= 100;		long terms;		m_Terms->GetValue().ToLong(&terms,10);		if (m_PayMethord->GetSelection() == 0)		{			wxDouble result=MoneyBook::GetHouseFeeSameCountPlusTax(totalcnt,monthrate,terms);		    wxMessageDialog dialog(NULL, wxString::Format(_("You need pay for your house %.2f each month\nTotally you will pay %.2f!"),result,result * terms),		      _("House Fee Result"), wxNO_DEFAULT|wxOK|wxICON_INFORMATION);			dialog.ShowModal();		}		else //if (m_PayMethord->GetSelection() == 1)		{		    wxTextEntryDialog dialog(this, 				_("Since You choose this kind of pay method, different month you pay different!\nPlease input which month(1,2 and so so)you want query or if "				"you want query total,leave it empty"),				_("House Fee Query"),				"",		        wxOK | wxCANCEL);			if (dialog.ShowModal() == wxID_OK)			{				if (dialog.GetValue().IsEmpty())				{						wxDouble resulttotal=0;						for (int i=0;i<terms;i++)						{							resulttotal+=MoneyBook::GetHouseFeeSameCountOnly(totalcnt,monthrate,terms,i+1);						}					    wxMessageDialog dialog(NULL, wxString::Format(_("You need pay for your house totally %.2f!"),resulttotal),					      _("House Fee Result"), wxNO_DEFAULT|wxOK|wxICON_INFORMATION);						dialog.ShowModal();				}				else				{					long monthindex;					dialog.GetValue().ToLong(&monthindex, 10);					if ((monthindex<=0) || (monthindex>terms))					{					    wxMessageDialog dialog(NULL, wxString::Format(_("Please input the value between %d and %d!"),1,terms),					      _("House Fee Alert"), wxNO_DEFAULT|wxOK|wxICON_INFORMATION);						dialog.ShowModal();						return;					}					else					{						wxDouble result=MoneyBook::GetHouseFeeSameCountOnly(totalcnt,monthrate,terms,monthindex);						wxDouble resulttotal=0;						for (int i=0;i<terms;i++)						{							resulttotal+=MoneyBook::GetHouseFeeSameCountOnly(totalcnt,monthrate,terms,i+1);						}					    wxMessageDialog dialog(NULL, wxString::Format(_("You need pay for your house %.2f in the %d(th) month\nTotally you will pay %.2f!"),result,monthindex,resulttotal),					      _("House Fee Result"), wxNO_DEFAULT|wxOK|wxICON_INFORMATION);						dialog.ShowModal();					}				}			}					}    }	else if ( event.GetEventObject() == m_btnSetDefault)	{			wxDouble totalcnt;			m_TotalCount->GetValue().ToDouble(&totalcnt);			wxDouble monthrate;			m_MonthRate->GetValue().ToDouble(&monthrate);			long terms;			m_Terms->GetValue().ToLong(&terms,10);		    wxTextEntryDialog dialog(this, 				_("Please Input the date when you start to pay for your house"),				_("House Fee Query"),				wxDateTime::Today().FormatISODate().c_str(),		        wxOK | wxCANCEL);			if (dialog.ShowModal() == wxID_OK)			{				wxDateTime tmpdate;				if (NULL==tmpdate.ParseDate(dialog.GetValue()))				{					wxLogError(_("Please Input the correct date as the sample!"));				}				frame->moneybook->SetHousePay(totalcnt, monthrate, terms, tmpdate,m_PayMethord->GetSelection());			    wxMessageDialog dialog2(NULL, _("Your house Fee data has been stored!"),			      _("House Fee"), wxNO_DEFAULT|wxOK|wxICON_INFORMATION);				dialog2.ShowModal();				 			}			}    else    {        event.Skip();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -