【VC开源代码栏目提醒】:本文主要为网学会员提供DlgInputBack2.cpp,希望对需要DlgInputBack2.cpp网友有所帮助,学习一下!
// DlgInputBack2.cpp : implementation file
//
#include "stdafx.h"
#include "bbb.h"
#include "DlgInputBack2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr m_pCon; //ADO连接对象
extern _RecordsetPtr m_pRs;
extern _RecordsetPtr m_pRs1;
extern _CommandPtr m_pCom;
extern CString user;
/////////////////////////////////////////////////////////////////////////////
// CDlgInputBack2 dialog
CDlgInputBack2::CDlgInputBack2(CWnd* pParent /*=NULL*/)
: CDialog(CDlgInputBack2::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgInputBack2)
//}}AFX_DATA_INIT
}
void CDlgInputBack2::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgInputBack2)
DDX_Control(pDX, IDC_FACTMONEY, m_factmoney);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_SUMMONEY, m_summoney);
DDX_Control(pDX, IDC_STORAGELIST, m_storagelist);
DDX_Control(pDX, IDC_REBATE, m_rebate);
DDX_Control(pDX, IDC_PROVIDERLIST, m_providerlist);
DDX_Control(pDX, IDC_PROVIDER, m_provider);
DDX_Control(pDX, IDC_PAYMONEY, m_paymoney);
DDX_Control(pDX, IDC_OPERATOR, m_operator);
DDX_Control(pDX, IDC_LIST2, m_auxilist);
DDX_Control(pDX, IDC_DATETIME, m_date);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgInputBack2, CDialog)
//{{AFX_MSG_MAP(CDlgInputBack2)
ON_EN_CHANGE(IDC_REBATE, OnChangeRebate)
ON_EN_CHANGE(IDC_SUMMONEY, OnChangeSummoney)
ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
ON_LBN_DBLCLK(IDC_PROVIDERLIST, OnDblclkProviderlist)
ON_LBN_DBLCLK(IDC_STORAGELIST, OnDblclkStoragelist)
ON_NOTIFY(NM_KILLFOCUS, IDC_LIST2, OnKillfocusList2)
ON_LBN_KILLFOCUS(IDC_STORAGELIST, OnKillfocusStoragelist)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgInputBack2 message handlers
void CDlgInputBack2::AddNewRow()
{
int counts = m_list.GetItemCount();
if (m_list.row == counts-1)//当前行为最后一行
{
m_list.InsertItem(100,"");
m_list.row+=1;
m_list.SetItemText(m_list.row,5,"1.0");
m_list.col = 0;
m_list.ShowEdit();
}
else
{
m_list.row+=1;
m_list.col = 0;
m_list.ShowEdit();
}
}
float CDlgInputBack2::CalculateMoney()
{
float money,temp;
money = 0.0;
CString c_money;
int rowcounts = m_list.GetItemCount();
for (int i = 0;i<rowcounts;i++)
{
c_money = m_list.GetItemText(i,6);
if (!c_money.IsEmpty())
{
temp = atof(c_money);
money += temp;
}
}
return money;
}
bool CDlgInputBack2::CurrentRowIsNull()
{
int row = m_list.GetSelectionMark();
if (row !=-1)
{
for (int index = 0;index <7;index++)
{
CString str;
str = m_list.GetItemText(m_list.row,index);
if (str.IsEmpty())
{
return true;
}
}
}
else
return true;
return false;
}
void CDlgInputBack2::DeleteCurRow()
{
int currow;
currow = m_list.row;
if (currow!=-1)
{
if (MessageBox("确实要删除当前行吗?","提示",MB_YESNO)==IDYES)
{
int m = m_list.GetItemCount();
if (m >1)
{
for (int i = currow+1;i<m_list.GetItemCount();i++)
{
for(int c = 0; c<7 ;c++)
{
m_list.SetItemText(i-1,c,m_list.GetItemText(i,c));
}
}
m_list.DeleteItem(m_list.GetItemCount()-1);
}
else
{
for (int i = 0;i< 7;i++)
{
m_list.SetItemText(0,i,"");
}
}
CString temp;
temp.Format("%10.2f",CalculateMoney());//重新统计数据
temp.TrimLeft();
m_summoney.SetWindowText(temp);
}
}
}
bool CDlgInputBack2::DetailInfoIsNull()
{
int rowcount = m_list.GetItemCount();
if (rowcount ==-1)
return true;
for (int r = 0;r <rowcount;r++)
for (int i = 0;i<7;i++)
{
CString temp;
temp = m_list.GetItemText(r,i);
if (temp.IsEmpty()==true)
return true;
}
return false;
}
void CDlgInputBack2::EditChange()
{
CString str;
m_list.edit.GetWindowText(str);
CString sql = "";
switch (m_list.col)
{
case 1 :
{
if (!str.IsEmpty())
sql.Format("select barcode,bookname,author,shortname,price from tb_bookinfo where barcode like '%s%%' or shortname like '%s%%' ",str,str);
break;
}
case 2 :
{
if (!str.IsEmpty())
sql.Format("select barcode,bookname,author,shortname,price from tb_bookinfo where bookname like '%s%%' or shortname like '%s%%'",str,str);
break;
}
case 3:
{
CString c_price,c_num,c_rebate,c_money;
float f_price,f_num,f_rebate,f_money;
c_price = str;
c_num = m_list.GetItemText(m_list.row,4);
c_rebate = m_list.GetItemText(m_list.row,5);
if (c_price.IsEmpty()||c_num.IsEmpty()||c_rebate.IsEmpty())
{
//如果单价\数量\折扣为空,金额将为空
m_list.SetItemText(m_list.row,6,"");
}
else
{
f_price = atof(c_price);
f_num = atof(c_num);
f_rebate = atof(c_rebate);
f_money = f_price*f_num*f_rebate;
c_money.Format("%10.2f",f_money);
c_money.TrimLeft();
m_list.SetItemText(m_list.row,6,c_money);
}
str.Format("%10.2f",CalculateMoney());
str.TrimLeft();
m_summoney.SetWindowText(str);
break;
}
case 4:
{
CString c_price,c_num,c_rebate,c_money;
float f_price,f_num,f_rebate,f_money;
c_price = m_list.GetItemText(m_list.row,3);
c_num = str;
c_rebate = m_list.GetItemText(m_list.row,5);
if (c_price.IsEmpty()||c_num.IsEmpty()||c_rebate.IsEmpty())
{
//如果单价\数量\折扣为空,金额将为空
m_list.SetItemText(m_list.row,6,"");
}
else
{
f_price = atof(c_price);
f_num = atof(c_num);
f_rebate = atof(c_rebate);
f_money = f_price*f_num*f_rebate;
c_money.Format("%10.2f",f_money);
c_money.TrimLeft();
m_list.SetItemText(m_list.row,6,c_money);
}
str.Format("%10.2f",CalculateMoney());
str.TrimLeft();
m_summoney.SetWindowText(str);
break;
}
case 5:
{
CString c_price,c_num,c_rebate,c_money;
float f_price,f_num,f_rebate,f_money;
c_price = m_list.GetItemText(m_list.row,3);
c_num = m_list.GetItemText(m_list.row,4);
c_rebate = str;
if (c_price.IsEmpty()||c_num.IsEmpty()||c_rebate.IsEmpty())
{
//如果单价\数量\折扣为空,金额将为空
m_list.SetItemText(m_list.row,6,"");
}
else
{
f_price = atof(c_price);
f_num = atof(c_num);
f_rebate = atof(c_rebate);
f_money = f_price*f_num*f_rebate;
c_money.Format("%10.2f",f_money);
c_money.TrimLeft();
m_list.
上一篇:
DlgHuffman.cpp
下一篇:
谈初中数学“一元二次方程”的几种常见题型