📄 hcl.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "HCL.h"
#include "AHCLF.h"
#include "TBMain.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
typedef struct HList
{
char hclbz[32];
char hclmc[32];
} THList;
typedef THList* PHList;
THCLForm *HCLForm;
//---------------------------------------------------------------------------
__fastcall THCLForm::THCLForm(TComponent* Owner)
: TForm(Owner)
{
TListItem *ListItem;
PHList HStruct;
try{
Query1->Active=false;
Query1->SQL->Clear();
Query1->SQL->Add("select * from hcl order by hclbz");
Query1->Active=true;
}
catch (EDatabaseError &e)
{
Application->MessageBox(e.Message.c_str(),"错误",MB_OK |MB_ICONERROR);
return ;
}
if(0 < Query1->RecordCount)
{
ListView1->Items->Clear();
for(int i=0;i<Query1->RecordCount;i++)
{
HStruct = new THList;
strcpy(HStruct->hclbz,Query1->FieldByName("hclbz")->AsString.c_str ());
strcpy(HStruct->hclmc,Query1->FieldByName("hclmc")->AsString.c_str ());
ListItem = ListView1->Items->Add();
ListItem->Caption = HStruct->hclbz;
ListItem->SubItems->Add(HStruct->hclmc);
Query1->Next();
}
}
}
//---------------------------------------------------------------------------
void __fastcall THCLForm::ADDClick(TObject *Sender)
{
TListItem *ListItem;
try
{
Application->CreateForm(__classid(TAddHclForm), &AddHclForm);
}
catch (Exception &exception)
{
Application->ShowException(&exception);
return;
}
TAddHclForm * newmenu = new TAddHclForm( this );
newmenu->Caption = "添加后处理标志";
newmenu->ShowModal();
if(newmenu->IsAdd == true)
{
ListItem = ListView1->Items->Add();
ListItem->Caption = newmenu->Edit1->Text;
ListItem->SubItems->Add(newmenu->Edit2->Text);
try{
Query1->Active=false;
Query1->SQL->Clear();
Query1->SQL->Add("insert into hcl (hclbz,hclmc) values ('"+ newmenu->Edit1->Text + "','" + newmenu->Edit2->Text + "')");
Query1->ExecSQL();
}
catch (EDatabaseError &e)
{
Application->MessageBox(e.Message.c_str(),"错误",MB_OK |MB_ICONERROR);
return ;
}
MainForm->dxInspector2Row6->Items->Add(newmenu->Edit1->Text);
MainForm->dxInspector2->Update();
MainForm->dxInspector2->Repaint();
MainForm->dxInspector2->Refresh();
}
delete newmenu;
AddHclForm->Destroying();
AddHclForm->Release();
}
//---------------------------------------------------------------------------
void __fastcall THCLForm::DeleteClick(TObject *Sender)
{
TListItem *ListItem;
ListItem=ListView1->Selected;
if(ListItem!=NULL)
{
try{
Query1->Active=false;
Query1->SQL->Clear();
Query1->SQL->Add("delete from hcl where hclbz='"+ ListItem->Caption +"'");
Query1->ExecSQL();
}
catch (EDatabaseError &e)
{
Application->MessageBox(e.Message.c_str(),"错误",MB_OK |MB_ICONERROR);
return ;
}
int i=MainForm->dxInspector2Row6->Items->IndexOf(ListItem->Caption);
if(i>=0)
{
MainForm->dxInspector2Row6->Items->Delete(i);
MainForm->dxInspector2->Update();
MainForm->dxInspector2->Repaint();
MainForm->dxInspector2->Refresh();
}
ListItem->Delete();
}
}
//---------------------------------------------------------------------------
void __fastcall THCLForm::ModefyClick(TObject *Sender)
{
TListItem *ListItem;
ListItem=ListView1->Selected;
if(ListItem!=NULL)
{
try
{
Application->CreateForm(__classid(TAddHclForm), &AddHclForm);
}
catch (Exception &exception)
{
Application->ShowException(&exception);
return;
}
TAddHclForm * newmenu = new TAddHclForm( this );
newmenu->Caption = "修改后处理标志";
newmenu->Edit1->Text=ListItem->Caption;
newmenu->Edit2->Text=ListItem->SubItems->Text;
newmenu->ShowModal();
if(newmenu->IsAdd == true)
{
try{
Query1->Active=false;
Query1->SQL->Clear();
Query1->SQL->Add("delete from hcl where hclbz='"+ ListItem->Caption +"'");
Query1->ExecSQL();
}
catch (EDatabaseError &e)
{
Application->MessageBox(e.Message.c_str(),"错误",MB_OK |MB_ICONERROR);
return;
}
try{
Query1->Active=false;
Query1->SQL->Clear();
Query1->SQL->Add("insert into hcl (hclbz,hclmc) values ('"+ newmenu->Edit1->Text + "','" + newmenu->Edit2->Text + "')");
Query1->ExecSQL();
}
catch (EDatabaseError &e)
{
Application->MessageBox(e.Message.c_str(),"错误",MB_OK |MB_ICONERROR);
return;
}
int i=MainForm->dxInspector2Row6->Items->IndexOf(ListItem->Caption);
if(i>=0)
{
MainForm->dxInspector2Row6->Items->Delete(i);
}
MainForm->dxInspector2Row6->Items->Add(newmenu->Edit1->Text);
MainForm->dxInspector2->Update();
MainForm->dxInspector2->Repaint();
MainForm->dxInspector2->Refresh();
ListItem->Delete();
ListItem = ListView1->Items->Add();
ListItem->Caption = newmenu->Edit1->Text;
ListItem->SubItems->Add(newmenu->Edit2->Text);
}
delete newmenu;
AddHclForm->Destroying();
AddHclForm->Release();
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -