DlgGongYingShangBase.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:6k
源码类别:
百货/超市行业
开发平台:
Visual C++
- // DlgGongYingShangBase.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ncshop.h"
- #include "DlgGongYingShangBase.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgGongYingShangBase dialog
- CDlgGongYingShangBase::CDlgGongYingShangBase(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgGongYingShangBase::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgGongYingShangBase)
- m_str1 = _T("");
- m_str2 = _T("");
- m_str3 = _T("");
- m_str4 = _T("");
- m_str5 = _T("");
- m_str6 = _T("");
- m_str7 = _T("");
- m_intSelect = 0;
- //}}AFX_DATA_INIT
- }
- void CDlgGongYingShangBase::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgGongYingShangBase)
- DDX_Control(pDX, IDC_LIST1, m_listMain);
- DDX_Control(pDX, IDMODIFY, m_Btn2);
- DDX_Control(pDX, IDDEL3, m_Btn3);
- DDX_Control(pDX, IDC_BTNFIND, m_Btn4);
- DDX_Control(pDX, IDADD3, m_Btn1);
- 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, 20);
- DDX_Text(pDX, IDC_EDIT4, m_str4);
- DDV_MaxChars(pDX, m_str4, 20);
- DDX_Text(pDX, IDC_EDIT5, m_str5);
- DDV_MaxChars(pDX, m_str5, 255);
- DDX_Text(pDX, IDC_EDIT7, m_str6);
- DDV_MaxChars(pDX, m_str6, 255);
- DDX_Text(pDX, IDC_EDIT17, m_str7);
- DDX_CBIndex(pDX, IDC_COMBO2, m_intSelect);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgGongYingShangBase, CDialog)
- //{{AFX_MSG_MAP(CDlgGongYingShangBase)
- ON_BN_CLICKED(IDADD3, OnAdd3)
- ON_BN_CLICKED(IDMODIFY, OnModify)
- ON_BN_CLICKED(IDDEL3, OnDel3)
- ON_BN_CLICKED(IDC_BTNFIND, OnBtnfind)
- ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgGongYingShangBase message handlers
- BOOL CDlgGongYingShangBase::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CString strSql;
- CADOConn adoMain;
- m_Btn1.SetXIcon(IDI_ICONBUTTON);
- m_Btn2.SetXIcon(IDI_ICONBUTTON);
- m_Btn3.SetXIcon(IDI_ICONBUTTON);
- m_Btn4.SetXIcon(IDI_ICONFIND);
- GetDlgItem(IDC_STATIC1)->SetFont(&ftHeader,TRUE);
- strSql="select * from 供应商基本信息表";
- adoMain.Open(strSql);
- adoMain.InitList(&m_listMain,7);
- adoMain.FillList(&m_listMain,7);
- adoMain.ExitConnect();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgGongYingShangBase::OnAdd3()
- {
- // 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,7);
- m_listMain.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_intSelect=0;
- UpdateData(FALSE);
- adoMain.ExitConnect();
- }
- void CDlgGongYingShangBase::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+"',单位性质=";
- str.Format("%d",m_intSelect);
- strSql=strSql+str+",联系人='";
- strSql=strSql+m_str3+"',联系方式='";
- strSql=strSql+m_str4+"',地址='";
- strSql=strSql+m_str5+"',备注='";
- strSql=strSql+m_str6+"'";
- str=m_listMain.GetItemText(i,0);
- strSql=strSql+" where 编号='"+str+"'";
- adoMain.ExecuteSQL(strSql);
- strSql="select * from 供应商基本信息表";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,7);
- while(m_listMain.GetItemText(i,1)!=m_str1&&i<m_listMain.GetItemCount())
- {
- i++;
- }
- if(m_listMain.GetItemCount()>0)
- m_listMain.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
- adoMain.ExitConnect();
- }
- void CDlgGongYingShangBase::OnDel3()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain;
- 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;
- }
- }
- strSql="select * from 供应商基本信息表";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,2);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_intSelect=0;
- UpdateData(FALSE);
- adoMain.ExitConnect();
- }
- void CDlgGongYingShangBase::OnBtnfind()
- {
- // TODO: Add your control notification handler code here
- CADOConn adoMain;
- CString strSql;
- UpdateData(TRUE);
- strSql="select * from 供应商基本信息表 where 编号='";
- strSql=strSql+m_str7+"'";
- adoMain.Open(strSql);
- adoMain.FillList(&m_listMain,7);
- m_str1="";
- m_str2="";
- m_str3="";
- m_str4="";
- m_str5="";
- m_str6="";
- m_intSelect=0;
- UpdateData(FALSE);
- }
- void CDlgGongYingShangBase::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,3);
- m_str4=m_listMain.GetItemText(i,4);
- m_str5=m_listMain.GetItemText(i,5);
- m_str6=m_listMain.GetItemText(i,6);
- m_intSelect=atoi(m_listMain.GetItemText(i,2));
- UpdateData(FALSE);
- }
- *pResult = 0;
- }