Автор: Пользователь скрыл имя, 02 Ноября 2012 в 17:03, курсовая работа
В настоящее время все большую актуальность приобретает использование при разработке приложений реляционных баз данных. Это связано с тем, что современные информационные системы имеют дело с большими объемами информации.
Введение………………………………………………………...………………
Задание на проектирование…………………..………………………....
Разработка структуры БД………………….…………………..………..
2.1 Описание предметной области………..………………………....
2.2 Анализ информационных потоков………………..……………..
2.3 Создание инфологической модели ………………………..…….
2.3.1 Процедура нормализации сущностей……………………...
2.4 Создание даталогической модели……………………..…………
2.5 Выбор технических и программных средств реализации БД и клиентского приложения………………………………………………..
Создание базы данных……………………………………………...…...
3.1 Описание структуры БД ………………………………………....
3.2 Описание свойств таблиц БД…………………………………….
3.3 Описание связей между таблицами БД и условий целостности данных………..……………………………………………………
3.4 Описание хранимых процедур…………………………………...
Создание пользовательского интерфейса информационной системы……………..................................................................................
4.1 Пользовательское меню …………………………………………
4.2 Формы как средство добавления, удаления, просмотра, изменений данных в БД…………………………………..……..
4.3 Формирование запросов к базе данных………………….……...
4.4 Формирование отчетов……….…………………………………..
4.5 Справочная система…………………….………………………...
Заключение……………………………………………………………………...
Литература………………………………………………………………………
Приложения……………………………………………………………………..
Приложение 2
Листинг программы
unit Kassovie_operacii;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, DB, ADODB;
type
TBase = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N25: TMenuItem;
N26: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
Label1: TLabel;
Server: TEdit;
LogIn: TButton;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
procedure N8Click(Sender: TObject);
procedure N26Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure LogInClick(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Connect: Boolean;
public
{ Public declarations }
end;
var
Base: TBase;
implementation
uses Tables, Zaprosi, HranProc, Otcheti;
{$R *.dfm}
procedure TBase.N8Click(Sender: TObject);
begin
MessageBox(Base.Handle,'
end;
procedure TBase.N26Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TBase.N2Click(Sender: TObject);
begin
if Connect=true then Table_ko.ShowModal;
end;
procedure TBase.N3Click(Sender: TObject);
begin
if Connect=true then Zaprosi_ko.ShowModal;
end;
procedure TBase.N5Click(Sender: TObject);
begin
if Connect=true then Hranproc_ko.ShowModal;
end;
procedure TBase.N4Click(Sender: TObject);
begin
if Connect=true then Otcheti_ko.ShowModal;
end;
procedure TBase.LogInClick(Sender: TObject);
begin
try
Connect := false;
ADOConnection1.Connected := false;
ADOConnection1.
'Integrated Security=SSPI;'+
'Persist Security Info=False;'+
'Initial Catalog=Kassovie_operacii;'+
'Data Source=' + Server.Text + ';';
ADOConnection1.Connected := true;
Connect:= true;
MessageBox(Base.Handle,'База подключена!','Кассовые операции', MB_DEFBUTTON3 or MB_ICONINFORMATION);
except
Connect := false;
MessageBox(Base.handle,'Ошибка подключения','Ошибка!', MB_DEFBUTTON3 or MB_ICONWARNING);
end;
end;
procedure TBase.N7Click(Sender: TObject);
begin
Winhelp(Base.Handle,'Справка\
end;
procedure TBase.FormCreate(Sender: TObject);
var
h: THandle;
begin
//Использовать анимированный курсор.
h := LoadImage(0, 'Справка\cursor.ani', IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE or LR_LOADFROMFILE);
Screen.Cursors[crArrow] := h;
end;
end.
unit Tables;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, ADODB, DB, Mask, Kassovie_operacii,
DBCtrls, Buttons;
const Naz_tab: array[0..7] of string = ('Kassiri', 'Doc', 'Podotch_lic', 'Buh_sch', 'Dvigenie', 'Ostatki', 'Banki', 'Podrazd');
type
TTable_ko = class(TForm)
rg_tab: TRadioGroup;
DataSource_t: TDataSource;
ADOTable_t: TADOTable;
DBGrid1: TDBGrid;
Param_kas: TPanel;
Label1: TLabel;
Label2: TLabel;
id_kas: TEdit;
FIO: TEdit;
Param_doc: TPanel;
Label3: TLabel;
Label4: TLabel;
id_doc: TEdit;
Naim_doc: TEdit;
Param_podlic: TPanel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
id_sotr: TEdit;
FIO_sotr: TEdit;
Lic_sch: TEdit;
Kod_banka: TEdit;
Kod_podr: TEdit;
Param_sch: TPanel;
Label10: TLabel;
Label11: TLabel;
id_sch: TEdit;
Naimen_sch: TEdit;
Param_dvig: TPanel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Date_dvig: TMaskEdit;
kod_kas_d: TEdit;
kod_sch_d: TEdit;
kod_sotr_d: TEdit;
sum_d: TEdit;
Kod_doc_d: TEdit;
num_doc: TEdit;
rg_prizoper: TRadioGroup;
rg_tipoper: TRadioGroup;
Param_ost: TPanel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Kod_kas_o: TEdit;
Ost_nach_o: TEdit;
sum_prih_o: TEdit;
sum_rash_o: TEdit;
Date_o: TMaskEdit;
Param_banki: TPanel;
Label24: TLabel;
Label25: TLabel;
id_banka: TEdit;
Naimen_banka: TEdit;
Param_podr: TPanel;
Label26: TLabel;
Label27: TLabel;
Label28: TLabel;
id_podr: TEdit;
Naimen_podrazd: TEdit;
id_nach: TEdit;
BitBtn1: TBitBtn;
Prev_rec: TSpeedButton;
Next_rec: TSpeedButton;
Insert_rec: TBitBtn;
Edit_rec: TBitBtn;
Del_rec: TBitBtn;
Savebase: TBitBtn;
procedure id_kasKeyPress(Sender: TObject; var Key: Char);
procedure Lic_schetKeyPress(Sender: TObject; var Key: Char);
procedure id_podrKeyPress(Sender: TObject; var Key: Char);
procedure id_schKeyPress(Sender: TObject; var Key: Char);
procedure kod_bankaKeyPress(Sender: TObject; var Key: Char);
procedure id_docKeyPress(Sender: TObject; var Key: Char);
procedure Lic_schKeyPress(Sender: TObject; var Key: Char);
procedure Ost_nach_oKeyPress(Sender: TObject; var Key: Char);
procedure Kod_podrKeyPress(Sender: TObject; var Key: Char);
procedure kod_kas_dKeyPress(Sender: TObject; var Key: Char);
procedure kod_sch_dKeyPress(Sender: TObject; var Key: Char);
procedure kod_sotr_dKeyPress(Sender: TObject; var Key: Char);
procedure sum_dKeyPress(Sender: TObject; var Key: Char);
procedure Kod_doc_dKeyPress(Sender: TObject; var Key: Char);
procedure num_docKeyPress(Sender: TObject; var Key: Char);
procedure Kod_kas_oKeyPress(Sender: TObject; var Key: Char);
procedure sum_prih_oKeyPress(Sender: TObject; var Key: Char);
procedure sum_rash_oKeyPress(Sender: TObject; var Key: Char);
procedure id_bankaKeyPress(Sender: TObject; var Key: Char);
procedure id_nachKeyPress(Sender: TObject; var Key: Char);
procedure rg_tabClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure Prev_recClick(Sender: TObject);
procedure Next_recClick(Sender: TObject);
procedure Edit_recClick(Sender: TObject);
procedure Del_recClick(Sender: TObject);
procedure Insert_recClick(Sender: TObject);
procedure SavebaseClick(Sender: TObject);
procedure FIOKeyPress(Sender: TObject; var Key: Char);
procedure FIO_sotrKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ShowTabl(id: integer);
procedure show_info;
procedure save_rec;
procedure clear_info;
public
{ Public declarations }
end;
var
Table_ko: TTable_ko;
implementation
{$R *.dfm}
procedure TTable_ko.clear_info;
begin
date_dvig.Clear;
date_o.Clear;
FIO.Clear;
FIO_sotr.Clear;
id_banka.Clear;
id_kas.Clear;
id_doc.Clear;
id_nach.Clear;
id_podr.Clear;
id_sch.Clear;
id_sotr.Clear;
Kod_banka.Clear;
kod_doc_d.Clear;
kod_sotr_d.Clear;
kod_kas_d.Clear;
kod_kas_o.Clear;
kod_sch_d.Clear;
kod_podr.Clear;
Naim_doc.Clear;
Naimen_banka.Clear;
Lic_sch.Clear;
Naimen_podrazd.Clear;
Naimen_sch.Clear;
Num_doc.Clear;
Ost_nach_o.Clear;
sum_d.Clear;
sum_prih_o.Clear;
sum_rash_o.Clear;
end;
procedure TTable_ko.show_info;
begin
case rg_tab.ItemIndex of
0: begin
with DataSource_t.DataSet do
begin
id_kas.Text:= Trim(Fields[0].AsString);
FIO.Text:= Trim(Fields[1].AsString);
end;
end;
1: begin
with DataSource_t.DataSet do
begin
id_doc.Text:= Trim(Fields[0].AsString);
Naim_doc.Text:= Trim(Fields[1].AsString);
end;
end;
2: begin
with DataSource_t.DataSet do
begin
FIO_sotr.Text:= Trim(Fields[1].AsString);
Lic_sch.Text:= Trim(Fields[2].AsString);
id_sotr.Text:=Trim(Fields[0].
Kod_banka.Text:=Trim(Fields[3]
Kod_podr.Text:=Trim(Fields[4].
end;
end;
3: begin
with DataSource_t.DataSet do
begin
id_sch.Text:= Trim(Fields[0].AsString);
Naimen_sch.Text:= Trim(Fields[1].AsString);
end;
end;
4: begin
with DataSource_t.DataSet do
begin
date_dvig.Text:= Trim(Fields[0].AsString);
kod_kas_d.Text:= Trim(Fields[1].AsString);
kod_sch_d.Text:=Trim(Fields[3]
Kod_sotr_d.Text:=Trim(Fields[
sum_d.Text:=Trim(Fields[6].
kod_doc_d.Text:=Trim(Fields[7]
num_doc.Text:=Trim(Fields[8].
if Trim(Fields[2].AsString)='
else rg_prizoper.ItemIndex:=1;
if Trim(Fields[4].AsString)='
else rg_tipoper.ItemIndex:=1;
end;
end;
5: begin
with DataSource_t.DataSet do
begin
Kod_kas_o.Text:= Trim(Fields[0].AsString);
Date_o.Text:= Trim(Fields[1].AsString);
Ost_nach_o.Text:=Trim(Fields[
sum_prih_o.Text:=Trim(Fields[
sum_rash_o.Text:=Trim(Fields[
end;
end;
6: begin
with DataSource_t.DataSet do
begin
id_banka.Text:= Trim(Fields[0].AsString);
Naimen_banka.Text:= Trim(Fields[1].AsString);
end;
end;
7: begin
with DataSource_t.DataSet do
begin
id_podr.Text:= Trim(Fields[0].AsString);
Naimen_podrazd.Text:= Trim(Fields[1].AsString);
id_nach.Text:= Trim(Fields[2].AsString);
end;
end;
end;
end;
procedure TTable_ko.save_rec;
var
fl: boolean;
begin
fl:= true;
case rg_tab.ItemIndex of
0: begin
if (trim(id_kas.Text) = '') or (trim(FIO.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_kas.Text);
Fields[1].AsString := Trim(FIO.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
1: begin
if (trim(id_doc.Text) = '') or (trim(Naim_doc.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_doc.Text);
Fields[1].AsString := Trim(Naim_doc.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
2: begin
if (trim(FIO_sotr.Text) = '') or (trim(Lic_sch.Text) = '') or (trim(id_sotr.Text) = '') or (trim(Kod_banka.Text) = '') or (trim(Kod_podr.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_sotr.Text);
Fields[1].AsString := Trim(FIO_sotr.Text);
Fields[2].AsString := Trim(Lic_sch.Text);
Fields[3].AsString := Trim(Kod_banka.Text);
Fields[4].AsString := Trim(Kod_podr.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
3: begin
if (trim(id_sch.Text) = '') or (trim(Naimen_sch.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_sch.Text);
Fields[1].AsString := Trim(Naimen_sch.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
4: begin
if (trim(date_dvig.Text) = '') or (trim(kod_kas_d.Text) = '') or (trim(kod_sch_d.Text) = '') or (trim(Kod_sotr_d.Text) = '') or (trim(sum_d.Text) = '') or (trim(kod_doc_d.Text) = '') or (trim(num_doc.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(date_dvig.Text);
Fields[1].AsString := Trim(kod_kas_d.Text);
Fields[3].AsString := Trim(kod_sch_d.Text);
Fields[5].AsString := Trim(Kod_sotr_d.Text);
Fields[6].AsString := Trim(sum_d.Text);
Fields[7].AsString := Trim(kod_doc_d.Text);
Fields[8].AsString := Trim(num_doc.Text);
if rg_prizoper.ItemIndex=0 then Fields[2].AsString:=Trim('
else Fields[2].AsString:=Trim('
if rg_tipoper.ItemIndex=0 then Fields[4].AsString:=Trim('
else Fields[4].AsString:=Trim('Внут
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
5: begin
if (trim(Kod_kas_o.Text) = '') or (trim(Date_o.Text) = '') or (trim(Ost_nach_o.Text) = '') or (trim(sum_prih_o.Text) = '') or (trim(sum_rash_o.Text) = '')then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(Kod_kas_o.Text);
Fields[1].AsString := Trim(Date_o.Text);
Fields[2].AsString := Trim(Ost_nach_o.Text);
Fields[3].AsString := Trim(sum_prih_o.Text);
Fields[4].AsString := Trim(sum_rash_o.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'
dataSource_t.DataSet.Cancel;
end;
end;
6: begin
if (trim(id_banka.Text) = '') or (trim(Naimen_banka.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_banka.Text);
Fields[1].AsString := Trim(Naimen_banka.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'Пр
dataSource_t.DataSet.Cancel;
end;
end;
7: begin
if (trim(id_podr.Text) = '') or (trim(Naimen_podrazd.Text) = '') or (trim(id_nach.Text) = '') then fl := false;
if fl then
with DataSource_t.DataSet do
begin
Edit;
try
Fields[0].AsString := Trim(id_podr.Text);
Fields[1].AsString := Trim(Naimen_podrazd.Text);
Fields[2].AsString := Trim(id_nach.Text);
Post;
except
fl := false;
end;
end;
if not fl then
begin
MessageBox(Table_ko.handle,'Пр
dataSource_t.DataSet.Cancel;
end;
end;
end;
end;
procedure TTable_ko.rg_tabClick(Sender: TObject);
begin
Prev_rec.Enabled:=True;
Next_rec.Enabled:=True;
Insert_rec.Enabled:=True;
Edit_rec.Enabled:=True;
Del_rec.Enabled:=True;
case rg_tab.ItemIndex of
0: begin
ShowTabl(rg_tab.ItemIndex);
Param_banki.Visible:=False;
Param_doc.Visible:=False;
Param_dvig.Visible:=False;
Param_kas.Visible:=True;
Param_ost.Visible:=False;
Param_podlic.Visible:=False;
Param_podr.Visible:=False;
Param_sch.Visible:=False;
end;
1: begin
ShowTabl(rg_tab.ItemIndex);
Param_banki.Visible:=False;
Param_doc.Visible:=True;
Param_dvig.Visible:=False;
Param_kas.Visible:=False;
Param_ost.Visible:=False;
Param_podlic.Visible:=False;
Param_podr.Visible:=False;
Param_sch.Visible:=False;
end;
2: begin
ShowTabl(rg_tab.ItemIndex);
Param_banki.Visible:=False;
Param_doc.Visible:=False;
Param_dvig.Visible:=False;
Param_kas.Visible:=False;