www.pudn.com > shangdianguanlixitong.rar > list.cpp, change:2005-06-25,size:20792b


// list.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "shop.h" 
#include "list.h" 
#include "goodinformation.h" 
#include "consumer.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
extern CShopApp theApp; 
 
///////////////////////////////////////////////////////////////////////////// 
// Clist dialog 
 
 
Clist::Clist(CWnd* pParent /*=NULL*/) 
	: CDialog(Clist::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(Clist) 
	m_amount = _T(""); 
	m_consumerno = _T(""); 
	m_goodno = _T(""); 
	m_listno = _T(""); 
	m_date = _T(""); 
	m_mode = _T(""); 
	m_condition = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void Clist::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(Clist) 
	DDX_Control(pDX, IDC_goodno, m_goodno1); 
	DDX_Control(pDX, IDC_consumerno, m_consumerno1); 
	DDX_Control(pDX, IDC_USERLIST, m_userlist); 
	DDX_Text(pDX, amount, m_amount); 
	DDX_CBString(pDX, IDC_consumerno, m_consumerno); 
	DDX_CBString(pDX, IDC_goodno, m_goodno); 
	DDX_Text(pDX, IDC_listno, m_listno); 
	DDX_Text(pDX, IDC_date1, m_date); 
	DDX_CBString(pDX, IDC_mode, m_mode); 
	DDX_Text(pDX, IDC_condition, m_condition); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(Clist, CDialog) 
	//{{AFX_MSG_MAP(Clist) 
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_USERLIST, OnItemchangedUserlist) 
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2) 
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3) 
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6) 
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1) 
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2) 
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// Clist message handlers 
 
BOOL Clist::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	//////下面两个函数初始化顾客号和货号列表框中的内容 
	fun1(); 
	fun2(); 
	 
::SendMessage(m_userlist.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);//当被选中时,所有子项都处于选中状态 
	//////////为列表控件添加列////////// 
    
   
	m_userlist.InsertColumn(0,"订单号",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(1,"顾客编号",LVCFMT_LEFT,100); 
    m_userlist.InsertColumn (2,"货号",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(3,"数量",LVCFMT_LEFT,100); 
	m_userlist.InsertColumn(4,"定货日期",LVCFMT_LEFT,100); 
	  
 
	//////////读取数据库中的信息添加到列表控件/////////// 
	displayintheuserlist();	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void Clist::displayintheuserlist () 
{ 
	//////////读取数据库中的信息添加到列表控件/////////// 
	 
 
	try 
	{ 
		 
		m_userlist.DeleteAllItems(); 
		m_pRecordset.CreateInstance("ADODB.Recordset"); 
		m_pRecordset->Open("select  *  from listview order by listno",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	     
		 
	 
		//m_bSuccess = TRUE; 
		while(!m_pRecordset->adoEOF) 
		{ 
		    //	定单号 
           //  顾客编号 
          //    货号 
          //   数量 
           //  定货日期 
 
			  
			vlistno= m_pRecordset->GetCollect("listno"); 
			vconsumerno= m_pRecordset->GetCollect("consumerno"); 
			vgoodno = m_pRecordset->GetCollect("goodno"); 
			vamount= m_pRecordset->GetCollect("amount"); 
			vdate= m_pRecordset->GetCollect("date"); 
			 
			  
			 
			//this->AbleFalse(); 
	     	//this->LoadData(); 
			//this->GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE); 
			//this->GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE); 
			nItem=m_userlist.InsertItem(0xffff,(_bstr_t)vlistno);//先插第一个项 
			m_userlist.SetItem(nItem,1,1,(_bstr_t)vconsumerno,NULL,0,0,0); 
			m_userlist.SetItem(nItem,2,1,(_bstr_t)vgoodno ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,3,1,(_bstr_t)vamount ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,4,1,(_bstr_t)vdate ,NULL,0,0,0); 
			  
			  
			 
 
			m_pRecordset->MoveNext(); 
		} 
	} 
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
 
 
 
 
} 
 
void Clist::LoadData0() 
{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select  *  from listview order by listno",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	    
 
     
	m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	  
	vlistno = m_pRecordset->GetCollect("listno"); 
	vconsumerno = m_pRecordset->GetCollect("consumerno"); 
	vgoodno = m_pRecordset->GetCollect("goodno"); 
	vamount = m_pRecordset->GetCollect("amount"); 
	vdate = m_pRecordset->GetCollect("date"); 
	  
    UpdateData(true);//使得控件显示值 
	//m_num = vNum.lVal; 
//	m_name = (LPCTSTR)(_bstr_t)vName; 
	//m_sex = vSex.lVal; 
///	m_brithday = vBrithday.lVal; 
	//m_tel=vTel.lVal; 
	//m_addr=vAddr.lVal; 
 
 
	  
	m_listno= (LPCTSTR)(_bstr_t)vlistno; 
	m_consumerno = (LPCTSTR)(_bstr_t)vconsumerno; 
	m_goodno = (LPCTSTR)(_bstr_t)vgoodno; 
	m_amount = (LPCTSTR)(_bstr_t)vamount; 
	m_date= (LPCTSTR)(_bstr_t)vdate; 
	  
	  
    //m_pRecordset->Move(m_nCurrentSel,_variant_t((long)adBookmarkFirst));//从第一条记录移动 
	UpdateData(FALSE);//使得控件显示值 
 
} 
 
void Clist::OnItemchangedUserlist(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; 
if(pNMListView->uNewState&LVIS_SELECTED) 
	{ 
	//UpdateData(true); 
	//SaveData();///保存旧数据 
	m_nCurrentSel = pNMListView->iItem; 
	LoadData0();///加载新数据 
	//m_cdelitem.EnableWindow(); 
	 
	}	 
	*pResult = 0; 
} 
 
void Clist::fun1() 
{ 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select consumerno from consumer",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	while(!m_pRecordset->adoEOF) 
	{ 
		vconsumerno = m_pRecordset->GetCollect("consumerno"); 
		vconsumerno1 = (LPCTSTR)(_bstr_t)vconsumerno; 
		m_consumerno1.AddString(vconsumerno1); 
		m_pRecordset->MoveNext(); 
		 
 
	} 
	} 
 
	catch(_com_error e)///捕捉异常 
	{ 
	//////////////////////////////AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
} 
 
void Clist::fun2() 
{ 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select goodno from good",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	while(!m_pRecordset->adoEOF) 
	{ 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vgoodno1 = (LPCTSTR)(_bstr_t)vgoodno; 
		m_goodno1.AddString(vgoodno1); 
		m_pRecordset->MoveNext(); 
		 
 
	} 
	} 
 
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
 
} 
 
 
 
  
 
void Clist::OnButton2()  
{ 
    int yuanmoney,houlaimoney,zhengsellprice,zhengamount,yuanamount,houlaiamount,xianamount; 
    CString subleftmoney,subamount,vvconsumerno,vvleftmoney,vvgoodno,vvsellprice,vvamount; 
	UpdateData(true);//把控件的值传给相应的变量 
	UpdateData(false); 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select listno,goodno from include",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	CString vvlistno; 
	vvlistno = ""; 
	vvgoodno = ""; 
	while(!m_pRecordset->adoEOF && (vvlistno != m_listno || vvgoodno != m_goodno) ) 
	{ 
		vlistno = m_pRecordset->GetCollect("listno"); 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vvlistno = (LPCTSTR)(_bstr_t)vlistno; 
		vvgoodno = (LPCTSTR)(_bstr_t)vgoodno; 
		m_pRecordset->MoveNext(); 
		 
 
	} 
	if (!m_pRecordset->adoEOF) 
	{ 
	   AfxMessageBox("此订单已经存在,请输入不同的订单号和货号!"); 
	   goto addfail; 
	} 
	} 
 
	catch(_com_error e)///捕捉异常 
	{ 
	//////////////////////////////AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
 
	/////////////////////////////// 
	///////////////////////////////// 
	//顾客余额减去订单应付费用 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select consumerno,leftmoney from consumer",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	vvconsumerno = ""; 
	while(!m_pRecordset->adoEOF && vvconsumerno != m_consumerno) 
	{ 
		vconsumerno = m_pRecordset->GetCollect("consumerno"); 
		vleftmoney = m_pRecordset->GetCollect("leftmoney"); 
		vvconsumerno = (LPCTSTR)(_bstr_t)vconsumerno; 
		vvleftmoney = (LPCTSTR)(_bstr_t)vleftmoney; 
		m_pRecordset->MoveNext(); 
	} 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
	 ////// 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select goodno,sellprice from good",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	vvgoodno = ""; 
	while(!m_pRecordset->adoEOF && vvgoodno != m_goodno) 
	{ 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vsellprice = m_pRecordset->GetCollect("sellprice"); 
		vvgoodno = (LPCTSTR)(_bstr_t)vgoodno; 
		vvsellprice = (LPCTSTR)(_bstr_t)vsellprice; 
		m_pRecordset->MoveNext(); 
	} 
	yuanmoney = atoi(vvleftmoney); 
	zhengsellprice = atoi(vvsellprice); 
	zhengamount = atoi(m_amount); 
    houlaimoney = yuanmoney - (zhengamount*zhengsellprice); 
	if(houlaimoney <=0 ) 
	{ 
		AfxMessageBox("顾客余额不足,需要充值!"); 
		goto addfail; 
	} 
 
 
    subleftmoney.Format("%d",houlaimoney); 
 
 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
/////// 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select goodno,amount from provide",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	vvgoodno = ""; 
	while(!m_pRecordset->adoEOF && vvgoodno != m_goodno) 
	{ 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vamount = m_pRecordset->GetCollect("amount"); 
		vvgoodno = (LPCTSTR)(_bstr_t)vgoodno; 
		vvamount = (LPCTSTR)(_bstr_t)vamount; 
		m_pRecordset->MoveNext(); 
	} 
	yuanamount = atoi(vvamount); 
	//xianamount = atoi(m_amount); 
	zhengamount = atoi(m_amount); 
    houlaiamount = yuanmoney - zhengamount; 
	if(houlaiamount <=0 ) 
	{ 
		AfxMessageBox(" 库存货品不足,需要进货!"); 
		goto addfail; 
		 
	} 
	subamount.Format("%d",houlaiamount); 
 
 
      
 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
 
    m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("update consumer set leftmoney = 'subleftmoney' where consumerno = 'm_consumerno'",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("update provide set amount = 'subamount' where goodno = 'm_goodno'",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
 
	} 
     
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	}  
 
   // m_pRecordset.CreateInstance("ADODB.Recordset"); 
//	m_pRecordset->Open("update consumer set leftmoney = 'subleftmoney' where",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
 
	} 
     
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	}  
 
	 
      
//	m_pRecordset->Close(); 
 //   m_pRecordset = NULL; 
 
  //  m_pRecordset.CreateInstance("ADODB.Recordset"); 
//	m_pRecordset->Open("update consumer set leftmoney =  from consumer",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
 
	} 
     
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	}  
 
	/////////////////////////////////////////////////////////// 
	//AfxMessageBox("注意: 添加的五项内容均不能为空!!"); 
	   
 
		   m_pRecordset.CreateInstance(_uuidof(Recordset));// 
	       m_pRecordset->Open("select * from list",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
           
		  
	try 
	   { 
		 
		    
	   	m_pRecordset->AddNew(); 
		 
		  
	    vlistno = m_listno; 
	    vconsumerno = m_consumerno; 
	    vdate = m_date; 
	      
	    m_pRecordset->PutCollect("listno",vlistno); 
		m_pRecordset->PutCollect("consumerno",vconsumerno); 
	    m_pRecordset->PutCollect("date",vdate); 
		  
		 m_pRecordset->Update(); 
		 m_pRecordset->Close(); 
		 m_pRecordset = NULL; 
		 
	} 
	 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
	   } 
	     
        UpdateData(false);	 
 
		 
		UpdateData(true); 
	    m_pRecordset.CreateInstance(_uuidof(Recordset));// 
	    m_pRecordset->Open("select * from include",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
         
		try 
	   { 
		 
		    
	   	m_pRecordset->AddNew(); 
		 
		  
	    vlistno = m_listno; 
	   // vconsumerno = m_consumerno; 
	    vgoodno = m_goodno; 
		vamount = m_amount; 
	//	vdate = m_date; 
	      
	      
        //UpdateData(true); 
 
		  
		m_pRecordset->PutCollect("listno",vlistno); 
		//m_pRecordset->PutCollect("consumerno",vconsumerno); 
		m_pRecordset->PutCollect("goodno",vgoodno); 
		m_pRecordset->PutCollect("amount",vamount); 
	//	m_pRecordset->PutCollect("date",vdate); 
		  
		  
		 
 
		//UpdateData(true); 
                   
		 //m_pRecordset.CreateInstance("ADODB.Recordset"); 
		 //m_pRecordset->Open("insert into employee values(empno,empname,sex,salary,duty,deptno,birthday,address,telephone,remark)  ",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	      
        //AfxMessageBox("添加记录成功!"); 
 
		 m_pRecordset->Update(); 
		  
		 m_pRecordset->Close(); 
		 m_pRecordset = NULL; 
		  
		 //重建指针,以备下次添加记录时使用      
         //m_pRecordset1.CreateInstance(_uuidof(Recordset));// 
	     //m_pRecordset1->Open("select * from employee",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
          
         displayintheuserlist(); 
		  
         AfxMessageBox("添加订单成功!"); 
		  
          
		  
 
 
	 
	} 
	 
	   catch(_com_error e)///捕捉异常 
	   { 
		    
		  //AfxMessageBox("此订单已存在!");///显示错误信息 
		    
	   } 
	 
 
addfail: 
	  // AfxMessageBox("顾客余额不足或者库存货品不足,请检查!"); 
	   UpdateData(false); 
	    
	  
  
	    
} 
 
void Clist::OnButton3()  
{ 
	 
	UpdateData(true); 
    if(MessageBox("确定要删除吗?",0, 
			MB_OKCANCEL|MB_DEFBUTTON2|MB_ICONWARNING)==IDOK) 
	{ 
		//删除list表中相关内容,由于是级联删除和更新,故include表中的相关内容被自动删除 
	m_listno = "'"+m_listno + "'";  
	sql = "select * from list where  listno = "+m_listno ; 
	////////////////////////////////////////////////////////////////////////////// 
	try 
	 { 
 
        m_pRecordset->Close(); 
        m_pRecordset = NULL; 
        m_pRecordset.CreateInstance(_uuidof(Recordset));// 
 
        m_pRecordset->Open( (_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
        m_pRecordset->Delete(adAffectCurrent); 
		displayintheuserlist(); 
        AfxMessageBox("删除订单成功!!"); 
	} 
	 catch(_com_error e)///捕捉异常 
	   { 
		  AfxMessageBox("删除订单失败!");///显示错误信息 
		   
	   } 
	 ///////////////////////////////////// 
	 ////下面是对consumer和provide表中的相关内容进行修改 
	 int yuanmoney,houlaimoney,zhengsellprice,zhengamount,yuanamount,yuanamount2; 
	 int houlaiamount,houlaiamount2,yuanleftmoney,houlaileftmoney,yuanlaileftmoney; 
     
	CString subleftmoney,subamount,vvconsumerno; 
	CString vvleftmoney,vvgoodno,vvsellprice,vvamount,vvamount2,vvlistno; 
	 
	UpdateData(true);//把控件的值传给相应的变量 
	UpdateData(false); 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select goodno,amount from provide",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	vvgoodno = ""; 
	while(!m_pRecordset->adoEOF &&  vvgoodno != m_goodno ) 
	{ 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vamount = m_pRecordset->GetCollect("amount"); 
		vvgoodno = (LPCTSTR)(_bstr_t)vgoodno; 
		vvamount = (LPCTSTR)(_bstr_t)vamount; 
		m_pRecordset->MoveNext(); 
	} 
	  
	} 
    catch(_com_error e)  
	{ 
	 /////// 
	} 
    yuanamount = atoi(vvamount);   
    zhengamount = atoi(m_amount); 
	houlaiamount = yuanamount + zhengamount; 
    subamount.Format("%d",houlaiamount); 
    ///对provide表中的商品数量更新 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
    m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("update provide set amount = 'subamount' where goodno = 'm_goodno'",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	//下面是更新顾客表consumer表中的顾客余额 
    try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select goodno,sellprice from good",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	vvgoodno = ""; 
	while(!m_pRecordset->adoEOF &&  vvgoodno != m_goodno ) 
	{ 
		vgoodno = m_pRecordset->GetCollect("goodno"); 
		vsellprice = m_pRecordset->GetCollect("sellprice"); 
		vvgoodno = (LPCTSTR)(_bstr_t)vgoodno; 
		vvsellprice = (LPCTSTR)(_bstr_t)vsellprice; 
		m_pRecordset->MoveNext(); 
	} 
	  
	} 
    catch(_com_error e)  
	{ 
	 /////// 
	} 
    zhengsellprice = atoi(vvsellprice); 
    zhengsellprice = zhengsellprice*zhengamount; 
	try 
	{ 
	m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("select consumerno,leftmoney from consumer",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	vvconsumerno = ""; 
	while(!m_pRecordset->adoEOF &&  vvconsumerno != m_consumerno ) 
	{ 
		vconsumerno = m_pRecordset->GetCollect("consumerno"); 
		vleftmoney = m_pRecordset->GetCollect("leftmoney"); 
		vvconsumerno = (LPCTSTR)(_bstr_t)vconsumerno; 
		vvleftmoney = (LPCTSTR)(_bstr_t)vleftmoney; 
		m_pRecordset->MoveNext(); 
	} 
	} 
    catch(_com_error e)  
	{ 
	 /////// 
	} 
	yuanleftmoney = atoi(vvleftmoney); 
	houlaileftmoney = yuanlaileftmoney + zhengsellprice; 
	subleftmoney.Format("%d",houlaileftmoney); 
    ///对consumer表中的leftmoney更新 
	m_pRecordset->Close(); 
    m_pRecordset = NULL; 
    m_pRecordset.CreateInstance("ADODB.Recordset"); 
	m_pRecordset->Open("update consumer set leftmoney = 'subleftmoney' where consumerno = 'm_consumerno'",_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	 
	} 
 
 
	 
} 
 
void Clist::OnButton6()  
{ 
	UpdateData(true); 
    /////////////////////////////////// 
   //定单号 
//顾客编号 
//货号 
//数量 
//定货日期     
	if (m_mode=="定单号") 
		mode="listno"; 
	if (m_mode=="顾客编号") 
		mode="consumerno"; 
    if (m_mode=="货号") 
		mode="goodno"; 
	if (m_mode=="数量") 
		mode="amount"; 
	if (m_mode=="定货日期") 
		mode="date"; 
////////////////////////////////// 
	 condition = m_condition; 
	  
	 if(mode == "") 
		AfxMessageBox("请选择查询方式!"); 
	 
	if(option11 == true) 
	{ 
	 sql = "select * from listview where " + mode +" "+ option1 +" " + "'"+ condition + "'" ; 
	   
	} 
	   
	 else 
		goto label; 
	try 
	{ 
		  
		m_pRecordset->Close(); 
		m_pRecordset = NULL; 
		m_userlist.DeleteAllItems(); 
    	m_pRecordset.CreateInstance("ADODB.Recordset"); 
        m_pRecordset->Open( (_variant_t)sql,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); 
	      
		if(m_pRecordset->adoEOF) 
			AfxMessageBox("没有满足您查询的结果!"); 
	     
		while(!m_pRecordset->adoEOF) 
		{ 
			 
			vlistno= m_pRecordset->GetCollect("listno"); 
			vconsumerno= m_pRecordset->GetCollect("consumerno"); 
			vgoodno = m_pRecordset->GetCollect("goodno"); 
			vamount= m_pRecordset->GetCollect("amount"); 
			vdate= m_pRecordset->GetCollect("date"); 
			  
			nItem=m_userlist.InsertItem(0xffff,(_bstr_t)vlistno);//先插第一个项 
			m_userlist.SetItem(nItem,1,1,(_bstr_t)vconsumerno,NULL,0,0,0); 
			m_userlist.SetItem(nItem,2,1,(_bstr_t)vgoodno ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,3,1,(_bstr_t)vamount ,NULL,0,0,0); 
			m_userlist.SetItem(nItem,4,1,(_bstr_t)vdate ,NULL,0,0,0); 
			  
			m_pRecordset->MoveNext(); 
		} 
	} 
	catch(_com_error e)///捕捉异常 
	{ 
		//AfxMessageBox("读取数据库失败!");///显示错误信息 
	} 
     
 label:	   
	  
	//////////////////////////////////////////////////////////////////// 
  	 UpdateData(false); 
	 
} 
 
void Clist::OnRadio1()  
{ 
    option1 = "<"; 
	option11 = true;	 
} 
 
void Clist::OnRadio2()  
{ 
    option1 = "="; 
	option11 = true;	 
} 
 
void Clist::OnRadio3()  
{ 
    option1 = ">"; 
	option11 = true;	 
} 
 
void Clist::OnButton1()  
{ 
      Cgoodinformation dlg; 
	  dlg.DoModal(); 
} 
 
void Clist::OnButton4()  
{ 
       Cconsumer dlg; 
	   dlg.DoModal(); 
}