📄 table2dialog.cpp
字号:
// table2Dialog.cpp : implementation file
//
#include "stdafx.h"
#include "MyWork.h"
#include "table2Dialog.h"
#include "Set2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Ctable2Dialog dialog
Ctable2Dialog::Ctable2Dialog(CWnd* pParent /*=NULL*/)
: CDialog(Ctable2Dialog::IDD, pParent)
{
//{{AFX_DATA_INIT(Ctable2Dialog)
m_bc = _T("");
m_cname = _T("");
m_gdx = _T("");
m_jcq = _T("");
m_jyl = _T("");
m_ldx = _T("");
m_num = _T("");
m_spz = _T("");
m_count = 0;
m_set2=NULL;
flag=false;
m_time = _T("");
//}}AFX_DATA_INIT
}
void Ctable2Dialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Ctable2Dialog)
DDX_Control(pDX, IDC_COMBO4, m_combo4);
DDX_Control(pDX, IDC_COMBO3, m_combo3);
DDX_Control(pDX, IDC_COMBO2, m_combo2);
DDX_Control(pDX, IDC_COMBO1, m_combo1);
DDX_Control(pDX, IDC_CHECK_GDX, m_concheck4);
DDX_Control(pDX, IDC_CHECK_LDX, m_concheck3);
DDX_Control(pDX, IDC_CHECK_SPZ, m_concheck2);
DDX_Control(pDX, IDC_CHECK_CNAME, m_concheck1);
DDX_Text(pDX, IDC_EDIT_BC, m_bc);
DDX_Text(pDX, IDC_EDIT_CNAME, m_cname);
DDX_Text(pDX, IDC_EDIT_GDX, m_gdx);
DDX_Text(pDX, IDC_EDIT_JCQ, m_jcq);
DDX_Text(pDX, IDC_EDIT_JYL, m_jyl);
DDX_Text(pDX, IDC_EDIT_LDX, m_ldx);
DDX_Text(pDX, IDC_EDIT_NUM, m_num);
DDX_Text(pDX, IDC_EDIT_SPZ, m_spz);
DDX_Text(pDX, IDC_EDIT_COUNT, m_count);
DDX_Text(pDX, IDC_EDIT_TIME, m_time);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Ctable2Dialog, CDialog)
//{{AFX_MSG_MAP(Ctable2Dialog)
ON_BN_CLICKED(IDC_BUTTON_MOVEFIRST, OnButtonMovefirst)
ON_BN_CLICKED(IDC_BUTTON_MOVELAST, OnButtonMovelast)
ON_BN_CLICKED(IDC_BUTTON_MOVENEXT, OnButtonMovenext)
ON_BN_CLICKED(IDC_BUTTON_MOVEPRE, OnButtonMovepre)
ON_BN_CLICKED(IDC_CAIXUN, OnCaixun)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Ctable2Dialog message handlers
void Ctable2Dialog::OnButtonMovefirst()
{
// TODO: Add your control notification handler code here
if (flag)
{
m_set2->MoveFirst();
m_cname=m_set2->m_herbal_cname;
m_bc=m_set2->m_herbal_cybc;
m_gdx=m_set2->m_herbal_gdx;
m_ldx=m_set2->m_herbal_ldx;
m_jcq=m_set2->m_herbal_jcq;
m_spz=m_set2->m_herbal_spz;
m_jyl=m_set2->m_herbal_jyl;
m_num=m_set2->m_herbal_number;
thetime1=m_set2->m_herbal_datetime;
ss=thetime1.Format("%H:%M:%S %A,%B %d,%Y");
m_time=ss;
UpdateData(false);
}
else MessageBox("此前没有记录,请先打开记录!","操作失败!",MB_ICONINFORMATION);
}
void Ctable2Dialog::OnButtonMovelast()
{
// TODO: Add your control notification handler code here
if (flag)
{
m_set2->MoveLast();
m_cname=m_set2->m_herbal_cname;
m_bc=m_set2->m_herbal_cybc;
m_gdx=m_set2->m_herbal_gdx;
m_ldx=m_set2->m_herbal_ldx;
m_jcq=m_set2->m_herbal_jcq;
m_spz=m_set2->m_herbal_spz;
m_jyl=m_set2->m_herbal_jyl;
m_num=m_set2->m_herbal_number;
thetime1=m_set2->m_herbal_datetime;
ss=thetime1.Format("%H:%M:%S %A,%B %d,%Y");
m_time=ss;
UpdateData(false);
}
else MessageBox("此前没有记录,请先打开记录!","操作失败!",MB_ICONINFORMATION);
}
void Ctable2Dialog::OnButtonMovenext()
{
// TODO: Add your control notification handler code here
if (flag)
{
m_set2->MoveNext();
if (m_set2->IsEOF())
{
m_set2->MoveLast();
MessageBox("记录移到最后!","移动记录!",MB_ICONINFORMATION);
}
m_cname=m_set2->m_herbal_cname;
m_bc=m_set2->m_herbal_cybc;
m_gdx=m_set2->m_herbal_gdx;
m_ldx=m_set2->m_herbal_ldx;
m_jcq=m_set2->m_herbal_jcq;
m_spz=m_set2->m_herbal_spz;
m_jyl=m_set2->m_herbal_jyl;
m_num=m_set2->m_herbal_number;
thetime1=m_set2->m_herbal_datetime;
ss=thetime1.Format("%H:%M:%S %A,%B %d,%Y");
m_time=ss;
UpdateData(false);
}
else MessageBox("此前没有记录,请先打开记录!","操作失败!",MB_ICONINFORMATION);
}
void Ctable2Dialog::OnButtonMovepre()
{
// TODO: Add your control notification handler code here
if (flag)
{
m_set2->MovePrev();
if (m_set2->IsBOF())
{
m_set2->MoveFirst();
MessageBox("记录移到最前!","移动记录!",MB_ICONINFORMATION);
}
m_cname=m_set2->m_herbal_cname;
m_bc=m_set2->m_herbal_cybc;
m_gdx=m_set2->m_herbal_gdx;
m_ldx=m_set2->m_herbal_ldx;
m_jcq=m_set2->m_herbal_jcq;
m_spz=m_set2->m_herbal_spz;
m_jyl=m_set2->m_herbal_jyl;
m_num=m_set2->m_herbal_number;
thetime1=m_set2->m_herbal_datetime;
ss=thetime1.Format("%H:%M:%S %A,%B %d,%Y");;
m_time=ss;
UpdateData(false);
}
else MessageBox("此前没有记录,请先打开记录!","操作失败!",MB_ICONINFORMATION);
}
void Ctable2Dialog::OnCaixun()
{
// TODO: Add your control notification handler code here
//查询条件:
int m1,m2,m3,m4;
m1=0;
m2=0;
m3=0;
m4=0;
CString str;
CString temp;
CString lg;
UINT nradio=GetCheckedRadioButton(IDC_RADIO_YU,IDC_RADIO_HUO);
//判断选择了什么运算符
switch (nradio)
{
case IDC_RADIO_YU: lg="and"; break;
case IDC_RADIO_HUO: lg="or"; break;
default:
{ m1=m_concheck1.GetCheck();
m2=m_concheck2.GetCheck();
m3=m_concheck3.GetCheck();
m4=m_concheck4.GetCheck();
if((m1+m2+m3+m4)>=2)
{
MessageBox("你没有选择运算关系,请重选!","操作失败!",MB_ICONINFORMATION);
goto turn;
}
else
if((m1+m2+m3+m4)==0)
{
MessageBox("你没有选择运算关系和查询条件,请重选!","操作失败!",MB_ICONINFORMATION);
goto turn;
}
//break;
}
}
m1=m_concheck1.GetCheck();
m2=m_concheck2.GetCheck();
m3=m_concheck3.GetCheck();
m4=m_concheck4.GetCheck();
if((m1+m2+m3+m4)==0)
{
MessageBox("你没有选择查询条件,请重选!","操作失败!",MB_ICONINFORMATION);
goto turn;
}
// 判断复合选项
if (m_concheck1.GetCheck())
{
m_combo1.GetWindowText(temp);
str+=" herbal_cname='"+temp+"' ";
str+=lg;
}
if (m_concheck2.GetCheck())
{
m_combo2.GetWindowText(temp);
str+=" herbal_spz like'%"+temp+"%' ";
str+=lg;
}
if (m_concheck3.GetCheck())
{
m_combo3.GetWindowText(temp);
str+=" herbal_ldx like'%"+temp+"%' ";
str+=lg;
}
if (m_concheck4.GetCheck())
{
m_combo4.GetWindowText(temp);
str+=" herbal_gdx like'%"+temp+"%' ";
str+=lg;
}
if (lg=="and")
str=str.Left(str.GetLength()-3);
else if (lg=="or")
str=str.Left(str.GetLength()-2);
MessageBox(str);
//记录查询
m_set2=new Set2 (&db);
m_set2->m_strFilter=str;
m_set2->Open();
flag=true;
if (!m_set2->IsBOF())
m_set2->MoveFirst();
while (!m_set2->IsEOF())
m_set2->MoveNext();
nCnt=m_set2->GetRecordCount();
m_count=nCnt;
m_set2->MoveFirst();
m_cname=m_set2->m_herbal_cname;
m_bc=m_set2->m_herbal_cybc;
m_gdx=m_set2->m_herbal_gdx;
m_ldx=m_set2->m_herbal_ldx;
m_jcq=m_set2->m_herbal_jcq;
m_spz=m_set2->m_herbal_spz;
m_jyl=m_set2->m_herbal_jyl;
m_num=m_set2->m_herbal_number;
thetime1=m_set2->m_herbal_datetime;
ss=thetime1.Format("%H:%M:%S %A,%B %d,%Y");
m_time=ss;
UpdateData(false);
turn: m1=m1;
}
void Ctable2Dialog::OnOK()
{
// TODO: Add extra validation here
if (flag)
{
if (m_set2->IsOpen())
{
m_set2->Close();
delete m_set2;
}
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -