Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Otchet_k_kursovoy.doc
Скачиваний:
7
Добавлен:
23.04.2019
Размер:
606.72 Кб
Скачать
  1. Главная

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, StdCtrls, Menus, TeEngine, Series, ExtCtrls, TeeProcs,

Chart, ComCtrls, ToolWin, ImgList;

type

TForm1 = class(TForm)

StringGrid1: TStringGrid;

Button1: TButton;

MainMenu1: TMainMenu;

File1: TMenuItem;

Save1: TMenuItem;

Saveas1: TMenuItem;

SaveDialog1: TSaveDialog;

Open1: TMenuItem;

OpenDialog1: TOpenDialog;

Label1: TLabel;

Edit1: TEdit;

Label2: TLabel;

Edit2: TEdit;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Edit3: TEdit;

Edit4: TEdit;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

Chart1: TChart;

Series1: TPieSeries;

Button2: TButton;

ToolBar1: TToolBar;

ToolButton1: TToolButton;

ToolButton2: TToolButton;

ToolButton3: TToolButton;

ToolButton4: TToolButton;

ToolButton5: TToolButton;

ImageList1: TImageList;

N4: TMenuItem;

N5: TMenuItem;

procedure FormCreate(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Saveas1Click(Sender: TObject);

procedure N2Click(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure Save1Click(Sender: TObject);

procedure Open1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure ToolButton1Click(Sender: TObject);

procedure ToolButton2Click(Sender: TObject);

procedure ToolButton3Click(Sender: TObject);

procedure ToolButton4Click(Sender: TObject);

procedure ToolButton5Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N4Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

type copyAp=record

data:string[30];

familiya:string[20];

otdel:string[20];

kolvoStr:integer;

kolvoCopy:integer;

price:real;

nadbavka:integer;

itogo:integer;

end;

var

Form1: TForm1;

f:file of copyAp;

i,j,k,n:integer;

fil:string;

a:array[0..100] of copyAp;

w:copyAp;

Part:array[1..3]of integer;

vr:array [1..3] of integer;

implementation

uses Unit3, Unit2;

{$R *.dfm}

//заполнение форм

procedure TForm1.FormCreate(Sender: TObject);

begin

stringgrid1.Cells[1,0]:='дата';

stringgrid1.Cells[2,0]:='фамилия';

stringgrid1.Cells[3,0]:='отдел';

stringgrid1.Cells[4,0]:='кол-во стр';

stringgrid1.Cells[5,0]:='кол-во копий';

stringgrid1.Cells[6,0]:='цена';

stringgrid1.Cells[7,0]:='надбавка';

stringgrid1.Cells[8,0]:='итого';

n:=0;

stringgrid1.RowCount:=2;

end;

//Добавление записи

procedure TForm1.Button1Click(Sender: TObject);

begin

a[n].data:=edit1.text;

a[n].familiya:=edit2.text;

a[n].otdel:=edit3.text;

a[n].kolvoStr:=StrToInt(edit4.text);

a[n].kolvoCopy:=StrToInt(edit5.text);

a[n].price:=StrToFloat(edit6.text);

a[n].nadbavka:=StrToInt(edit7.text);

n:=n+1;

edit1.Text:='';

edit2.Text:='';

edit3.Text:='';

edit4.Text:='';

edit5.Text:='';

edit6.Text:='';

edit7.Text:='';

stringgrid1.RowCount:=n+1;

for i:=0 to n-1 do begin

stringgrid1.Cells[0,i+1]:=inttostr(i+1);

stringgrid1.Cells[1,i+1]:=a[i].data;

stringgrid1.Cells[2,i+1]:=a[i].familiya;

stringgrid1.Cells[3,i+1]:=a[i].otdel;

stringgrid1.Cells[4,i+1]:=inttostr(a[i].kolvoStr);

stringgrid1.Cells[5,i+1]:=inttostr(a[i].kolvoCopy);

stringgrid1.Cells[6,i+1]:=floattostr(a[i].price);

stringgrid1.Cells[7,i+1]:=inttostr(a[i].nadbavka);

stringgrid1.Cells[8,i+1]:=floattostr(a[i].kolvostr*a[i].kolvoCopy*a[i].price+a[i].nadbavka);

end;

end;

//сохранить как

procedure TForm1.Saveas1Click(Sender: TObject);

begin

if saveDialog1.execute then

AssignFile(f,saveDialog1.FileName);

fil:=saveDialog1.FileName;

Rewrite(f);

for i:=0 to stringgrid1.RowCount-2 do

begin

Seek(f,i);

a[i].data:=stringgrid1.Cells[1,i+1];

a[i].familiya:=stringgrid1.Cells[2,i+1];

a[i].otdel:=stringgrid1.Cells[3,i+1];

a[i].kolvoStr:=strToiNt(stringgrid1.Cells[4,i+1]);

a[i].kolvoCopy:=strToiNt(stringgrid1.Cells[5,i+1]);

a[i].price:=StrToFloat(stringgrid1.Cells[6,i+1]);

a[i].nadbavka:=strToiNt(stringgrid1.Cells[7,i+1]);

a[i].itogo:=strToiNt(stringgrid1.Cells[8,i+1]);

write(f,a[i]);

end;

closefile(f);

end;

//сортировать

procedure TForm1.N2Click(Sender: TObject);

begin

For k:=0 to n-2 do

for i:=0 to n-k-2 do

if a[i].data>a[i+1].data

then

begin

w:=a[i];

a[i]:=a[i+1];

a[i+1]:=w;

end;

for i:=0 to StringGrid1.RowCount-1 do begin

stringgrid1.Cells[1,i+1]:=a[i].data;

stringgrid1.Cells[2,i+1]:=a[i].familiya;

stringgrid1.Cells[3,i+1]:=a[i].otdel;

stringgrid1.Cells[4,i+1]:=IntToStr(a[i].kolvoStr);

stringgrid1.Cells[5,i+1]:=IntToStr(a[i].kolvoCopy);

stringgrid1.Cells[6,i+1]:=FloatToStr(a[i].price);

stringgrid1.Cells[7,i+1]:=IntToStr(a[i].nadbavka);

stringgrid1.Cells[8,i+1]:=IntToStr(a[i].itogo);

end;

end;

//поиск по фамилии

procedure TForm1.N3Click(Sender: TObject);

var fa:string;

begin

fa:=form2.edit1.text;

form2.show;

form2.button1.caption:='OK';

end;

//сохранить

procedure TForm1.Save1Click(Sender: TObject);

begin

rewrite(f);

For i:=0 to n-1 do write(f,a[i]);

closefile(f)

end;

//открыть

procedure TForm1.Open1Click(Sender: TObject);

begin

if openDialog1.execute then

AssignFile(f,openDialog1.FileName);

fil:=openDialog1.FileName;

i:=0;

reset(f);

while not eof(f) do

begin

seek(f,i);

read(f,a[i]);

stringgrid1.RowCount:=i+2;

stringgrid1.Cells[0,i+1]:=inttostr(i+1);

stringgrid1.Cells[1,i+1]:=a[i].data;

stringgrid1.Cells[2,i+1]:=a[i].familiya;

stringgrid1.Cells[3,i+1]:=a[i].otdel;

stringgrid1.Cells[4,i+1]:=intToStr(a[i].kolvoStr);

stringgrid1.Cells[5,i+1]:=intToStr(a[i].kolvoCopy);

stringgrid1.Cells[6,i+1]:=FloatToStr(a[i].price);

stringgrid1.Cells[7,i+1]:=intToStr(a[i].nadbavka);

stringgrid1.Cells[8,i+1]:=intToStr(a[i].itogo);

i:=i+1;

end;

closefile(f); n:=i;

Form1.Caption:=fil;

end;

//диаграмма

procedure TForm1.Button2Click(Sender: TObject);

var

i:Integer;

begin

for i:=0 to Form1.StringGrid1.RowCount-1 do begin

if Form1.StringGrid1.Cells[3,1]='Бухгалтерия' then vr[1]:=strtoint(Form1.StringGrid1.Cells[4,1]);

if Form1.StringGrid1.Cells[3,2]='Бухгалтерия' then vr[2]:=strtoint(Form1.StringGrid1.Cells[4,2]);

if Form1.StringGrid1.Cells[3,3]='Бухгалтерия' then vr[3]:=strtoint(Form1.StringGrid1.Cells[4,3]);

end;

Chart1.Series[0].Add(vr[1],Form1.StringGrid1.Cells[2,1],RGB(random(255),random(255),random(255)));

Chart1.Series[0].Add(vr[2],Form1.StringGrid1.Cells[2,2],RGB(random(255),random(255),random(255)));

Chart1.Series[0].Add(vr[3],Form1.StringGrid1.Cells[2,3],RGB(random(255),random(255),random(255)));

end;

procedure TForm1.ToolButton1Click(Sender: TObject);

begin

Open1Click(Sender);

end;

procedure TForm1.ToolButton2Click(Sender: TObject);

begin

Saveas1Click(Sender);

end;

procedure TForm1.ToolButton3Click(Sender: TObject);

begin

Save1Click(Sender);

end;

procedure TForm1.ToolButton4Click(Sender: TObject);

begin

N2Click(Sender);

end;

procedure TForm1.ToolButton5Click(Sender: TObject);

begin

N3Click(Sender);

end;

procedure TForm1.N5Click(Sender: TObject);

begin

StringGrid1.RowCount:=n;

j:=StringGrid1.Row;

if n>1 then

begin

for i:= j-1 to n do

begin

a[i]:=a[i+1];

end;

n:=n-1;

end

else

begin

stringgrid1.cells[0,i+1]:=inttostr(i+1);

stringgrid1.cells[1,i+1]:=a[i].data;

stringgrid1.cells[2,i+1]:=a[i].familiya;

stringgrid1.cells[3,i+1]:=a[i].otdel;

stringgrid1.cells[4,i+1]:=IntToStr(a[i].kolvoStr);

stringgrid1.cells[5,i+1]:=IntToStr(a[i].kolvoCopy);

stringgrid1.cells[6,i+1]:=FloatToStr(a[i].price);

stringgrid1.cells[7,i+1]:=IntToStr(a[i].nadbavka);

stringgrid1.cells[8,i+1]:=IntToStr(a[i].itogo);

end;

end;

procedure TForm1.N4Click(Sender: TObject);

begin

form3.ShowModal;

end;

end.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]