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

📄 dlgpurview.cpp

📁 这是一个信息管理系统的源代码
💻 CPP
字号:
// DlgPurview.cpp : implementation file
//

#include "stdafx.h"
#include "a1.h"
#include "DlgPurview.h"

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


/////////////////////////////////////////////////////////////////////////////
// CDlgPurview dialog


CDlgPurview::CDlgPurview(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgPurview::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgPurview)
	m_iPurview = -1;
	m_bXiaoshou = FALSE;
	m_bRuku = FALSE;
	m_bKucun = FALSE;
	m_bDiaohuo = FALSE;
	m_bCaiwu = FALSE;
	m_bZhangmu = FALSE;
	m_bJichuxinxi = FALSE;
	m_bXitong = FALSE;
	//}}AFX_DATA_INIT
	this->m_iNewPurview=0;
	this->m_iOldPurview=0;
}


void CDlgPurview::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgPurview)
	DDX_Control(pDX, IDC_CHECK10, m_btnXitong);
	DDX_Control(pDX, IDC_CHECK9, m_btnJichuxinxi);
	DDX_Control(pDX, IDC_CHECK8, m_btnZhangmu);
	DDX_Control(pDX, IDC_CHECK7, m_btnCaiwu);
	DDX_Control(pDX, IDC_CHECK6, m_btnDiaohuo);
	DDX_Control(pDX, IDC_CHECK5, m_btnKucun);
	DDX_Control(pDX, IDC_CHECK3, m_btnRuku);
	DDX_Control(pDX, IDC_CHECK2, m_btnXiaoshou);
	DDX_Radio(pDX, IDC_RADIO1, m_iPurview);
	DDX_Check(pDX, IDC_CHECK2, m_bXiaoshou);
	DDX_Check(pDX, IDC_CHECK3, m_bRuku);
	DDX_Check(pDX, IDC_CHECK5, m_bKucun);
	DDX_Check(pDX, IDC_CHECK6, m_bDiaohuo);
	DDX_Check(pDX, IDC_CHECK7, m_bCaiwu);
	DDX_Check(pDX, IDC_CHECK8, m_bZhangmu);
	DDX_Check(pDX, IDC_CHECK9, m_bJichuxinxi);
	DDX_Check(pDX, IDC_CHECK10, m_bXitong);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgPurview, CDialog)
	//{{AFX_MSG_MAP(CDlgPurview)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	ON_BN_CLICKED(IDC_CHECK3, OnCheck3)
	ON_BN_CLICKED(IDC_CHECK5, OnCheck5)
	ON_BN_CLICKED(IDC_CHECK6, OnCheck6)
	ON_BN_CLICKED(IDC_CHECK7, OnCheck7)
	ON_BN_CLICKED(IDC_CHECK8, OnCheck8)
	ON_BN_CLICKED(IDC_CHECK9, OnCheck9)
	ON_BN_CLICKED(IDC_CHECK10, OnCheck10)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgPurview message handlers

BOOL CDlgPurview::OnInitDialog() 
{
	CDialog::OnInitDialog();
	this->GetDataFromDatabase(m_iOldPurview);
	this->RefreshData(this->m_iOldPurview);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgPurview::OnOK() 
{
	this->UpdateData();
	
	CDialog::OnOK();
}

void CDlgPurview::RefreshData(int purview)
{
	m_iPurview=purview;
	switch(purview)
	{
	case 0:
		this->m_bCaiwu=true;
		this->m_bDiaohuo=true;
		this->m_bJichuxinxi=true;
		this->m_bKucun=true;
		this->m_bRuku=true;
		this->m_bXiaoshou=true;
		this->m_bXitong=true;
		this->m_bZhangmu=true;
		this->m_btnCaiwu.EnableWindow(false);
		this->m_btnDiaohuo.EnableWindow(false);
		this->m_btnJichuxinxi.EnableWindow(false);
		this->m_btnKucun.EnableWindow(false);
		this->m_btnRuku.EnableWindow(false);
		this->m_btnXiaoshou.EnableWindow(false);
		this->m_btnXitong.EnableWindow(false);
		this->m_btnZhangmu.EnableWindow(false);
		break;
	case 1:
		this->m_btnCaiwu.EnableWindow(true);
		this->m_btnDiaohuo.EnableWindow(true);
		this->m_btnJichuxinxi.EnableWindow(true);
		this->m_btnKucun.EnableWindow(true);
		this->m_btnRuku.EnableWindow(true);
		this->m_btnXiaoshou.EnableWindow(true);
		this->m_btnXitong.EnableWindow(true);
		this->m_btnZhangmu.EnableWindow(true);
		break;
	case 2:

		this->m_btnCaiwu.EnableWindow(true);
		this->m_btnDiaohuo.EnableWindow(true);
		this->m_btnJichuxinxi.EnableWindow(true);
		this->m_btnKucun.EnableWindow(true);
		this->m_btnRuku.EnableWindow(true);
		this->m_btnXiaoshou.EnableWindow(true);
		this->m_btnXitong.EnableWindow(true);
		this->m_btnZhangmu.EnableWindow(true);
		break;
	case 3:

		this->m_btnCaiwu.EnableWindow(true);
		this->m_btnDiaohuo.EnableWindow(true);
		this->m_btnJichuxinxi.EnableWindow(true);
		this->m_btnKucun.EnableWindow(true);
		this->m_btnRuku.EnableWindow(true);
		this->m_btnXiaoshou.EnableWindow(true);
		this->m_btnXitong.EnableWindow(true);
		this->m_btnZhangmu.EnableWindow(true);
		break;
	}
	this->UpdateData(false);
}

void CDlgPurview::OnRadio1() 
{
	this->UpdateData();
	this->GetDataFromDatabase(m_iPurview);
	this->RefreshData(this->m_iPurview);
}

void CDlgPurview::OnRadio2() 
{
	this->UpdateData();
		this->GetDataFromDatabase(m_iPurview);
	this->RefreshData(this->m_iPurview);	
}

void CDlgPurview::OnRadio3() 
{
	this->UpdateData();
		this->GetDataFromDatabase(m_iPurview);
	this->RefreshData(this->m_iPurview);	
}

void CDlgPurview::OnRadio4() 
{
	this->UpdateData();
		this->GetDataFromDatabase(m_iPurview);
	this->RefreshData(this->m_iPurview);	
}

void CDlgPurview::OnCheck2() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_xiaoshou",m_bXiaoshou);
	
}
  
void CDlgPurview::GetDataFromDatabase(int purview)
{
	CString sql;
	sql.Format("select b_xiaoshou,b_ruku,b_kucun,b_diaohuo,b_caiwu,b_zhangmu,b_jichuxinxi,b_xitong from tabpurviewctrl where admi_purview=%d ",purview);
	_variant_t value;
	if(m_runsql.CheckSQLResult(sql))
	{
		value=m_runsql.m_recordset->GetCollect("b_xiaoshou");
		if(value.vt!=VT_NULL)
			this->m_bXiaoshou=(bool)value.boolVal;		
		value=m_runsql.m_recordset->GetCollect("b_ruku");
		if(value.vt!=VT_NULL)
			this->m_bRuku=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_kucun");
		if(value.vt!=VT_NULL)
			this->m_bKucun=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_diaohuo");
		if(value.vt!=VT_NULL)
			this->m_bDiaohuo=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_caiwu");
		if(value.vt!=VT_NULL)
			this->m_bCaiwu=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_zhangmu");
		if(value.vt!=VT_NULL)
			this->m_bZhangmu=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_jichuxinxi");
		if(value.vt!=VT_NULL)
			this->m_bJichuxinxi=(bool)value.boolVal;
		value=m_runsql.m_recordset->GetCollect("b_xitong");
		if(value.vt!=VT_NULL)
			this->m_bXitong=(bool)value.boolVal;
	}
}

void CDlgPurview::ChangeData(int purview, CString field,bool b_value)
{
	CString sql;
	sql.Format("update tabpurviewctrl set %s=%d  where admi_purview=%d ",
		field,b_value,purview);
	m_runsql.RunSQL(sql);
}

void CDlgPurview::OnCheck3() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_ruku",m_bRuku);
	
}

void CDlgPurview::OnCheck5() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_kucun",m_bKucun);
	
}

void CDlgPurview::OnCheck6() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_diaohuo",m_bDiaohuo);
	
}

void CDlgPurview::OnCheck7() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_caiwu",m_bCaiwu);
	
}

void CDlgPurview::OnCheck8() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_zhangmu",m_bZhangmu);
	
}

void CDlgPurview::OnCheck9() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_jichuxinxi",m_bJichuxinxi);
	
}

void CDlgPurview::OnCheck10() 
{
	this->UpdateData();
	this->ChangeData(m_iPurview,"b_xitong",m_bXitong);
	
}

⌨️ 快捷键说明

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