📄 lurudialog.cpp
字号:
// luruDialog.cpp : implementation file
//
#include "stdafx.h"
#include "MyWork.h"
#include "luruDialog.h"
#include "picDialog.h"//////
#include "Set1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CluruDialog dialog
CluruDialog::CluruDialog(CWnd* pParent /*=NULL*/)
: CDialog(CluruDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CluruDialog)
m_edit_pathname = _T("");
m_pSet=NULL;
flag=false;
//}}AFX_DATA_INIT
}
void CluruDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CluruDialog)
DDX_Control(pDX, IDC_ATTRI_JNAME, m_attri_jname);
DDX_Control(pDX, IDC_ATTRI_ZWXT, m_attri_zwxt);
DDX_Control(pDX, IDC_ATTRI_XZ, m_attri_xz);
DDX_Control(pDX, IDC_ATTRI_XW, m_attri_xw);
DDX_Control(pDX, IDC_ATTRI_PATHNAME, m_attri_pathname);
DDX_Control(pDX, IDC_ATTRI_LY, m_attri_ly);
DDX_Control(pDX, IDC_ATTRI_HXCF, m_attri_hxcf);
DDX_Control(pDX, IDC_ATTRI_GNZZ, m_attri_gnzz);
DDX_Control(pDX, IDC_ATTRI_FZ, m_attri_fz);
DDX_Control(pDX, IDC_ATTRI_ENAME, m_attri_ename);
DDX_Control(pDX, IDC_ATTRI_CZ, m_attri_cz);
DDX_Control(pDX, IDC_ATTRI_CNAME, m_attri_cname);
DDX_Control(pDX, IDC_ATTRI_BNAME, m_attri_bname);
DDX_Text(pDX, IDC_ATTRI_PATHNAME, m_edit_pathname);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CluruDialog, CDialog)
//{{AFX_MSG_MAP(CluruDialog)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_LIULAN, OnLiulan)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CluruDialog message handlers
void CluruDialog::OnButton2()
{
// TODO: Add your control notification handler code here
CDatabase db;
m_pSet=new Set1(&db);
if(!m_pSet->IsOpen())
m_pSet->Open();
flag=true;
////////////////////////////
//判断关键字是否为空?
CString temp;
m_attri_cname.GetWindowText(temp);
int blank;
blank=temp.Compare("");
if (blank==0)
{
MessageBox("不能录入空记录!","警告!",MB_ICONINFORMATION);
return;
}
//判断关键字是否重复?
m_pSet->MoveFirst();
while (!m_pSet->IsEOF())
{
int zz;
int longth;
CString temp_set;
longth=temp.GetLength();
temp_set=m_pSet->m_name_c.Left(longth);
zz=temp.Compare(temp_set);
if (zz!=0)
m_pSet->MoveNext();
else
{
MessageBox("数据库中已有该种中药材的记载,请查看中药材属性表!","数据重复!",MB_ICONINFORMATION);
return;
}
}
/////////////////////////////
//添加新纪录到数据库中:
m_pSet->AddNew();
m_attri_cname.GetWindowText(m_pSet->m_name_c);
m_attri_ename.GetWindowText(m_pSet->m_name_e);
m_attri_bname.GetWindowText(m_pSet->m_name_b);
m_attri_jname.GetWindowText(m_pSet->m_name_j);
m_attri_ly.GetWindowText(m_pSet->m_herbal_ly);
m_attri_zwxt.GetWindowText(m_pSet->m_herbal_zwxt);
m_attri_xz.GetWindowText(m_pSet->m_herbal_xz);
m_attri_cz.GetWindowText(m_pSet->m_herbal_cz );
m_attri_hxcf.GetWindowText (m_pSet->m_herbal_hxcf );
m_attri_xw.GetWindowText (m_pSet->m_herbal_xw );
m_attri_gnzz.GetWindowText (m_pSet->m_herbal_gnzz );
m_attri_fz.GetWindowText (m_pSet->m_herbal_fz );
m_attri_pathname.GetWindowText(m_pSet->m_herbal_pathname );
m_pSet->Update();
m_pSet->Requery();
MessageBox("你已成功向数据库添加一条药材属性记录!,可选择继续添加!","数据添加成功!",MB_ICONINFORMATION);
m_attri_cname.SetWindowText("");
m_attri_ename.SetWindowText("");
m_attri_jname.SetWindowText("");
m_attri_bname.SetWindowText("");
m_attri_ly.SetWindowText("");
m_attri_cz.SetWindowText("");
m_attri_xw.SetWindowText("");
m_attri_xz.SetWindowText("");
m_attri_zwxt.SetWindowText("");
m_attri_gnzz.SetWindowText("");
m_attri_fz.SetWindowText("");
m_attri_hxcf.SetWindowText("");
m_attri_pathname.SetWindowText("");
}
void CluruDialog::OnOK()
{
// TODO: Add extra validation here
if (flag)
{
if (m_pSet->IsOpen())
{
m_pSet->Close();
delete m_pSet;
}
}
CDialog::OnOK();
}
void CluruDialog::OnLiulan()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,_T("BMP"),_T("*.BMP"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("文本文件(*.BMP)|*.BMP|"));
if(IDOK==dlg.DoModal())
{
Bmpname.Format("%s",dlg.GetPathName());
m_edit_pathname=Bmpname;
UpdateData(false);
//显示图片
CpicDialog dlg;
dlg.Getpath(Bmpname);
dlg.DoModal();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -