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

📄 developview.cpp

📁 我上数据库课的课程作业
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// DevelopView.cpp : implementation of the CDevelopView class
//

#include "stdafx.h"
#include "Develop.h"

#include "DevelopSet.h"
#include "DevelopDoc.h"
#include "DevelopView.h"
#include "Showinfo.h"
#include "SelectDlg.h"
#include "DelDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDevelopView

IMPLEMENT_DYNCREATE(CDevelopView, CRecordView)

BEGIN_MESSAGE_MAP(CDevelopView, CRecordView)
	//{{AFX_MSG_MAP(CDevelopView)
	ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnDblclkTree1)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	ON_COMMAND(ID_SELECT_NUM, OnSelectNum)
	ON_COMMAND(ID_FILE_LOOK, OnFileLook)
	ON_COMMAND(ID_FILE_DEL, OnFileDel)
	ON_COMMAND(ID_FILE_CREAT, OnFileCreat)
	ON_COMMAND(ID_SELECT_NAME, OnSelectName)
	//}}AFX_MSG_MAP
	// Standard printing commands
//	ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
//	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
//	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDevelopView construction/destruction

CDevelopView::CDevelopView()
	: CRecordView(CDevelopView::IDD)
{
	//{{AFX_DATA_INIT(CDevelopView)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CDevelopView::~CDevelopView()
{
}

void CDevelopView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDevelopView)
	DDX_Control(pDX, IDC_LIST1, m_list1);
	DDX_Control(pDX, IDC_TREE1, m_tree1);
	//}}AFX_DATA_MAP
}

BOOL CDevelopView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRecordView::PreCreateWindow(cs);
}

void CDevelopView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_developSet;
    m_encourageSet=&GetDocument()->m_encourageSet;
	m_repairSet=&GetDocument()->m_repairSet;

	CRecordView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

	HTREEITEM MAINROOT=m_tree1.InsertItem("电器开发部管理系统",NULL);
	m_tree1.InsertItem("个人信息",MAINROOT);
	m_tree1.InsertItem("获奖记录",MAINROOT);
    m_tree1.InsertItem("维修记录",MAINROOT);
}

/////////////////////////////////////////////////////////////////////////////
// CDevelopView printing

BOOL CDevelopView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDevelopView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDevelopView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDevelopView diagnostics

#ifdef _DEBUG
void CDevelopView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CDevelopView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CDevelopDoc* CDevelopView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDevelopDoc)));
	return (CDevelopDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDevelopView database support
CRecordset* CDevelopView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CDevelopView message handlers

void CDevelopView::OnDblclkTree1(NMHDR* pNMHDR, LRESULT* pResult) 
{

	HTREEITEM root=m_tree1.GetSelectedItem();
	table=m_tree1.GetItemText(root); //table为CString类型的变量
	// get recordset field information
	if(!m_tree1.ItemHasChildren(root))
	{ 
	   m_list1.DeleteAllItems();
	   while(m_list1.DeleteColumn(0));
	   UpdateWindow();
    }

   CRect rect;
   m_list1.GetWindowRect(rect);
   BeginWaitCursor();

		if(table=="个人信息")//填充列表(information)
		{
		table="Informatiom";
        strSQL="select * from "+table;
		if(m_pSet->IsOpen()) m_pSet->Close();  
		m_pSet->Open(CRecordset::dynaset, strSQL);

		if(!m_pSet->IsEOF())
		{
			m_pSet->MoveLast(); 
			m_pSet->MoveFirst(); 
		}
		int nFieldCount = m_pSet->GetODBCFieldCount();
		CODBCFieldInfo fieldinfo; 
		for(int n=0;n<nFieldCount;n++)
		{
			m_pSet->GetODBCFieldInfo(n, fieldinfo);
			int nWidth = m_list1.GetStringWidth(fieldinfo.m_strName) + 15;
			m_list1.InsertColumn(n, fieldinfo.m_strName, LVCFMT_LEFT, nWidth);
		}
		// get recordset data information
		CString strValue; 
		m_pSet->MoveFirst(); 
		int nCount = 0;

		while(!m_pSet->IsEOF())
		{
			m_list1.InsertItem(nCount, strValue);
			for(int j=0;j<nFieldCount;j++)
			{
				m_pSet->GetFieldValue(j, strValue);
				m_list1.SetItemText(nCount, j, strValue);
			}
			m_pSet->MoveNext(); 
			nCount ++;
		}

}
		if(table=="维修记录")//填充列表(Repair)
		{
		table="Repair";
        strSQL="select * from "+table;
		if(m_repairSet->IsOpen()) m_repairSet->Close();  
		m_repairSet->Open(CRecordset::dynaset, strSQL);

		if(!m_repairSet->IsEOF())
		{
			m_repairSet->MoveLast(); 
			m_repairSet->MoveFirst(); 
		}
		int nFieldCount = m_repairSet->GetODBCFieldCount();
		CODBCFieldInfo fieldinfo; 
		for(int n=0;n<nFieldCount;n++)
		{
			m_repairSet->GetODBCFieldInfo(n, fieldinfo);
			int nWidth = m_list1.GetStringWidth(fieldinfo.m_strName) + 15;
			m_list1.InsertColumn(n, fieldinfo.m_strName, LVCFMT_LEFT, nWidth);
		}
		// get recordset data information
		CString strValue; 
		m_repairSet->MoveFirst(); 
		int nCount = 0;

		while(!m_repairSet->IsEOF())
		{
			m_list1.InsertItem(nCount, strValue);
			for(int j=0;j<nFieldCount;j++)
			{
				m_repairSet->GetFieldValue(j, strValue);
				m_list1.SetItemText(nCount, j, strValue);
			}
			m_repairSet->MoveNext(); 
			nCount ++;
		}

}
		if(table=="获奖记录")//填充列表(Encourage)
		{
		table="Encourage";
        strSQL="select * from "+table;
		if(m_encourageSet->IsOpen()) m_encourageSet->Close();  
		m_encourageSet->Open(CRecordset::dynaset, strSQL);

		if(!m_encourageSet->IsEOF())
		{
			m_encourageSet->MoveLast(); 
			m_encourageSet->MoveFirst(); 
		}
		int nFieldCount = m_encourageSet->GetODBCFieldCount();
		CODBCFieldInfo fieldinfo; 
		for(int n=0;n<nFieldCount;n++)
		{
			m_pSet->GetODBCFieldInfo(n, fieldinfo);
			int nWidth = m_list1.GetStringWidth(fieldinfo.m_strName) + 15;
			m_list1.InsertColumn(n, fieldinfo.m_strName, LVCFMT_LEFT, nWidth);
		}
		// get recordset data information
		CString strValue; 
		m_encourageSet->MoveFirst(); 
		int nCount = 0;

		while(!m_encourageSet->IsEOF())
		{
			m_list1.InsertItem(nCount, strValue);
			for(int j=0;j<nFieldCount;j++)
			{
				m_encourageSet->GetFieldValue(j, strValue);
				m_list1.SetItemText(nCount, j, strValue);
			}
			m_encourageSet->MoveNext(); 
			nCount ++;
		}

}

}

void CDevelopView::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
    long m=m_list1.GetSelectionMark();
	Delcount=m;
	Donum=m_list1.GetItemText(m,0);
	CString strSQL;

	strSQL="select * from Informatiom";//~~~~~~~~~~~
	if(m_pSet->IsOpen()) m_pSet->Close();  
	m_pSet->Open(CRecordset::dynaset, strSQL);
 //   m_pSet->MoveFirst(); 
    while(!m_pSet->IsEOF())
	{
      if(m_pSet->m_column4==Donum)
	  {
//	     m_pSet->Edit();
         m_name=m_pSet->m_column2;
         m_sex=m_pSet->m_column3;
         m_num=m_pSet->m_column4;
         m_dormitory=m_pSet->m_column5;
         m_class=m_pSet->m_column6;
         m_tel=m_pSet->m_column7;
         m_mobile=m_pSet->m_E_mail;
         m_Email=m_pSet->m_Mobile;
		 break;
	  }
      else
      {
     	 m_pSet->MoveNext();
      }
	}




	strSQL="select * from Encourage";//~~~~~~~~~~~
	if(m_encourageSet->IsOpen()) m_encourageSet->Close();  
	m_encourageSet->Open(CRecordset::dynaset, strSQL);
//	m_encourageSet->MoveFirst(); 
	m_name2="";
    m_num2="";
    m_encourage2="";
    while(!m_encourageSet->IsEOF())
	{
      if(m_encourageSet->m_column3==m_num)
	  {
//	     m_encourageSet->Edit();
		 m_name2=m_encourageSet->m_column2;
         m_num2=m_encourageSet->m_column3;
         m_encourage2=m_encourageSet->m_column5;
	     break;
	  }
      else
      {
     	 m_encourageSet->MoveNext();
      }
	}

	strSQL="select * from Repair";//~~~~~~~~~~~
	if(m_repairSet->IsOpen()) m_repairSet->Close();  
	m_repairSet->Open(CRecordset::dynaset, strSQL);
//  m_repairSet->MoveFirst(); 
    m_name3="";
    m_num3="";
    m_repair3="";
    while(!m_repairSet->IsEOF())
	{
      if(m_repairSet->m_column3==m_num)
	  {
//	     m_repairSet->Edit();
         m_name3=m_repairSet->m_column2;
         m_num3=m_repairSet->m_column3;
         m_repair3=m_repairSet->m_column5;
		 break;
	  }
      else
      {
     	 m_repairSet->MoveNext();
      }
	}


    WorkModelinfo=2;
	CShowinfo info;
	info.DoModal();
}

void CDevelopView::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
if(table=="Informatiom")
{
    long m=m_list1.GetSelectionMark();
	Delcount=m;
	Donum=m_list1.GetItemText(m,3);

	strSQL="select * from Informatiom";//~~~~~~~~~~~
	if(m_pSet->IsOpen()) m_pSet->Close();  
	m_pSet->Open(CRecordset::dynaset, strSQL);
    while(!m_pSet->IsEOF())
	{
      if(m_pSet->m_column4==Donum)
	  {
         m_name=m_pSet->m_column2;
         m_sex=m_pSet->m_column3;
         m_num=m_pSet->m_column4;
         m_dormitory=m_pSet->m_column5;
         m_class=m_pSet->m_column6;
         m_tel=m_pSet->m_column7;
         m_mobile=m_pSet->m_E_mail;
         m_Email=m_pSet->m_Mobile;
		 break;
	  }
      else
      {
     	 m_pSet->MoveNext();
      }
	}

	strSQL="select * from Encourage";//~~~~~~~~~~~
	if(m_encourageSet->IsOpen()) m_encourageSet->Close();  
	m_encourageSet->Open(CRecordset::dynaset, strSQL);
	m_name2="";
    m_num2="";
    m_encourage2="";
    while(!m_encourageSet->IsEOF())
	{
      if(m_encourageSet->m_column3==m_num)
	  {
		 m_name2=m_encourageSet->m_column2;
         m_num2=m_encourageSet->m_column3;
         m_encourage2=m_encourageSet->m_column5;
	     break;
	  }
      else
      {
     	 m_encourageSet->MoveNext();
      }
	}

	strSQL="select * from Repair";//~~~~~~~~~~~
	if(m_repairSet->IsOpen()) m_repairSet->Close();  
	m_repairSet->Open(CRecordset::dynaset, strSQL);
    m_name3="";
    m_num3="";
    m_repair3="";
    while(!m_repairSet->IsEOF())
	{
      if(m_repairSet->m_column3==m_num)
	  {
         m_name3=m_repairSet->m_column2;
         m_num3=m_repairSet->m_column3;
         m_repair3=m_repairSet->m_column5;
		 break;
	  }
      else
      {
     	 m_repairSet->MoveNext();
      }
	}
}
else if(table=="Repair")
{
	long m=m_list1.GetSelectionMark();
	Delcount=m;
	Donum=m_list1.GetItemText(m,2);
	strSQL="select * from Encourage";
	if(m_encourageSet->IsOpen()) m_encourageSet->Close();  
	m_encourageSet->Open(CRecordset::dynaset, strSQL);
	m_name2="";
    m_num2="";
    m_encourage2="";
    while(!m_encourageSet->IsEOF())
	{
      if(m_encourageSet->m_column3==Donum)
	  {
		 m_name2=m_encourageSet->m_column2;
         m_num2=m_encourageSet->m_column3;
         m_encourage2=m_encourageSet->m_column5;
	     break;
	  }
      else
      {
     	 m_encourageSet->MoveNext();
      }
	}

	strSQL="select * from Informatiom";//~~~~~~~~~~~
	if(m_pSet->IsOpen()) m_pSet->Close();  
	m_pSet->Open(CRecordset::dynaset, strSQL);
    while(!m_pSet->IsEOF())
	{
      if(m_pSet->m_column4==Donum)
	  {
         m_name=m_pSet->m_column2;
         m_sex=m_pSet->m_column3;
         m_num=m_pSet->m_column4;
         m_dormitory=m_pSet->m_column5;
         m_class=m_pSet->m_column6;
         m_tel=m_pSet->m_column7;
         m_mobile=m_pSet->m_E_mail;
         m_Email=m_pSet->m_Mobile;
		 break;
	  }
      else
      {
     	 m_pSet->MoveNext();
      }
	}

	m_name3="";
    m_num3="";
    m_repair3="";
	strSQL="select * from Repair";
	if(m_repairSet->IsOpen()) m_repairSet->Close();  
	m_repairSet->Open(CRecordset::dynaset, strSQL);
    while(!m_repairSet->IsEOF())
	{
      if(m_repairSet->m_column3==Donum)
	  {
         m_name3=m_repairSet->m_column2;
         m_num3=m_repairSet->m_column3;
         m_repair3=m_repairSet->m_column5;
		 break;
	  }
      else
      {
     	 m_repairSet->MoveNext();
      }
	}
 }
else if(table=="Encourage")
{
	long m=m_list1.GetSelectionMark();
	Delcount=m;
	Donum=m_list1.GetItemText(m,2);
	strSQL="select * from Encourage";
	if(m_encourageSet->IsOpen()) m_encourageSet->Close();  
	m_encourageSet->Open(CRecordset::dynaset, strSQL);
	m_name2="";
    m_num2="";
    m_encourage2="";
    while(!m_encourageSet->IsEOF())
	{
      if(m_encourageSet->m_column3==Donum)
	  {
		 m_name2=m_encourageSet->m_column2;
         m_num2=m_encourageSet->m_column3;
         m_encourage2=m_encourageSet->m_column5;
	     break;
	  }
      else
      {
     	 m_encourageSet->MoveNext();
      }
	}

	strSQL="select * from Informatiom";//~~~~~~~~~~~
	if(m_pSet->IsOpen()) m_pSet->Close();  
	m_pSet->Open(CRecordset::dynaset, strSQL);
    while(!m_pSet->IsEOF())
	{
      if(m_pSet->m_column4==Donum)
	  {
         m_name=m_pSet->m_column2;

⌨️ 快捷键说明

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