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

📄 dcurview.cpp

📁 物流综合管理系统
💻 CPP
字号:
// DCurView.cpp : implementation file
//

#include "stdafx.h"
#include "MyProject.h"
#include "DCurView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDCurView dialog


CDCurView::CDCurView(CWnd* pParent /*=NULL*/)
	: CDialog(CDCurView::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDCurView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDCurView::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDCurView)
	DDX_Control(pDX, IDC_STANAME, m_StaName);
	DDX_Control(pDX, IDC_LIST1, m_List);
	DDX_Control(pDX, IDC_CHKYSGL, m_ChkYSGL);
	DDX_Control(pDX, IDC_CHKXTGL, m_ChkXTGL);
	DDX_Control(pDX, IDC_CHKPSGL, m_ChkPSGL);
	DDX_Control(pDX, IDC_CHKXSGL, m_ChkXSGL);
	DDX_Control(pDX, IDC_CHKJCXX, m_ChkJCXX);
	DDX_Control(pDX, IDC_CHKJCGL, m_ChkJCGL);
	DDX_Control(pDX, IDC_CHKCKGL, m_ChkCKGL);
	DDX_Control(pDX, IDC_CHKBGGL, m_ChkBGGL);
	DDX_Control(pDX, IDC_BUTSAVE, m_ButSave);
	DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
	DDX_Control(pDX, IDC_BUTCHANGE, m_ButChange);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDCurView, CDialog)
	//{{AFX_MSG_MAP(CDCurView)
	ON_BN_CLICKED(IDC_BUTCHANGE, OnButchange)
	ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
	ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnItemchangedList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDCurView message handlers

void CDCurView::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

void CDCurView::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}


void CDCurView::OnButchange() 
{

	this->Enabled(true);	
}

void CDCurView::OnButsave() 
{
	if(MessageBox("确定要保存对用户权限的修改吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL;
	RxRecordset rst;
	sSQL.Format("UPDATE 权限表 SET 基础信息=%d,仓库管理=%d,运输管理=%d,配送管理=%d,销售管理=%d,报关管理=%d,系统管理=%d,决策管理=%d WHERE 操作员编号=%s",m_ChkJCXX.GetCheck(),m_ChkCKGL.GetCheck(),m_ChkYSGL.GetCheck(),m_ChkXSGL.GetCheck(),m_ChkPSGL.GetCheck(),m_ChkBGGL.GetCheck(),m_ChkXTGL.GetCheck(),m_ChkJCGL.GetCheck(),m_sID);
	rst.Open(sSQL,adCmdText);
	this->Enabled(false);
}

void CDCurView::OnButexit() 
{
	this->OnCancel();	
}

void CDCurView::Enabled(bool bEnabled)
{
	this->m_ButChange.EnableWindow(!bEnabled);
	this->m_ButExit.EnableWindow(!bEnabled);
	this->m_ButSave.EnableWindow(bEnabled);
	this->m_ChkBGGL.EnableWindow(bEnabled);
	this->m_ChkCKGL.EnableWindow(bEnabled);
	this->m_ChkJCGL.EnableWindow(bEnabled);
	this->m_ChkJCXX.EnableWindow(bEnabled);
	this->m_ChkPSGL.EnableWindow(bEnabled);
	this->m_ChkXSGL.EnableWindow(bEnabled);
	this->m_ChkXTGL.EnableWindow(bEnabled);
	this->m_ChkYSGL.EnableWindow(bEnabled);
	this->m_List.EnableWindow(!bEnabled);
}

BOOL CDCurView::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//筛选出操作员信息表中存在而权限表中不存在记录
	RxRecordset rst;
	CString sSQL;
	CString sName,sID;
	sSQL.Format("SELECT * FROM 操作员信息表 WHERE 操作员编号 NOT IN(SELECT 操作员编号 FROM 权限表)");
	rst.Open(sSQL,adCmdText);
	if(rst.GetRecordCount()>=1)
	{
		for(int i=0;i<rst.GetFieldCount();i++)
		{
			rst.Move(i);
			sID=rst.GetFieldValue("操作员编号");
			sSQL.Format("INSERT INTO 权限表 VALUES (%s,1,1,1,1,1,1,1,1)",sID);
			rst.Open(sSQL,adCmdText);
		}
	
	
	}
	m_ImageList.Create(32,32,ILC_COLOR32|ILC_MASK,0,0);
	m_ImageList.Add(::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_USER)));
	this->m_List.SetImageList(&m_ImageList,LVSIL_NORMAL);
	rst.Open("操作员信息表");
	if(rst.GetRecordCount()<1)
		return true;
	for(int i=1;i<rst.GetRecordCount();i++)
	{
		rst.Move(i);
		sName=rst.GetFieldValue("用户名");
		this->m_List.InsertItem(i,sName,0);
	}
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CDCurView::Display(CString sID)
{
	RxRecordset dRst;
	CString sSQL;
	sSQL.Format("SELECT * FROM 权限表 WHERE 操作员编号=%s",sID);
	dRst.Open(sSQL,adCmdText);
	if(dRst.GetRecordCount()<1)
		return;
	this->m_ChkJCXX.SetCheck(atoi(dRst.GetFieldValue("基础信息")));
	this->m_ChkCKGL.SetCheck(atoi(dRst.GetFieldValue("仓库管理")));
	this->m_ChkXSGL.SetCheck(atoi(dRst.GetFieldValue("销售管理")));
	this->m_ChkYSGL.SetCheck(atoi(dRst.GetFieldValue("运输管理")));
	this->m_ChkPSGL.SetCheck(atoi(dRst.GetFieldValue("配送管理")));
	this->m_ChkBGGL.SetCheck(atoi(dRst.GetFieldValue("报关管理")));
	this->m_ChkJCGL.SetCheck(atoi(dRst.GetFieldValue("决策管理")));
	this->m_ChkXTGL.SetCheck(atoi(dRst.GetFieldValue("系统管理")));
}	

void CDCurView::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CString sName;
	sName=this->m_List.GetItemText(m_List.GetSelectionMark(),0);
	this->m_StaName.SetWindowText(sName);
	m_sID=ado.FieldToOtherField("操作员信息表","用户名",sName,"操作员编号",1);
	this->Display(m_sID);
	
	*pResult = 0;
}

void CDCurView::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	
	OnDblclkList1(pNMHDR,pResult);
	*pResult = 0;
}

⌨️ 快捷键说明

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