📄 newsaleman.cpp
字号:
// NewSaleMan.cpp : implementation file
//
#include "stdafx.h"
#include "ShopManage.h"
#include "NewSaleMan.h"
#include "DataManage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _RecordsetPtr Record1;
extern _ConnectionPtr DataConn;
extern _RecordsetPtr DataRecord;
extern _CommandPtr Com;
/////////////////////////////////////////////////////////////////////////////
// NewSaleMan dialog
NewSaleMan::NewSaleMan(CWnd* pParent /*=NULL*/)
: CDialog(NewSaleMan::IDD, pParent)
{
//{{AFX_DATA_INIT(NewSaleMan)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void NewSaleMan::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(NewSaleMan)
DDX_Control(pDX, IDC_Telephone, m_Telephone);
DDX_Control(pDX, IDC_Name, m_Name);
DDX_Control(pDX, IDC_MailCode, m_MailCode);
DDX_Control(pDX, IDC_LinkTelephone, m_LinkTelephone);
DDX_Control(pDX, IDC_LinkMan, m_LinkMan);
DDX_Control(pDX, IDC_Address, m_Address);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(NewSaleMan, CDialog)
//{{AFX_MSG_MAP(NewSaleMan)
ON_BN_CLICKED(IDQUIT, OnQuit)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// NewSaleMan message handlers
void NewSaleMan::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void NewSaleMan::OnQuit()
{
// TODO: Add your control notification handler code here
EndDialog(0);
}
void NewSaleMan::OnAdd()
{
// TODO: Add your control notification handler code here
CString SaleManID,Name,MailCode,Address,Telephone,LinkMan,LinkTelephone;
CString sql;
CDataManage dm;
/*Name*/
m_Name.GetWindowText(Name);
if(Name.GetLength() == 0)
{
MessageBox("请输入供应商信息","提示");
return;
}
/*SaleManID*/
/**************************************************/
try
{
dm.ConnectDataBase();
Record1->Open(_variant_t("SaleMan"),
_variant_t((IDispatch *)DataConn,true), adOpenKeyset,
adLockOptimistic, adCmdTable);
}
catch (_com_error& e)
{
MessageBox(e.ErrorMessage(),"提示");
}
/*****************************************/
sql.Format("select SaleManID from SaleMan");
try
{
Record1->raw_Close();
Record1->Open((_variant_t)sql,DataConn.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
}
catch(_com_error &e)
{
MessageBox(e.ErrorMessage(),"提示");
}
if(Record1->RecordCount > 0)
{
Record1->MoveLast();
SaleManID = (TCHAR*)(_bstr_t)Record1->GetFields()->GetItem((long)0)->Value;
int salemanid = atoi(SaleManID);
salemanid+=1;
SaleManID.Format("%d",salemanid);
}
else
{
SaleManID = "20060001";
}
/********************************************************************/
/*Other information*/
m_MailCode.GetWindowText(MailCode);
m_Address.GetWindowText(Address);
m_Telephone.GetWindowText(Telephone);
m_LinkMan.GetWindowText(LinkMan);
m_LinkTelephone.GetWindowText(LinkTelephone);
sql.Format("insert into SaleMan values('%s','%s','%s','%s','%s','%s','%s')",
SaleManID,Name,MailCode,Address,Telephone,LinkMan,LinkTelephone);
try
{
dm.ExecSQL(sql);
this->MessageBox("操作成功","提示");
}
catch(_com_error &e)
{
MessageBox(e.ErrorMessage(),"提示");
}
/*********************************************************************/
m_Name.SetWindowText("");
m_MailCode.SetWindowText("");
m_Address.SetWindowText("");
m_Telephone.SetWindowText("");
m_LinkMan.SetWindowText("");
m_LinkTelephone.SetWindowText("");
}
void NewSaleMan::OnClose()
{
// TODO: Add your message handler code here and/or call default
//CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -