📄 dbiz.cpp
字号:
// DBiz.cpp : implementation file
//
#include "stdafx.h"
#include "源程序.h"
#include "DBiz.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
/////////////////////////////////////////////////////////////////////////////
// CDBiz dialog
CDBiz::CDBiz(CWnd* pParent /*=NULL*/)
: CDialog(CDBiz::IDD, pParent)
{
//{{AFX_DATA_INIT(CDBiz)
//}}AFX_DATA_INIT
}
void CDBiz::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDBiz)
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_DDate);
DDX_Control(pDX, IDC_EDTRem, m_EdtRem);
DDX_Control(pDX, IDC_EDTMoney, m_EdtMoney);
DDX_Control(pDX, IDC_EdtID, m_EdtID);
DDX_Control(pDX, IDC_COMStyle, m_ComStyle);
DDX_Control(pDX, IDC_COMName, m_ComName);
DDX_Control(pDX, IDC_SLIDER1, m_Slider);
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_BUTChange, m_ButChange);
DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDBiz, CDialog)
//{{AFX_MSG_MAP(CDBiz)
ON_BN_CLICKED(IDC_BUTADD, OnButadd)
ON_BN_CLICKED(IDC_BUTChange, OnBUTChange)
ON_BN_CLICKED(IDC_BUTDele, OnBUTDele)
ON_BN_CLICKED(IDC_BUTSave, OnBUTSave)
ON_BN_CLICKED(IDC_BUTUnDo, OnBUTUnDo)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDBiz message handlers
void CDBiz::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CDBiz::Enabled(bool enabled)
{
m_EdtRem.EnableWindow(!enabled);
m_EdtMoney.EnableWindow(!enabled);
m_DDate.EnableWindow(!enabled);
m_ComStyle.EnableWindow(!enabled);
m_ComName.EnableWindow(!enabled);
m_ButUndo.EnableWindow(!enabled);
m_ButSave.EnableWindow(!enabled);
m_ButExit.EnableWindow(enabled);
m_ButDele.EnableWindow(enabled);
m_ButChange.EnableWindow(enabled);
m_ButAdd.EnableWindow(enabled);
m_Slider.EnableWindow(enabled);
}
void CDBiz::Display()
{
_variant_t ID,Date,Name,Style,Money,Rem;
CTime Mydate;
ID=rst->GetCollect("编号");
if(ID.vt==VT_EMPTY)
sID="";
else
sID=(char*)(_bstr_t)ID;
Date=rst->GetCollect("日期");
if(Date.vt==VT_EMPTY)
Mydate=Mydate.GetCurrentTime();
else
{
sDate=(char*)(_bstr_t)Date;
Mydate=function.CStringTOCTime(sDate);
}
Name=rst->GetCollect("客户");
if(Name.vt==VT_EMPTY)
sName="";
else
sName=(char*)(_bstr_t)Name;
Style=rst->GetCollect("往来类型");
if(Style.vt==VT_EMPTY)
sStyle="";
else
sStyle=(char*)(_bstr_t)Style;
Money=rst->GetCollect("涉及金额");
if(Money.vt==VT_EMPTY)
sMoney="";
else
sMoney=(char*)(_bstr_t)Money;
Rem=rst->GetCollect("活动描述");
if(Rem.vt==VT_EMPTY)
sRem="";
else
sRem=(char*)(_bstr_t)Rem;
m_EdtID.SetWindowText(sID);
m_ComName.SetWindowText(sName);
m_ComStyle.SetWindowText(sStyle);
m_EdtMoney.SetWindowText(sMoney);
m_EdtRem.SetWindowText(sRem);
m_DDate.SetTime(&Mydate);
}
BOOL CDBiz::OnInitDialog()
{
CString cSQL;
CDialog::OnInitDialog();
rst.CreateInstance(__uuidof(Recordset));
CTime curtime;
rst=cnn->Execute((_bstr_t)"客户通讯表",NULL,adCmdTable);
if(function.RecordCount(rst)>0)
{
m_ComName.record=rst;
m_ComName.DateBaseName="客户通讯表";
m_ComName.IDStyle=2;
m_ComName.Init("姓名");
}
rst->Close();
rst=cnn->Execute((_bstr_t)"商业往来类型表",NULL,adCmdTable);
if(function.RecordCount(rst)>0)
{
m_ComStyle.record=rst;
m_ComStyle.DateBaseName="商业往来类型表";
m_ComStyle.IDStyle=1;
m_ComStyle.Init("名称");
}
rst->Close();
rst=cnn->Execute((_bstr_t)"客户往来查询",NULL,adCmdTable);
if(function.RecordCount(rst)>0)
{
rst->MoveFirst();
this->Display();
this->m_Slider.Recordset=rst;
this->m_Slider.Init();
}
m_ComName.EmptyValidate=true;
m_ComStyle.EmptyValidate=true;
m_EdtMoney.EmptyValidate=true;
curtime=function.CStringTOCTime("2004-01-01");
m_DDate.SetTime(&curtime);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CDBiz::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->hwnd==m_DDate.GetSafeHwnd()&&pMsg->message==WM_KEYDOWN&&pMsg->wParam==13)
{
pMsg->wParam=9;
}
return CDialog::PreTranslateMessage(pMsg);
}
void CDBiz::OnButadd()
{
CString ID;
ID=function.AutoNumber("客户往来表","WL",1);
this->m_EdtID.SetWindowText(ID);
this->Enabled(false);
this->AddOrChange=true;
this->ClearFrom();
m_DDate.SetFocus();
}
void CDBiz::OnBUTChange()
{
AddOrChange=false;
this->Enabled(false);
m_DDate.SetFocus();
}
void CDBiz::OnBUTDele()
{
CString sSQL,ID;
this->m_EdtID.GetWindowText(ID);
int a=MessageBox("确定要删除此条记录?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
sSQL.Format("Delete from 客户往来表 Where 编号='%s'",ID);
cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
rst->MoveFirst();
this->Display();
m_Slider.Init();
this->Enabled(true);
if(function.RecordCount(rst)>0)
{
this->m_Slider.Recordset=rst;
this->m_Slider.Init();
}
}
}
void CDBiz::OnBUTSave()
{
CTime Mytime;
CString ID,Date,Name,Style,Money,Rem,sSQL,NameID;
m_EdtID.GetWindowText(ID);
m_DDate.GetTime(Mytime);
Date=function.CTimeToCString(Mytime);
m_EdtMoney.GetWindowText(Money);
m_EdtRem.GetWindowText(Rem);
m_ComStyle.GetWindowText(Style);
m_ComName.GetWindowText(Name);
int nStyle;
int a=MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
if(Style.IsEmpty() || Style=="--")
{
MessageBox("请添入往来类型!","系统提示",MB_OK|MB_ICONSTOP);
m_ComStyle.SetFocus();
return;
}
if(Name.IsEmpty() || Name=="--")
{
MessageBox("请添入客户姓名!","系统提示",MB_OK|MB_ICONSTOP);
m_ComName.SetFocus();
return;
}
if(Rem.IsEmpty())
{
Rem="无";
}
nStyle=m_ComStyle.Recno;
NameID=m_ComName.sID;
if(this->AddOrChange==true)
sSQL.Format("Insert into 客户往来表 values('%s',#%s#,'%s',%d,%s,'%s')",ID,Date,NameID,nStyle,Money,Rem);
else
sSQL.Format("Update 客户往来表 SET 日期=#%s#,客户编号='%s',往来类型=%d,涉及金额=%s,活动描述='%s' Where 编号='%s'",Date,NameID,nStyle,Money,Rem,ID);
cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
m_Slider.Init();
this->Enabled(true);
if(function.RecordCount(rst)>0)
{
this->m_Slider.Recordset=rst;
this->m_Slider.Init();
}
}
}
void CDBiz::ClearFrom()
{
m_EdtRem.SetWindowText("");
m_EdtMoney.SetWindowText("");
CTime curtime=curtime.GetCurrentTime();
m_DDate.SetTime(&curtime);
m_ComStyle.SetWindowText("");
m_ComName.SetWindowText("");
}
BOOL CDBiz::DestroyWindow()
{
rst->Close();
return CDialog::DestroyWindow();
}
void CDBiz::OnBUTUnDo()
{
int a=MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
rst->MoveFirst();
this->Display();
this->Enabled(true);
}
}
void CDBiz::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult)
{
if(function.RecordCount(rst)>0)
{
rst->MoveFirst();
rst->Move(this->m_Slider.GetPos()-1);
this->Display();
}
*pResult = 0;
}
void CDBiz::OnButexit()
{
this->OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -