📄 jichu.cpp
字号:
// jichu.cpp : implementation file
//
#include "stdafx.h"
#include "test.h"
#include "jichu.h"
#include "yonghutianjia.h"
#include "tianjia.h"
#include "testSet.h"
#include "zhichenSet.h"
#include "bumenSet.h"
#include "zhiweiSet.h"
#include "yonghuSet.h"
#include "shituSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// jichu property page
IMPLEMENT_DYNCREATE(jichu, CPropertyPage)
jichu::jichu() : CPropertyPage(jichu::IDD)
{
//{{AFX_DATA_INIT(jichu)
m_nShezhi = -1;
//}}AFX_DATA_INIT
}
jichu::~jichu()
{
}
void jichu::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(jichu)
DDX_Control(pDX, IDC_LIST_JICHU, m_nOptionList);
DDX_Radio(pDX, IDC_RADIO_BUMEN, m_nShezhi);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(jichu, CPropertyPage)
//{{AFX_MSG_MAP(jichu)
ON_BN_CLICKED(IDC_OPTION_DELETE, OnOptionDelete)
ON_BN_CLICKED(IDC_OPTION_EDIT, OnOptionEdit)
ON_BN_CLICKED(IDC_RADIO_YONGHU, OnRadioYonghu)
ON_BN_CLICKED(IDC_RADIO_BUMEN, OnRadioBumen)
ON_BN_CLICKED(IDC_RADIO_ZHIWEI, OnRadioZhiwei)
ON_BN_CLICKED(IDC_RADIO_ZHICHENG, OnRadioZhicheng)
ON_BN_CLICKED(IDC_ADD, OnAdd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// jichu message handlers
void jichu::OnOptionDelete()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_nShezhi==3)
{
if(m_nOptionList.GetSelectionMark()!=-1)
{
CString tmp;
tmp=m_nOptionList.GetItemText(m_nOptionList.GetSelectionMark(),0);
CString tmep;
tmep.Format("请确认是否删除%s这个用户?\n(请注意,该删除操作无法恢复!)",tmp);
if(MessageBox(tmep,"警告",MB_OKCANCEL|MB_ICONWARNING)!=1)
return;
if(tmp!="admin")
{
CTestSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("managername='%s'",tmp);
m_Set.Open();
m_Set.Delete();
m_nOptionList.DeleteItem(m_nOptionList.GetSelectionMark());
m_Set.Close();
m_nOptionList.SetSelectionMark(-1);
MessageBox("删除成功!","提示",MB_OK);
}
else
{
MessageBox("超级用户不能删除!","警告",MB_ICONWARNING|MB_OK);
}
}
}
if(m_nShezhi>=0&&m_nShezhi<=2)
{
if(m_nOptionList.GetSelectionMark()!=-1)
{
CString tmp;
tmp=m_nOptionList.GetItemText(m_nOptionList.GetSelectionMark(),0);
CString tmep;
CString temp;
int ID;
switch(m_nShezhi)
{
case 0:
{
tmep.Format("请确认是否删除%s这个部门?\n(请注意,该删除操作无法恢复!)",tmp);
if(MessageBox(tmep,"警告",MB_OKCANCEL|MB_ICONWARNING)!=1)
return;
CBumenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("bumen='%s'",tmp);
m_Set.Open();
ID=m_Set.m_ID;
m_Set.Delete();
m_Set.Close();
m_nOptionList.DeleteItem(m_nOptionList.GetSelectionMark());
temp.Format("已经成功删除%s!",tmp);
MessageBox(temp,"提示",MB_OK);
CYonghuSet n_Set;
if(n_Set.IsOpen())
n_Set.Close();
tmp.Format("%i",ID);
n_Set.m_strFilter.Format("bumen='%s'",tmp);
n_Set.Open();
if(!n_Set.IsEOF())
{
n_Set.Edit();
for(;!n_Set.IsEOF();n_Set.MoveNext())
n_Set.m_bumen="";
}
n_Set.Close();
break;
}
case 1:
{
tmep.Format("请确认是否删除%s这个职位?\n(请注意,该删除操作无法恢复!)",tmp);
if(MessageBox(tmep,"警告",MB_OKCANCEL|MB_ICONWARNING)!=1)
return;
CZhiweiSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("zhiwei='%s'",tmp);
m_Set.Open();
ID=m_Set.m_ID;
m_Set.Delete();
m_Set.Close();
m_nOptionList.DeleteItem(m_nOptionList.GetSelectionMark());
temp.Format("已经成功删除%s!",tmp);
MessageBox(temp,"提示",MB_OK);
CYonghuSet n_Set;
if(n_Set.IsOpen())
n_Set.Close();
tmp.Format("%i",ID);
n_Set.m_strFilter.Format("zhiwei='%s'",tmp);
n_Set.Open();
if(!n_Set.IsEOF())
{
n_Set.Edit();
for(;!n_Set.IsEOF();n_Set.MoveNext()) n_Set.m_zhiwei="";
n_Set.Close();
}
break;
}
case 2:
{
tmep.Format("请确认是否删除%s这个职称?\n(请注意,该删除操作无法恢复!)",tmp);
if(MessageBox(tmep,"警告",MB_OKCANCEL|MB_ICONWARNING)!=1)
return;
CZhichenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("zhichen='%s'",tmp);
m_Set.Open();
ID=m_Set.m_ID;
m_Set.Delete();
m_Set.Close();
m_nOptionList.DeleteItem(m_nOptionList.GetSelectionMark());
temp.Format("已经成功删除%s!",tmp);
MessageBox(temp,"提示",MB_OK);
CYonghuSet n_Set;
if(n_Set.IsOpen())
n_Set.Close();
tmp.Format("%i",ID);
n_Set.m_strFilter.Format("zhichen='%s'",tmp);
n_Set.Open();
if(!n_Set.IsEOF())
{
n_Set.Edit();
for(;!n_Set.IsEOF();n_Set.MoveNext()) n_Set.m_zhichen="";
n_Set.Close();
}
break;
}
default:break;
}
}
}
}
void jichu::OnOptionEdit()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_nShezhi==3)
{
if(m_nOptionList.GetSelectionMark()!=-1)
{
yonghutianjia dlg;
CString tmp;
tmp=m_nOptionList.GetItemText(m_nOptionList.GetSelectionMark(),0);
dlg.m_nYonghu=tmp;
if(tmp=="admin") dlg.TYPE=FALSE;
if(dlg.DoModal()==IDOK)
{
if((dlg.m_nMima==dlg.m_nMima2)&&dlg.m_nMima!="")
{
CTestSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("managername='%s'",tmp);
m_Set.Open();
m_Set.Edit();
m_Set.m_managername=dlg.m_nYonghu;
m_Set.m_managerpassword=dlg.m_nMima;
m_Set.Update();
m_Set.Close();
}
else
{
MessageBox("用户名为空或输入的2次密码不相等或密码为空!","提示",MB_OK);
}
}
}
}
if(m_nShezhi>=0&&m_nShezhi<=2)
{
if(m_nOptionList.GetSelectionMark()!=-1)
{
tianjia dlg;
CString tmp;
tmp=m_nOptionList.GetItemText(m_nOptionList.GetSelectionMark(),0);
dlg.m_nIN=tmp;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_nIN!="")
{
CString tmep;
switch(m_nShezhi)
{
case 0:
{
CBumenSet m_Setc;
if(m_Setc.IsOpen())
m_Setc.Close();
m_Setc.m_strFilter.Format("bumen='%s'",tmp);
m_Setc.Open();
m_Setc.Edit();
m_Setc.m_bumen=dlg.m_nIN;
m_Setc.Update();
m_Setc.Close();
OnRadioBumen();
tmep.Format("已经成功把%s改成%s!",tmp,dlg.m_nIN);
MessageBox(tmep,"提示",MB_OK);
break;
}
case 1:
{
CZhiweiSet m_Seta;
if(m_Seta.IsOpen())
m_Seta.Close();
m_Seta.m_strFilter.Format("zhiwei='%s'",tmp);
m_Seta.Open();
m_Seta.Edit();
m_Seta.m_zhiwei=dlg.m_nIN;
m_Seta.Update();
m_Seta.Close();
OnRadioBumen();
tmep.Format("已经成功把%s改成%s!",tmp,dlg.m_nIN);
MessageBox(tmep,"提示",MB_OK);
break;
}
case 2:
{
CZhichenSet m_Setb;
if(m_Setb.IsOpen())
m_Setb.Close();
m_Setb.m_strFilter.Format("zhichen='%s'",tmp);
m_Setb.Open();
m_Setb.Edit();
m_Setb.m_zhichen=dlg.m_nIN;
m_Setb.Update();
m_Setb.Close();
OnRadioBumen();
tmep.Format("已经成功把%s改成%s!",tmp,dlg.m_nIN);
MessageBox(tmep,"提示",MB_OK);
break;
}
default:break;
}
}
else
{
MessageBox("不能为空!","提示",MB_OK);
}
}
}
}
}
void jichu::OnRadioYonghu()
{
// TODO: Add your control notification handler code here
CTestSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.Open(CRecordset::snapshot,"select * from manager order by managername DESC");
m_nOptionList.DeleteAllItems();
for(;!m_Set.IsEOF();m_Set.MoveNext())
{
m_nOptionList.InsertItem(0,m_Set.m_managername);
}
m_Set.Close();
}
void jichu::OnRadioBumen()
{
// TODO: Add your control notification handler code here
CBumenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.Open(CRecordset::snapshot,"select * from bumen order by bumen DESC");
m_nOptionList.DeleteAllItems();
for(;!m_Set.IsEOF();m_Set.MoveNext())
{
m_nOptionList.InsertItem(0,m_Set.m_bumen);
}
m_Set.Close();
}
void jichu::OnRadioZhiwei()
{
// TODO: Add your control notification handler code here
CZhiweiSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.Open(CRecordset::snapshot,"select * from zhiwei order by zhiwei DESC");
m_nOptionList.DeleteAllItems();
for(;!m_Set.IsEOF();m_Set.MoveNext())
{
m_nOptionList.InsertItem(0,m_Set.m_zhiwei);
}
m_Set.Close();
}
void jichu::OnRadioZhicheng()
{
// TODO: Add your control notification handler code here
CZhichenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.Open(CRecordset::snapshot,"select * from zhichen order by zhichen DESC");
m_nOptionList.DeleteAllItems();
for(;!m_Set.IsEOF();m_Set.MoveNext())
{
m_nOptionList.InsertItem(0,m_Set.m_zhichen);
}
m_Set.Close();
}
BOOL jichu::OnInitDialog()
{
CPropertyPage::OnInitDialog();
LV_COLUMN lvc;
lvc.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
lvc.fmt=LVCFMT_LEFT;
lvc.pszText="项目明细";
lvc.cx=250;
lvc.iSubItem=0;
m_nOptionList.InsertColumn(0,&lvc);
m_nOptionList.SetExtendedStyle(LVS_EX_FLATSB|
LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// TODO: Add extra initialization here
// |LVS_EX_ONECLICKACTIVATE|LVS_EX_UNDERLINEHOT);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void jichu::OnAdd()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_nShezhi==3)
{
yonghutianjia dlg;
if(dlg.DoModal()==IDOK)
{
if(dlg.m_nYonghu!=""
&&(dlg.m_nMima==dlg.m_nMima2)&&dlg.m_nMima!="")
{
CTestSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("managername='%s'",dlg.m_nYonghu);
m_Set.Open();
if(m_Set.IsEOF()) {
m_nOptionList.InsertItem(0,dlg.m_nYonghu);
m_Set.AddNew();
m_Set.m_managername=dlg.m_nYonghu;
m_Set.m_managerpassword=dlg.m_nMima;
m_Set.Update();
MessageBox("已经成功修改!","提示",MB_OK);
}
else
{
MessageBox("用户名已存在!","提示",MB_OK);
}
m_Set.Close();
}
else
{
MessageBox("用户名为空或输入的2次密码不相等或密码为空!","提示",MB_OK);
}
}
}
if(m_nShezhi>=0&&m_nShezhi<=2)
{
tianjia dlg;
if(dlg.DoModal()==IDOK&&dlg.m_nIN!="")
{
switch(m_nShezhi)
{
case 0:{
CBumenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("bumen='%s'",dlg.m_nIN);
m_Set.Open();
if(m_Set.IsEOF()) {
m_nOptionList.InsertItem(0,dlg.m_nIN);
m_Set.AddNew();
m_Set.m_bumen=dlg.m_nIN;
m_Set.Update();
}
else
{
MessageBox("项目已存在!","提示",MB_OK);
}
m_Set.Close();
break;
}
case 1:{
CZhiweiSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("zhiwei='%s'",dlg.m_nIN);
m_Set.Open();
if(m_Set.IsEOF()) {
m_nOptionList.InsertItem(0,dlg.m_nIN);
m_Set.AddNew();
m_Set.m_zhiwei=dlg.m_nIN;
m_Set.Update();
}
else
{
MessageBox("项目已存在!","提示",MB_OK);
}
m_Set.Close();
break;
}
case 2:{
CZhichenSet m_Set;
if(m_Set.IsOpen())
m_Set.Close();
m_Set.m_strFilter.Format("zhichen='%s'",dlg.m_nIN);
m_Set.Open();
if(m_Set.IsEOF()) {
m_nOptionList.InsertItem(0,dlg.m_nIN);
m_Set.AddNew();
m_Set.m_zhichen=dlg.m_nIN;
m_Set.Update();
}
else
{
MessageBox("项目已存在!","提示",MB_OK);
}
m_Set.Close();
break;
}
}
MessageBox("添加成功!","提示",MB_OK);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -