📄 typemandlg.cpp
字号:
// TypeManDlg.cpp : implementation file
//
#include "stdafx.h"
#include "QuoteManage.h"
#include "TypeManDlg.h"
#include "Type.h"
#include "FittingInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTypeManDlg dialog
CTypeManDlg::CTypeManDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTypeManDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTypeManDlg)
m_TypeName = _T("");
//}}AFX_DATA_INIT
}
void CTypeManDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTypeManDlg)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATALIST1, m_DataList);
DDX_Text(pDX, IDC_TYPENAME_EDIT, m_TypeName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTypeManDlg, CDialog)
//{{AFX_MSG_MAP(CTypeManDlg)
ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton)
ON_BN_CLICKED(IDC_MODI_BUTTON, OnModiButton)
ON_BN_CLICKED(IDC_DEL_BUTTON, OnDelButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTypeManDlg message handlers
void CTypeManDlg::OnAddButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//判断科室名称是否为空
if (m_TypeName == "")
{
MessageBox("请输入类别名称");
return;
}
CType cBT;
cBT.TypeName = m_TypeName;
// 判断是否有相同的名称
if(cBT.HaveTypeName(cFlag))
{
MessageBox("已经存在此类别名称!");
return;
}
cBT.Flag = atoi(cFlag) ;
cBT.sql_Insert();
RefreshData();
}
void CTypeManDlg::OnModiButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//判断是否选择了要修改的类别
if (m_DataList.GetText() == "")
{
MessageBox("请选择要修改的类别名称");
return;
}
//判断类别名称是否为空
if (m_TypeName == "")
{
MessageBox("请输入类别名称");
return;
}
// 如果不同则查看数据库是否已经存在新的类别名称
if(cTNameOld!=m_TypeName)
{
CType cBT;
cBT.TypeName = m_TypeName;
if(cBT.HaveTypeName(cFlag))
MessageBox("新的类别名称已经存在!");
else
{
cBT.sql_Update(cTId);
RefreshData();
}
}
}
void CTypeManDlg::OnDelButton()
{
// TODO: Add your control notification handler code here
// 删除类别信息
if (cTId=="")
{
MessageBox("请选择要删除的数据");
return;
}
CFittingInfo cfit;
if (cfit.HaveTypeId(cTId,atoi(cFlag)) == 1)
{
MessageBox("配件信息表中存在此编号,不能删除!");
return;
}
if (MessageBox("是否删除当前记录?","请确认", MB_YESNO) == IDYES)
{
CType cBT;
cBT.sql_Delete(cTId);
RefreshData();
}
}
BEGIN_EVENTSINK_MAP(CTypeManDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CTypeManDlg)
ON_EVENT(CTypeManDlg, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CTypeManDlg::OnClickDatalist1()
{
// TODO: Add your control notification handler code here
// 点击类别信息后将类别名称放入编辑框中
m_TypeName = m_DataList.GetText();
cTId = m_DataList.GetBoundText();
cTNameOld = m_DataList.GetText();
UpdateData(FALSE);
}
BOOL CTypeManDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RefreshData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTypeManDlg::RefreshData()
{
UpdateData(TRUE);
// 设置Select语句
CString cSource = "SELECT * FROM Type Where Flag=" + cFlag;
//刷新ADO Data控件的记录源
m_Adodc.SetRecordSource(cSource);
m_Adodc.Refresh();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -