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

📄 dop.cpp

📁 用Visual c++实现的合同管理系统
💻 CPP
字号:
// DOp.cpp : implementation file
//

#include "stdafx.h"
#include "htglxt.h"
#include "DOp.h"
#include "DBaseQuery.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDOp dialog


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


void CDOp::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDOp)
	DDX_Control(pDX, IDC_EDTSPWD, m_EdtSpwd);
	DDX_Control(pDX, IDC_EDTPWD, m_EdtPwd);
	DDX_Control(pDX, IDC_EDTNAME, m_EdtName);
	DDX_Control(pDX, IDC_EDTID, m_EdtID);
	DDX_Control(pDX, IDC_BUTUNDO, m_ButUndo);
	DDX_Control(pDX, IDC_BUTSAVE, m_ButSave);
	DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
	DDX_Control(pDX, IDC_BUTDELE, m_ButDele);
	DDX_Control(pDX, IDC_BUTCHANGE1, m_ButChange);
	DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDOp, CDialog)
	//{{AFX_MSG_MAP(CDOp)
	ON_BN_CLICKED(IDC_BUTADD, OnButadd)
	ON_BN_CLICKED(IDC_BUTCHANGE1, OnButchange1)
	ON_BN_CLICKED(IDC_BUTDELE, OnButdele)
	ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
	ON_BN_CLICKED(IDC_BUTUNDO, OnButundo)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDOp message handlers

void CDOp::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

void CDOp::Clear()
{
	m_EdtSpwd.SetWindowText("");
	m_EdtPwd.SetWindowText("");
	m_EdtName.SetWindowText("");
	m_EdtID.SetWindowText("");

}

void CDOp::Display(CString sID)
{
	if(sID.IsEmpty())
		return;
	CString sSQL;
	RxRecordset drst;
	sSQL.Format("SELECT * FROM 用户信息表 WHERE 编号='%s'",sID);
	drst.Open(sSQL,adCmdText);
	if(drst.GetRecordCount()<1)
		return;
	CString sName,sPwd;
	sName=drst.GetFieldValue("用户名");
	sPwd=drst.GetFieldValue("密码");	
	
	m_EdtID.SetWindowText(sID);
	m_EdtName.SetWindowText(sName);
	m_EdtPwd.SetWindowText(sPwd);
	m_EdtSpwd.SetWindowText(sPwd);
}

void CDOp::Enabled(bool bEnabled)
{
	m_EdtSpwd.EnableWindow(bEnabled);
	m_EdtPwd.EnableWindow(bEnabled);
	m_EdtName.EnableWindow(bEnabled);
	m_ButUndo.EnableWindow(bEnabled);
	m_ButSave.EnableWindow(bEnabled);
	m_ButExit.EnableWindow(!bEnabled);
	m_ButDele.EnableWindow(!bEnabled);
	m_ButChange.EnableWindow(!bEnabled);
	m_ButAdd.EnableWindow(!bEnabled);

}

BOOL CDOp::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	
	CDBaseQuery* ParentWnd=(CDBaseQuery*)FindWindow(NULL,"用户信息查询");
	m_sID=ParentWnd->m_Grid.GetItemText(ParentWnd->m_Grid.GetRow(),0);
	this->Display(m_sID);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDOp::OnButadd() 
{
	AddOrChange=1;
	this->Enabled(true);
	this->Clear();
	CString NewID=ado.AutoNumber("用户信息表","编号","",1);
	m_EdtID.SetWindowText(NewID);
	m_EdtName.SetFocus();
	
}

void CDOp::OnButchange1() 
{
	AddOrChange=2;
	this->Enabled(true);
	m_EdtName.SetFocus();
	
}

void CDOp::OnButdele() 
{
	if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL;
	sSQL.Format("DELETE FROM 用户信息表 WHERE 编号=%s",m_sID);
	RxRecordset Drst;
	Drst.Open(sSQL,adCmdText);
	this->OnCancel();
	
}

void CDOp::OnButsave() 
{
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL,sID,sName,sPwd,sSpwd;
	m_EdtID.GetWindowText(sID);
	m_EdtName.GetWindowText(sName);
	m_EdtPwd.GetWindowText(sPwd);
	m_EdtSpwd.GetWindowText(sSpwd);
	if (sPwd!=sSpwd)
	{
		MessageBox("您两次输入的密码不一致,请确认后重新输入!","系统提示",MB_OK);
		m_EdtPwd.SetWindowText("");
		m_EdtSpwd.SetWindowText("");
		m_EdtPwd.SetFocus();
		return;
	}
	OP=sName;
	if(AddOrChange==1)//添加操作
		sSQL.Format("Insert Into 用户信息表 Values(%s,'%s','%s')",sID,sName,sPwd);
	else
		sSQL.Format("Update 用户信息表 set 用户名='%s',密码='%s' WHERE 编号=%s",sName,sPwd,sID);
	RxRecordset arst;
	arst.Open(sSQL,adCmdText);
	this->Enabled(false);
	this->m_ButAdd.SetFocus();

}

void CDOp::OnButundo() 
{
	if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	this->Enabled(false);
	this->Clear();
	this->Display(m_sID);
	this->m_ButAdd.SetFocus();

}

void CDOp::OnButexit() 
{
this->OnCancel();	
}

⌨️ 快捷键说明

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