📄 posclientdlg.cpp
字号:
// PosClientDlg.cpp : implementation file
// 主窗口类
#include "stdafx.h"
#include "PosClient.h"
#include "PosClientDlg.h"
#include "Users.h"
#include "Goods.h"
#include "LoginDlg.h"
#include "Global.h"
#include "LockWin.h"
#include "UnlockWin.h"
#include "ChangId.h"
#include "FindGoods.h"
#include "ZheKouDan.h"
#include "ZheKouAll.h"
#include "Sells.h"
#include "Sellinfo.h"
#include "ADOConn.h"
#include "DelGoods.h"
#include "DelAll.h"
#include "ExitSys.h"
#include "Next.h"
extern CUsers curUser;
extern CGoods curGood;
extern CString temppsw;
extern float zhekou;
extern float allzhekou;
extern float allmoney;
extern int count;
extern CString uid;
extern int sellid;
extern CString exchangnum;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosClientDlg dialog
CPosClientDlg::CPosClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPosClientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPosClientDlg)
m_good_id = _T("");
m_good_num = 1;
m_num = _T("");
m_all_money = _T("");
m_return_money = _T("");
m_zk = _T("1.00");
m_recive_money = _T("");
m_userid = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPosClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPosClientDlg)
DDX_Control(pDX, IDC_STATIC_RETURN_MONEY, m_returnmoney);
DDX_Control(pDX, IDC_STATIC_ALL_MONEY, m_allmoney);
DDX_Control(pDX, IDC_EDIT_RECIVE_MONEY, m_recive);
DDX_Control(pDX, IDC_EDIT_GOOD_NUM, m_goodnum);
DDX_Control(pDX, IDC_EDIT_GOOD_ID, m_id);
DDX_Control(pDX, IDC_LIST2, m_ListCtrl);
DDX_Text(pDX, IDC_EDIT_GOOD_ID, m_good_id);
DDX_Text(pDX, IDC_EDIT_GOOD_NUM, m_good_num);
DDX_Text(pDX, IDC_EDIT_NUM, m_num);
DDX_Text(pDX, IDC_STATIC_ALL_MONEY, m_all_money);
DDX_Text(pDX, IDC_STATIC_RETURN_MONEY, m_return_money);
DDX_Text(pDX, IDC_STATIC_ZHEKOU, m_zk);
DDX_Text(pDX, IDC_EDIT_RECIVE_MONEY, m_recive_money);
DDX_Text(pDX, IDC_USERID_STATIC, m_userid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPosClientDlg, CDialog)
//{{AFX_MSG_MAP(CPosClientDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON11, OnInput)
ON_BN_CLICKED(IDC_BUTTON7, OnDanZhekou)
ON_BN_CLICKED(IDC_BUTTON8, OnAllZheKou)
ON_BN_CLICKED(IDC_BUTTON10, OnExit)
ON_BN_CLICKED(IDC_BUTTON1, OnReceiveMoney)
ON_BN_CLICKED(IDC_BUTTON5, OnChangId)
ON_BN_CLICKED(IDC_BUTTON6, OnLockWin)
ON_BN_CLICKED(IDC_BUTTON4, OnFindGoods)
ON_BN_CLICKED(IDC_BUTTON2, OnDelGoods)
ON_BN_CLICKED(IDC_BUTTON3, OnDelAll)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPosClientDlg message handlers
BOOL CPosClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CLoginDlg dlg;
if (dlg.DoModal() != IDOK)
OnOK();
else
//读取用户信息到curUser对象中
curUser.GetData(dlg.m_UserName);
m_ListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);//对
m_ListCtrl.InsertColumn(0,_T("序号"),LVCFMT_IMAGE|LVCFMT_LEFT); //列
m_ListCtrl.InsertColumn(1,"商品编码"); //表
m_ListCtrl.InsertColumn(2,"商品名称"); //框
m_ListCtrl.InsertColumn(3,"单价"); //进
m_ListCtrl.InsertColumn(4,"数量"); //行
m_ListCtrl.InsertColumn(5,"折扣"); //初
m_ListCtrl.InsertColumn(6,"金额"); //始
m_ListCtrl.SetColumnWidth(0,60); //化
m_ListCtrl.SetColumnWidth(1,98); //
m_ListCtrl.SetColumnWidth(2,280); //
m_ListCtrl.SetColumnWidth(3,80); //
m_ListCtrl.SetColumnWidth(4,80); //
m_ListCtrl.SetColumnWidth(5,80); //
m_ListCtrl.SetColumnWidth(6,85); //
zhekou=allzhekou=1.0;
CSells sell;
CSellinfo sellinfo;
sellid=sell.LastID()+1;
count=sellid-1;
CString ttt;
ttt.Format("%d",count);
sell.GetData(ttt);
int a;
CString sss;
a=atoi(sellinfo.LastID())+1;
sss.Format("%d",a);
//判断有没有因为系统非法关闭而在数据库在添加了多余的商品,有的话就删除
if(sell.getN()==sss) {sell.sqldel(sell.getN());sellid=sell.LastID()+1;count=sellid-1;}
exchangnum.Format("%d",a);
UpdateData(true);
m_userid.Format(curUser.GetUserId());
UpdateData(false);
iii=0;
CFont myFont1; //设
CWnd* pWnd; //置
myFont1.CreatePointFont(300,"Rockwell"); //控
pWnd=GetDlgItem(IDC_STATIC_ALL_MONEY); //件
pWnd->SetFont(&myFont1); //的
pWnd=GetDlgItem(IDC_STATIC_RETURN_MONEY);//字
pWnd->SetFont(&myFont1); //体
return TRUE; // return TRUE unless you set the focus to a control
}
void CPosClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPosClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPosClientDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPosClientDlg::OnInput()
{//商品输入函数
UpdateData(true);
CGoods good;
CSells sell;
CString s,goodid;
int num;
float temp=0;
goodid=m_good_id;
num=m_good_num;
m_ListCtrl.DeleteAllItems();
//设置控件字体
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);
if(good.HaveId(goodid)==1)
{
good.GetData(goodid);
//判断商品库存是否有
if(good.GetGoodsNum()<=0)
{
MessageBox("购买失败!没有库存!","提示");
UpdateData(true);
m_good_id="";
m_id.SetFocus();
UpdateData(false);
return;
}
}
else
{
MessageBox("没有此商品!请确认后重新输入商品编号!","友情提示");
m_good_id="";
UpdateData(false);
m_id.SetFocus();
Show(exchangnum);
return;
}
//往数据库在添加销售信息
sell.iId(sellid);
sell.insId(m_good_id);
sell.insNum(m_good_num);
sell.insDiscount(zhekou);
sell.insN(exchangnum);
sell.sql_insert();
Show(exchangnum);
goodids[iii]=goodid;
goodnums[iii]=num;
iii++;
m_good_id="";
m_good_num=1;
zhekou=1.0;
sellid++;
m_zk.Format("1.00");
m_id.SetFocus();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -