📄 dlgfenleibase.cpp
字号:
// DlgFenLeiBase.cpp : implementation file
//
#include "stdafx.h"
#include "ncshop.h"
#include "DlgFenLeiBase.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgFenLeiBase dialog
CDlgFenLeiBase::CDlgFenLeiBase(CWnd* pParent /*=NULL*/)
: CDialog(CDlgFenLeiBase::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgFenLeiBase)
// NOTE: the ClassWizard will add member initialization here
m_str1 = _T("");
m_str2 = _T("");
m_str3 = _T("");
//}}AFX_DATA_INIT
}
void CDlgFenLeiBase::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgFenLeiBase)
DDX_Control(pDX, IDDEL, m_Btn3);
DDX_Control(pDX, IDMODIFY, m_Btn2);
DDX_Control(pDX, IDADD, m_Btn1);
DDX_Control(pDX, IDC_LIST1, m_listMain);
DDX_Text(pDX, IDC_EDIT1, m_str1);
DDV_MaxChars(pDX, m_str1, 255);
DDX_Text(pDX, IDC_EDIT2, m_str2);
DDV_MaxChars(pDX, m_str2, 255);
DDX_Text(pDX, IDC_EDIT3, m_str3);
DDV_MaxChars(pDX, m_str3, 255);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgFenLeiBase, CDialog)
//{{AFX_MSG_MAP(CDlgFenLeiBase)
// NOTE: the ClassWizard will add message map macros here
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_BN_CLICKED(IDADD, OnAdd)
ON_BN_CLICKED(IDMODIFY, OnModify)
ON_BN_CLICKED(IDDEL, OnDel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgFenLeiBase message handlers
BOOL CDlgFenLeiBase::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CADOConn adoMain;
CString strSql;
strSql="select * from 商品分类基本信息表";
adoMain.Open(strSql);
adoMain.InitList(&m_listMain,2);
adoMain.FillList(&m_listMain,2);
GetDlgItem(IDC_STATIC1)->SetFont(&ftHeader,TRUE);
m_Btn1.SetXIcon(IDI_ICONBUTTON);
m_Btn2.SetXIcon(IDI_ICONBUTTON);
m_Btn3.SetXIcon(IDI_ICONBUTTON);
adoMain.ExitConnect();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgFenLeiBase::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION pos;
int i;
pos=m_listMain.GetFirstSelectedItemPosition();
i=m_listMain.GetNextSelectedItem(pos);
if (i>=0)
{
m_str1=m_listMain.GetItemText(i,0);
m_str2=m_listMain.GetItemText(i,1);
m_str3=m_listMain.GetItemText(i,2);
UpdateData(FALSE);
}
*pResult = 0;
}
void CDlgFenLeiBase::OnAdd()
{
// TODO: Add your control notification handler code here
CADOConn adoMain;
CString strSql;
int i=0;
UpdateData(TRUE);
strSql="insert into 商品分类基本信息表 values('','','')";
adoMain.ExecuteSQL(strSql);
strSql="select * from 商品分类基本信息表";
adoMain.Open(strSql);
adoMain.FillList(&m_listMain,2);
m_listMain.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
m_str1="";
m_str2="";
m_str3="";
UpdateData(FALSE);
adoMain.ExitConnect();
}
void CDlgFenLeiBase::OnModify()
{
// TODO: Add your control notification handler code here
CADOConn adoMain;
CString strSql,str;
POSITION pos;
int i;
pos=m_listMain.GetFirstSelectedItemPosition();
i=m_listMain.GetNextSelectedItem(pos);
if (i>=0)
{
str=m_listMain.GetItemText(i,0);
}
UpdateData(TRUE);
strSql="update 商品分类基本信息表 set 编号='";
strSql=strSql+m_str1+"',名称='";
strSql=strSql+m_str2+"',备注='";
strSql=strSql+m_str3+"' where 编号='"+str+"'";
if(adoMain.ExecuteSQL(strSql))
{
m_listMain.SetItemText(i,0,m_str1);
m_listMain.SetItemText(i,1,m_str2);
m_listMain.SetItemText(i,2,m_str3);
}
else
{
m_str1=m_listMain.GetItemText(i,0);
m_str2=m_listMain.GetItemText(i,1);
m_str3=m_listMain.GetItemText(i,2);
UpdateData(FALSE);
}
adoMain.ExitConnect();
}
void CDlgFenLeiBase::OnDel()
{
// TODO: Add your control notification handler code here
CADOConn adoMain,adoFile;
CString strSql;
POSITION pos;
int i;
UINT j=0;
pos=m_listMain.GetFirstSelectedItemPosition();
i=m_listMain.GetNextSelectedItem(pos);
if (i>=0)
{
if(MessageBox("确信删除这些信息吗?","提示",MB_YESNO|MB_ICONQUESTION)==IDNO) return;
while(j<m_listMain.GetSelectedCount()&&i<m_listMain.GetItemCount())
{
if(m_listMain.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
{
strSql="delete * from 商品分类基本信息表 where 编号='"+m_listMain.GetItemText(i,0)+"'";
adoMain.ExecuteSQL(strSql);
j=j+1;
}
i=i+1;
}
}
adoMain.ExitConnect();
strSql="select * from 商品分类基本信息表";
adoFile.Open(strSql);
adoFile.FillList(&m_listMain,2);
adoFile.ExitConnect();
m_str1="";
m_str2="";
m_str3="";
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -