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

📄 systemdlg.cpp

📁 学生成绩管理系统
💻 CPP
字号:
// SYSTEMDLG.cpp : implementation file
//

#include "stdafx.h"
#include "cyj.h"
#include "SYSTEMDLG.h"

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

/////////////////////////////////////////////////////////////////////////////
// SYSTEMDLG dialog


SYSTEMDLG::SYSTEMDLG(CWnd* pParent /*=NULL*/)
	: CDialog(SYSTEMDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(SYSTEMDLG)
	m_newpass = _T("");
	m_newpassr = _T("");
	m_oldpass = _T("");
	m_pass = _T("");
	m_passr = _T("");
	m_user = _T("");
	//}}AFX_DATA_INIT
}


void SYSTEMDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SYSTEMDLG)
	DDX_Control(pDX, IDC_POWER, m_combo);
	DDX_Control(pDX, IDC_LIST2, m_list);
	DDX_Text(pDX, IDC_NEWPASS, m_newpass);
	DDX_Text(pDX, IDC_NEWPASSR, m_newpassr);
	DDX_Text(pDX, IDC_OLDPASS, m_oldpass);
	DDX_Text(pDX, IDC_PASS, m_pass);
	DDX_Text(pDX, IDC_PASSR, m_passr);
	DDX_Text(pDX, IDC_USER, m_user);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(SYSTEMDLG, CDialog)
	//{{AFX_MSG_MAP(SYSTEMDLG)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_HELP1, OnHelp1)
	ON_BN_CLICKED(IDC_MODIFY, OnModify)
	ON_BN_CLICKED(IDC_DEL, OnDel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// SYSTEMDLG message handlers

void SYSTEMDLG::OnAdd() 
{	UpdateData();
	CString str,temp;
	m_combo.GetLBText(m_combo.GetCurSel(),temp);
	str.Format("insert into password values('%s','%s','%s')",m_user,m_pass,temp);
	pdb->ExecuteSQL(str);
	m_pSet->Requery();
	if(m_pass!=m_passr)
	{
		MessageBox("用户密码与用户密码确认不同,请重新输入密码!");
        	pdb->ExecuteSQL(str);
	m_pSet->Requery();
		
	}
	else
	{
		
		ShowData();
	}
	
	
}

void SYSTEMDLG::OnHelp1() 
{	CString sPath;
 GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
 sPath.ReleaseBuffer();
 int nPos;
 nPos=sPath.ReverseFind('\\');
 sPath=sPath.Left(nPos);
    nPos=sPath.ReverseFind('\\');
 sPath=sPath.Left(nPos);
 ShellExecute(NULL,NULL,_T("help.doc"),NULL,_T(sPath),NULL);

	
}

void SYSTEMDLG::OnModify() 
{UpdateData();
	CString str,tempr,getpassword;
	m_list.GetText(m_list.GetCurSel(),tempr);
	tempr=tempr.Left(tempr.GetLength()-8);
 	m_pSet->MoveFirst();  
    while(!m_pSet->IsEOF())
    {	  
	   m_pSet->m_user.TrimRight();	   
       if(m_pSet->m_user==tempr)
	      {getpassword=m_pSet->m_password;break;}
	   else  m_pSet->MoveNext();
	 }
       getpassword.TrimRight();
       if(m_oldpass==getpassword)
	   {if(m_newpass==m_newpassr)
		   {
		     m_pSet->Edit();		  
		     m_pSet->m_password=m_newpass;
			 m_pSet->Update();
             m_pSet->Requery(); 
			 MessageBox("修改密码成功!!!");
		  
	   }
	   else MessageBox("两次输入不相符!!!");
	   }
	   else MessageBox("密码错误,请重新输入!!!");
	 
   
	UpdateData(false);	
	

	
}

void SYSTEMDLG::OnDel() 
{
CString str,tempr;
   if(m_list.GetCurSel()==-1)
   {MessageBox("请选中一个再删除");return;}
   else
   { m_list.GetText(m_list.GetCurSel(),tempr);
       tempr=tempr.Left(tempr.GetLength()-8);
	   m_pSet->MoveFirst();	
	  while(!m_pSet->IsEOF())
	  {
		 m_pSet->m_user.TrimRight();  
 	     if(m_pSet->m_user==tempr)
		 {if(MessageBox("确定要删除吗?","提示",MB_YESNO))	 
		 {m_pSet->Delete();
           m_pSet->Requery();
		   ShowData();
           MessageBox("注销成功!!!");break;
		 }
		 else return ;}
		 m_pSet->MoveNext();
	   }          
   }   
	
}

BOOL SYSTEMDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	 pdb=new CDatabase;
	pdb->Open("ODBC;DSN=成绩管理");
	m_pSet=new PASSSET(pdb);
    m_pSet->Open();
    m_combo.SetCurSel(0);
	ShowData();	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void SYSTEMDLG::ShowData()
{
	for(int k=m_list.GetCount();k>=0;k--)
    m_list.DeleteString(k);
	int i=0;
 
	while(!m_pSet->IsEOF())
	{ m_pSet->m_user.TrimRight();
      m_pSet->m_power.TrimRight();
	  m_list.InsertString(i,m_pSet->m_user+"["+m_pSet->m_power+"]");
	  i++;
	  m_pSet->MoveNext();
	}
    

}

⌨️ 快捷键说明

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