retrieve.cpp

来自「脑电信号分析软件」· C++ 代码 · 共 195 行

CPP
195
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "log.h"
#include "Retrieve.h"
//#include "Form_analysis.h"  //主窗体
#include "dangan.h"
#include "print.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm_Retrieve *Form_Retrieve;
//---------------------------------------------------------------------------
__fastcall TForm_Retrieve::TForm_Retrieve(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm_Retrieve::Button_tcClick(TObject *Sender)
{
  Close();
}
//---------------------------------------------------------------------------

/*void __fastcall TForm_Retrieve::Button_ndtClick(TObject *Sender)
{
   Form_Anlysis->Show();
}
*/
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::FormCreate(TObject *Sender)
{ //String  databasepath;
    //Table1->DatabaseName = ExtractFilePath(Application->ExeName)+"dangan.mdb";
    //Table1->TableName = "Pinfo";
    //Table1->Open();
    //Table1->Filter = "PNO >= 100001 and PNO <= 100004";
    //Table1->Filtered = true;
    //databasepath= ExtractFilePath(Application->ExeName)+"dangan.mdb";
    if (ADOConnection1->Connected==false)
     // {ADOConnection1->ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" + databasepath + ";Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
       //}
       ADOConnection1->Connected=true;
    ADOTable1->Active=true;
    //>Open();
    ///DBGrid1->ReadOnly=true;
    //FirstTime = true;
   // DataSource1->DataSet=ADOTable1;
}
//---------------------------------------------------------------------------

/*void __fastcall TForm_Retrieve::Button_dxtClick(TObject *Sender)
{
  Form_Anlysis->Show();
}
*/
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::Button_cxClick(TObject *Sender)
{ if(CheckBox_xm->Checked==false && CheckBox_bh->Checked==false)
     {Application->MessageBox("请先选择查询条件!","查询提示",MB_OK);
      goto Jump;
     }
  if(CheckBox_xm->Checked==true && CheckBox_bh->Checked==true)
     {Application->MessageBox("只能选择一种查询条件!","查询提示",MB_OK);
      goto Jump;
     }
  if (CheckBox_xm->Checked==true)
     {if(ComboBox_xm->Text =="")
        {Application->MessageBox("请输入要查询档案的姓名!","查询提示",MB_OK);
         goto Jump;
         }
       else
       { ADOQuery1->Close();
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("SELECT * FROM Pinfo WHERE 姓名='" + ComboBox_xm->Text+"'");
         ADOQuery1->Open();
       }
      }
    if (CheckBox_bh->Checked==true)
     {if(ComboBox_bh->Text =="")
        {Application->MessageBox("请输入要查询档案的编号!","查询提示",MB_OK);
         goto Jump;
         }
       else
       { ADOQuery1->Close();
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("SELECT * FROM Pinfo WHERE  编号='" + ComboBox_bh->Text + "'");
         ADOQuery1->Open();
         }
     }

  if (ADOQuery1->Eof==true)
    {Application->MessageBox("档案中无您要查询的记录!","查询提示",MB_OK);
    goto Jump;
    }
  DataSource1->DataSet=ADOQuery1;
  ADOQuery1->Open();
  QRListForm->ID=ADOQuery1->FieldByName("编号")->AsString;
Jump:

}
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::CheckBox_xmClick(TObject *Sender)
{
   //CheckBox_xm->Checked =true;
   //CheckBox_bh->Checked =false;
}
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::CheckBox_bhClick(TObject *Sender)
{
  //CheckBox_xm->Checked =false;
  //CheckBox_bh->Checked =true;
}
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::Button_gjcxClick(TObject *Sender)
{
  if(CheckBox_xm->Checked==false || CheckBox_bh->Checked==false)
     {Application->MessageBox("两种查询条件必须选中!","查询提示",MB_OK);
      goto Jump;
     }
  if(ComboBox_bh->Text =="")
  {Application->MessageBox("请输入要查询档案的编号!","查询提示",MB_OK);
    goto Jump;
  }
  if(ComboBox_bh->Text =="")
    {Application->MessageBox("请输入要查询档案的编号!","查询提示",MB_OK);
      goto Jump;
    }

   ADOQuery1->Close();
   ADOQuery1->SQL->Clear();
   ADOQuery1->SQL->Add("SELECT * FROM Pinfo WHERE  编号='" + ComboBox_bh->Text + "'and 姓名='" + ComboBox_xm->Text+"'");
   ADOQuery1->Open();
   //ADOTable1->Open();
   //ADOTable1->Filter= "编号=" + ComboBox_bh->Text + "and 姓名=" + ComboBox_xm->Text;
   //ADOTable1->Filtered=true;
   if (ADOQuery1->Eof==true)
    {Application->MessageBox("档案中无您要查询的记录!","查询提示",MB_OK);
    goto Jump;
    }
    DataSource1->DataSet=ADOQuery1;
    ADOQuery1->Open();
    QRListForm->ID =ADOQuery1->FieldByName("编号")->AsString;
Jump:
}
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::Button_bjClick(TObject *Sender)
{
  //DBGrid1->ReadOnly=false;
 // DBGrid1->Options->dgRowSelect=false;
 Form_dangan->Show();
}
//---------------------------------------------------------------------------

/*void __fastcall TForm_Retrieve::DBGrid1ColExit(TObject *Sender)
{  String strTmp;
   String content;
    //content=DBGrid1->SelectedRows->Items[1].c_str();
    ADOQuery1->Close();
    ADOQuery1->SQL->Clear();
    strTmp="Select * from Pinfo where 编号='"+content+"'";
    ADOQuery1->SQL->Add(strTmp);
    ADOQuery1->Open();
    if (ADOQuery1->RecordCount!=0 )
      {  //ADOQuery1->Close() ;
        Application->MessageBox("该编号已存在,请重新设定!","新建提示",MB_OK);
        goto Jump;
        //break;
     }
Jump:
}
//---------------------------------------------------------------------------

void __fastcall TForm_Retrieve::DBGrid1ColEnter(TObject *Sender)
{
  //DBGrid1->SelectedField->DisplayLabel = "* " + DBGrid1->SelectedField->DisplayLabel;
  //FirstTime = false;

} */
//---------------------------------------------------------------------------


//---------------------------------------------------------------------------


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?