SIMPLE语言编译器

源代码在线查看: table.cpp

软件大小: 252 K
上传用户: lxwcqq
关键词: SIMPLE 语言 编译器
下载地址: 免注册下载 普通下载 VIP

相关代码

				// table.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "040410201lei.h"
				#include "table.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				/////////////////////////////////////////////////////////////////////////////
				// table dialog
				
				
				table::table(CWnd* pParent /*=NULL*/)
					: CDialog(table::IDD, pParent)
				{
					//{{AFX_DATA_INIT(table)
					m_sContent = _T("");
					m_sName = _T("");
					m_sCheckname = _T("");
					//}}AFX_DATA_INIT
				}
				
				
				void table::DoDataExchange(CDataExchange* pDX)
				{
					CDialog::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(table)
					DDX_Text(pDX, ID_TABLE_CONGTENT, m_sContent);
					DDX_Text(pDX, ID_TABLE_NAME, m_sName);
					DDX_CBString(pDX, ID_TABLE_SEARCH, m_sCheckname);
					//}}AFX_DATA_MAP
				}
				
				
				BEGIN_MESSAGE_MAP(table, CDialog)
					//{{AFX_MSG_MAP(table)
					ON_BN_CLICKED(ID_TABEL_ADD, OnTabelAdd)
					ON_BN_CLICKED(ID_TABLE_CHECK, OnTableCheck)
					ON_BN_CLICKED(ID_TABLE_DELETE, OnTableDelete)
					ON_BN_CLICKED(ID_TABLE_FREASH, OnTableFreash)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// table message handlers
				CMy040410201leiApp theApp;
				void table::OnTabelAdd() 
				{
					// TODO: Add your control notification handler code here
					// TODO: Add your control notification handler code here
					UpdateData(true);
					_variant_t  strQuery;
				
					m_sName.TrimRight(" ");
				    m_sContent.TrimRight(" ");
					CString sWarning="";
					if ( ""==m_sName ) sWarning=_T("符号名称");
					if ( ""!=sWarning ) 
					{
					   sWarning += _T("不能为空");
					   AfxMessageBox(sWarning, MB_ICONEXCLAMATION);
					   return;
					}
					// Insert Record
					strQuery = "select * from Fh where Name='"+m_sName+"'";
					    theApp.ADOExecute(theApp.m_pADOSet, strQuery);
					    int iCount = theApp.m_pADOSet->GetRecordCount();
					    if ( 0!=iCount )
						{
					       AfxMessageBox(_T("已经存在此符号记录!"), MB_ICONEXCLAMATION);
					       return;
						}
					strQuery = "insert Fh (Name, Content) values ('"+m_sName+"', '"+m_sContent+"')";
				
					if (theApp.ADOExecute(theApp.m_pADOSet, strQuery) ) 
					{
							AfxMessageBox(_T("添加符号信息成功!"), MB_ICONINFORMATION);
					        // Clear all input
				            m_sName=m_sContent="";
				            UpdateData(false);
						}
					else 
					{
						 AfxMessageBox(_T("添加符号信息失败!"), MB_ICONEXCLAMATION);
					}  
				}
				
				
				
				void table::OnTableCheck() 
				{
				// TODO: Add your control notification handler code here
					UpdateData(true);
					_variant_t strQuery, Holder;
					strQuery = "select * from Fh where Name like '"+m_sCheckname+"'  ";
					theApp.ADOExecute(theApp.m_pADOSet, strQuery);
					Holder = theApp.m_pADOSet->GetCollect("Name");
					m_sName = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
				    // Get Phone
					Holder = theApp.m_pADOSet->GetCollect("Content");
					m_sContent = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
						UpdateData(false);
				}
				
				
				void table::OnTableDelete() 
				{
					// TODO: Add your control notification handler code here
					UpdateData(true);
					_variant_t strQuery, Holder;
					strQuery = "delete from Fh where Name like '"+m_sCheckname+"'  ";
					theApp.ADOExecute(theApp.m_pADOSet, strQuery);
						UpdateData(false);
				}
				
				void table::OnTableFreash() 
				{
					// TODO: Add your control notification handler code here
				//	CComboBox  m_Ptfl;
				//	m_Ptfl.ResetContent();
					_variant_t strQuery, Holder;	
					strQuery = "select * from Fh";
					theApp.ADOExecute(theApp.m_pADOSet, strQuery);
				    int iCount = theApp.m_pADOSet->GetRecordCount();
						theApp.m_pADOSet->MoveFirst();
						for (int i=0; i						{
						    Holder = theApp.m_pADOSet->GetCollect("Name");
					        ((CComboBox*)GetDlgItem(ID_TABLE_SEARCH))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
						    // Get other onfo to display
							//if ( 0==i )
							//{
								// Get Person
								//Holder = theApp.m_pADOSet->GetCollect("ContactName");
								//m_sProviderPerson = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
				                // Get Phone
								//Holder = theApp.m_pADOSet->GetCollect("Phone");
								//m_sProviderPhone = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
							//}	
							m_sCheckname = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder; 
							theApp.m_pADOSet->MoveNext();
						}
					    ((CComboBox*)GetDlgItem(ID_TABLE_SEARCH))->SetCurSel(0);
					// TODO: Add extra initialization here
					
				}
				
				BOOL table::OnInitDialog() 
				{
					CDialog::OnInitDialog();
					_variant_t strQuery, Holder;	
					strQuery = "select * from Fh";
					theApp.ADOExecute(theApp.m_pADOSet, strQuery);
				    int iCount = theApp.m_pADOSet->GetRecordCount();
						//theApp.m_pADOSet->MoveFirst();
						for (int i=0; i						{
						    Holder = theApp.m_pADOSet->GetCollect("Name");
					        ((CComboBox*)GetDlgItem(ID_TABLE_SEARCH))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
						    // Get other onfo to display
							//if ( 0==i )
							//{
								// Get Person
								//Holder = theApp.m_pADOSet->GetCollect("ContactName");
								//m_sProviderPerson = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
				                // Get Phone
								//Holder = theApp.m_pADOSet->GetCollect("Phone");
								//m_sProviderPhone = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder;
							//}	
							m_sCheckname = Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder; 
							theApp.m_pADOSet->MoveNext();
						}
					    ((CComboBox*)GetDlgItem(ID_TABLE_SEARCH))->SetCurSel(0);
					// TODO: Add extra initialization here
					
					return TRUE;  // return TRUE unless you set the focus to a control
					              // EXCEPTION: OCX Property Pages should return FALSE
				}
							

相关资源