📄 clientregedit.cpp
字号:
// ClientRegedit.cpp : implementation file
//
#include "stdafx.h"
#include "SuperMarket.h"
#include "ClientRegedit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientRegedit dialog
CClientRegedit::CClientRegedit(CWnd* pParent /*=NULL*/)
: CDialog(CClientRegedit::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientRegedit)
m_strFax = _T("");
m_strDes = _T("");
m_strAddr = _T("");
m_strName = _T("");
m_strPhone = _T("");
m_strPost = _T("");
m_intID = 0;
m_strPwd1 = _T("");
m_strPwd2 = _T("");
boolModify=false;
//}}AFX_DATA_INIT
}
void CClientRegedit::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientRegedit)
DDX_Text(pDX, IDC_CFAX, m_strFax);
DDX_Text(pDX, IDC_CDESCRIPTION, m_strDes);
DDX_Text(pDX, IDC_ADDR, m_strAddr);
DDX_Text(pDX, IDC_CNAME, m_strName);
DDX_Text(pDX, IDC_CPHONE, m_strPhone);
DDX_Text(pDX, IDC_CPOST, m_strPost);
DDX_Text(pDX, IDC_CID, m_intID);
DDX_Text(pDX, IDC_CPWD1, m_strPwd1);
DDX_Text(pDX, IDC_CPWD2, m_strPwd2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientRegedit, CDialog)
//{{AFX_MSG_MAP(CClientRegedit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientRegedit message handlers
void CClientRegedit::OnOK()
{
// TODO: Add extra validation here
if(boolModify==true)
{
UpdateData(true);
m_pRecordset1.CreateInstance(__uuidof(Recordset));
try
{
//从SQL数据库中打开Clients表
// m_pRecordset->Close();
m_pRecordset1->Open("SELECT*FROM Client",
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
_variant_t var;
CString str;
try
{
var.iVal=m_intID;
m_pRecordset1->PutCollect("Cid",var.iVal);
m_pRecordset1->PutCollect("Cname",_variant_t(m_strName));
m_pRecordset1->PutCollect("Address",_variant_t(m_strAddr));
m_pRecordset1->PutCollect("Postcode",_variant_t(m_strPost));
m_pRecordset1->PutCollect("Phone",_variant_t(m_strPhone));
m_pRecordset1->PutCollect("Fax",_variant_t(m_strFax));
m_pRecordset1->PutCollect("Memo",_variant_t(m_strDes));
m_pRecordset1->PutCollect("Cpwd",_variant_t(m_strPwd2));
m_pRecordset1->Update();
m_pRecordset1->MoveLast();
AfxMessageBox("修改成功");
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
else ClientRegedit();
CDialog::OnOK();
}
void CClientRegedit::ClientRegedit()
{
UpdateData(true);
m_pRecordset.CreateInstance(__uuidof(Recordset));
OpenClient();
_variant_t var;
CString str;
if(m_intID!=0&& !m_pRecordset->BOF)
{
m_pRecordset->MoveFirst();
while(!m_pRecordset->adoEOF)
{
var=m_pRecordset->GetCollect("Cid");
if(m_intID==var.iVal)
{
AfxMessageBox("已经存在这个注册号,希望您重新填写客户ID!");
return;
}
m_pRecordset->MoveNext();
}
if(!m_pRecordset->adoEOF)
{
return;
}
MessageBox("BBBBBBBBBBBBBBBBBBBBBB");
}
if(m_strPwd1=="")
{
AfxMessageBox("密码不能为空!");
return;
}
if(m_strPwd1!=m_strPwd2)
{
AfxMessageBox("你两次输入的密码不一致。请你重新输入!");
}
else
{
try
{
m_pRecordset->AddNew();
var.iVal=m_intID;
m_pRecordset->PutCollect("Cid",var.iVal);
m_pRecordset->PutCollect("Cname",_variant_t(m_strName));
m_pRecordset->PutCollect("Address",_variant_t(m_strAddr));
m_pRecordset->PutCollect("Postcode",_variant_t(m_strPost));
m_pRecordset->PutCollect("Phone",_variant_t(m_strPhone));
m_pRecordset->PutCollect("Fax",_variant_t(m_strFax));
m_pRecordset->PutCollect("Memo",_variant_t(m_strDes));
m_pRecordset->PutCollect("Cpwd",_variant_t(m_strPwd1));
m_pRecordset->Update();
m_pRecordset->MoveLast();
AfxMessageBox("注册成功");
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
}
void CClientRegedit::ClientModify()
{
UpdateData(true);
m_pRecordset.CreateInstance(__uuidof(Recordset));
OpenClient();
}
void CClientRegedit::OpenClient()
{
try
{
//从SQL数据库中打开Users表
// AfxMessageBox((theApp.m_pConnection.GetInterfacePtr()));
m_pRecordset->Open("SELECT*FROM Client",
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error*e)
{
AfxMessageBox(e->ErrorMessage());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -