Додаток 1. Лістинг програми

/*

- Управління базою даних «Медична діагностична клініка» MDC.mdb

- Автор Гребенюк Іван Андрійович

- Версія 1.0

- Програмування модулів (форм) алгоритмами

*/

//diagnozi_delete_zaput.cpp (daig_delete)

#include <vcl.h>

#pragma hdrstop

#include "diagnozi_delete_zaput.h"

#include "work_bd.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

Tdiag_delete *diag_delete;

__fastcall Tdiag_delete::Tdiag_delete(TComponent* Owner): TForm(Owner) { }

void __fastcall Tdiag_delete::Button1Click(TObject *Sender)

{ Memo1->Clear(); bd_work->diagnoziz->Active=false; AnsiString text[]={"DELETE FROM Діагнози",

" WHERE Діагнози.[Код діагнозу]=\""+Edit1->Text+"\"", " OR Діагнози.[Термін лікування]=\""+Edit3->Text+"\" OR",

"Діагнози.Термін=\""+Edit2->Text+"\""}; for(unsigned t=0; t<sizeof(text)/sizeof(int); t++) Memo1->Lines->Add(text[t]);

bd_work->diagnoziz->Close(); bd_work->diagnoziz->SQL->Clear(); bd_work->diagnoziz->SQL->Add(Memo1->Text);

bd_work->diagnoziz->ExecSQL(); AnsiString text2[]={"SELECT *", "FROM Діагнози;"}; Memo1->Clear();

for(unsigned t=0; t<sizeof(text2)/sizeof(int); t++) Memo1->Lines->Add(text2[t]); bd_work->diagnoziz->Close();

bd_work->diagnoziz->SQL->Clear(); bd_work->diagnoziz->SQL->Add(Memo1->Text); bd_work->diagnoziz->Open();

bd_work->diagnoziz->Active=true; bd_work->count_diagnozi->Active=false; bd_work->count_diagnozi->Active=true; }

void __fastcall Tdiag_delete::FormCreate(TObject *Sender) { Left = 387; Top = 523; }

void __fastcall Tdiag_delete::Edit3KeyPress(TObject *Sender, char &Key)

{ if(Key == VK_RETURN) Button1Click(Sender); }

// diagnozi_insert_zaput.cpp (diag_insert)

#include <vcl.h>

#pragma hdrstop

#include "diagnozi_insert_zaput.h"

#include "work_bd.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

Tdiag_insert *diag_insert;

__fastcall Tdiag_insert::Tdiag_insert(TComponent* Owner): TForm(Owner) { }

void __fastcall Tdiag_insert::Button1Click(TObject *Sender)

{ Memo1->Clear();

bd_work->diagnoziz->Active=false; AnsiString text[]={"INSERT INTO Діагнози([Код діагнозу], Термін,[Термін лікування])",

" VALUES (\""+Edit1->Text+"\",\""+Edit2->Text+"\",\""+Edit3->Text+"\")"};

for(unsigned t=0; t<sizeof(text)/sizeof(int); t++) Memo1->Lines->Add(text[t]);

bd_work->diagnoziz->Close(); bd_work->diagnoziz->SQL->Clear(); bd_work->diagnoziz->SQL->Add(Memo1->Text);

bd_work->diagnoziz->ExecSQL(); AnsiString text2[]={"SELECT *", "FROM Діагнози;"}; Memo1->Clear();

for(unsigned t=0; t<sizeof(text2)/sizeof(int); t++) Memo1->Lines->Add(text2[t]); bd_work->diagnoziz->Close();

bd_work->diagnoziz->SQL->Clear(); bd_work->diagnoziz->SQL->Add(Memo1->Text); bd_work->diagnoziz->Open();

bd_work->diagnoziz->Active=true; bd_work->count_diagnozi->Active=false; bd_work->count_diagnozi->Active=true; }

void __fastcall Tdiag_insert::FormCreate(TObject *Sender) { Left = 387; Top = 523; }

void __fastcall Tdiag_insert::Button1KeyPress(TObject *Sender, char &Key) { if(Key == VK_RETURN) Button1Click(Sender); }

//diagnozi_search_zaput.cpp (diag_search)

#include <vcl.h>

#pragma hdrstop

#include "diagnozi_search_zaput.h"

#include "work_bd.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

Tdiag_search *diag_search;

__fastcall Tdiag_search::Tdiag_search(TComponent* Owner): TForm(Owner) { }

void __fastcall Tdiag_search::Button1Click(TObject *Sender)

{ if((RadioButton2->Checked==true)&&(bd_work->diagnoziz->Locate("Термін",Edit2->Text, TLocateOptions())))

{ShowMessage("Присутній!");}

if((RadioButton1->Checked==true)&&(bd_work->diagnoziz->Locate("Код діагнозу",Edit1->Text, TLocateOptions())))

{ShowMessage("Присутній!");}

if((RadioButton3->Checked==true)&&(bd_work->diagnoziz->Locate("Термін лікування",Edit3->Text, TLocateOptions())))

{ShowMessage("Присутній!");} }

void __fastcall Tdiag_search::Edit3KeyPress(TObject *Sender, char &Key) { if(Key==VK_RETURN) Button1Click(Sender); }

void __fastcall Tdiag_search::FormCreate(TObject *Sender) { Left = 387; Top = 523; }

//password.cpp (PasswordDlg)

#include <vcl.h>

#pragma hdrstop

#include "password.h"

#include "diagnozi.h"

#include "work_bd.h"

#include "password_new.h"

#include "fstream.h"

#pragma resource "*.dfm"

TPasswordDlg *PasswordDlg;

__fastcall TPasswordDlg::TPasswordDlg(TComponent* AOwner): TForm(AOwner) { }

void __fastcall TPasswordDlg::OKBtnClick(TObject *Sender)

{ Memo1->Clear(); Memo1->Lines->LoadFromFile("renew.bin"); String pass_file = Memo1->Text;

if(pass_file!= Password->Text) { ShowMessage("Невірний пароль!"); } else { PasswordDlg->Visible=false; Diagnoz->Show(); } }

void __fastcall TPasswordDlg::CancelBtnClick(TObject *Sender) { PasswordDlg->Close(); }

void __fastcall TPasswordDlg::FormCreate(TObject *Sender)

{ fstream file("renew.bin"); if(!file.is_open()) { ofstream sozdat("renew.bin"); sozdat.close(); } Left = 529; Top = 317; }

void __fastcall TPasswordDlg::SpeedButton1Click(TObject *Sender)

{ PasswordDlg->Visible = false; Pass_renew->Visible = true; }

//kvitancii_suma_za_den_zaput.cpp (suma_za_den_form)

#include <vcl.h>

#pragma hdrstop

#include "kvitancii_suma_za_den_zaput.h"

#include "work_bd.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

Tsuma_za_den_form *suma_za_den_form;

__fastcall Tsuma_za_den_form::Tsuma_za_den_form(TComponent* Owner): TForm(Owner) { }

void proverka()

{ if(suma_za_den_form->DBText1->Caption == "") {String none = "0"; suma_za_den_form->DBText1->Caption = none;}}

void __fastcall Tsuma_za_den_form::Button1Click(TObject *Sender)

{ String date = DateToStr(MonthCalendar1->Date); date = StringReplace(date,".","/",TReplaceFlags()<<rfReplaceAll);

char *d = date.c_str(); char first_2_day[5]; first_2_day[0] = d[0];first_2_day[1] = d[1];

char month[5]; month[0] = d[3];month[1] = d[4]; d[0] = month[0];d[1] = month[1]; d[3] = first_2_day[0];d[4] = first_2_day[1];

char d1[100]; for(int i=0;i<10;i++) { d1[i] = d[i]; } Edit1->Text = d1; Memo1->Clear();

bd_work->suma_za_den->Active=false; String sum = "SELECT SUM(Квитанція.[Всього до оплати]) FROM Квитанція";

AnsiString text= sum+" WHERE Квитанція.[Дата видачі]=#"+Edit1->Text+"#";

Memo1->Lines->Add(text); bd_work->suma_za_den->SQL->Clear();

bd_work->suma_za_den->SQL->Add(Memo1->Text); bd_work->suma_za_den->ExecSQL();

bd_work->suma_za_den->Active=true; suma_za_den_form->Height = 281; proverka(); }

void __fastcall Tsuma_za_den_form::FormCreate(TObject *Sender) { Left = 1168; Top = 450;suma_za_den_form->Height=257; }

void __fastcall Tsuma_za_den_form::MonthCalendar1KeyPress(TObject *Sender, char &Key)

{ if(Key == VK_RETURN)Button1Click(Sender); }

//diagnozi.cpp (Diagnoz)

#include <vcl.h>

#pragma hdrstop

#include "diagnozi.h"

#include "work_bd.h"

#pragma package(smart_init)

#pragma resource "*.dfm"

TDiagnoz *Diagnoz;

String atribute[] = {"Код діагнозу","Термін","Термін лікування"};

__fastcall TDiagnoz::TDiagnoz(TComponent* Owner): TForm(Owner) { }

void __fastcall TDiagnoz::FormClose(TObject *Sender, TCloseAction &Action) { PasswordDlg->Close(); }

void __fastcall TDiagnoz::ComboBox1KeyPress(TObject *Sender, char &Key) { if(Key==Key)Key = 0x00; }

void __fastcall TDiagnoz::Button3Click(TObject *Sender) { Panel2->Visible=false; }

void __fastcall TDiagnoz::DBGrid1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)

{ bd_work->count_diagnozi->Active=false;

bd_work->count_diagnozi->Active=true; Diagnoz->StatusBar1->Panels->Items[1]->Text = DBText1->Caption; }

void __fastcall TDiagnoz::FormCanResize(TObject *Sender, int &NewWidth, int &NewHeight, bool &Resize)

{ Edit1->Width=Diagnoz->Width-260; }

void __fastcall TDiagnoz::Button1Click(TObject *Sender)

{ if((ComboBox1->Text=="Скинути фільтр")||(Edit1->Text=="")) bd_work->diagnoziz->Filtered = false;

else if((ComboBox1->Text=="Фільтр по \"Код діагнозу\"")&&(Edit1->Text!=""))

{ bd_work->diagnoziz->Filtered = false; bd_work->diagnoziz->Filter = "[Код діагнозу] like '"+Edit1->Text+"*'";

bd_work->diagnoziz->Filtered = true; }

else if((ComboBox1->Text=="Фільтр по \"Термін\"")&&(Edit1->Text!=""))

{ bd_work->diagnoziz->Filtered = false; bd_work->diagnoziz->Filter = "[Термін] like '"+Edit1->Text+"*'";

bd_work->diagnoziz->Filtered = true; }

else if((ComboBox1->Text=="Фільтр по \"Термін лікування\"")&&(Edit1->Text!=""))

{ bd_work->diagnoziz->Filtered = false;

bd_work->diagnoziz->Filter = "[Термін лікування] like '"+Edit1->Text+"*'"; bd_work->diagnoziz->Filtered = true; } }

void __fastcall TDiagnoz::ToolButton1Click(TObject *Sender) { bd_work->table1Click(Sender); }

void __fastcall TDiagnoz::ToolButton2Click(TObject *Sender) { bd_work->vidalit1Click(Sender); }

void __fastcall TDiagnoz::ToolButton4Click(TObject *Sender) { bd_work->N1Click(Sender); }

void __fastcall TDiagnoz::ToolButton6Click(TObject *Sender) { bd_work->N3Click(Sender); }

void __fastcall TDiagnoz::ToolButton8Click(TObject *Sender) { bd_work->MeButtonClick(Sender); }

void __fastcall TDiagnoz::ToolButton10Click(TObject *Sender) { bd_work->N2Click(Sender); }

void __fastcall TDiagnoz::ToolButton12Click(TObject *Sender) { bd_work->N5Click(Sender); }

void __fastcall TDiagnoz::FormCreate(TObject *Sender) { Left = 387; Top = 74; }

void __fastcall TDiagnoz::ToolButton13Click(TObject *Sender) { bd_work->N63Click(Sender); }

void __fastcall TDiagnoz::DBGrid1KeyPress(TObject *Sender, char &Key) { if(Key == VK_RETURN)Button1Click(Sender); }



Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: