📄 ddgldlg.cpp
字号:
// DdglDlg.cpp : implementation file
//
#include "stdafx.h"
#include "图书销售管理系统.h"
#include "DdglDlg.h"
extern CDatabase pDb;//yingyong quanju bianliang
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDdglDlg dialog
CDdglDlg::CDdglDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDdglDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDdglDlg)
// NOTE: the ClassWizard will add member initialization here
finddd = _T("");
//}}AFX_DATA_INIT
}
void CDdglDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDdglDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX,IDC_LISTDDGL,dd);
DDX_Text(pDX,IDC_EDITchxdd, finddd);
DDX_Control(pDX,IDC_BUTTONshchdd,m_tjdd);
DDX_Text(pDX,IDC_EDITddddbh,m_dingdanbianhao);
DDX_Text(pDX,IDC_EDITddkhmch,m_kehuname);
DDX_Text(pDX,IDC_EDITddjfrq,m_jiaofuriqi);
DDX_Text(pDX,IDC_EDITddfzr,m_fuzerenxingming);
DDX_Text(pDX,IDC_EDITddjfgj,m_jiaofuguojia);
DDX_Text(pDX,IDC_EDITddhwzsh,m_huowuzongshu);
DDX_Text(pDX,IDC_EDITddshf,m_shufei);
DDX_Text(pDX,IDC_EDITddfkzl,m_fukuanzongliang);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDdglDlg, CDialog)
//{{AFX_MSG_MAP(CDdglDlg)
ON_BN_CLICKED(IDC_BUTTONchxdd, OnBUTTONchxdd)
ON_BN_CLICKED(IDC_BUTTONshchdd, OnBUTTONshchdd)
ON_BN_CLICKED(IDC_BUTTONtjdd, OnBUTTONtjdd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDdglDlg message handlers
int CDdglDlg::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DoModal();
}
BOOL CDdglDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strSQL=_T("select * from dd");
CRecordset* dbset=new CRecordset(&pDb);
TRY
{
if(!pDb.IsOpen ())
AfxMessageBox("Open dsnName Error.");//m_databaseinfo);
else
{
dbset->Open(CRecordset::dynaset,strSQL,CRecordset::readOnly);
//统计table信息
short FieldCount=dbset->GetODBCFieldCount();
do
{
dbset->MoveNext();
}
while (!dbset->IsEOF());
long RecordCount=dbset->GetRecordCount();
CString title[MAX_PATH]={""};
CODBCFieldInfo fieldinfo;
CStringArray strColTitle;
if(!dbset->IsBOF())
dbset->MoveFirst();
if(strColTitle.GetSize())
strColTitle.RemoveAll();
//显示列标题(字段名)
for(int i=0;i<FieldCount;i++)
{
dbset->GetODBCFieldInfo(i,fieldinfo);
strColTitle.Add(LPCTSTR(fieldinfo.m_strName));
dd.InsertColumn(i,strColTitle[i]);//title[i]);
}
CString item[MAX_PATH];
CString strField;
//显示记录
dbset->MoveFirst();
for(i=0;i<RecordCount;i++)
{
dd.InsertItem (i,"");
for(int j=0;j<FieldCount;j++)
{
dbset->GetFieldValue (j,strField);
dd.SetItemText (i,j,strField);
dd.SetColumnWidth (j,LVSCW_AUTOSIZE);
}
dbset->MoveNext ();
}
dbset->Close ();
delete dbset;
}
}
CATCH(CDBException, e)
{
dbset->Close ();
delete dbset;
CString strTip=_T("Database operate Fail!\n");
strTip+=_T("Because:\n")+e->m_strError;
AfxMessageBox(strTip);
}
END_CATCH
/////////////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDdglDlg::OnBUTTONchxdd()
{
// TODO: Add your control notification handler code here
CString strSQL;
UpdateData(TRUE);
strSQL.Format("select * from dd where 客户名称='%s'",finddd);
dd.DeleteAllItems();
//MessageBox(strSQL);
CRecordset* dbset=new CRecordset(&pDb);
TRY
{
if(!pDb.IsOpen ())
AfxMessageBox("Open dsnName Error.");//m_databaseinfo);
else
{
dbset->Open(CRecordset::dynaset,strSQL,CRecordset::readOnly);
//统计table信息
short FieldCount=dbset->GetODBCFieldCount();
long RecordCount=dbset->GetRecordCount();
CString title[MAX_PATH]={""};
CODBCFieldInfo fieldinfo;
CStringArray strColTitle;
if(!dbset->IsBOF())
dbset->MoveFirst();
if(strColTitle.GetSize())
strColTitle.RemoveAll();
CString item[MAX_PATH];
CString strField;
//显示记录
dbset->MoveFirst();
for(int i=0;i<RecordCount;i++)
{
dd.InsertItem (i,"");
for(int j=0;j<FieldCount;j++)
{
dbset->GetFieldValue (j,strField);
dd.SetItemText (i,j,strField);
}
dbset->MoveNext ();
}
dbset->Close ();
delete dbset;
}
}
CATCH(CDBException, e)
{
dbset->Close ();
delete dbset;
CString strTip=_T("Database operate Fail!\n");
strTip+=_T("Because:\n")+e->m_strError;
AfxMessageBox(strTip);
}
END_CATCH
}
void CDdglDlg::OnBUTTONshchdd()
{
// TODO: Add your control notification handler code here
CString strSQL;
UpdateData(TRUE);
strSQL.Format("select * from dd where 客户名称='%s'",finddd);
dd.DeleteAllItems();
//MessageBox(strSQL);
CRecordset* dbset=new CRecordset(&pDb);
TRY
{
if(!pDb.IsOpen ())
AfxMessageBox("Open dsnName Error.");//m_databaseinfo
else
{
dbset->Open(CRecordset::dynaset,strSQL,CRecordset::readOnly);
//统计table信息
short FieldCount=dbset->GetODBCFieldCount();
long RecordCount=dbset->GetRecordCount();
CString title[MAX_PATH]={""};
CODBCFieldInfo fieldinfo;
CStringArray strColTitle;
if(!dbset->IsBOF())
dbset->MoveFirst();
if(strColTitle.GetSize())
strColTitle.RemoveAll();
CString item[MAX_PATH];
CString strField;
strSQL.Format("delete from dd where 客户名称='%s'",finddd);
pDb.ExecuteSQL(strSQL);
MessageBox("此订单信息已删除~_~");
dbset->Close ();
delete dbset;
}
}
CATCH(CDBException, e)
{
dbset->Close ();
delete dbset;
CString strTip=_T("Database operate Fail!\n");
strTip+=_T("Because:\n")+e->m_strError;
AfxMessageBox(strTip);
}
END_CATCH
}
void CDdglDlg::OnBUTTONtjdd()
{
// TODO: Add your control notification handler code here
CString strSQL;
UpdateData(TRUE);
if(m_kehuname.IsEmpty())
{
MessageBox("请添加客户名称!");
}
else
{strSQL.Format("insert into dd values('%s','%s','%s','%s','%s','%s','%s','%s')",
m_dingdanbianhao,m_kehuname,m_jiaofuriqi,m_fuzerenxingming,m_jiaofuguojia,m_huowuzongshu,m_shufei,m_fukuanzongliang);
pDb.ExecuteSQL(strSQL); MessageBox("添加订单记录成功!");//MessageBox();
}
m_dingdanbianhao="";
m_kehuname="";
m_jiaofuriqi="";
m_fuzerenxingming="";
m_jiaofuguojia="";
m_huowuzongshu="";
m_shufei="";
m_fukuanzongliang="";
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -