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

📄 usermanage.cpp

📁 java 大作业 《处方跟踪系统》源代码 gui界面
💻 CPP
字号:
// UserManage.cpp : implementation file
//

#include "stdafx.h"
#include "libraryMS.h"
#include "UserManage.h"
/////////////////////////////////////////////
#include "column.h"
#include "columns.h"
////////////////////////////////////////////
#include "datagrid.h"
#include "adodc.h"
#include "ADOConn.h"
#include "UserAdd.h"
#include "UserChange.h"
#include "LogLibrary.h"
////////////////////////////////////////////////

#include "COMDEF.h"




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


extern _bstr_t ConnectionString; 
extern _bstr_t UserID; 
extern _bstr_t Password;
extern _bstr_t strConnect;
/////////////////////////////////////////////////////////////////////////////
// CUserManage dialog


CUserManage::CUserManage(CWnd* pParent /*=NULL*/)
	: CDialog(CUserManage::IDD, pParent)
{
	//{{AFX_DATA_INIT(CUserManage)
	m_QUser = _T("");
	//}}AFX_DATA_INIT
}


void CUserManage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CUserManage)
	DDX_Control(pDX, IDC_Condition, m_condition);
	DDX_Control(pDX, IDC_ADODC1, m_adodc);
	DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
	DDX_Text(pDX, IDC_User_EDIT, m_QUser);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CUserManage, CDialog)
	//{{AFX_MSG_MAP(CUserManage)
	ON_BN_CLICKED(IDAdd, OnAdd)
	ON_BN_CLICKED(IDC_exit, Onexit)
	ON_BN_CLICKED(IDC_change, Onchange)
	ON_BN_CLICKED(IDDelete, OnDelete)
	ON_BN_CLICKED(IDC_Query, OnQuery)
	ON_BN_CLICKED(IDC_QueryAll, OnQueryAll)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CUserManage message handlers

BOOL CUserManage::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_condition.SetCurSel(0);
	UpdateData(false);
	m_adodc.SetConnectionString(strConnect);
	//m_adodc.SetRecordSource("SELECT IDUser as 用户名,NameUser as 身份, PaswUser as 用户密码 FROM t_User");
   m_adodc.Refresh();
   /* _variant_t vIndex;
	vIndex = long(0);
	m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80);
	
	vIndex = long(1);
	m_datagrid.GetColumns().GetItem(vIndex).SetWidth(90);
	*/
	//vIndex = long(2);
	//m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CUserManage::OnAdd() 
{
	// TODO: Add extra validation here
	CUserAdd add_dlg;
	add_dlg.DoModal();
	m_adodc.Refresh();
	
}

BEGIN_EVENTSINK_MAP(CUserManage, CDialog)
    //{{AFX_EVENTSINK_MAP(CUserManage)
	//ON_EVENT(CUserManage, IDC_DATAGRID1, -601 /* DblClick */, OnDblClickDatagrid1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

//DEL void CUserManage::OnDblClickDatagrid1() 
//DEL {
//DEL 	// TODO: Add your control notification handler code here
//DEL 		CString sRecord;
//DEL 	sRecord = "用户名:"+m_datagrid.GetItem(0)+"\n";
//DEL 	sRecord += "身份:"+m_datagrid.GetItem(1)+"\n";
//DEL 	sRecord += "密码:"+m_datagrid.GetItem(2)+"\n";
//DEL 
//DEL 	MessageBox(sRecord);
//DEL 	
//DEL }

void CUserManage::Onexit() 
{
	// TODO: Add your control notification handler code here
	OnOK();
	
}

void CUserManage::Onchange() 
{
	// TODO: Add your control notification handler code here
	//if(m_datagrid.GetItem(0))
	CUserChange change_dlg;
	change_dlg.m_IDUser = m_datagrid.GetItem(0);
	change_dlg.m_NameUser = m_datagrid.GetItem(1);
	change_dlg.m_PwdUser = m_datagrid.GetItem(2);
	
	change_dlg.DoModal();
	m_adodc.Refresh();
}

//DEL void CUserManage::OnRefresh() 
//DEL {
//DEL 	// TODO: Add your control notification handler code here
//DEL 	m_adodc.Refresh();
//DEL 	
//DEL }

void CUserManage::OnDelete() 
{
	// TODO: Add your control notification handler code here
//    if(m_adodc.GetRecordset().GetEof() == 1)
//	{
//		MessageBox("没有数据");
//		return;
//	}
    
	CUsers user;
	user.SetIDUser  (m_datagrid.GetItem(0));
	user.SetNameUser  (m_datagrid.GetItem(1));//删除功能可以不用设置NameUser
	//user.SetPwdUser  (m_datagrid.GetItem(2));//删除功能可以不用设置PwdUser

	CString str;

	if(user.GetNameUser() == "超级管理员")
	{
		MessageBox("超级管理员不能删除");
		return;
	}
	str="ID:    "+user.GetIDUser()+"\n"+"身份:  "+user.GetNameUser()+"\n";
	int nChoice = MessageBox(str,"确定要删除吗",MB_OKCANCEL|MB_ICONQUESTION);
    
	if(nChoice == IDOK)
	{
		CLogLibrary Log_dlg;
    	Log_dlg.DoModal();
	    user.SetLogUser(Log_dlg.m_logMS);
		MessageBox("删除进行");
		user.sql_delete(user.GetIDUser());
	}
	m_adodc.Refresh();
		
}

void CUserManage::OnQuery() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m_adodc.SetRecordSource("SELECT IDUser as 用户名, NameUser as 身份, PwdUser as 用户密码 FROM t_User where IDUser = '"+m_QUser+"'");
	m_adodc.Refresh();
}

void CUserManage::OnQueryAll() 
{
	// TODO: Add your control notification handler code here
	m_adodc.SetRecordSource("SELECT IDUser as 用户名, NameUser as 身份, PwdUser as 用户密码 FROM t_User ");
	m_adodc.Refresh();
}

⌨️ 快捷键说明

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