⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gygldlg.cpp

📁 可以帮助管理员进行图书的采购、销售记录管理
💻 CPP
字号:
// GyglDlg.cpp : implementation file
//

#include "stdafx.h"
#include "图书销售管理系统.h"
#include "GyglDlg.h"
extern CDatabase pDb;//yingyong quanju bianliang

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGyglDlg dialog


CGyglDlg::CGyglDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CGyglDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CGyglDlg)
		// NOTE: the ClassWizard will add member initialization here
		findmemberr = _T("");
	//}}AFX_DATA_INIT
}


void CGyglDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGyglDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
		DDX_Control(pDX,IDC_LISTGYGY,memberr);
		DDX_Text(pDX,IDC_EDITchxgy, findmemberr);
		DDX_Control(pDX,IDC_BUTTONtjgy,m_tjgy);
		DDX_Text(pDX,IDC_EDITgygyxm,m_guyuanname);
		DDX_Text(pDX,IDC_EDITgygymm,m_guyuanmima);
		DDX_Text(pDX,IDC_EDITgygydh,m_guyuandianhua);
		DDX_Text(pDX,IDC_EDITgypyshj,m_pinyongshijian);
		DDX_Text(pDX,IDC_EDITgyxsh,m_xinshui);

	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGyglDlg, CDialog)
	//{{AFX_MSG_MAP(CGyglDlg)
	ON_BN_CLICKED(IDC_BUTTONchxgy, OnBUTTONchxgy)
	ON_BN_CLICKED(IDC_BUTTONshchgy, OnBUTTONshchgy)
	ON_BN_CLICKED(IDC_BUTTONtjgy, OnBUTTONtjgy)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGyglDlg message handlers

int CGyglDlg::DoModal() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::DoModal();
}

BOOL CGyglDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString strSQL=_T("select * from memberr");
	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));
				memberr.InsertColumn(i,strColTitle[i]);//title[i]);
			 } 

	  CString item[MAX_PATH];
	  CString strField;

	  //显示记录
	  dbset->MoveFirst();
	  for(i=0;i<RecordCount;i++)
	  { 
	   memberr.InsertItem (i,"");
	   for(int j=0;j<FieldCount;j++)
	   {
		dbset->GetFieldValue (j,strField);
		memberr.SetItemText (i,j,strField);
		memberr.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 CGyglDlg::OnBUTTONchxgy() 
{
	// TODO: Add your control notification handler code here
	 CString strSQL;
	 UpdateData(TRUE);
	 strSQL.Format("select * from memberr where 雇员姓名='%s'",findmemberr);
	 memberr.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++)
		  { 
		   memberr.InsertItem (i,"");
		   for(int j=0;j<FieldCount;j++)
		   {
			dbset->GetFieldValue (j,strField);
			memberr.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 CGyglDlg::OnBUTTONshchgy() 
{
	// TODO: Add your control notification handler code here
	 CString strSQL;
	 UpdateData(TRUE);
	 strSQL.Format("select * from memberr where 雇员姓名='%s'",findmemberr);
	 memberr.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 memberr where 雇员姓名='%s'",findmemberr);
		  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 CGyglDlg::OnBUTTONtjgy() 
{
	// TODO: Add your control notification handler code here
	CString strSQL;
	UpdateData(TRUE);
	if(m_guyuanname.IsEmpty())
	{
      MessageBox("请添加雇员名称!"); 
	}
	else
   
	{strSQL.Format("insert into memberr values('%s','%s','%s','%s','%s')",
	m_guyuanname,m_guyuanmima,m_guyuandianhua,m_pinyongshijian,m_xinshui);

	pDb.ExecuteSQL(strSQL);	MessageBox("添加雇员记录成功!");//MessageBox();
	}
	m_guyuanname="";
	m_guyuanmima="";
	m_guyuandianhua="";
	m_pinyongshijian="";
	m_xinshui="";
	UpdateData(FALSE);	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -