Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::Button1Click(TObject *Sender)
  16. {
  17.   AnsiString ass;
  18.   ass=Table1->FieldByName("科目代码")->AsString;
  19.   if(Application->MessageBox(("一定要删除科目代码为:"+ass+" 的记录吗?").c_str(),"提示",MB_YESNO)==IDYES)
  20.     Table1->Delete();
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::Button2Click(TObject *Sender)
  24. {
  25.   AnsiString filename,oldkmno;
  26.   filename="test.dbf";
  27.   oldkmno=Table1->FieldByName("科目代码")->AsString;
  28.   if(Application->MessageBox(("一定要删除科目代码为:"+oldkmno+" 的记录吗?").c_str(),"提示",MB_YESNO)!=IDYES)return;
  29.   Query1->Active=False;
  30.   Query1->SQL->Clear();
  31.   Query1->SQL->Add("DELETE FROM ""+filename+""");
  32.   Query1->SQL->Add("WHERE  科目代码='"+oldkmno+"'");
  33.   Query1->ExecSQL();
  34.   if(Query1->RowsAffected>=1)
  35.     ShowMessage("记录删除成功!");
  36. }
  37. //---------------------------------------------------------------------------