
- •Теоретична частина
- •1. Технічне завдання
- •1.1. Підстави для розробки
- •1.2. Призначення розробки
- •1.3. Аналіз вимог до програмного забезпечення
- •1.3.1. Функціональні вимоги
- •1.3.2. Вимоги до складу та параметрів технічних засобів
- •1.3.4. Вимоги до інформаційної та програмної сумісності
- •1.5. Стадії та етапи розробки
- •1.6. Порядок контролю і приймання
- •Практична частина
- •2. Архітектура, функціональні та технічні показники
- •2.1. Призначення та область застосування
- •2. 2. Опис та обґрунтування обраної архітектури
- •2.3. Функціональна специфікація
- •2.3.1. Опис функціональних можливостей
- •2.3.2. Опис інтерфейсу користувача
- •2.4. Технічна специфікація
- •2.4.1. Опис і обґрунтування вхідних і вихідних даних
- •3. Конструювання програмного забезпечення
- •3.1. Опис і обґрунтування обраних програмних засобів
- •3.2. Опис програми
- •3.2.1. Функціональні можливості
- •3.2.2. Опис логічної структури
- •Опис бази даних
- •3.2.3. Використані технічні засоби
- •4. Програма та методика випробувань
- •4.1. Об’єкт випробувань
- •4.2. Використані технічні засоби
- •4.3. Порядок та методика випробувань
- •4.4. Результати випробувань
- •5. Висновки
- •Використана література
- •7. Додатки Додаток а. Код програми
Використана література
Г.В. Галисеев – Програмирование в среде Delphi.
Бакнелл - Фундаминтальные алгоритмы и структуриы даных в Delphi
Бобровский – Delphi 7 Учебный курс.
Фаронов – Искуство создания компонентов Delphi.
Фаронов В.В – Програмирование баз даных в Delphi 7.
В.В Фаронов, П.В Шумаков – Руководство разроботчика баз даных.
Рей Конолка – Создание оригинальних компонент в среде Delphi.
Парижский Сергей – Delphi . Учимся на примерах.
В. Пестриков, А. Маслобоев – Delphi на примерах.
Тиней Дианна – Програмирование в Paradox for Windows на примерах.
Тихонов А.В – Енциклопедия ро СУБД Paradox 4.5 for DOS.
Архангельський А.Я – Програмування в Delphi 7.
Довідкова документація програми Delphi 7.
Дейт. К. – Введение в системы баз даных.
7. Додатки Додаток а. Код програми
Модуль «Unit1»
#include <vcl.h>
#include "shellapi.h"
#include "stdio.h"
#include "conio.h"
#include "windows.h"
#pragma hdrstop
#include "Unit1.h"
#include "User.h"
#include "NetOP.h"
#include "PassWord.h"
#include "SendF.h"
#include "RecF.h"
#include "About.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "trayicon"
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString Al = "ABCDEFGHIJKLMNOPQRSTUVWXYZАБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯabcdefghijklmnopqrstuvwxyzабвгґдеєжзиіїйклмнопрстуфхцчшщьюя !@\"#№$;%^:&?*()-_+={}[]\\/<>.,~`0123456789";
AnsiString MyText = "";
AnsiString Key = "";
AnsiString R = "";
AnsiString ResText = "";
AnsiString Pust = "";
char Resh[10][16];
AnsiString Dir;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void CreateR()
{Key=Form4->Edit1->Text;
R = Key;
AnsiString Alphabet = Al;
for (int i=1; i<=Key.Length(); i++)
for (int j=1; j<=Alphabet.Length(); j++)
if (Key[i] == Alphabet[j])
Alphabet = Alphabet.Delete(j,1);
R += Alphabet;
int num = 1;
AnsiString Str = "";
for (int i=0; i<10; i++)
{ Str = "";
for (int j=0; j<16; j++)
{ Str += R[num];
if (j != 16)
Str += " ";
num++; } }
num = 1;
for (int i=0; i<10; i++)
for (int j=0; j<16; j++)
{ Resh[i][j] = R[num];
num++; }}
//---------------------------------------------------------------------------
void ChoosePust()
{ int k = 0;
int m = 1000;
for (int i=1; i<=R.Length(); i++)
{ for (int j=1; j<=MyText.Length(); j++)
if (R[i] == MyText[j])
k++;
if (k<m)
{ m = k;
k = 0;
Pust = " ";}}}
//---------------------------------------------------------------------------
void EditText()
{ ChoosePust();
for (int i=1; i<MyText.Length(); i++)
if (MyText[i] == MyText[i+1])
MyText = MyText;
int Len = MyText.Length();
if (Len % 2 != 0)
MyText += Pust;}
//---------------------------------------------------------------------------
void Encrypt()
{ResText = "";
int ind_x1 = 0;
int ind_y1 = 0;
int ind_x2 = 0;
int ind_y2 = 0;
int k = 1;
while (k<MyText.Length())
{ for (int i=0; i<10; i++)
for (int j=0; j<16; j++)
{ if (MyText[k] == Resh[i][j])
{ ind_x1 = i;
ind_y1 = j;}
if (MyText[k+1] == Resh[i][j])
{ ind_x2 = i;
ind_y2 = j;}}
if (ind_x1 == ind_x2)
{ if (ind_y1 == ind_y2)
{ ResText += Resh[ind_x1][ind_y1];
ResText += Resh[ind_x2][ind_y2]; }}
else
if (ind_x1 == ind_x2)
{if (ind_y1 == 15)
{ ResText += Resh[ind_x1][0];
ResText += Resh[ind_x2][ind_y2+1]; }
else
if (ind_y2 == 15)
{ResText += Resh[ind_x1][ind_y1+1];
ResText += Resh[ind_x2][0];}
else
{ResText += Resh[ind_x1][ind_y1+1];
ResText += Resh[ind_x2][ind_y2+1];} }
if (ind_y1 == ind_y2)
{ if (ind_x1 == 9)
{ ResText += Resh[0][ind_y1];
ResText += Resh[ind_x2+1][ind_y2];}
else
if (ind_x2 == 9)
{ ResText += Resh[ind_x1+1][ind_y1];
ResText += Resh[0][ind_y2];}
Else
{ ResText += Resh[ind_x1+1][ind_y1];
ResText += Resh[ind_x2+1][ind_y2] } }
if ((ind_x1 != ind_x2) && (ind_y1 != ind_y2))
{ ResText += Resh[ind_x1][ind_y2];
ResText += Resh[ind_x2][ind_y1]; }
k = k + 2;}}
//---------------------------------------------------------------------------
void Decrypt()
{ ResText = "";
int ind_x1 = 0;
int ind_y1 = 0;
int ind_x2 = 0;
int ind_y2 = 0;
int k = 1;
while (k<MyText.Length()-2)
{for (int i=0; i<10; i++)
for (int j=0; j<16; j++)
{if (MyText[k] == Resh[i][j])
{ind_x1 = i;
ind_y1 = j;
if (MyText[k+1] == Resh[i][j])
{ind_x2 = i;
ind_y2 = j; }}
if (ind_x1 == ind_x2)
{if (ind_y1 == 0)
{ ResText += Resh[ind_x1][15];
ResText += Resh[ind_x2][ind_y2-1]; }
else
if (ind_y2 == 0)
{ResText += Resh[ind_x1][ind_y1-1];
ResText += Resh[ind_x2][15]; }
else
{ResText += Resh[ind_x1][ind_y1-1];
ResText += Resh[ind_x2][ind_y2-1]; }}
else
if (ind_y1 == ind_y2)
{ if (ind_x1 == 0)
{ ResText += Resh[9][ind_y1];
ResText += Resh[ind_x2-1][ind_y2]; }
else
if (ind_x2 == 0)
{ResText += Resh[ind_x1-1][ind_y1];
ResText += Resh[9][ind_y2]; }
else
{ ResText += Resh[ind_x1-1][ind_y1];
ResText += Resh[ind_x2-1][ind_y2]; }}
else
if ((ind_x1 != ind_x2) && (ind_y1 != ind_y2))
{ ResText += Resh[ind_x1][ind_y2];
ResText += Resh[ind_x2][ind_y1]; }
k = k + 2; }}
//---------------------------------------------------------------------------
void __fastcall TForm1::SS1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{
Log->Lines->Add("Client connected");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::CS1Connect(TObject *Sender,
TCustomWinSocket *Socket)
{Log->Lines->Add("Connected");}
//---------------------------------------------------------------------------
void __fastcall TForm1::CS1Read(TObject *Sender, TCustomWinSocket *Socket)
{CreateR();
DWORD id = 0;
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Decrypt, NULL, 0, &id);
Log->Lines->Add(Socket->ReceiveText());}
//---------------------------------------------------------------------------
void __fastcall TForm1::SS1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{CreateR();
DWORD id = 0;
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Decrypt, NULL, 0, &id);
Log->Lines->Add(Socket->ReceiveText());}
//---------------------------------------------------------------------------
void __fastcall TForm1::Network1Click(TObject *Sender)
{Form2->ShowModal();}
//--------------------------------------------------------------------------
void __fastcall TForm1::Name1Click(TObject *Sender)
{Form3->ShowModal();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Password1Click(TObject *Sender)
{Form4->ShowModal();}
//---------------------------------------------------------------------------
void __fastcall TForm1::SendFile1Click(TObject *Sender)
{Form5->ShowModal();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Recievefile1Click(TObject *Sender)
{Form6->ShowModal();}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{if (Form3->Edit1->Text=="")
{ShowMessage("Enter your name!!!");
return; }
if (Ms->Lines->Text=="")
{ ShowMessage("Enter text!!!");
return;}
Log->Lines->Add(Form3->Edit1->Text+":: "+Form1->Ms->Lines->Text);
if (Form1->CheckBox1->Checked == true)
{MyText = Form1->Ms->Lines->Text;
CreateR();
EditText();
DWORD id = 0;
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Encrypt, NULL, 0, &id);
if (SS1->Active==true)
{SS1->Socket->Connections[0]->SendText(Form3->Edit1->Text+":: "+MyText);}
else
{CS1->Socket->SendText(Form3->Edit1->Text+":: "+MyText);}
Ms->Lines->Text= "";}
else
if (SS1->Active==true)
{SS1->Socket->Connections[0]->SendText(Form3->Edit1->Text+":: "+Form1->Ms->Lines->Text);}
else
{CS1->Socket->SendText(Form3->Edit1->Text+":: "+Form1->Ms->Lines->Text);}
Ms->Clear();
Ms->SetFocus();}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{SS1->Active=true;
BitBtn4->Enabled=false;
BitBtn3->Enabled=true;
Log->Lines->Add("Server created");}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn4Click(TObject *Sender)
{Form2->ShowModal();
CS1->Host = Form2->Edit1->Text;
CS1->Address = Form2->Edit1->Text;
CS1->Active = true;
BitBtn2->Enabled = false;
BitBtn5->Enabled = true;}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn3Click(TObject *Sender)
{SS1->Active=false;
BitBtn4->Enabled=true;
BitBtn3->Enabled=false;
Log->Lines->Add("Server shutted down");}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn5Click(TObject *Sender)
{CS1->Active = false;
BitBtn2->Enabled = true;
BitBtn5->Enabled = false;}
//---------------------------------------------------------------------------
void __fastcall TForm1::Minimize1Click(TObject *Sender)
{TrayIcon1->Minimize();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Restore1Click(TObject *Sender)
{TrayIcon1->Restore();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit2Click(TObject *Sender)
{Form1->Close();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{Form1->Close();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Clearlog1Click(TObject *Sender)
{Log->Clear();
Ms->Clear();
Form5->Memo1->Clear();
Form6->Memo1->Clear();
Ms->SetFocus();}
//---------------------------------------------------------------------------
void __fastcall TForm1::Help1Click(TObject *Sender)
{ShellExecute(NULL, "open", "help.htm", NULL, "Система обміну" , SW_SHOWNORMAL);}
//---------------------------------------------------------------------------
void __fastcall TForm1::About2Click(TObject *Sender)
{Form7->ShowModal();}
//---------------------------------------------------------------------------
Модуль «NetOp»
#include <vcl.h>
#pragma hdrstop
#include "NetOp.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TForm2::BitBtn1Click(TObject *Sender)
{String ServIp;
ServIp=Edit1->Text;
Form1->Log->Lines->Add("You are connecting to "+Edit1->Text+"...");
Form1->Ms->SetFocus();
Close();}
//---------------------------------------------------------------------------
Модуль «User»
#include <vcl.h>
#pragma hdrstop
#include "User.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TForm3::BitBtn1Click(TObject *Sender)
{String Nic;
Nic = Edit1->Text;
Form1->Log->Lines->Add("Name changed to "+Edit1->Text);
Form1->Ms->SetFocus();
Close();}
//---------------------------------------------------------------------------
Модуль «PassWord»
#include <vcl.h>
#pragma hdrstop
#include "PassWord.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm4 *Form4;
AnsiString PassW;
//---------------------------------------------------------------------------
__fastcall TForm4::TForm4(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
bool CheckPassW()
{for (int i=1; i<=PassW.Length(); i++)
for (int j=1; j <= PassW.Length(); j++)
if ((PassW[i] == PassW[j]) && (i != j))
return false;// ShowMessage("");
return true;}
//---------------------------------------------------------------------------
void __fastcall TForm4::BitBtn1Click(TObject *Sender)
{PassW=Edit1->Text;
Form1->Log->Lines->Add("Password changed!!!");
Form1->Ms->SetFocus();
CheckPassW();
if (!CheckPassW())
MessageBox(NULL, "The key consist of repeated symbols!!!", "Error!", MB_OK);
else
Close();}
//---------------------------------------------------------------------------
Модуль «SendF»
#include <vcl.h>
#pragma hdrstop
#include "SendF.h"
#include "PassWord.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
TMemoryStream *MS1=new TMemoryStream ;
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TForm5::ServerSocket1Accept(TObject *Sender,
TCustomWinSocket *Socket)
{Memo1->Lines->Add("Client connected");}
//---------------------------------------------------------------------------
void __fastcall TForm5::ServerSocket1ClientError(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{ErrorCode = 0;
ShowMessage("Server error");}
//---------------------------------------------------------------------------
void __fastcall TForm5::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{if(ServerSocket1->Socket->Connections[0]->ReceiveText()=="end")
{Memo1->Lines->Add("Client recieved file");
MS1->Clear();}}
//---------------------------------------------------------------------------
void __fastcall TForm5::ServerSocket1ClientConnect(TObject *Sender,
TCustomWinSocket *Socket)
{Memo1->Lines->Add("Client connected");}
//---------------------------------------------------------------------------
void __fastcall TForm5::BitBtn1Click(TObject *Sender)
{ServerSocket1->Active = true;
ServerSocket1->Open();
Memo1->Lines->Add("Server created");}
//---------------------------------------------------------------------------
void __fastcall TForm5::BitBtn2Click(TObject *Sender)
{void *P;
int Size;
if( OpenDialog1->Execute() )
{MS1->LoadFromFile( OpenDialog1->FileName );
Memo1->Lines->Add( "File loaded to stream..." );}
ServerSocket1->Socket->Connections[0]->SendText( "file#" + OpenDialog1->FileName + "#" + IntToStr( MS1->Size ) + "#" );
MS1->Position = 0 ;
P=MS1->Memory ;
Size=ServerSocket1->Socket->Connections[0]->SendBuf( P,MS1->Size );
Memo1->Lines->Add("Sent:"+IntToStr(Size)+"of"+IntToStr(MS1->Size));}
//---------------------------------------------------------------------------
void __fastcall TForm5::Memo1DblClick(TObject *Sender)
{Memo1->Clear();}
//---------------------------------------------------------------------------
Модуль «RecF»
#include <vcl.h>
#pragma hdrstop
#include "RecF.h"
#include "NetOp.h"
#include "PassWord.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm6 *Form6;
TMemoryStream *MS2=new TMemoryStream ;
void Write( AnsiString Text );
int Size ;
bool Receive ;
AnsiString FileName;
//---------------------------------------------------------------------------
__fastcall TForm6::TForm6(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void Write( AnsiString Text )
{if(MS2->Size<Size)
{MS2->Write(Text.c_str(), Text.Length());
Form6->Memo1->Lines->Add( "Recieving files...");}
if(MS2->Size == Size)
{Receive = false ;
MS2->Position = 0 ;
Form6->ClientSocket1->Socket->SendText( "end" );
CreateDir("Downloads");
MS2->SaveToFile("Downloads\\"+FileName );
MS2->Clear() ;
Size = 0 ;
Form6->Memo1->Lines->Add("File recieved!");}}
//---------------------------------------------------------------------------
void __fastcall TForm6::ClientSocket1Read(TObject *Sender,
TCustomWinSocket *Socket)
{AnsiString Rtext ;
Rtext = ClientSocket1->Socket->ReceiveText() ;
if( Receive == true )
{Write( Rtext );}
else
{Memo1->Lines->Add( "File recieving...:" + Rtext );
if(Rtext.SubString( 0,Rtext.Pos("#")-1) == "file" )
{Rtext.Delete( 1 , Rtext.Pos( "#" ) ) ;
Name = Rtext.SubString( 0 , Rtext.Pos( "#" ) -1 );
FileName = Name.SubString( Name.LastDelimiter( "\\" ) + 1 , Name.Length() );
Rtext.Delete( 1 , Rtext.Pos( "#" ) );
Size = StrToInt( Rtext.SubString( 0 , Rtext.Pos( "#" ) - 1) ) ;
Rtext.Delete( 1 , Rtext.Pos( "#" ) );
Memo1->Lines->Add( "File size: " + IntToStr( Size ) + " bites" );
Memo1->Lines->Add( "File name: " + FileName );
Receive = true;}}}
//---------------------------------------------------------------------------
void __fastcall TForm6::ClientSocket1Connect(TObject *Sender,
TCustomWinSocket *Socket)
{Memo1->Lines->Add( "Connected" ); }
//---------------------------------------------------------------------------
void __fastcall TForm6::ClientSocket1Error(TObject *Sender,
TCustomWinSocket *Socket, TErrorEvent ErrorEvent, int &ErrorCode)
{ErrorCode = 0;
ShowMessage( "Client Error" ); }
//---------------------------------------------------------------------------
void __fastcall TForm6::BitBtn1Click(TObject *Sender)
{Form2->ShowModal();
ClientSocket1->Active=true;
ClientSocket1->Host=Form2->Edit1->Text;
ClientSocket1->Address=Form2->Edit1->Text;
Memo1->Lines->Add( "Connecting..." );}
//---------------------------------------------------------------------------
void __fastcall TForm6::Memo1DblClick(TObject *Sender)
{Memo1->Clear();}
//---------------------------------------------------------------------------
Модуль «About»
#include <vcl.h>
#pragma hdrstop
#include "About.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm7 *Form7;
//---------------------------------------------------------------------------
__fastcall TForm7::TForm7(TComponent* Owner)
: TForm(Owner)
{}
//---------------------------------------------------------------------------
void __fastcall TForm7::BitBtn1Click(TObject *Sender)
{Form7->Close();}
//---------------------------------------------------------------------------
void __fastcall TForm7::FormCreate(TObject *Sender)
{Memo1->Lines->Clear();
Memo1->Lines->Add ("Dear User! ");
Memo1->Lines->Add ("There is a program ");
Memo1->Lines->Add ("with which ");
Memo1->Lines->Add ("you can communicate ");
Memo1->Lines->Add ("with your friends ");
Memo1->Lines->Add (" in the local net. ");
Memo1->Lines->Add ("This program can ");
Memo1->Lines->Add ("transport files too. ");
Memo1->Lines->Add ("Program made by Dima Chayka ");
Memo1->Lines->Add ("Ukraine, Chernivtsi ");
Memo1->Lines->Add ("e-mail mister_dima@mail.ru ");
Memo1->Lines->Add ("May, 2010 ");}
//---------------------------------------------------------------------------