📄 kcgl_frm_form1.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "KCGL_frm_form1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
try
{
KCGL_frm_adoQuery2->Active = false;
KCGL_frm_adoQuery2->SQL->Clear();
KCGL_frm_adoQuery2->SQL->Add("select * from Store");
KCGL_frm_adoQuery2->Active = true;
KCGL_frm_adoQuery2->Open();
KCGL_frm_adoQuery3->Active = false;
KCGL_frm_adoQuery3->SQL->Clear();
KCGL_frm_adoQuery3->SQL->Add("select ClinicId from Clinic ");
KCGL_frm_adoQuery3->Active = true;
KCGL_frm_adoQuery3->Open();
//ADOQuery1
ADOQuery1->Active = false;
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("select * from ItemTable");
ADOQuery1->Active = true;
}
catch(...)
{
MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
for(int i=0;i<KCGL_frm_adoQuery3->RecordCount;i++)
{
KCGL_frm_cmbClinicId->Items->Add(KCGL_frm_adoQuery3->FieldByName("ClinicId")->AsString);
KCGL_frm_cmbClinicId1->Items->Add(KCGL_frm_adoQuery3->FieldByName("ClinicId")->AsString);
DBComboBox2->Items->Add(KCGL_frm_adoQuery3->FieldByName("ClinicId")->AsString);
DBComboBox3->Items->Add(KCGL_frm_adoQuery3->FieldByName("ClinicId")->AsString);
KCGL_frm_adoQuery3->Next() ;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_btnUpdateClick(TObject *Sender)
{ /*
KCGL_frm_adoQuery1->Close() ;
KCGL_frm_adoQuery1->UpdateRecord() ;
KCGL_frm_adoQuery1->FieldByName("MedicineId")->AsString=KCGL_frm_dbeMedicineId->Text ;
KCGL_frm_adoQuery1->Post() ;
KCGL_frm_adoQuery1->Open() ; */
try
{
KCGL_frm_DBNavigator1->BtnClick(nbPost);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_btnDeleteClick(TObject *Sender)
{
try
{
KCGL_frm_DBNavigator1->BtnClick(nbDelete);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_btnAddClick(TObject *Sender)
{
try
{
KCGL_frm_DBNavigator1->BtnClick(nbInsert);
}
catch(...)
{MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_btnCancelClick(TObject *Sender)
{
try
{
KCGL_frm_DBNavigator1->BtnClick(nbCancel);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_cmbClinicIdChange(TObject *Sender)
{
/*adoQuery1->Parameters->ParamByName("name")->Value=Edit2->Text;
adoQuery1->Parameters->ParamByName("phone")->Value=Edit3->Text;*/
try
{
KCGL_frm_adoQuery1->Active = false;
KCGL_frm_adoQuery1->SQL->Clear();
KCGL_frm_adoQuery1->SQL->Add("select A.* from MedicineTable as A INNER JOIN Bill as B on A.MedicineId=B.MedicineId where B.ClinicId= :id");
KCGL_frm_adoQuery1->Parameters->ParamByName("id")->Value=KCGL_frm_cmbClinicId->Text ;
KCGL_frm_adoQuery1->Active = true;
KCGL_frm_adoQuery1->Open();
if(KCGL_frm_adoQuery1->RecordCount==0)
MessageDlg("没有任何记录 !",mtError,TMsgDlgButtons()<<mbOK,0);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_btnSearchClick(TObject *Sender)
{
AnsiString sql;
if(KCGL_frm_cmbSearchType->Text=="药品")
sql="select * from MedicineTable";
//if(KCGL_frm_chbItemId->Checked)
//{
//sql+=" where ItemId= :ItemId";
//KCGL_frm_adoQuery4->Parameters->ParamByName("ItemId")->Value=KCGL_frm_edtItemId->Text;
//}
//if(KCGL_frm_chbItemName->Checked)
// {
// sql+=" and ItemName= :ItemName";
// KCGL_frm_adoQuery4->Parameters->ParamByName("ItemName")->Value=KCGL_frm_edtItemName->Text;
//sql+=" and ItemName= :ItemName";
// }
if(KCGL_frm_cmbSearchType->Text=="用品")
sql="select * from ItemTable where DifferNumber=1";
//if(KCGL_frm_cmbSearchType->Text=="非用品")
//sql="select * from ItemTable where DifferNumber=0";
if(KCGL_frm_cmbSearchType->Text=="围栏")
sql="select * from FenceInfoTable";
/* if(KCGL_frm_chbItemId->Checked)
KCGL_frm_adoQuery4->Parameters->ParamByName("ItemId")->Value=KCGL_frm_edtItemId->Text;
sql+="select * from MedicineTable where ItemId= :ItemId";
if(KCGL_frm_chbItemName->Checked)
KCGL_frm_adoQuery4->Parameters->ParamByName("ItemName")->Value=KCGL_frm_edtItemName->Text;
// sql+="and ItemId=KCGL_frm_chbItemName->text";
sql+="select * from MedicineTable where ItemName= :ItemName"; */
KCGL_frm_adoQuery4->Active = false;
KCGL_frm_adoQuery4->SQL->Clear();
KCGL_frm_adoQuery4->SQL->Add(sql);
// KCGL_frm_adoQuery4->Parameters->ParamByName("ItemId")->Value="m1111";
KCGL_frm_adoQuery4->Prepared;
KCGL_frm_adoQuery4->Active = true;
KCGL_frm_adoQuery4->Open();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_chbItemIdClick(TObject *Sender)
{
if(KCGL_frm_chbItemId->Checked)
KCGL_frm_edtItemId->Visible =true;
else
KCGL_frm_edtItemId->Visible =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::KCGL_frm_chbItemNameClick(TObject *Sender)
{
if(KCGL_frm_chbItemName->Checked)
KCGL_frm_edtItemName->Visible =true;
else
KCGL_frm_edtItemName->Visible =false;
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
try
{
DBNavigator1->BtnClick(nbInsert);
}
catch(...)
{MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button2Click(TObject *Sender)
{
try
{
DBNavigator1->BtnClick(nbPost);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button3Click(TObject *Sender)
{
try
{
DBNavigator1->BtnClick(nbDelete);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button4Click(TObject *Sender)
{
try
{
DBNavigator1->BtnClick(nbCancel);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm2::DBComboBox3Change(TObject *Sender)
{
//ADOQuery2
//ADOQuery2->Parameters->ParamByName("id")->Value=DBComboBox3->Text ;
/*adoQuery1->Parameters->ParamByName("name")->Value=Edit2->Text;
adoQuery1->Parameters->ParamByName("phone")->Value=Edit3->Text;*/
try
{
ADOQuery2->Open();
ADOQuery2->Active = false;
ADOQuery2->SQL->Clear();
AnsiString sql;
sql="select A.FenceId,A.FenceVolumn,A.FenceState from FenceInfoTable as A inner join Clinic as B on A.ClinicId=B.ClinicId where B.ClinicId='c00001'";
ADOQuery2->SQL->Add(sql);
ADOQuery2->Active = true;
ADOQuery2->Open();
if(KCGL_frm_adoQuery2->RecordCount==0)
MessageDlg("没有任何记录 !",mtError,TMsgDlgButtons()<<mbOK,0);
}
catch(...)
{ MessageDlg("Error:xxxx. The values of parameters have some problems. You should try your best to solve it !",
mtError,TMsgDlgButtons()<<mbOK,0);
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -