📄 dcarback.cpp
字号:
// DCarBack.cpp : implementation file
//
#include "stdafx.h"
#include "myproject.h"
#include "DCarBack.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Lkic32.h"
/////////////////////////////////////////////////////////////////////////////
// CDCarBack dialog
#define CARDTYPE 32
CDCarBack::CDCarBack(CWnd* pParent /*=NULL*/)
: CDialog(CDCarBack::IDD, pParent)
{
m_IsOver=true;
//{{AFX_DATA_INIT(CDCarBack)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDCarBack::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDCarBack)
DDX_Control(pDX, IDC_STATIT, m_Static);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDCarBack, CDialog)
//{{AFX_MSG_MAP(CDCarBack)
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDCarBack message handlers
void CDCarBack::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
BOOL CDCarBack::OnInitDialog()
{
CDialog::OnInitDialog();
this->SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
CRect rcWnd;
this->GetClientRect(rcWnd);
CRgn rgn;
rgn.CreateRoundRectRgn(rcWnd.left,rcWnd.top,rcWnd.Width(),rcWnd.Height(),12,12);
this->SetWindowRgn(rgn,true);
m_Static.SetBkColor();
m_handle=IC_InitComm(0);
IC_InitType(m_handle,CARDTYPE); //设置IC卡类型
this->SetTimer(1,300,NULL);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDCarBack::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcWnd;
this->GetClientRect(&rcWnd);
dc.FillSolidRect(rcWnd,RGB(0,0,0));
// Do not call CDialog::OnPaint() for painting messages
}
void CDCarBack::OnTimer(UINT nIDEvent)
{
//从IC卡机读取数据
CDialog::OnTimer(nIDEvent);
if(m_IsOver==true)
//读取IC卡记录的员工编号
{
m_IsOver=false;
unsigned char *lpID=new unsigned char[5];
IC_Read(m_handle,0,5,lpID);
char* lpTemp=new char[5];
strcpy(lpTemp,(char*)lpID);
CString sText;
sText.Format("%s",lpTemp);
free(lpID);
free(lpTemp);
//验证
CString sSQL;
sSQL.Format("SELECT * FROM 驾驶员信息表 WHERE 编号='%s'",sText);
RxRecordset rst;
rst.Open(sSQL,adCmdText);
if(rst.GetRecordCount()<1)
{
m_IsOver=true;
return;
}
else
{
//修改车辆信息表
sSQL.Format("UPdate 车辆信息表 set 回厂标志=-1 Where 编号=(select b.车辆编号 from 配送申请表 a inner join 配送审核表 b on a.配送票号=b.配送票号 WHERE 开票日期=(select MAX (c.开票日期) AS 日期 from 配送申请表 c inner join 配送审核表 d on c.配送票号=d.配送票号 WHERE d.司机编号=%s) AND b.司机编号=%s)",sText,sText);
rst.Open(sSQL,adCmdText);
//增加回厂记录
sSQL.Format("insert into 派车回厂确认表 select a.配送票号,b.司机编号 AS 驾驶员编号,getdate() as 回厂时间 from 配送申请表 a inner join 配送审核表 b on a.配送票号=b.配送票号 WHERE 开票日期=(select MAX (c.开票日期) AS 日期 from 配送申请表 c inner join 配送审核表 d on c.配送票号=d.配送票号 WHERE d.司机编号=%s) AND b.司机编号=%s",sText,sText);
rst.Open(sSQL,adCmdText);
//吉A-45321回厂确认成功
sSQL.Format("select e.主车牌照+' 回厂确认成功' AS 消息 from 配送申请表 a inner join 配送审核表 b on a.配送票号=b.配送票号 inner join 车辆信息表 e ON b.车辆编号=e.编号 WHERE 开票日期=(select MAX (c.开票日期) AS 日期 from 配送申请表 c inner join 配送审核表 d on c.配送票号=d.配送票号 WHERE d.司机编号=%s) AND b.司机编号=%s",sText,sText);
rst.Open(sSQL,adCmdText);
this->m_Static.SetWindowText(rst.GetFieldValue("消息"));
this->Invalidate();
m_IsOver=true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -