📄 posclientdlg.cpp
字号:
m_num=exchangnum;
UpdateData(false);
}
void CPosClientDlg::OnDanZhekou()
{//修改单品折扣
CZheKouDan zhekoudandlg;
UpdateData(true);
if(zhekoudandlg.DoModal()==IDOK)
{
m_zk.Format("%.2f",zhekou);
m_id.SetFocus();
}
UpdateData(false);
}
void CPosClientDlg::OnAllZheKou()
{//修改交易折扣
CZheKouAll zhekoualldlg;
//设置控件字体
CFont myFont1;
CWnd* pWnd;
myFont1.CreatePointFont(280,"Rockwell");
pWnd=GetDlgItem(IDC_STATIC_ALL_MONEY);
pWnd->SetFont(&myFont1);
pWnd=GetDlgItem(IDC_STATIC_RETURN_MONEY);
pWnd->SetFont(&myFont1);
UpdateData(true);
if(zhekoualldlg.DoModal()==IDOK)
{
allmoney=allzhekou*allmoney;
m_all_money.Format("%.2f",allmoney);
}
UpdateData(false);
}
void CPosClientDlg::OnExit()
{//退出系统
CExitSys exitdlg;
if(exitdlg.DoModal()==IDOK)
{
UpdateData(true);
m_good_id=_T("");
m_good_num=1;
m_recive_money=_T("");
UpdateData(false);
OnOK();
}
}
void CPosClientDlg::OnReceiveMoney()
{//收钱函数
float a,b;
CString s;
long c;
CNext nextdlg;
CSells sell;
CGoods gd;
UpdateData(true);
count=sell.LastID();
b=atof(m_recive_money);
a=b-allmoney;
if(a<0)
{
MessageBox("实收金额不足!","警告!");
UpdateData(true);
m_recive_money=_T("");
UpdateData(false);
m_recive.SetFocus();
return;
}
CSellinfo sellinfo;
CTime time=CTime::GetCurrentTime();
CString aaa,bbb;
aaa.Format("%d:%d:%d,",time.GetHour(),time.GetMinute(),time.GetSecond());
bbb=time.Format("%A,%B %d,%Y");
aaa=aaa+bbb;
//向数据库中写入销售信息
sellinfo.insAlldiscount(allzhekou);
sellinfo.insAllmoney(allmoney);
sellinfo.insDate(aaa);
sellinfo.insN(exchangnum);
sellinfo.insRecive(atof(m_recive_money));
sellinfo.insReturn(a);
sellinfo.insUserid(curUser.GetUserId());
sellinfo.sql_insert();
for(int k=0;k<iii;k++)
{//更新商品库存
gd.GetData(goodids[k]);
int j=gd.GetGoodsNum()-goodnums[k];
gd.UpdateNum(j,goodids[k]);
}
count=sell.LastID();
//更改控件字体
CFont myFont1;
CWnd* pWnd;
myFont1.CreatePointFont(280,"Rockwell");
pWnd=GetDlgItem(IDC_STATIC_ALL_MONEY);
pWnd->SetFont(&myFont1);
pWnd=GetDlgItem(IDC_STATIC_RETURN_MONEY);
pWnd->SetFont(&myFont1);
m_return_money.Format("%.2f",a);
c=atoi(exchangnum)+1;
exchangnum.Format("%d",c);
UpdateData(false);
//进入下笔交易
if(nextdlg.DoModal()==IDOK)
{
UpdateData(true);
m_recive_money=_T("");
m_return_money="";
m_all_money="";
m_id.SetFocus();
m_ListCtrl.DeleteAllItems();
}
UpdateData(false);
}
void CPosClientDlg::OnChangId()
{//换收银员
CChangId changiddlg;
UpdateData(true);
if(changiddlg.DoModal()==IDOK)
{m_userid=uid;m_id.SetFocus();}
UpdateData(false);
}
void CPosClientDlg::OnLockWin()
{//锁定屏幕
CLockWin lockdlg;
if(lockdlg.DoModal()==IDOK) m_id.SetFocus();
}
void CPosClientDlg::OnFindGoods()
{//查询商品信息
CFindGoods findgoodsdlg;
if(findgoodsdlg.DoModal()==IDOK) m_id.SetFocus();
}
BOOL CPosClientDlg::PreTranslateMessage(MSG* pMsg)
{//热键设置
CLockWin lockdlg;
CZheKouDan zhekoudandlg;
CZheKouAll zhekoualldlg;
CChangId changiddlg;
CFindGoods findgoodsdlg;
CDelGoods deldlg;
CDelAll delalldlg;
CExitSys exitdlg;
if( IsDialogMessage( pMsg ) )
{
if (pMsg->message== WM_KEYDOWN)
{
switch(pMsg->wParam)
{
case VK_F2:
OnDanZhekou();
break;
case VK_F3:
OnAllZheKou();
break;
case VK_F4:
OnExit();
break;
case VK_F5:
OnDelGoods();
break;
case VK_F6:
OnDelAll();
break;
case VK_F7:
findgoodsdlg.DoModal();
break;
case VK_F8:
lockdlg.DoModal();
break;
case VK_F9:
changiddlg.DoModal();
break;
case VK_F10:
CDialog::OnOK();
break;
case VK_HOME:
m_id.SetFocus();
break;
case VK_END:
m_goodnum.SetFocus();
break;
case VK_PRIOR:
m_recive.SetFocus();
m_recive_money=_T("");
break;
case VK_NEXT:
OnReceiveMoney();
}
}
return TRUE;
}
else
return CDialog::PreTranslateMessage(pMsg);
}
int CPosClientDlg::Show(CString n)
{//显示已购商品
int order=0;
float temp=0;
CSells sell;
CGoods good;
UpdateData(true);
//连接数据库
ADOConn m_AdoConn;
m_ListCtrl.DeleteAllItems();
allmoney=0;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = "SELECT * FROM sells WHERE sellN='" + n + "'";
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
if(m_pRecordset->adoEOF) m_all_money="";
while (!m_pRecordset->adoEOF)
{
int id=atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("id"));
CString ss;
ss.Format("%d",id);
sell.GetData(ss);
good.GetData(sell.getID());
CString s;
s.Format("%d",order+1);
m_ListCtrl.InsertItem(order,s,0);
m_ListCtrl.SetItemText(order,1,sell.getID());
s=good.GetGoodsName();
m_ListCtrl.SetItemText(order,2,s);
s.Format("%.2f",good.GetGoodsPrice());
m_ListCtrl.SetItemText(order,3,s);
s.Format("%d",sell.getNum());
m_ListCtrl.SetItemText(order,4,s);
s.Format("%.2f",sell.getDiscount());
m_ListCtrl.SetItemText(order,5,s);
temp=good.GetGoodsPrice()*sell.getNum()*sell.getDiscount();
s.Format("%.2f",temp);
m_ListCtrl.SetItemText(order,6,s);
allmoney+=temp;
m_all_money.Format("%.2f",allmoney);
m_pRecordset->MoveNext();
order++;
}
UpdateData(false);
return order;
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
void CPosClientDlg::OnDelGoods()
{//删除单件商品
CDelGoods deldlg;
UpdateData(true);
if(deldlg.DoModal()==IDOK)
{del(deldlg.m_n);m_id.SetFocus();Show(exchangnum);}
UpdateData(false);
}
int CPosClientDlg::del(int n)
{//删除单件商品
CSells sell;
CString s;
if(n<=0) return 0;
s.Format("%d",n+count);
sell.sql_delete(s);
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置SELECT语句
_bstr_t vSQL;
vSQL = "SELECT * FROM sells WHERE id>" + s;
//执行SELETE语句
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet(vSQL);
if(m_pRecordset->adoEOF) return 0;
while(!m_pRecordset->adoEOF)
{
int id=atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("id"));
CString a;
a.Format("%d",id);
sell.GetData(a);
sell.iId(id-1);
sell.sql_delete(a);
sell.sql_insert();
m_pRecordset->MoveNext();
}
Show(exchangnum);
CFont myFont1;
CWnd* pWnd;
myFont1.CreatePointFont(280,"Rockwell");
pWnd=GetDlgItem(IDC_STATIC_ALL_MONEY);
pWnd->SetFont(&myFont1);
pWnd=GetDlgItem(IDC_STATIC_RETURN_MONEY);
pWnd->SetFont(&myFont1);
return 1;
}
void CPosClientDlg::delall(CString n)
{//删除所有商品
//连接数据库
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//设置DELETE语句
_bstr_t vSQL;
vSQL = "DELETE FROM sells WHERE sellN='" + n + "'";
UpdateData(true);
allmoney=0;
m_all_money="";
UpdateData(false);
//执行DELETE语句
m_AdoConn.ExecuteSQL(vSQL);
//断开与数据库的连接
m_AdoConn.ExitConnect();
}
void CPosClientDlg::OnDelAll()
{//删除所有商品
CDelAll delalldlg;
if(delalldlg.DoModal()==IDOK)
{
m_ListCtrl.DeleteAllItems();
delall(exchangnum);
Show(exchangnum);
m_id.SetFocus();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -