⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typedlg.cpp

📁 用VC和SQL Server开发的固定资产管理系统
💻 CPP
字号:
// TypeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AssetsMan.h"
#include "TypeDlg.h"
#include "Type.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTypeDlg dialog


CTypeDlg::CTypeDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTypeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTypeDlg)
	m_TypeName = _T("");
	//}}AFX_DATA_INIT
}


void CTypeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTypeDlg)
	DDX_Control(pDX, IDC_ADODC1, m_AdoType);
	DDX_Control(pDX, IDC_DATALIST1, m_DataType);
	DDX_Text(pDX, IDC_EDIT1, m_TypeName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTypeDlg, CDialog)
	//{{AFX_MSG_MAP(CTypeDlg)
	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()

/////////////////////////////////////////////////////////////////////////////
// CTypeDlg message handlers

BEGIN_EVENTSINK_MAP(CTypeDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CTypeDlg)
	ON_EVENT(CTypeDlg, IDC_DATALIST1, -600 /* Click */, OnClickDatalist1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CTypeDlg::OnClickDatalist1() 
{
	// TODO: Add your control notification handler code here
	m_TypeName = m_DataType.GetText();
	cTypeId = m_DataType.GetBoundText();
	cTypeNameOld = m_DataType.GetText();
	UpdateData(FALSE);
}

void CTypeDlg::OnAddButton() 
{
	// 将用户输入数据读取到成员变量中
	UpdateData(TRUE);
	//判断类别名称是否为空
	if (m_TypeName == "")
	{
		MessageBox("请输入类别名称");
		return;
	}
	//保存数据
	CType obj;
	obj.SetTypeName(m_TypeName);
	if(obj.HaveName(m_TypeName) == 1)
		MessageBox("此类别名称已经存在!");
	else
	{
		obj.sql_Insert();
		m_AdoType.Refresh();
	}
}

void CTypeDlg::OnModiButton() 
{
	UpdateData(TRUE);
	//判断是否选择了要修改的类别
	if (m_DataType.GetText() == "")
	{
		MessageBox("请选择要修改的类别名称");
		return;
	}
	//判断部门名称是否为空
	if (m_TypeName == "")
	{
		MessageBox("请输入类别名称");
		return;
	}

	// 如果不同则查看数据库是否已经存在新的部门名称
	if(cTypeNameOld!=m_TypeName)
	{
		CType obj;
		obj.SetTypeName(m_TypeName);
		if (obj.HaveName(m_TypeName) == 1)
			MessageBox("此类别名称已经存在!");
		else
		{
			obj.sql_Update(cTypeId);
			m_AdoType.Refresh();
		}
	}
}

void CTypeDlg::OnDelButton() 
{
	// TODO: Add your control notification handler code here
	CType obj;
	obj.sql_Delete(cTypeId);
	m_AdoType.Refresh();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -