xiaopiao.cpp
来自「一个用VC写的超市管理系统」· C++ 代码 · 共 85 行
CPP
85 行
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "xiaopiao.h"
#include "data.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tfm_xiaopiao *fm_xiaopiao;
//---------------------------------------------------------------------------
__fastcall Tfm_xiaopiao::Tfm_xiaopiao(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::FormShow(TObject *Sender)
{
Left=100;
Top=100;
dm_data->ds_xiaopiao->Close();
dm_data->ds_xiaopiao->Open();
dm_data->ds_xiaopiao->Edit();
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from code where id=20000";
dm_data->ds_guest->Open();
piaotou->Text=dm_data->ds_guest->FieldByName("content")->AsString;
dm_data->ds_guest->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::FormClose(TObject *Sender,
TCloseAction &Action)
{
dm_data->ds_xiaopiao->Edit();
dm_data->ds_xiaopiao->Post();
dm_data->ds_xiaopiao->Close();
dm_data->ds_guest->Close();
dm_data->ds_guest->CommandText="select * from code where id=20000";
dm_data->ds_guest->Open();
dm_data->ds_guest->Edit();
dm_data->ds_guest->FieldByName("content")->AsString=piaotou->Text;
dm_data->ds_guest->Post();
dm_data->ds_guest->Close();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button1Click(TObject *Sender)
{
int id;
dm_data->ds_xiaopiao->Last();
id=dm_data->ds_xiaopiao->FieldByName("id")->AsInteger+1;
if(id>=29999)
return;
dm_data->ds_xiaopiao->Append();
dm_data->ds_xiaopiao->FieldByName("id")->AsInteger=id;
dm_data->ds_xiaopiao->Post();
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button2Click(TObject *Sender)
{
if(Application->MessageBoxA("真的要删除最后一行吗?","提示",MB_OKCANCEL)==IDOK)
{
if(dm_data->ds_xiaopiao->RecordCount==1) return;
dm_data->ds_xiaopiao->Last();
dm_data->ds_xiaopiao->DeleteRecords(arCurrent);
}
}
//---------------------------------------------------------------------------
void __fastcall Tfm_xiaopiao::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?