📄 dialogmight.cpp
字号:
// AddOperatorView.cpp : implementation file
//
#include "stdafx.h"
#include "DialogMight.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogMight
IMPLEMENT_DYNCREATE(CDialogMight, CDialog)
CDialogMight::CDialogMight()
: CDialog(CDialogMight::IDD)
{
//{{AFX_DATA_INIT(CDialogMight)
m_strId = _T("");
m_strOperator = _T("");
//}}AFX_DATA_INIT
}
void CDialogMight::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogMight)
DDX_Control(pDX, IDC_LIST_BOUND_ORIGN, m_ListBoundOrign);
DDX_Control(pDX, IDC_LIST_BOUND_NEW, m_ListBoundNew);
DDX_Text(pDX, IDC_EDIT_ID, m_strId);
DDX_Text(pDX, IDC_EDIT_OPERATOR, m_strOperator);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogMight, CDialog)
//{{AFX_MSG_MAP(CDialogMight)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
ON_BN_CLICKED(ID_BUTTON_SET, OnButtonSet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogMight diagnostics
#ifdef _DEBUG
void CDialogMight::AssertValid() const
{
CDialog::AssertValid();
}
void CDialogMight::Dump(CDumpContext& dc) const
{
CDialog::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDialogMight message handlers
void CDialogMight::OnButtonAdd()
{
// TODO: Add your control notification handler code here
int nItem, i;
CString name, value;
POSITION pos = m_ListBoundOrign.GetFirstSelectedItemPosition();
if (pos != NULL)
{
while (pos)
{
nItem = m_ListBoundOrign.GetNextSelectedItem(pos);
i = m_ListBoundNew.GetItemCount();
value = m_ListBoundOrign.GetItemText(nItem,0);
LVFINDINFO info;
info.flags = LVFI_PARTIAL|LVFI_STRING;
info.psz = value;
if(m_ListBoundNew.FindItem(&info) != -1)
continue;
m_ListBoundNew.InsertItem(i, value);
}
}
else
{
return;
}
}
void CDialogMight::OnButtonDel()
{
// TODO: Add your control notification handler code here
int nItem;
POSITION pos = m_ListBoundNew.GetFirstSelectedItemPosition();
if (pos != NULL)
{
while (pos)
{
nItem = m_ListBoundNew.GetNextSelectedItem(pos);
m_ListBoundNew.DeleteItem(nItem);
if(pos != 0)
pos--;
}
}
else
{
return;
}
}
void CDialogMight::SetMight()
{
strMight[0] = "操作员维护";
strMight[1] = "生产管理";
strMight[2] = "客户生产单查询";
strMight[3] = "生产任务查询";
strMight[4] = "物资采购";
strMight[5] = "物资出库";
strMight[6] = "物资退库";
strMight[7] = "仓库物资查询";
strMight[8] = "物资采购查询";
strMight[9] = "物资出库查询";
strMight[10] = "物资退库查询";
strMight[11] = "物资采购报表";
strMight[12] = "物资出库报表";
strMight[13] = "物资退库报表";
strMight[14] = "窗口收费";
strMight[15] = "收银记录查询";
strMight[16] = "收入报表";
strMight[17] = "部门维护";
strMight[18] = "原材料种类维护";
strMight[19] = "物品名维护";
strMight[20] = "数据库备份";
}
BOOL CDialogMight::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CenterWindow();
if(m_pMightSet->IsOpen())
m_pMightSet->Close();
m_ListBoundOrign.SetExtendedStyle
(m_ListBoundOrign.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_ListBoundNew.SetExtendedStyle
(m_ListBoundNew.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
m_ListBoundOrign.InsertColumn(0,"所有的权限",LVCFMT_LEFT,140,-1);
m_ListBoundNew.InsertColumn(0,"分配的权限",LVCFMT_LEFT,140,-1);
SetMight();
for(int i = 0; i < MAXRIGHT; i++)
{
if(i != 11)
m_ListBoundOrign.InsertItem(i, strMight[i]);
}
CString strSql;
strSql.Format("select * from [Might] where [OperatorId] = '%s'", m_strId);
if(m_pMightSet->IsOpen())
m_pMightSet->Close();
m_pMightSet->Open(CRecordset::snapshot, strSql);
while(!m_pMightSet->IsEOF())
{
m_ListBoundNew.InsertItem(m_ListBoundNew.GetItemCount(), strMight[m_pMightSet->m_Might]);
m_pMightSet->MoveNext();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogMight::OnButtonSet()
{
// TODO: Add your control notification handler code here
UpdateData();
CString strSql;
strSql.Format("delete from [Might] where [OperatorId] = '%s'", m_strId);
m_pMightSet->m_pDatabase->ExecuteSQL(strSql);
for(int i = 0; i < m_ListBoundNew.GetItemCount(); i++)
{
for(int j = 0; j < MAXRIGHT; j++)
{
if(strMight[j] == m_ListBoundNew.GetItemText(i , 0))
break;
}
if(!m_pMightSet->IsOpen())
m_pMightSet->Open();
m_pMightSet->AddNew();
m_pMightSet->m_OperatorId = m_strId;
m_pMightSet->m_Might = j;
m_pMightSet->Update();
}
MessageBox("设置成功");
}
LRESULT CDialogMight::OnKickIdle(WPARAM, LPARAM lCount)
{
// Do idle processing here, just like CWinApp::OnIdle
//
Sleep(100); //1ms
if(lCount >= 6000) //5分钟5*60*1000=3000*100
{
CDialogEnter dlg;
dlg.m_strUser = m_strOperatorId;
dlg.m_pOperatorSet = m_pOperatorSet;
dlg.DoModal();
return FALSE;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -