ProTypeManDlg.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:5k
源码类别:
数据库系统
开发平台:
Visual C++
- // ProTypeManDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "ProTypeManDlg.h"
- #include "ProTypeEditDlg.h"
- #include "ProType.h"
- #include "Product.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CProTypeManDlg dialog
- CProTypeManDlg::CProTypeManDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CProTypeManDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CProTypeManDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CProTypeManDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CProTypeManDlg)
- DDX_Control(pDX, IDC_ADODC1, m_adodc1);
- DDX_Control(pDX, IDC_ADODC2, m_adodc2);
- DDX_Control(pDX, IDC_DATALIST1, m_datalist1);
- DDX_Control(pDX, IDC_DATALIST2, m_datalist2);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CProTypeManDlg, CDialog)
- //{{AFX_MSG_MAP(CProTypeManDlg)
- ON_BN_CLICKED(IDC_ADD1_BUTTON, OnAdd1Button)
- ON_BN_CLICKED(IDC_MODI1_BUTTON, OnModi1Button)
- ON_BN_CLICKED(IDC_DEL1_BUTTON, OnDel1Button)
- ON_BN_CLICKED(IDC_ADD2_BUTTON, OnAdd2Button)
- ON_BN_CLICKED(IDC_MODI2_BUTTON, OnModi2Button)
- ON_BN_CLICKED(IDC_DEL2_BUTTON, OnDel2Button)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CProTypeManDlg message handlers
- void CProTypeManDlg::OnAdd1Button()
- {
- // TODO: Add your control notification handler code here
- CProTypeEditDlg dlg;
- dlg.cTypeId = ""; //表示添加记录
- dlg.cTypeName = "";
- dlg.iUpperId = 0; //表示一级类别
- //打开编辑对话框
- if (dlg.DoModal() == IDOK)
- m_adodc1.Refresh();
- }
- void CProTypeManDlg::OnModi1Button()
- {
- // TODO: Add your control notification handler code here
- if (m_datalist1.GetText() == "")
- {
- MessageBox("请选择要修改的产品类别");
- return;
- }
- CProTypeEditDlg dlg;
- dlg.cTypeId = m_datalist1.GetBoundText(); //表示修改记录
- dlg.cTypeName = m_datalist1.GetText();
- dlg.iUpperId = 0; //表示一级类别
- dlg.m_TypeName = m_datalist1.GetText();
- dlg.m_Upper = "";
- //打开编辑对话框
- if (dlg.DoModal() == IDOK)
- m_adodc1.Refresh();
- }
- void CProTypeManDlg::OnDel1Button()
- {
- // TODO: Add your control notification handler code here
- if (m_datalist1.GetText() == "")
- {
- MessageBox("请选择要删除的产品类别");
- return;
- }
- CString Tid;
- Tid = m_datalist1.GetBoundText();
- //判断是否包含下级类别
- CProType pt;
- if (pt.HaveSon(Tid) == 1)
- {
- MessageBox("当前类别包含下级类别,不能删除");
- return;
- }
- //确定是否删除
- if (MessageBox("是否删除当前类别", "请确认", MB_YESNO) == IDYES)
- {
- pt.sql_delete(Tid); //删除
- m_adodc1.Refresh(); //刷新
- }
- }
- BEGIN_EVENTSINK_MAP(CProTypeManDlg, CDialog)
- //{{AFX_EVENTSINK_MAP(CProTypeManDlg)
- ON_EVENT(CProTypeManDlg, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
- void CProTypeManDlg::OnClickDatalist1()
- {
- // TODO: Add your control notification handler code here
- CString cUpper;
- cUpper = m_datalist1.GetBoundText(); //读取选择类别的编号
- //设置二级类别的记录源
- m_adodc2.SetRecordSource("SELECT * FROM ProType WHERE UpperId=" + cUpper);
- m_adodc2.Refresh();
- }
- void CProTypeManDlg::OnAdd2Button()
- {
- // TODO: Add your control notification handler code here
- if (m_datalist1.GetText() == "")
- {
- MessageBox("请选择上级产品类别");
- return;
- }
- CProTypeEditDlg dlg;
- dlg.cTypeId = ""; //表示添加记录
- dlg.cTypeName = "";
- dlg.iUpperId = atoi(m_datalist1.GetBoundText()); //设置上级类别编号
- dlg.m_TypeName = "";
- dlg.m_Upper = m_datalist1.GetText();
- //打开编辑对话框
- if (dlg.DoModal() == IDOK)
- OnClickDatalist1();
- }
- void CProTypeManDlg::OnModi2Button()
- {
- // TODO: Add your control notification handler code here
- if (m_datalist2.GetText() == "")
- {
- MessageBox("请选择要修改的产品类别");
- return;
- }
- CProTypeEditDlg dlg;
- dlg.cTypeId = m_datalist2.GetBoundText(); //表示修改记录
- dlg.cTypeName = m_datalist2.GetText();
- dlg.iUpperId = atoi(m_datalist1.GetBoundText()); //上级类别编号
- dlg.m_TypeName = m_datalist2.GetText();
- dlg.m_Upper = m_datalist1.GetText();
- //打开编辑对话框
- if (dlg.DoModal() == IDOK)
- OnClickDatalist1();
- }
- void CProTypeManDlg::OnDel2Button()
- {
- // TODO: Add your control notification handler code here
- if (m_datalist2.GetText() == "")
- {
- MessageBox("请选择要删除的产品类别");
- return;
- }
- CString Tid;
- Tid = m_datalist2.GetBoundText();
- //判断类别中是否包含产品
- CProduct pro;
- if (pro.HaveType(Tid) == 1)
- {
- MessageBox("当前类别中包含产品,不能删除");
- return;
- }
- //确定是否删除
- if (MessageBox("是否删除当前类别", "请确认", MB_YESNO) == IDYES)
- {
- CProType pt;
- pt.sql_delete(Tid); //删除
- OnClickDatalist1(); //刷新
- }
- }