DlgFenJiBase.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:5k
- // DlgFenJiBase.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ncshop.h"
- #include "DlgFenJiBase.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgFenJiBase dialog
- CDlgFenJiBase::CDlgFenJiBase(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgFenJiBase::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgFenJiBase)
- m_str1 = _T("");
- m_str2 = _T("");
- m_str3 = _T("");
- //}}AFX_DATA_INIT
- }
- void CDlgFenJiBase::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgFenJiBase)
- 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, 50);
- DDX_Text(pDX, IDC_EDIT2, m_str2);
- DDV_MaxChars(pDX, m_str2, 50);
- DDX_Text(pDX, IDC_EDIT3, m_str3);
- DDV_MaxChars(pDX, m_str3, 255);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgFenJiBase, CDialog)
- //{{AFX_MSG_MAP(CDlgFenJiBase)
- 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()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgFenJiBase message handlers
- BOOL CDlgFenJiBase::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 CDlgFenJiBase::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 CDlgFenJiBase::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 CDlgFenJiBase::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 CDlgFenJiBase::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);
- }