Смекни!
smekni.com

Разработка информационно-справочной системы Аптека (стр. 3 из 4)

Writeln(f,'==== Отчет за ',curmonth-1,'/',curyear,'г ====');

Writeln(f);

Writeln(f,'Совершено ',num,' сделок на общую сумму ',rash,' рублей.');

Writeln(f,'Ожидаемая выручка от реализации ',doh-rash);

closefile(f);

end;

begin

If not PassForm.regexists then begin

ShowMessage('Ключи паролей не найдены и будут воссозданы');

PropForm.writereg('Продажа','1');

PropForm.writereg('Завоз','2');

PropForm.writereg('Администрирование','3');

end;

Mode:='Просмотр';

Rights;

DecodeDate(Date,curyear,curmonth,curday);

if curday=1 then GenerateReport;

end;

procedure TMainForm.SaleButtonClick(Sender: TObject);

begin

with SaleForm do begin

SpinEdit1.MaxValue:=TableTov.Fields[4].AsInteger;

SpinEdit1.Value:=TableTov.Fields[4].AsInteger;

ShowModal;

end;

end;

procedure TMainForm.RecieveButtonClick(Sender: TObject);

begin

RecieveForm.ShowModal;

end;

procedure TMainForm.ReportButtonClick(Sender: TObject);

begin

ReportForm.ShowModal;

end;

procedure TMainForm.PropButtonClick(Sender: TObject);

begin

PropForm.ShowModal;

end;

procedure TMainForm.SelectButtonClick(Sender: TObject);

begin

SelectForm.SortButton.Visible:=true;

SelectForm.SelectButton.Caption:='Выборка';

SelectForm.Caption:='Найти все';

SelectForm.Height:=260;

SelectForm.Panel1.Visible:=true;

CancelSelection:=false;

SelectForm.Show;

end;

procedure TMainForm.SaveButtonClick(Sender: TObject);

begin

If TableTov.State in [dsInsert,dsEdit] then TableTov.Post;

If TableNakl.State in [dsInsert,dsEdit] then TableNakl.Post;

If TablePost.State in [dsInsert,dsEdit] then TablePost.Post;

end;

procedure TMainForm.CancelSelectButtonClick(Sender: TObject);

begin

SelectForm.SortButton.Visible:=false;

SelectForm.Caption:='Отменить выборку';

SelectForm.SelectButton.Caption:='Отменить';

SelectForm.Height:=140;

SelectForm.Panel1.Visible:=false;

SelectForm.Show;

CancelSelection:=true;

end;

procedure TMainForm.FormDestroy(Sender: TObject);

begin

QueryTov.Active:=false;

QueryNakl.Active:=false;

QueryPost.Active:=false;

end;

end.

unit FindUnit;

interface

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

Dialogs, StdCtrls, ExtCtrls, DBCtrls;

type TSelectForm = class(TForm)

RadioGroup1: TRadioGroup;

SelectButton: TButton;

ExitButton: TButton;

Panel1: TPanel;

ComboBox1: TComboBox;

Label1: TLabel;

Label2: TLabel;

ComboBox2: TComboBox;

Label3: TLabel;

Edit1: TEdit;

SortButton: TButton;

procedure ExitClick(Sender: TObject);

procedure SelectButtonClick(Sender: TObject);

procedure SortClick(Sender: TObject);

procedure RadioGroup1Click(Sender: TObject);

procedure ComboBox1Change(Sender: TObject);

private { Private declarations }

public { Public declarations }

end;

var SelectForm: TSelectForm;

Selecttype:boolean;

CancelSelection:boolean;

implementation

uses MainUnit;

{$R *.dfm}

procedure TSelectForm.ExitClick(Sender: TObject);

begin

Close;

end;

procedure TSelectForm.SelectButtonClick(Sender: TObject);

begin

With MainForm do

case RadioGroup1.ItemIndex of

0: begin

QueryTov.Active:=false;

QueryTov.SQL.Clear;

If CancelSelection Then begin

QueryTov.SQL.Add('Select * From Tovar');

DataSourceTov.DataSet:=TableTov;

end

else begin

DataSourceTov.DataSet:=QueryTov;

QueryTov.SQL.Add('Select * From Tovar where '+ComboBox1.Text);

If SelectType then QueryTov.SQL.Add(ComboBox2.Text+Edit1.text)

else QueryTov.SQL.Add(' Like "'+Edit1.text+'"');

end;

QueryTov.Active:=true;

end;

1: begin

QueryNakl.Active:=false;

QueryNakl.SQL.Clear;

If CancelSelection Then begin

QueryNakl.SQL.Add('Select * From Nakladnie');

DataSourceNakl.DataSet:=TableNakl;

end

else begin

DataSourceNakl.DataSet:=QueryNakl;

QueryNakl.SQL.Add('Select * From Nakladnie where '+ComboBox1.Text);

If SelectType then

QueryNakl.SQL.Add(' '+ComboBox2.Text+' '+Edit1.text)

else QueryNakl.SQL.Add(' Like "'+Edit1.text+'"');

end;

QueryNakl.Active:=true;

end;

2: begin

QueryPost.Active:=false;

QueryPost.SQL.Clear;

If CancelSelection Then begin

QueryPost.SQL.Add('Select * From Postavschik');

DataSourcePost.DataSet:=TablePost;

end

else begin

DataSourcePost.DataSet:=QueryPost;

QueryPost.SQL.Add('Select * From Postavschik where '+ComboBox1.Text);

If SelectType then

QueryPost.SQL.Add(' '+ComboBox2.Text+' '+Edit1.text)

else QueryPost.SQL.Add(' Like "'+Edit1.text+'"');

end;

QueryPost.Active:=true;

end;

end;

Close;

end;

procedure TSelectForm.RadioGroup1Click(Sender: TObject);

begin

case RadioGroup1.ItemIndex of

0:begin ComboBox1.Items:=MainForm.TableTov.FieldList; end;

1:begin ComboBox1.Items:=MainForm.TableNakl.FieldList; end;

2:begin ComboBox1.Items:=MainForm.TablePost.FieldList;end;

end;

end;

procedure TSelectForm.ComboBox1Change(Sender: TObject);

begin

Combobox2.Items.Clear;

If (ComboBox1.Text='Price') or

(ComboBox1.Text='Col') or

(ComboBox1.Text='Recieved') or

(ComboBox1.Text='Sum')

then begin

Combobox2.Items.Add('=');

Combobox2.Items.Add('>');

Combobox2.Items.Add('<');

Combobox2.Items.Add('>=');

Combobox2.Items.Add('<=');

Combobox2.Items.Add('<>');

Selecttype:=true;

end

else If (ComboBox1.Text='TovarCode') or

(ComboBox1.Text='NaklNum') or

(ComboBox1.Text='PostCode')

then begin

Combobox2.Items.Add('=');

Combobox2.ItemIndex:=0;

Selecttype:=true;

end

else If (ComboBox1.Text='TovarName') or

(ComboBox1.Text='PostName')

then begin

Combobox2.Items.Add('ёютярфрхЄ');

Combobox2.ItemIndex:=0;

Selecttype:=false;

end;

end;

procedure TSelectForm.SortClick(Sender: TObject);

Var txt:string;

begin

txt:=ComboBox1.Text;

With MainForm do

case RadioGroup1.ItemIndex of

0:begin

QueryTov.Active:=false;

QueryTov.SQL.Clear;

DataSourceTov.DataSet:=QueryTov;

QueryTov.SQL.Add('Select * From Tovar where '+txt+'='+Txt+' order by '+txt);

QueryTov.Active:=true;

end;

1:begin

QueryNakl.Active:=false;

QueryNakl.SQL.Clear;

DataSourceNakl.DataSet:=QueryNakl;

QueryNakl.SQL.Add('Select * From Nakladnie where '+Txt+'='+txt+' order by '+Txt);

QueryNakl.Active:=true;

end;

2:begin

QueryPost.Active:=false;

QueryPost.SQL.Clear;

DataSourcePost.DataSet:=QueryPost;

QueryPost.SQL.Add('Select * From Postavschik where '+Txt+'='+Txt+' order by '+Txt);

QueryPost.Active:=true;

end;

end;

Close;

end;end.

unit PassUnit;

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Registry;

type TPassForm = class(TForm)

ComboBox1: TComboBox;

Label1: TLabel;

Label2: TLabel;

Edit1: TEdit;

PassButton: TButton;

CancelButton: TButton;

procedure ComboBoxChange(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure ChMode;

procedure PassButtonClick(Sender: TObject);

procedure CancelButtonClick(Sender: TObject);

function regexists:boolean;

private { Private declarations }

public { Public declarations }

end;

var PassForm: TPassForm;

Mode:string[20];

SalerPwd, RecieverPwd, AdminPwd:string[10];

implementation

uses mainunit;

{$R *.DFM}

Function TPassForm.regexists:boolean;

Var reg:tregistry;

begin

regexists:=true;

Reg:=TRegistry.Create;

Reg.RootKey:=HKEY_CURRENT_USER;

If REG.OpenKey('Software&bsol;OM',true) then begin

if REG.ValueExists('Продажа') then SalerPwd:=REG.ReadString('Продажа')

else regexists:=false;

if REG.ValueExists('Завоз') then RecieverPwd:=REG.ReadString('Завоз')

else regexists:=false;

if REG.ValueExists('Администрирование') then AdminPwd:=REG.ReadString('Администрирование')

else regexists:=false;

end

else ShowMessage('Ошибка работы с реестром');

REG.CloseKey;

Reg.Destroy;

end;

Procedure TPassForm.ChMode;

begin

If ComboBox1.Text='Просмотр' then begin

Label2.enabled:=false;

Edit1.enabled:=false;

Edit1.text:='';

end

else begin

Label2.enabled:=true;

edit1.enabled:=true;

end;

end;

procedure TPassForm.ComboBoxChange(Sender: TObject);

begin

ChMode;

end;

procedure TPassForm.FormCreate(Sender: TObject);

var Reg:TRegistry;

begin

ChMode;

end;

procedure TPassForm.PassButtonClick(Sender: TObject);

var modestr,pwd:shortstring;

begin

modestr:=AnsiUppercase(Combobox1.text);

pwd:=Edit1.text;

If (modestr='ПРОСМОТР') or

((modestr='АДМИНИСТРИРОВАНИЕ') and (pwd=AdminPwd)) or

((modestr='ПРОДАЖА') and (pwd=SalerPwd)) or

((modestr='ЗАВОЗ') and (pwd=RecieverPwd))

then Mode:=Combobox1.text

else ShowMessage('Не верно задан режим '+modestr+#13+'или неверно введен пароль для режима '+modestr);

Close;

end;

procedure TPassForm.CancelButtonClick(Sender: TObject);

begin

Close;

end;end.

unit PropUnit;

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, Registry;

type TPropForm = class(TForm)

ChPassButton: TButton;

ExitButton: TButton;

ComboBox1: TComboBox;

Label1: TLabel;

Label2: TLabel;

Edit1: TEdit;

Label3: TLabel;

Edit2: TEdit;

procedure ExitButtonClick(Sender: TObject);

procedure ChPassButtonClick(Sender: TObject);

Procedure writereg(name,value:string);

private { Private declarations }

public { Public declarations }

end;

var PropForm: TPropForm;

implementation

{$R *.DFM}

Procedure TPropForm.writereg(name,value:string);

var Reg:TRegistry;

begin

Reg:=Tregistry.Create;

Reg.Rootkey:=HKEY_CURRENT_USER;

Reg.OpenKey('Software&bsol;OM',true);

Reg.WriteString(name,value);

Reg.CloseKey;

Reg.Destroy;

end;

procedure TPropForm.ExitButtonClick(Sender: TObject);

begin

Close;

end;

procedure TPropForm.ChPassButtonClick(Sender: TObject);

begin

If Edit1.text<>Edit2.text then ShowMessage('Пароли не совппадают')

else if length(Edit1.text)>10 then Showmessage('Пароль должен быть не более 10 символов')

else writereg(ComboBox1.text,Edit1.text);

end;

end.

unit RecieveUnit;

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, DBCtrls, Spin, ExtCtrls, ComCtrls;

type TRecieveForm = class(TForm)

AddButton: TButton;

CancelButton: TButton;

DBLookupComboBox1: TDBLookupComboBox;

SpinEdit2: TSpinEdit;

SpinEdit3: TSpinEdit;

Label1: TLabel;

Label3: TLabel;

Label4: TLabel;

Label6: TLabel;

Bevel1: TBevel;

Bevel2: TBevel;

DateTimePicker1: TDateTimePicker;

Label7: TLabel;

DBLookupComboBox2: TDBLookupComboBox;

Label8: TLabel;

CheckBox1: TCheckBox;

Edit1: TEdit;

ComboBox1: TComboBox;

Label9: TLabel;

Label10: TLabel;

CheckBox2: TCheckBox;

Edit2: TEdit;

Edit3: TEdit;

Label11: TLabel;

Edit4: TEdit;

procedure CancelButtonClick(Sender: TObject);

procedure NewPostButtonClick(Sender: TObject);

procedure AddButtonClick(Sender: TObject);

procedure CheckBox1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure CheckBox2Click(Sender: TObject);

private { Private declarations }

public { Public declarations }

end;

var RecieveForm: TRecieveForm;

implementation

uses mainunit;

{$R *.DFM}

procedure TRecieveForm.CancelButtonClick(Sender: TObject);

begin

Close;

end;

procedure TRecieveForm.AddButtonClick(Sender: TObject);

begin

with MainForm do begin

If CheckBox1.checked then

begin

TableTov.Insert;

TableTov.FieldByName('TovarName').AsString:=Edit1.Text;

TableTov.FieldByName('EdIzm').AsString:=ComboBox1.Text;

TableTov.FieldByName('Price').AsFloat:=strtofloat(Edit4.Text);

TableTov.FieldByName('Col').AsInteger:=SpinEdit2.Value;

TableTov.Post;

end

//Увеличиваем количество в таблице "медикаменты"

else begin

TableTov.edit;

TableTov.FieldByName('Col').AsInteger:= TableTov.FieldByName('Col').AsInteger+SpinEdit2.Value;

TableTov.post;

end;

//Дополняем таблицу "Накладные"

TableNakl.Insert;

If not (CheckBox1.checked) then TableNakl.FieldByName('TovarCode').AsInteger:=strtoint(DBLookUpComboBox1.text)

else TableNakl.FieldByName('TovarCode').AsInteger:=TableTov.FieldByName('TovarCode').AsInteger;

TableNakl.FieldByName('Date').AsDateTime:=DateTimePicker1.Date;

TableNakl.FieldByName('Sum').AsInteger:=SpinEdit3.Value;

TableNakl.FieldByName('Recieved').AsInteger:=Spinedit2.Value;

If CheckBox2.checked then

begin

TablePost.Insert;

TablePost.FieldByName('PostName').AsString:=Edit2.text;

TablePost.FieldByName('PostPhone').AsInteger:=strtoint(Edit3.text);

TablePost.Post;

TableNakl.FieldByName('PostCode').AsInteger:=TablePost.FieldByName('PostCode').AsInteger;

end

else TableNakl.FieldByName('PostCode').AsInteger:=strtoint(DBLookUpComboBox2.Text);

TableNakl.Post;

end;

end;

procedure TRecieveForm.CheckBox1Click(Sender: TObject);

begin

DBLookupComboBox1.enabled:=not(DBLookupComboBox1.enabled);

edit1.enabled:=not(edit1.enabled);

ComboBox1.enabled:=not(ComboBox1.enabled);

Edit4.enabled:=not(Edit4.enabled);

end;

procedure TRecieveForm.FormCreate(Sender: TObject);

begin

Edit1.enabled:=false;

ComboBox1.enabled:=false;

Edit4.enabled:=false;

Edit2.enabled:=false;

Edit3.enabled:=false;

end;

procedure TRecieveForm.CheckBox2Click(Sender: TObject);

begin

DBLookupComboBox2.enabled:=not(DBLookupComboBox2.enabled);

Edit2.enabled:=not(Edit2.enabled);

Edit3.enabled:=not(Edit3.enabled);

end;

end.

unit reportUnit;

interface

uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls;

type TReportForm = class(TForm)

Memo1: TMemo;

Button1: TButton;

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private { Private declarations }

public { Public declarations }

end;

var ReportForm: TReportForm;

implementation

{$R *.DFM}

procedure TReportForm.Button1Click(Sender: TObject);

begin

Close;

end;

procedure TReportForm.FormCreate(Sender: TObject);

begin