Файл: Разработка информационной системы управления банковскими операциями.pdf
Добавлен: 28.03.2023
Просмотров: 1699
Скачиваний: 40
СОДЕРЖАНИЕ
Глава 1. Исследование предметной области
1.1 Общее описание предприятия
1.2 Характеристика текущих бизнес-процессов
1.5 Описание входных и выходных данных
1.6 Разработка диаграммы «TO-BE»
Глава 2. Проектирование и разработка ИС
2.1 Проектирование структуры базы данных
2.2 Дерево функций и сценарий диалога
2.4 Описание таблиц базы данных
2.5 Описание программных модулей
Child.DBGrid1.DataSource.DataSet.Filtered:=true;
Child.Account.Active:=true;
if not Child.DbGrid1.DataSource.DataSet.FieldByName('number').IsNull then
begin
Child.DBGrid2.DataSource.DataSet.Filtered:=false;
Child.DBGrid2.DataSource.DataSet.Filter:='accountid = '+Child.DbGrid1.DataSource.DataSet.FieldByName('number').AsString;
Child.DBGrid2.DataSource.DataSet.Filtered:=true;
Child.DBGrid2.DataSource.DataSet.active:=true;
end
else
begin
Child.DBGrid2.DataSource.DataSet.active:=true;
end;
Child.ResetChange;
Child.Setgridcolumnwidths;
end;
end;
end.
unit OneClient;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, ComCtrls, ExtCtrls, DB, ADODB,
Menus;
type
TForm4 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
DateTimePicker1: TDateTimePicker;
BitBtn1: TBitBtn;
Panel3: TPanel;
Panel4: TPanel;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
Label6: TLabel;
ADOQuery1: TADOQuery;
Account: TADOTable;
DataSource1: TDataSource;
Accountnumber: TAutoIncField;
Accountclientid: TIntegerField;
Accountmetallid: TIntegerField;
Accountopendate: TDateTimeField;
AccountMetallL: TStringField;
DataSource2: TDataSource;
Operation: TADOTable;
OperationId: TAutoIncField;
Operationuserid: TIntegerField;
Operationaccountid: TIntegerField;
Operationtypeid: TIntegerField;
Operationcreatedat: TDateTimeField;
OperationTypeL: TStringField;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
Accountbalance: TFloatField;
Operationsumma: TFloatField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit1Change(Sender: TObject);
procedure Clientchange;
procedure Edit2Change(Sender: TObject);
procedure Edit3Change(Sender: TObject);
procedure Edit4Change(Sender: TObject);
procedure DateTimePicker1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure N4Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure ResetChange;
procedure Setgridcolumnwidths;
procedure N5Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
Uses DataM, Main, NewAccount;
{$R *.dfm}
Procedure TForm4.Setgridcolumnwidths;
var
i,x,dx:integer;
begin
x:=round(width/2);
Panel4.width:=x;
x:=Round((DbGrid1.width-80)/(DbGrid1.Columns.Count-1));
DbGrid1.Columns[0].Width:=40;
For i:=1 to DbGrid1.Columns.Count-1 do
begin
DbGrid1.Columns[i].Width:=x;
end;
x:=Round((DbGrid2.width-80)/(DbGrid2.Columns.Count-1));
DbGrid2.Columns[0].Width:=40;
For i:=1 to DbGrid2.Columns.Count-1 do
begin
DbGrid2.Columns[i].Width:=x;
end;
end;
Procedure TForm4.Clientchange;
begin
if Pos('*',caption)=0 then
caption:=caption+'*';
bitbtn1.Enabled:=true;
end;
Procedure TForm4.ResetChange;
var
capt:string;
begin
if Pos('*',caption)<>0 then
begin
capt:=caption;
caption:=Copy(caption, 0,length(caption)-1);
bitbtn1.Enabled:=false;
end;
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
action:=cafree;
end;
procedure TForm4.Edit1Change(Sender: TObject);
begin
Clientchange;
end;
procedure TForm4.Edit2Change(Sender: TObject);
begin
Clientchange;
end;
procedure TForm4.Edit3Change(Sender: TObject);
begin
Clientchange;
end;
procedure TForm4.Edit4Change(Sender: TObject);
begin
Clientchange;
end;
procedure TForm4.DateTimePicker1Change(Sender: TObject);
begin
Clientchange;
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
//проверяем наличие данных
if edit1.text='' then begin Showmessage('Введите ФИО клиента'); edit1.SetFocus; exit; end;
if edit2.text='' then begin Showmessage('Введите телефон клиента'); edit2.SetFocus; exit; end;
if edit3.text='' then begin Showmessage('Введите данные паспорта клиента'); edit3.SetFocus; exit; end;
if edit4.text='' then begin Showmessage('Введите адрес регистрации клиента'); edit4.SetFocus; exit; end;
if label6.caption='0' then
begin
With AdoQuery1 do
begin
close;
SQL.clear;
SQL.add('INSERT INTO Client(FIO, phone, passport, address, birthdate) VALUES ');
SQL.Add('(:fio, :phone, :passport, :address, :birthdate )');
Parameters.ParamByName('fio').Value:=Edit1.Text;
Parameters.ParamByName('phone').Value:=Edit2.Text;
Parameters.ParamByName('passport').Value:=Edit3.Text;
Parameters.ParamByName('address').Value:=Edit4.Text;
Parameters.ParamByName('birthdate').Value:=DateTimePicker1.DateTime;
execSQL;
end;
ResetChange;
close;
end
else
begin
With AdoQuery1 do
begin
close;
SQL.clear;
SQL.add('UPDATE Client SET FIO = :fio, phone = :phone, passport = :passport, address = :address, birthdate = :birthdate) WHERE id = :id ');
Parameters.ParamByName('fio').Value:=Edit1.Text;
Parameters.ParamByName('phone').Value:=Edit2.Text;
Parameters.ParamByName('passport').Value:=Edit3.Text;
Parameters.ParamByName('address').Value:=Edit4.Text;
Parameters.ParamByName('birthdate').Value:=DateTimePicker1.DateTime;
Parameters.ParamByName('id').Value:=label6.Caption;
execSQL;
end;
ResetChange
end;
end;
procedure TForm4.DBGrid1CellClick(Column: TColumn);
begin
if not DbGrid1.DataSource.DataSet.FieldByName('number').isNULL then
begin
DBGrid2.DataSource.DataSet.Filtered:=false;
DBGrid2.DataSource.DataSet.Filter:='accountid = '+DbGrid1.DataSource.DataSet.FieldByName('number').AsString;
DBGrid2.DataSource.DataSet.Filtered:=true;
DBGrid2.DataSource.DataSet.active:=true;
end
else
begin
DBGrid2.DataSource.DataSet.active:=true;
end;
end;
procedure TForm4.N4Click(Sender: TObject);
begin
If MessageBox(Handle,PChar('Закрыть счет?'),PChar('Подтверждение'),MB_ICONINFORMATION+MB_YESNO+MB_DEFBUTTON2)=IdYes
then
begin
//добавляем операцию
With AdoQuery1 do
begin
close;
SQL.clear;
SQL.Add('INSERT INTO operation (userid, accountid, typeid, createdat, summa) VALUES');
SQL.Add('(:userid, :accountid, :typeid, :createdat, :summa)');
Parameters.ParamByName('userid').Value:=1;
Parameters.ParamByName('accountid').Value:=DbGrid1.DataSource.DataSet.FieldByName('number').Value;
Parameters.ParamByName('typeid').Value:=4;
Parameters.ParamByName('createdat').Value:=Now;
Parameters.ParamByName('summa').Value:=DbGrid1.DataSource.DataSet.FieldByName('Balance').Value;
EXECSQL;
end;
//Списываем деньги с счета
With AdoQuery1 do
begin
close;
SQL.clear;
SQL.Add('UPDATE account SET balance = 0 WHERE number= :number');
Parameters.ParamByName('number').Value:=DbGrid1.DataSource.DataSet.FieldByName('number').Value;
EXECSQL;
end;
//обновляем отображаемые данные
Account.Close;
Account.Open;
Operation.Close;
Operation.Open;
end;
end;
procedure TForm4.N3Click(Sender: TObject);
var
InputSumma:string;
Summa:extended;
begin
InputSumma:=InputBox('Дополнительный взнос','Введите сумму дополнительного взноса','0');