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

📄 listbugmandlg.cpp

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

#include "stdafx.h"
#include "CarService.h"
#include "ListBugManDlg.h"
#include "ListBugEditDlg.h"
#include "ListBug.h"
#include "Registration.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

/////////////////////////////////////////////////////////////////////////////
// CListBugManDlg dialog


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


void CListBugManDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CListBugManDlg)
	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(CListBugManDlg, CDialog)
	//{{AFX_MSG_MAP(CListBugManDlg)
	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()

/////////////////////////////////////////////////////////////////////////////
// CListBugManDlg message handlers

BOOL CListBugManDlg::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 CListBugManDlg::OnAddButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	
	// 初始化ListBugEditDlg对话框中的变量
	CListBugEditDlg dlg;
	dlg.cListId = "";   //设置列表编号初始值
	dlg.cRegId = cRegId;//设置登记编号
	// 打开ListBugEditDlg对话框
	if (dlg.DoModal() == IDOK)
		RefreshData();		
}

void CListBugManDlg::OnModiButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_Adodc.GetRecordset().GetEof()) 
	{
		MessageBox("请选择要修改的记录");
		return;
	}
	
	// 初始化ListBugEditDlg对话框中的变量
	CListBugEditDlg dlg;
	dlg.cListId = m_Datagrid.GetItem(0);   //设置列表编号初始值
	dlg.cRegId = cRegId;//设置登记编号
	dlg.cBugName = m_Datagrid.GetItem(1); 
	dlg.m_Memo = m_Datagrid.GetItem(4);
	// 打开ListBugEditDlg对话框
	if (dlg.DoModal() == IDOK)
		RefreshData();		
}

void CListBugManDlg::OnDelButton() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if (m_Adodc.GetRecordset().GetEof())
	{
		MessageBox("请选择要删除的记录!");
		return;
	}
	if (MessageBox("是否删除当前记录?","请确认", MB_YESNO + MB_ICONQUESTION) == IDYES)
	{
		// 删除
		CListBug cbug;
		cbug.SqlDelete(m_Datagrid.GetItem(0));
		RefreshData();
	}	
}
// 更新数据
void CListBugManDlg::RefreshData()
{
	UpdateData(TRUE);
	// 设置Select语句
	CString cSource = "SELECT l.ListId,b.BugName AS 故障名称,b.BDetail AS 故障描述,"
		"b.SDetail AS 解决方法,l.Memo AS 维修处理方式 FROM ListBug l,Bugs b"
		" Where l.BugId=b.BugId And RegId=" + cRegId ;

	//刷新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(150);
	vIndex = long(2);  //故障描述
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(150);
	vIndex = long(3);
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(150);
	vIndex = long(4);  //维修处理方式
	m_Datagrid.GetColumns().GetItem(vIndex).SetWidth(150);
}

⌨️ 快捷键说明

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