⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accountinfo.cpp

📁 这是我们班实习的时候做的一个宠物医院管理系统。sql数据库
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "AccountInfo.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TAccountinfoWf_Form1 *AccountinfoWf_Form1;
//---------------------------------------------------------------------------
__fastcall TAccountinfoWf_Form1::TAccountinfoWf_Form1(TComponent* Owner)
        : TForm(Owner)
{

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







void __fastcall TAccountinfoWf_Form1::PetinfoWf_SpeedButton3Click(
      TObject *Sender)
{

 
 AnsiString str;

ADOQuery1->Insert();
ADOQuery1->FieldByName("AccountId")->AsString=Trim(AccountinfoWf_Edit1->Text);
str=DateToStr(AccountinfoWf_DateTimePicker1->Date);
ADOQuery1->FieldByName("ExamineId")->AsString=Trim(AccountinfoWf_Edit7->Text);
ADOQuery1->FieldByName("CustomerId")->AsString=Trim(AccountinfoWf_Edit8->Text);
str=Trim(str);

ADOQuery1->FieldByName("AccountDate")->AsString=str;
ADOQuery1->FieldByName("TotalCost")->AsString=Trim(AccountinfoWf_Edit2->Text);
ADOQuery1->FieldByName("PayType")->AsString=Trim(AccountinfoWf_Edit3->Text);
ADOQuery1->Post();


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



void __fastcall TAccountinfoWf_Form1::PetinfoWf_SpeedButton2Click(
      TObject *Sender)
{
/* if ( MessageDlg("Are sure to delete the record of the employee which EmployeeID = " + ADOQuery1->FieldByName("EmployeeID")->AsString + " ? If your answer is positive, click the 'Yes' Button. otherwise click the 'No' Button.",
   mtConfirmation,TMsgDlgButtons()<<mbYes<<mbNo,0)==mrYes )
   {
      if (ADOQuery1->RecordCount != 0)
      {
          SpeedButton3->Enabled = true;
          SpeedButton4->Enabled = true;
          ADOQuery1->Delete();
          ADOQuery1->Refresh();
          DBGrid1->Refresh();
       }
       else
       {
           SpeedButton3->Enabled = false;
           SpeedButton4->Enabled = false;
        }
        if (ADOQuery1->RecordCount != 0)
        {
           SpeedButton3->Enabled = true;
           SpeedButton4->Enabled = true;
        }
        else
        {
           SpeedButton3->Enabled = false;
           SpeedButton4->Enabled = false;
        }
   } */

  DBNavigator1->BtnClick(nbDelete);
   }
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::AccountinfoWf_SpeedButton5Click(
      TObject *Sender)
{        bool chk;

         try
      {
         ADOQuery1->Active = false;
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("select * from AccountTable");
         chk=false;
      }
      catch(...)
      {
         MessageDlg("Error:xxxx. DataBase Searching was falure. ",mtError,TMsgDlgButtons()<<mbOK,0);
      }
      try{
         if(AccountinfoWf_CheckBox1->Checked)
         {
         chk=true;
         ADOQuery1->SQL->Add(" where AccountId like '%"+AccountinfoWf_Edit4->Text+AnsiString("%'"));
          }
         if(AccountinfoWf_CheckBox2->Checked)
           {
             if(chk=true)
             ADOQuery1->SQL->Add(" and ExamineId='"+AccountinfoWf_Edit5->Text.Trim()+"'");
             else
             { chk=true;
             ADOQuery1->SQL->Add(" where ExamineId like '%"+AccountinfoWf_Edit5->Text.Trim()+AnsiString("%'"));
             }
           }
         if(AccountinfoWf_CheckBox3->Checked)
           {
             if(chk=true)
           ADOQuery1->SQL->Add(" and CustomerId like '%"+AccountinfoWf_Edit6->Text.Trim()+AnsiString("%'"));
             else
             ADOQuery1->SQL->Add(" where CustomerId like '%"+AccountinfoWf_Edit6->Text.Trim()+AnsiString("%'"));
           }
         }
         catch(...)
         { ShowMessage("输入无效!!");
         }

     ADOQuery1->Active = true;
        ADOQuery1->Open();
}
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::AccountinfoWf_SpeedButton6Click(
      TObject *Sender)
{
 bool chk=false;
   try
      {
         ADOQuery1->Active = false;
        ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("select * from AccountTable");
         chk=false;
      }
      catch(...)
      {
         MessageDlg("Error:xxxx. DataBase Searching was falure. ",mtError,TMsgDlgButtons()<<mbOK,0);
      }
   try
      {
      if(AccountinfoWf_CheckBox4->Checked)
      { chk=true;

       ADOQuery1->SQL->Add(" where AccountDate='"+DateToStr(AccountinfoWf_DateTimePicker3->Date)+"'");

       }
      if(AccountinfoWf_CheckBox5->Checked)
      {
      if(chk!=true)
         {
           ADOQuery1->SQL->Add(" where PayDate='"+DateToStr(AccountinfoWf_DateTimePicker4->Date)+"'");
           chk=true;
           }
      else
      ADOQuery1->SQL->Add(" and PayDate='"+DateToStr(AccountinfoWf_DateTimePicker4->Date)+"'");

      }

       ADOQuery1->Prepared;
       ADOQuery1->Active = true;
       ADOQuery1->Open();
       }
       catch(...)
      {
         MessageDlg("Error:xxxx. DataBase Searching was falure. ",mtError,TMsgDlgButtons()<<mbOK,0);
      }
}
//---------------------------------------------------------------------------





void __fastcall TAccountinfoWf_Form1::AccountinfoWf_DBGrid2CellClick(
      TColumn *Column)
{
AccountinfoWf_Edit4->Text=ADOQuery1->FieldByName("AccountId")->AsString;
AccountinfoWf_Edit5->Text=ADOQuery1->FieldByName("ExamineId")->AsString;
AccountinfoWf_Edit6->Text=ADOQuery1->FieldByName("CustomerId")->AsString;
AccountinfoWf_Edit1->Text=ADOQuery1->FieldByName("AccountId")->AsString;
AccountinfoWf_Edit7->Text=ADOQuery1->FieldByName("ExamineId")->AsString;
AccountinfoWf_Edit8->Text=ADOQuery1->FieldByName("CustomerId")->AsString;
AccountinfoWf_Edit2->Text=ADOQuery1->FieldByName("TotalCost")->AsString;
AccountinfoWf_Edit3->Text=ADOQuery1->FieldByName("TotalCost")->AsString;
}
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::AccountinfoWf_DBGrid1CellClick(
      TColumn *Column)
{
 AccountinfoWf_Edit4->Text=ADOQuery1->FieldByName("AccountId")->AsString;
AccountinfoWf_Edit5->Text=ADOQuery1->FieldByName("ExamineId")->AsString;
AccountinfoWf_Edit6->Text=ADOQuery1->FieldByName("CustomerId")->AsString;
AccountinfoWf_Edit1->Text=ADOQuery1->FieldByName("AccountId")->AsString;
AccountinfoWf_Edit7->Text=ADOQuery1->FieldByName("ExamineId")->AsString;
AccountinfoWf_Edit8->Text=ADOQuery1->FieldByName("CustomerId")->AsString;
AccountinfoWf_Edit2->Text=ADOQuery1->FieldByName("TotalCost")->AsString;
AccountinfoWf_Edit3->Text=ADOQuery1->FieldByName("TotalCost")->AsString;
AccountinfoWf_DateTimePicker1->Date=ADOQuery1->FieldByName("AccountDate")->AsString;
AccountinfoWf_DateTimePicker2->Date=ADOQuery1->FieldByName("PayDate")->AsString;


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

void __fastcall TAccountinfoWf_Form1::PetinfoWf_SpeedButton1Click(
      TObject *Sender)
{
DBNavigator1->BtnClick(nbCancel);
}
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::PetinfoWf_SpeedButton4Click(
      TObject *Sender)
{
DBNavigator1->BtnClick(nbEdit);
}
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::AccountinfoWf_DBGrid2DblClick(
      TObject *Sender)
{
AccountinfoWf_PageControl1->ActivePage=AccountinfoWf_TabSheet1;
}
//---------------------------------------------------------------------------

void __fastcall TAccountinfoWf_Form1::SpeedButton1Click(TObject *Sender)
{
 try
      {
        ADOQuery1->Active = false;
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("select * from AccountTable where AccountDate between'"+DfrmAccountInfoLdp_ateTimePicker5->Date+"' and '"+DfrmAccountInfoLdp_ateTimePicker6->Date+"'");
        ADOQuery1->Active = true;
         ADOQuery1->Open();
      }
      catch(...)
      {
         MessageDlg("Error:xxxx. DataBase Searching was falure. ",mtError,TMsgDlgButtons()<<mbOK,0);
      }

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

void __fastcall TAccountinfoWf_Form1::SpeedButton2Click(TObject *Sender)
{
try
      {
         ADOQuery1->Active = false;
         ADOQuery1->SQL->Clear();
         ADOQuery1->SQL->Add("select * from AccountTable where AccountDate between'"+DfrmAccountInfoLdp_ateTimePicker7->Date+"' and '"+DfrmAccountInfoLdp_ateTimePicker8->Date+"'");
         ADOQuery1->Active = true;
         ADOQuery1->Open();
      }
      catch(...)
      {
         MessageDlg("Error:xxxx. DataBase Searching was falure. ",mtError,TMsgDlgButtons()<<mbOK,0);
      }
}
//---------------------------------------------------------------------------


void __fastcall TAccountinfoWf_Form1::AccountinfoWf_Edit1Change(
      TObject *Sender)
{
//AccountinfoWf_Form1->PetinfoWf_SpeedButton3->Enabled=true;
//AccountinfoWf_Form1->PetinfoWf_SpeedButton4->Enabled=true;
//AccountinfoWf_Form1->PetinfoWf_SpeedButton1->Enabled=true;

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

void __fastcall TAccountinfoWf_Form1::AccountinfoWf_PageControl1ContextPopup(
      TObject *Sender, TPoint &MousePos, bool &Handled)
{
if(AccountinfoWf_Edit1->Text.Trim()=="")
PetinfoWf_SpeedButton3->Enabled=false;
}
//---------------------------------------------------------------------------


void __fastcall TAccountinfoWf_Form1::AccountinfoWf_GroupBox1MouseMove(
      TObject *Sender, TShiftState Shift, int X, int Y)
{
//if(AccountinfoWf_Edit1->Text.IsEmpty())
 //PetinfoWf_SpeedButton3->Enabled=false;
 //else
// PetinfoWf_SpeedButton3->Enabled=true;

 if(AccountinfoWf_Edit1->Text.IsEmpty()||AccountinfoWf_Edit7->Text.IsEmpty()||AccountinfoWf_Edit8->Text.IsEmpty()||AccountinfoWf_Edit2->Text.IsEmpty()||AccountinfoWf_Edit3->Text.IsEmpty())
 {
 PetinfoWf_SpeedButton3->Enabled=false;

 }
 else
 PetinfoWf_SpeedButton3->Enabled=true;

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

⌨️ 快捷键说明

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