分享
 
 
 

Brew 1.1 个人所得税计算小应用【附源码】

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

所有移动开发架构中高通Brew可能是最令人感到痛苦的一种通用平台,复杂的API和不禁详尽的文档,使开发者对Brew望而却步。

北京讯岚通过2年的研发实践完成了Brew标准类库BFC,协助BREW开发者爱好者一同步入BREW的神奇移动世界(购买BREW类库项目请来电垂询北京讯岚 TEL:51833115).

本文列举使用BREW标准类库所开发的示例应用个人所得税计算:

#if !defined(AFX_WisdomBFCAPP_H__10531DDA_D9FB_4912_976E_00879ADDE742__INCLUDED_)

#define AFX_WisdomBFCAPP_H__10531DDA_D9FB_4912_976E_00879ADDE742__INCLUDED_

#if _MSC_VER > 1000

#pragma once

#endif // _MSC_VER > 1000

#include "BFC\BFC.h"

#include "BFC\BASE\BFCApp.h"

#include "WisdomBFC_Res.h"

class CWisdomBFCApp : public CBFCApp

{

public:

CWisdomBFCApp(AEEApplet *pAEEApplet);

virtual ~CWisdomBFCApp();

virtual boolean OnStart();

virtual boolean OnStop();

virtual boolean OnSMSMessage(char*pMessage,IShell*pShell) ;

private:

CMedia* mm;

};

#endif

// WisdomBFCApp.cpp: implementation of the CWisdomBFCApp class.

//

//////////////////////////////////////////////////////////////////////

#include "WisdomBFCApp.h"

#include "CalculateWindow.h"

//////////////////////////////////////////////////////////////////////

// Construction/Destruction

//////////////////////////////////////////////////////////////////////

CWisdomBFCApp::CWisdomBFCApp(AEEApplet *pAEEApplet) : CBFCApp(pAEEApplet){}

CWisdomBFCApp::~CWisdomBFCApp(){}

boolean CWisdomBFCApp::OnStart()

{

mm=new CMedia(this->m_pAEEApplet);

mm->playSoundFile("sky.mid");

//1-欢迎屏幕

SetAppInfo(

(AECHAR *)L"个人所得税计算",

(AECHAR *)L"北京 ☆ QuickLine\nVersion 1.0\nCopyRight 2005",

(AECHAR *)L"src\\logo.png"

);

REFRESHAPPSTRING();

//2-创建所需窗体

CCalculateWindow *pCalculateWindow = new CCalculateWindow(0);

//3-将所创建窗体加入回收列表,便于程序结束后清理

AddTemplateWindow(pCalculateWindow);

//4-设置启始窗体

SetStartupWindow(pCalculateWindow, FALSE);

return TRUE;

}

boolean CWisdomBFCApp::OnStop(){

mm->stopSoundPlay();

delete mm;

return TRUE;

}

boolean CWisdomBFCApp::OnSMSMessage(char*pMessage,IShell*pShell){

return TRUE;

}

#include "BFC\BFC.h"

#include "tips.h"

#pragma once

class CCalculateWindow :

public CBrewWindow

{

public:

CCalculateWindow(uint16 wID);

virtual ~CCalculateWindow(void);

void OnCreate();

boolean OnCommand(uint16 wParam, uint32 dwParam);

boolean OnChildCommand(uint16 wID, uint16 wParam, uint32 dwParam);

boolean HandleEvent(IApplet *pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);

private:

void SetWindowLogo();

//:TODO

public:

//其他特有成员变量

private:

//其他特有成员变量

};

#include ".\calculatewindow.h"

#include "WisdomBFCApp.h"

#include <stdlib.h>

//构造

CCalculateWindow::CCalculateWindow(uint16 wID)

{

AEERect rc;

SETAEERECT(&rc, 0, 0, 0, 0);

CFlatLayout *pLayout = new CFlatLayout(1, 3, 1);

pLayout->AddControl(AddComponent(new CStatic(0)));//城市标题

pLayout->AddControl(AddComponent(new CListCtl(1), TRUE));//城市列表框

pLayout->AddControl(AddComponent(new CStatic(2)));//收入标题

pLayout->AddControl(AddComponent(new CTextCtl(3, rc, TP_FRAME)));//收入文本框

this->RegisterLayoutManager(pLayout);

this->SetTitleBar(TRUE, (AECHAR *)L"个人所得税计算");

this->SetSysCommandBar(TRUE);

}

//析构

CCalculateWindow::~CCalculateWindow(void){}

//初始化

void CCalculateWindow::OnCreate()

{

GetComponent(0)->SetText(/*GETAPPSTRING(IDS_LOGIN_PASSWORD1)*/(AECHAR *)L"您所在的城市");

CListCtl *pCityList = (CListCtl *)GetComponent(1);

pCityList->Reset();

pCityList->AddItem(0, (AECHAR *)L"北京");

pCityList->AddItem(1, (AECHAR *)L"上海");

pCityList->AddItem(2, (AECHAR *)L"深圳");

pCityList->AddItem(3, (AECHAR *)L"其它地区");

GetComponent(2)->SetText((AECHAR *)L"输入您欲计算的收入");

CTextCtl* pTextCtrl=(CTextCtl*)GetComponent(3);

pTextCtrl->SetInputMode(AEE_TM_NUMBERS);

pTextCtrl->setActive();

this->AddSysCommand(0, (AECHAR *)L"计算");

this->AddSysCommand(1, (AECHAR *)L"个人所得税常识");

this->AddSysCommand(2, (AECHAR *)L"退出");

this->SetWindowLogo();

pCityList=NULL;

pTextCtrl=NULL;

}

//获得命令

boolean CCalculateWindow::OnCommand(uint16 wParam, uint32 dwParam)

{

AEEApplet *pAEEApplet = (AEEApplet *)GETAPPINSTANCE();

CMessageBox *pBox;

AECHAR wstrResult[255];

float result=0;//结果

float v1,v2,v3=0;

CTextCtl* pTextCtrl=(CTextCtl*)GetComponent(3);

IMenuCtl *pList = (IMenuCtl *)(((CListCtl *)GetComponent(1))->m_pIControl);

switch (wParam)

{

case 0:

v1=800;

switch(IMENUCTL_GetSel(pList))

{

case 0:

v1=1000;

break;

case 1:

v1=1000;

break;

case 2:

v1=1600;

break;

}

v2 = WSTRTOFLOAT(pTextCtrl->GetText());

v3 = v2 - v1;

if (v3 <= 0) {

v3 = 0;

}

else if (v3 <= 500) {

result=(v3 * 0.05f);

}

else if(v3 <= 2000) {

result=(v3 * 0.1f - 25);

}

else if(v3 <= 5000) {

result=(v3 * 0.15f - 125);

}

else if(v3 <= 20000) {

result=(v3 * 0.2f - 375);

}

else if (v3 <= 40000) {

result=(v3 * 0.25f - 1375);

}

else if (v3 <= 60000) {

result=(v3 * 0.3f - 3375);

}

else if(v3 <= 80000) {

result=(v3 * 0.35f - 6375);

}

else if (v3 <= 100000) {

result=(v3 * 0.4f - 10375);

}

else{

result=(v3 * 0.45f - 15375);

}

result = FADD(result, WSTRTOFLOAT((AECHAR*)L"0.005"));//2位小数舍入+0.005

pBox= new CMessageBox(0, NULL);

if(FLOATTOWSTR(result, wstrResult,4*sizeof(wstrResult)))

{

AECHAR *pbuf = NULL;

AECHAR str1[500]=L"您应缴纳的个人所得税额为:\0";

AECHAR *str2 = NULL;

pbuf = WSTRCHR(wstrResult, (AECHAR)L'.');//取得小数点后第三位字符位置,将其替换为结束符。

if(pbuf)

{

pbuf += 3;

*pbuf = (AECHAR)L'\0';

}

str2=wstrResult;

WSTRCAT(str1,str2);

pBox->Show(this, (AECHAR *)L"计算结果",str1, MB_OK);

}

else

{

pBox->Show(this, (AECHAR *)L"计算错误", (AECHAR*)L"计算中出现错误!", MB_OK);

}

pBox=NULL;

return TRUE;

case 1:

this->NavigateToWindow(new CTips(0));

return TRUE;

case 2:

ISHELL_CloseApplet(pAEEApplet->m_pIShell, FALSE);

return TRUE;

default:

break;

}

return CBrewWindow::OnCommand(wParam, dwParam);

}

//子命令

boolean CCalculateWindow::OnChildCommand(uint16 wID, uint16 wParam, uint32 dwParam)

{

return TRUE;

}

//设置徽标

void CCalculateWindow::SetWindowLogo()

{

BFCApp *app = (BFCApp *)GETAPPINSTANCE();

app->pApp->SetWindowLogo(WISDOMBFC_RES_FILE,RES_IMAGE2_WINDOWSLOGO);

}

//其他事件

boolean CCalculateWindow::HandleEvent(IApplet *pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)

{

boolean bResult;

/*int16 wFocusID = m_wFocusID;*/

bResult = CBrewWindow::HandleEvent(pi, eCode, wParam, dwParam);

/*if (wFocusID == 1 && eCode == EVT_KEY && (wParam == AVK_LEFT || wParam == AVK_RIGHT))

{

//TODO:

}*/

return bResult;

}

#include "BFC\BFC.h"

#pragma once

class CTips :

public CBrewWindow

{

public:

CTips(uint16 wID);

virtual ~CTips(void);

void OnCreate();

boolean OnCommand(uint16 wParam, uint32 dwParam);

boolean OnChildCommand(uint16 wID, uint16 wParam, uint32 dwParam);

boolean HandleEvent(IApplet *pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);

private:

void SetWindowLogo();

//:TODO

public:

//其他特有成员变量

private:

uint16 GetStaticScrollCount();

int16 m_wScrollCount;

};

#include ".\tips.h"

#include "WisdomBFCApp.h"

#include "CalculateWindow.h"

//构造

CTips::CTips(uint16 wID) : CBrewWindow(wID)

{

m_wScrollCount = -1;

AEERect rc;

CGridLayout *pLayout = new CGridLayout(1, 1, 0, 0, 0);

pLayout->AddControl(AddComponent(new CStatic(0)), 0, 0, 1, 1);

RegisterLayoutManager(pLayout);

SetTitleBar(TRUE, (AECHAR *)L"个人所得税常识");

SetSysCommandBar(TRUE);

}

CTips::~CTips(void){};

uint16 CTips::GetStaticScrollCount()

{

IStatic *pIStatic;

pIStatic = (IStatic *)(((CStatic *)GetComponent(0))->m_pIControl);

if (!pIStatic)

return 0;

int pos;

int start, end, mid;

int height;

height = GetComponent(0)->m_rcLocation.dy;

start = 0;

mid = 100;

end = 200;

while (end - start > 1)

{

pos = ISTATIC_GoToLine(pIStatic, mid);

pos = ISTATIC_GoToLine(pIStatic, mid);

if (pos == mid)

{

start = mid;

mid = start + (end - start) / 2;

}

else

{

end = mid;

mid = start + (end - start) / 2;

}

}

ISTATIC_GoToLine(pIStatic, 0);

AEEApplet *pAEEApplet;

pAEEApplet = (AEEApplet *)GETAPPINSTANCE();

if (start + 1 > height / IDISPLAY_GetFontMetrics(pAEEApplet->m_pIDisplay, AEE_FONT_NORMAL, NULL, NULL))

return start + 1 - height / IDISPLAY_GetFontMetrics(pAEEApplet->m_pIDisplay, AEE_FONT_NORMAL, NULL, NULL);

else

return 0;

}

boolean CTips::HandleEvent(IApplet *pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)

{

IStatic *pIStatic;

pIStatic = (IStatic *)(((CStatic *)GetComponent(0))->m_pIControl);

if (!pIStatic)

return FALSE;

if (m_wScrollCount < 0)

m_wScrollCount = GetStaticScrollCount();

AEERect rc;

int pos;

switch (eCode)

{

case EVT_KEY:

if (wParam == AVK_SELECT || wParam == AVK_CLR)

{

IMENUCTL_HandleEvent((IMenuCtl *)(((CMenuCtl *)GetComponent(CTLID_SYS_COMMAND_BAR))->m_pIControl), eCode, wParam, dwParam);

return FALSE;

}

switch (wParam)

{

case AVK_UP:

pos = ISTATIC_GoToLine(pIStatic, 0);

ISTATIC_GoToLine(pIStatic, pos - 1);

break;

case AVK_DOWN:

pos = ISTATIC_GoToLine(pIStatic, 101);

if (pos < m_wScrollCount)

ISTATIC_GoToLine(pIStatic, pos + 1);

else

ISTATIC_GoToLine(pIStatic, pos);

break;

default:

break;

}

return TRUE;

case EVT_COMMAND:

return FALSE;

default:

return TRUE;

}

return TRUE;

}

//初始化

void CTips::OnCreate()

{

this->AddSysCommand(0, (AECHAR *)L"返回");

AECHAR szAboutText[500];

AECHAR szCrLf[10];

STRTOWSTR("\n", szCrLf, sizeof(AECHAR) * 10);

MEMSET(szAboutText, 0, sizeof(AECHAR) * 500);

WSTRLCAT(szAboutText, (AECHAR*)L"工资、薪金所得的个人所得税按超额累进税率来计算:", 500);

WSTRLCAT(szAboutText, szCrLf, 500);

WSTRLCAT(szAboutText, (AECHAR*)L"1.计算出你的 月工资、薪金所得。", 500);

WSTRLCAT(szAboutText, szCrLf, 500);

WSTRLCAT(szAboutText, (AECHAR*)L"2.月应纳税所得额 = 月工资、薪金所得-800元(注:北京、上海为减去1000元,深圳为减去1600元.)", 500);

WSTRLCAT(szAboutText, szCrLf, 500);

WSTRLCAT(szAboutText, (AECHAR*)L"3.月应纳税额 = 月应纳税所得额×适用税率-速算扣除数", 500);

GetComponent(0)->SetText(szAboutText);

SetWindowLogo();

}

//获得命令

boolean CTips::OnCommand(uint16 wParam, uint32 dwParam)

{

AEEApplet *pAEEApplet = (AEEApplet *)GETAPPINSTANCE();

switch (wParam)

{

case 0:

this->NavigateToWindow(new CCalculateWindow(0));

return TRUE;

default:

break;

}

return CBrewWindow::OnCommand(wParam, dwParam);

}

//设置徽标

void CTips::SetWindowLogo()

{

BFCApp *app = (BFCApp *)GETAPPINSTANCE();

app->pApp->SetWindowLogo(WISDOMBFC_RES_FILE,RES_IMAGE2_WINDOWSLOGO);

}

boolean CTips::OnChildCommand(uint16 wID, uint16 wParam, uint32 dwParam){return TRUE;}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有