📄 ydczygl.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "YDczygl.h"
#include "YDdatam.h"
#include "YDmain.h"
#include "YHDL.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFczygl *Fczygl;
TTreeNode *root,*node,*node1;
//---------------------------------------------------------------------------
__fastcall TFczygl::TFczygl(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::FormClose(TObject *Sender, TCloseAction &Action)
{
Fmain->Menuint();
Fmain->gnjs(Fmain->tcjc);
Action = caFree;
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::FormCreate(TObject *Sender)
{
Addms=false;
YDData->TBczy->Open();
YDData->TBmenu->Open();
root=new TTreeNode(TreeView1->Items);
node=new TTreeNode(TreeView1->Items);
node1=new TTreeNode(TreeView1->Items);
Clist();
}
//
void TFczygl::Freshtree()
{
TreeView1->Items->Clear();
root=TreeView1->Items->AddChild(NULL,"全部操作员");
root->ImageIndex=0;
root->SelectedIndex=1;
YDData->TBczy->First();
while (!YDData->TBczy->Eof)
{
node=TreeView1->Items->AddChild(root,YDData->TBczy->FieldByName("czymc")->AsString);
node->ImageIndex=0;
node->SelectedIndex=1;
YDData->TBczy->Next();
}
TreeView1->FullExpand();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::FormActivate(TObject *Sender)
{
if (CLogin->kzqx=="0")
PageControl1->Enabled=false;
else PageControl1->Enabled=true;
Freshtree();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton10Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::FormKeyPress(TObject *Sender, char &Key)
{
if(Key==VK_RETURN)
{
SendMessage(this->Handle,WM_NEXTDLGCTL,0,0);
Key=0;
}
}
//---------------------------------------------------------------------------
void TFczygl::Modify()
{
//TODO: Add your source code here
SpeedButton5->Caption="保存";
SpeedButton6->Caption="还原";
SpeedButton5->Glyph->LoadFromFile("c:\\ydgl_c\\bmps\\save.bmp");
SpeedButton6->Glyph->LoadFromFile("c:\\ydgl_c\\bmps\\Undo.bmp");
SpeedButton7->Enabled=false;
DBEdit1->ReadOnly=false;
DBEdit2->ReadOnly=false;
}
void TFczygl::Browse()
{
//TODO: Add your source code here
SpeedButton5->Caption="新增";
SpeedButton6->Caption="修改";
SpeedButton5->Glyph->LoadFromFile("c:\\ydgl_c\\bmps\\add.bmp");
SpeedButton6->Glyph->LoadFromFile("c:\\ydgl_c\\bmps\\wzedit.bmp");
SpeedButton7->Enabled=true;
DBEdit1->ReadOnly=true;
DBEdit2->ReadOnly=true;
}
void __fastcall TFczygl::SpeedButton7Click(TObject *Sender)
{
if (YDData->TBczy->FieldByName("KZQX1")->AsString=="1")
{
ShowMessage("对不起,不能删除系统管理员!");
return ;
}
if ( Application->MessageBox("真的要删除当前操作员吗?","提示", MB_YESNO|MB_ICONQUESTION)==IDYES)
{
YDData->TBczy->Delete();
TreeView1->Items->Delete(TreeView1->Selected);
Clist();
};
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton6Click(TObject *Sender)
{
if (SpeedButton6->Caption=="修改")
{
Modify();
YDData->TBczy->Edit();
}
else
{
YDData->TBczy->Cancel();
Browse();
}
Clist();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton5Click(TObject *Sender)
{
if (SpeedButton5->Caption=="新增")
{
Addms=true;
Modify();
DBEdit1->SetFocus();
YDData->TBczy->Append();
YDData->TBczy->FieldByName("kzqx1")->AsString="0";
YDData->TBczy->FieldByName("czqx1")->AsString="S12S18W11W12W13W14W16H11H12H13";
}
else
{
if (Trim(DBEdit1->Text)!="")
{
if (Addms&&Edit1->Text!=DBEdit2->Text)
{
MessageBox(NULL,"密码不一致,请重新输入!","提示",MB_OK|MB_ICONWARNING);
DBEdit2->SetFocus();
return;
};
YDData->TBczy->Post();
Clist();
Edit1->Text=DBEdit2->Text;
if (Addms)
{
node=TreeView1->Items->AddChild(root,YDData->TBczy->FieldByName("czymc")->AsString);
node->ImageIndex=0;
node->SelectedIndex=1;
}
else Freshtree();
Addms=false;
YDData->TBczy->Close();
YDData->TBczy->Open();
Browse();
}
else MessageBox(NULL,"操作员名称不能为空!","提示",MB_OK|MB_ICONWARNING);
}
Clist();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::TreeView1Click(TObject *Sender)
{
YDData->TBczy->First();
while (!YDData->TBczy->Eof)
{
if (YDData->TBczy->FieldByName("czymc")->AsString==TreeView1->Selected->Text)
break;
YDData->TBczy->Next();
}
Clist();
}
//---------------------------------------------------------------------------
void TFczygl::Clist()
{
ListBox1->Items->Clear();
ListBox2->Items->Clear();
YDData->TBmenu->First();
while (!YDData->TBmenu->Eof)
{
if (YDData->TBczy->FieldByName("CZQX1")->AsString.AnsiPos(YDData->TBmenu->FieldByName("jc")->AsString)==0)
ListBox1->Items->Add(YDData->TBmenu->FieldByName("cdxm")->AsString);
else ListBox2->Items->Add(YDData->TBmenu->FieldByName("cdxm")->AsString);
YDData->TBmenu->Next();
}
}
void __fastcall TFczygl::SpeedButton1Click(TObject *Sender)
{
int i;
for (i=0;i<ListBox1->Items->Count;i++)
{
if (ListBox1->Selected[i]==true)
{
YDData->TBmenu->First();
AnsiString cddm;
while (!YDData->TBmenu->Eof)
{
if (YDData->TBmenu->FieldByName("cdxm")->AsString==ListBox1->Items->Strings[i])
{
cddm=YDData->TBmenu->FieldByName("jc")->AsString;
break;
}
YDData->TBmenu->Next();
}
YDData->TBczy->Edit();
YDData->TBczy->FieldByName("czqx1")->AsString=YDData->TBczy->FieldByName("czqx1")->AsString+cddm;
YDData->TBczy->Post();
ListBox2->Items->Add(ListBox1->Items->Strings[i]);
ListBox1->Items->Delete(i);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton2Click(TObject *Sender)
{
int i;
for (i=0;i<ListBox1->Items->Count;i++)
{
ListBox2->Items->Add(ListBox1->Items->Strings[i]);
}
YDData->TBmenu->First();
AnsiString gnqx="";
while (!YDData->TBmenu->Eof)
{
gnqx=gnqx+YDData->TBmenu->FieldByName("jc")->AsString;
YDData->TBmenu->Next();
}
YDData->TBczy->Edit();
YDData->TBczy->FieldByName("czqx1")->AsString=gnqx;
YDData->TBczy->Post();
ListBox1->Items->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton4Click(TObject *Sender)
{
int i;
for (i=0;i<ListBox2->Items->Count;i++)
{
ListBox1->Items->Add(ListBox2->Items->Strings[i]);
}
YDData->TBczy->Edit();
YDData->TBczy->FieldByName("czqx1")->AsString="";
YDData->TBczy->Post();
ListBox2->Items->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TFczygl::SpeedButton3Click(TObject *Sender)
{
int i;
for (i=0;i<ListBox2->Items->Count;i++)
{
if (ListBox2->Selected[i]==true)
{
AnsiString gnqx=YDData->TBczy->FieldByName("czqx1")->AsString;
AnsiString cddm;
YDData->TBmenu->First();
while (!YDData->TBmenu->Eof)
{
if (YDData->TBmenu->FieldByName("cdxm")->AsString==ListBox2->Items->Strings[i])
{
cddm=YDData->TBmenu->FieldByName("jc")->AsString;
break;
}
YDData->TBmenu->Next();
}
int bbb=0;
for (int i=0;i<=gnqx.Length()/3;i++)
{
if (gnqx.SubString(i*3+1,3)==cddm)
{
bbb=1;
break;
};
}
if (bbb==1)
{
YDData->TBczy->Edit();
YDData->TBczy->FieldByName("czqx1")->AsString=gnqx.Delete(i*3+1,3);
YDData->TBczy->Post();
};
ListBox1->Items->Add(ListBox2->Items->Strings[i]);
ListBox2->Items->Delete(i);
}
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -