2.1商场收银软件
//图2-1
#define MAX 255
void CShopsumDlg::OnCompute()
{
UpdateData();
m_totalPrices = m_num * m_price;
char str[MAX+1];
sprintf (str, "单价:%8.2f 数量:%8d 合计:%10.2f",
m_price, m_num, m_totalPrices);
m_recordList.AddString( str );
UpdateData(FALSE);
}
2.2 增加打折
//图2-2
//添加了新的打折下拉列表,去掉sort属性
#define COUNT_TYPE_NUM 6
#define COUNT_TYPE_LENGTH 30
BOOL CShopsumDlg::OnInitDialog()
{
…………
char countType[COUNT_TYPE_NUM][COUNT_TYPE_LENGTH] = {"正常","打5折","打6折","打7折","打8折","打9折"};
// TODO: Add extra initialization here
for ( int i=0; i < COUNT_TYPE_NUM; i++ )
{
m_type.AddString(countType[i]);
}
m_type.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
//修改了结算中的代码
#define MAX 255
void CShopsumDlg::OnCompute()
{
enum countpercent{
COUNT100=0,COUNT50,COUNT60,COUNT70,COUNT80,COUNT90
};
UpdateData();
double count = 1.0;
switch (m_type.GetCurSel())
{
case COUNT100:
count = 1.0;
break;
case COUNT50:
count = 0.5;
break;
case COUNT60:
count = 0.6;
break;
case COUNT70:
count = 0.7;
break;
case COUNT80:
count = 0.8;
break;
case COUNT90:
count = 0.9;
break;
default:
count = 1.0;
break;
}
m_totalPrices = m_num * m_price * count;
char str[MAX+1];
sprintf (str, "单价:%5.2f 数量: %-5d 折扣:%.0f%% 合计:%5.2f",
m_price, m_num, count*100, m_totalPrices);
m_recordList.AddString( str );
UpdateData(FALSE);
}
//图2-1
#define MAX 255
void CShopsumDlg::OnCompute()
{
UpdateData();
m_totalPrices = m_num * m_price;
char str[MAX+1];
sprintf (str, "单价:%8.2f 数量:%8d 合计:%10.2f",
m_price, m_num, m_totalPrices);
m_recordList.AddString( str );
UpdateData(FALSE);
}
2.2 增加打折
//图2-2
//添加了新的打折下拉列表,去掉sort属性
#define COUNT_TYPE_NUM 6
#define COUNT_TYPE_LENGTH 30
BOOL CShopsumDlg::OnInitDialog()
{
…………
char countType[COUNT_TYPE_NUM][COUNT_TYPE_LENGTH] = {"正常","打5折","打6折","打7折","打8折","打9折"};
// TODO: Add extra initialization here
for ( int i=0; i < COUNT_TYPE_NUM; i++ )
{
m_type.AddString(countType[i]);
}
m_type.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
//修改了结算中的代码
#define MAX 255
void CShopsumDlg::OnCompute()
{
enum countpercent{
COUNT100=0,COUNT50,COUNT60,COUNT70,COUNT80,COUNT90
};
UpdateData();
double count = 1.0;
switch (m_type.GetCurSel())
{
case COUNT100:
count = 1.0;
break;
case COUNT50:
count = 0.5;
break;
case COUNT60:
count = 0.6;
break;
case COUNT70:
count = 0.7;
break;
case COUNT80:
count = 0.8;
break;
case COUNT90:
count = 0.9;
break;
default:
count = 1.0;
break;
}
m_totalPrices = m_num * m_price * count;
char str[MAX+1];
sprintf (str, "单价:%5.2f 数量: %-5d 折扣:%.0f%% 合计:%5.2f",
m_price, m_num, count*100, m_totalPrices);
m_recordList.AddString( str );
UpdateData(FALSE);
}