}
//---------------------------------------------------------------------------
void __fastcall TForm1::N39Click(TObject *Sender)
{
Form25->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N40Click(TObject *Sender)
{
Form26->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N41Click(TObject *Sender)
{
Form2->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N42Click(TObject *Sender)
{
Form3->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N43Click(TObject *Sender)
{
if(Application->MessageBox("Выдействительнохотитеудалитьзапись?","Подтвердитеудалениезаписи!",MB_YESNO+MB_ICONEXCLAMATION)==IDYES)
DataModule2->Table1->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N44Click(TObject *Sender)
{
DataModule2->Table1->Filtered=false;
DataModule2->Table1->Active=false;
DataModule2->Table1->Active=true;
RadioButton1->Checked=false;
RadioButton2->Checked=false;
RadioButton3->Checked=false;
RadioButton4->Checked=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N45Click(TObject *Sender)
{
Form25->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N46Click(TObject *Sender)
{
Form26->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N47Click(TObject *Sender)
{
ReportAgreem->QuickRep1->Preview();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N48Click(TObject *Sender)
{
Form20->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N49Click(TObject *Sender)
{
Form15->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N50Click(TObject *Sender)
{
Form16->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N51Click(TObject *Sender)
{
DataModule2->Table2->Delete();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N52Click(TObject *Sender)
{
Form14->QuickRep1->Preview();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N12Click(TObject *Sender)
{
Form1->frReport1->ShowReport();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N19Click(TObject *Sender)
{
FormRep->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N55Click(TObject *Sender)
{
FormRepAgreem->ShowModal();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N57Click(TObject *Sender)
{
Form4->ShowModal();
}
//---------------------------------------------------------------------------
Unit20
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Saw12.h"
#include "Unit20.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "Word_2K_SRVR"
#pragma resource "*.dfm"
TForm20 *Form20;
//---------------------------------------------------------------------------
__fastcall TForm20::TForm20(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton2Click(TObject *Sender)
{
//Прверка наличия открытого документа
if(WordApplication1->Documents->Count==0)
{
Application->MessageBoxA(PChar("В Word нет открытого документа"),"Varning",MB_OK+MB_ICONEXCLAMATION);
Abort();
}
WordDocument1->ConnectTo(WordApplication1->ActiveDocument);
}
//---------------------------------------------------------------------------
void __fastcall TForm20::FormCreate(TObject *Sender)
{
DataModule2->Table1->Open();
//Выключение проверок синтаксиса и грамматики что бы не замедлять работу Winword
WordApplication1->Options->CheckSpellingAsYouType=false;
WordApplication1->Options->CheckGrammarAsYouType=false;
if(WordApplication1->Documents->Count==0)
{
ToolButton3->Enabled=false;
ToolButton4->Enabled=false;
ToolButton6->Enabled=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton5Click(TObject *Sender)
{
//Открытие нового документа
WordApplication1->Documents->Add(EmptyParam, EmptyParam);
ToolButton3->Enabled=true;
ToolButton4->Enabled=true;
ToolButton5->Enabled=true;
ToolButton6->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton6Click(TObject *Sender)
{
//Перенос в документ всех записей
TBookmarkSavePlace;
//Закладка на текущей записи
SavePlace=DataModule2->Table1->GetBookmark();
DataModule2->Table1->First();
StatusBar1->SimpleText="Идет формирование документа";
//Настройка диаграммы
ProgressBar1->Max=DataModule2->Table1->RecordCount;
ProgressBar1->Position=0;
ProgressBar1->Visible=true;
//Цикл по записям
while(! DataModule2->Table1->Eof)
{
ARecordExecuteClick(Sender);
ProgressBar1->Position=ProgressBar1->Position+1;
DataModule2->Table1->Next();
}
//Возвращение на текущую запись
DataModule2->Table1->GotoBookmark(SavePlace);
//Очистка закладки,полосы состояния и диаграммы
StatusBar1->SimpleText="";
ProgressBar1->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ARecordExecuteClick(TObject *Sender)
{
TVariantsnew="\n";
//Перенос в документ одной записи
//DocumentSearch();
WordApplication1->Selection->InsertAfter(snew);
WordApplication1->Selection->InsertAfter(
TVariant(DataModule2->Table1Register_number->AsString + ' ' +
DataModule2->Table1Juridical_number->AsString + ' ' +
DataModule2->Table1Date_register->AsDateTime + ' ' +
DataModule2->Table1Date_agreement->AsDateTime + ' ' +
DataModule2->Table1Contractor->AsString + ' ' +
DataModule2->Table1Object_agreement->AsString + ' ' +
DataModule2->Table1Sum_agreement->AsInteger+ '\n'));
WordApplication1->Selection->InsertAfter(snew);
if(ToolButton7->Enabled==true)
{
WordApplication1->Selection->InsertAfter(
TVariant (DataModule2->Table1Date_completion->AsString + "Срок окончания \n"));
WordApplication1->Selection->InsertAfter(snew);
}
if(ToolButton8->Enabled==true)
{
WordApplication1->Selection->InsertAfter(
TVariant (DataModule2->Table1Perfomance->AsString + "Исполнитель\n"));
}
WordFont1->ConnectTo(WordApplication1->Selection->Font);
WordParagraphFormat1->ConnectTo(WordApplication1->Selection->ParagraphFormat);
TVariant Direction = wdCollapseEnd;
WordApplication1->Selection->Collapse(&Direction);
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton3Click(TObject *Sender)
{
//DocumentSearch();
WordApplication1->Dialogs->Item(wdDialogFileSaveAs)->Show(EmptyParam);
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton1Click(TObject *Sender)
{
//Открытие и соединение с word, если пользователь случайно закрыл его
WordApplication1->Connect();
//Включение видимости сервера
WordApplication1->Visible;
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ApplicationEvents1Hint(TObject *Sender)
{
//Отображение подсказок в строке состояния
StatusBar1->SimpleText=Application->Hint;
}
//---------------------------------------------------------------------------
void __fastcall TForm20::FormDestroy(TObject *Sender)
{
//Разрываем соединение с базой
DataModule2->Table1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton4Click(TObject *Sender)
{
//Предварительный просмотр документа
//DocumentSearch();
WordDocument1->PrintPreview();
WordApplication1->Visible;
}
//---------------------------------------------------------------------------
void __fastcall TForm20::BitBtn1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm20::ToolButton15Click(TObject *Sender)
{
//Открытие файла
WordApplication1->Visible;
if(WordApplication1->Dialogs->Item(wdDialogFileOpen)->Show(EmptyParam)==-1)
{
ToolButton3->Enabled=false;
ToolButton4->Enabled=false;
ToolButton5->Enabled=false;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm20::CheckBox1Click(TObject *Sender)
{
if(CheckBox1->Checked==true){
ToolButton6->Enabled=true;
ToolButton7->Enabled=true;
ToolButton8->Enabled=true;}
else {
ToolButton6->Enabled=false;
ToolButton7->Enabled=false;
ToolButton8->Enabled=false; }
}
//---------------------------------------------------------------------------
void __fastcall TForm20::FormShow(TObject *Sender)
{
CheckBox1->Checked=false;
}
//---------------------------------------------------------------------------
//ПоисквБД
#include <vcl.h>
#pragma hdrstop
#include "Unit25.h"
#include "Saw12.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm25 *Form25;
//---------------------------------------------------------------------------
__fastcall TForm25::TForm25(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm25::ComboBox1Change(TObject *Sender)
{
if(ComboBox1->ItemIndex==0){ //Установка видимости компонентов, //связанных с данными
EditReg->Visible=true;
EditJur->Visible=false;
EditDateReg->Visible=false;
EditDateAgreem->Visible=false;
EditObjAgreem->Visible=false;
EditContractor->Visible=false;}
else if(ComboBox1->ItemIndex==1){
EditJur->Visible=true;
EditReg->Visible=false;
EditDateReg->Visible=false;
EditDateAgreem->Visible=false;
EditObjAgreem->Visible=false;
EditContractor->Visible=false;}
else {if(ComboBox1->ItemIndex==2){
EditDateReg->Visible=true;
EditJur->Visible=false;
EditReg->Visible=false;
EditDateAgreem->Visible=false;
EditObjAgreem->Visible=false;
EditContractor->Visible=false;
}
else {if(ComboBox1->ItemIndex==3){
EditDateAgreem->Visible=true;
EditDateReg->Visible=false;
EditJur->Visible=false;
EditReg->Visible=false;
EditObjAgreem->Visible=false;
EditContractor->Visible=false;
}
else {if(ComboBox1->ItemIndex==4){
EditObjAgreem->Visible=true;
EditDateReg->Visible=false;
EditJur->Visible=false;
EditReg->Visible=false;
EditDateAgreem->Visible=false;
EditContractor->Visible=false;
}
else {if(ComboBox1->ItemIndex==5){
EditContractor->Visible=true;
EditDateReg->Visible=false;
EditJur->Visible=false;
EditReg->Visible=false;
EditDateAgreem->Visible=false;
EditObjAgreem->Visible=false;
}
}
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm25::BitBtn2Click(TObject *Sender)
{
Form25->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm25::BitBtn1Click(TObject *Sender)
{
if(ComboBox1->ItemIndex==0){ //Поиск в записи в базе данных
DataModule2->Table1->IndexFieldNames="Register_number";
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Register_number")->AsString=EditReg->Text;
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена!");}
else {if(ComboBox1->ItemIndex==1){
DataModule2->Table1->IndexFieldNames="Juridical_number"; //
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Juridical_number")->AsInteger=StrToInt(EditJur->Text);
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена!!");}
else {if(ComboBox1->ItemIndex==2){
DataModule2->Table1->IndexFieldNames="Date_register";
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Date_register")->AsDateTime=StrToDate(EditDateReg->Text); //
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена");}
else {if(ComboBox1->ItemIndex==3){
DataModule2->Table1->IndexFieldNames="Date_agreement"; //
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Date_agreement")->AsDateTime=StrToDate(EditDateAgreem->Text);
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена");}
else {if(ComboBox1->ItemIndex==4){
DataModule2->Table1->IndexFieldNames="Object_agreement"; //
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Object_agreement")->AsString=EditObjAgreem->Text;
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена");}
else {if(ComboBox1->ItemIndex==5){
DataModule2->Table1->IndexFieldNames="Contractor";
DataModule2->Table1->SetKey();
DataModule2->Table1->FieldByName("Contractor")->AsString=EditContractor->Text;
Form25->Close();
if(!DataModule2->Table1->GotoKey())
ShowMessage("Запись не найдена");}
}
}
}
}
}