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

📄 bugmandlg.cpp

📁 VC++做的汽车维修管理系统,很有参考价值的,附上源码与说明文档.
💻 CPP
字号:
// BugManDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CarService.h"
#include "BugManDlg.h"
#include "BugEditDlg.h"
#include "Bugs.h"
#include "COMDEF.H"
#include "Columns.h"
#include "Column.h"
#include "_Recordset.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBugManDlg dialog


CBugManDlg::CBugManDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBugManDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBugManDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CBugManDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBugManDlg)
	DDX_Control(pDX, IDC_MODI_BUTTON, m_Modi);
	DDX_Control(pDX, IDC_DEL_BUTTON, m_Del);
	DDX_Control(pDX, IDC_ADD_BUTTON, m_Add);
	DDX_Control(pDX, IDC_ADODC1, m_Adodc);
	DDX_Control(pDX, IDC_DATAGRID1, m_Datagrid);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CBugManDlg message handlers

void CBugManDlg::OnAddButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	// 初始化BugEditDlg对话框中的变量
	CBugEditDlg dlg;
	dlg.cBugId = "";   //设置编号初始值
	// 打开BugEditDlg对话框
	if (dlg.DoModal() == IDOK)
		RefreshData();			
}

void CBugManDlg::OnModiButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_Adodc.GetRecordset().GetEof()) 
	{
		MessageBox("请选择要修改的记录");
		return;
	}
	
	// 设置BugEditDlg对话框中的变量
	CBugEditDlg dlg;
	dlg.cBugId = m_Datagrid.GetItem(0);
	dlg.m_Name = m_Datagrid.GetItem(1);
	dlg.m_bDetail = m_Datagrid.GetItem(2); 
	dlg.m_sDetail = m_Datagrid.GetItem(3);

	// 打开BugEditDlg对话框
	if (dlg.DoModal() == IDOK)
		RefreshData();	
}

void CBugManDlg::OnDelButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_Adodc.GetRecordset().GetEof())
	{
		MessageBox("请选择要删除的记录!");
		return;
	}

	// 判断项目列表ListBug是否包含此故障编号
/*	if(m_Datagrid.GetItem(0) == "admin")
	{
		MessageBox("此用户为默认用户,不能删除!");
		return;
	}
*/
	if (MessageBox("是否删除当前记录?","请确认", MB_YESNO + MB_ICONQUESTION) == IDYES)
	{
		// 删除
		CBugs bug;
		bug.SqlDelete(m_Datagrid.GetItem(0));
		RefreshData();
	}	
}
// 更新数据
void CBugManDlg::RefreshData()
{
	UpdateData(TRUE);
	// 设置Select语句
	CString cSource = "SELECT BugId,BugName AS 故障名称,BDetail AS 故障描述,"
		"SDetail AS 故障处理 FROM Bugs Order By BugId";

	//刷新ADO Data控件的记录源
	m_Adodc.SetRecordSource(cSource);
	m_Adodc.Refresh();
	
	//设置列宽度
	_variant_t vIndex;
	vIndex = long(0);
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(0);
	vIndex = long(1);  //故障名称
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(100);
	vIndex = long(2);  //故障描述
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(200);
	vIndex = long(3);  //故障处理
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(200);
}

BOOL CBugManDlg::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
}

⌨️ 快捷键说明

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