Скачиваний:
16
Добавлен:
01.05.2014
Размер:
73.22 Кб
Скачать

unit Unit1;

Interface

uses

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

Dialogs, ExtCtrls, ADODB, DB, cxStyles, cxCustomData, cxGraphics,

cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, cxGridLevel,

cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,

cxGridTableView, cxGridDBTableView, cxGrid, StdCtrls, Buttons, Mask,

DBCtrls, Menus, ComCtrls;

type

TForm1 = class(TForm)

PopupMenu1: TPopupMenu;

N1: TMenuItem;

PageControl1: TPageControl;

TabSheet1: TTabSheet;

Panel1: TPanel;

cxGrid1: TcxGrid;

cxGrid1DBTableView1: TcxGridDBTableView;

cxGrid1Level1: TcxGridLevel;

Panel2: TPanel;

cxGrid2: TcxGrid;

cxGrid2DBTableView1: TcxGridDBTableView;

cxGrid2DBTableView1IZD: TcxGridDBColumn;

cxGrid2Level1: TcxGridLevel;

Panel3: TPanel;

DBEdit1: TDBEdit;

BitBtn1: TBitBtn;

Button3: TButton;

TabSheet2: TTabSheet;

cxGrid3: TcxGrid;

cxGrid3DBTableView1: TcxGridDBTableView;

cxGrid3DBTableView1Familiya: TcxGridDBColumn;

cxGrid3DBTableView1Name: TcxGridDBColumn;

cxGrid3DBTableView1Otchestvo: TcxGridDBColumn;

cxGrid3Level1: TcxGridLevel;

cxGrid1DBTableView1N_izv: TcxGridDBColumn;

cxGrid1DBTableView1data: TcxGridDBColumn;

cxGrid1DBTableView1PDM: TcxGridDBColumn;

cxGrid1DBTableView1Pril: TcxGridDBColumn;

cxGrid1DBTableView1FAM: TcxGridDBColumn;

cxGrid1DBTableView1Primechanie: TcxGridDBColumn;

MainMenu1: TMainMenu;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

M1: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N10: TMenuItem;

TabSheet3: TTabSheet;

N6: TMenuItem;

Panel4: TPanel;

Panel6: TPanel;

RadioGroup1: TRadioGroup;

Panel5: TPanel;

RadioGroup2: TRadioGroup;

LabeledEdit1: TLabeledEdit;

Panel7: TPanel;

Label4: TLabel;

Label5: TLabel;

RadioGroup3: TRadioGroup;

DateTimePicker1: TDateTimePicker;

DateTimePicker2: TDateTimePicker;

Panel8: TPanel;

BitBtn2: TBitBtn;

DBEdit2: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

Label1: TLabel;

Label2: TLabel;

Label3: TLabel;

Panel9: TPanel;

Button1: TButton;

Button2: TButton;

Button4: TButton;

procedure BitBtn1Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure N1Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure N8Click(Sender: TObject);

procedure M1Click(Sender: TObject);

procedure BitBtn5Click(Sender: TObject);

procedure N6Click(Sender: TObject);

procedure BitBtn6Click(Sender: TObject);

procedure PageControl1Change(Sender: TObject);

procedure RadioGroup1Click(Sender: TObject);

procedure cxGrid1DBTableView1DblClick(Sender: TObject);

procedure cxGrid1DBTableView1Editing(Sender: TcxCustomGridTableView;

AItem: TcxCustomGridTableItem; var AAllow: Boolean);

procedure Button4Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

uses Unit2,Unit3, Unit4;

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

with DM do

if Izdeliya.State=dsBrowse then begin

Izdeliya.Append;

DBEdit1.SetFocus;

end;

end;

{procedure TForm1.FormShow(Sender: TObject);

begin

{DM:=TDM.Create(self);

DM.Izdeliya.Active:=true;

DM.J.Active:=true;

end;}

procedure TForm1.Button1Click(Sender: TObject);

begin

with DM do

if J.State=dsBrowse then begin

J.Append;

j.fieldbyname('sostav').AsInteger:=2;

j.fieldbyname('id_fam').AsInteger:=9;

j.fieldbyname('pdm').AsBoolean:=false;

j.fieldbyname('pril').AsBoolean:=false;

end;

end;

procedure TForm1.Button2Click(Sender: TObject);

begin

with DM do

if J.State in [dsEdit,dsInsert] then begin

J.Post;

end;

end;

procedure TForm1.N1Click(Sender: TObject);

begin

Add_str.Visible:=true;

end;

procedure TForm1.Button3Click(Sender: TObject);

begin

with DM do

if Izdeliya.State in [dsInsert,dsEdit] then

Izdeliya.Post;

{DM.Izdeliya.Post;}

DBEdit1.Clear;

end;

procedure TForm1.BitBtn2Click(Sender: TObject);

begin

with DM do

if Familiya.State=dsBrowse then

begin

Familiya.Append;

DBEdit2.SetFocus;

end;

end;

procedure TForm1.BitBtn3Click(Sender: TObject);

begin

DM.Familiya.Post;

DBEdit2.Clear;

DBEdit3.Clear;

DBEdit4.Clear;

end;

procedure TForm1.BitBtn4Click(Sender: TObject);

begin

with DM do

if Familiya.State=dsBrowse then

if Familiya.FieldByName('id_f').AsInteger<>9 then

if MessageDlg('Удалить запись?',

mtConfirmation,[mbYes,mbNo],0)=mrYes

then Familiya.Delete;

end;

procedure TForm1.N3Click(Sender: TObject);

begin

PageControl1.ActivePage:=TabSheet1;

end;

procedure TForm1.N4Click(Sender: TObject);

begin

PageControl1.ActivePage:=TabSheet2;

end;

procedure TForm1.N8Click(Sender: TObject);

begin

close;

end;

procedure TForm1.M1Click(Sender: TObject);

begin

if not m1.Checked then begin

Form4:=TForm4.Create(self);

Form4.Show;

Form4.MaskEdit2.SetFocus;

end

else begin

m1.Checked:=false;

Button3.Enabled:=false;

bitbtn1.Enabled:=false;

button1.Enabled:=false;

button2.Enabled:=false;

bitbtn2.Enabled:=false;

bitbtn3.Enabled:=false;

DBEdit1.Enabled:=false;

DBEdit3.Enabled:=false;

DBEdit4.Enabled:=false;

Button4.Enabled:=false;

end;

end;

procedure TForm1.BitBtn5Click(Sender: TObject);

begin

if DM.J.State in [dsInsert,dsEdit] then

DM.J.Cancel;

end;

procedure TForm1.N6Click(Sender: TObject);

begin

PageControl1.ActivePage:=TabSheet3;

end;

procedure TForm1.BitBtn6Click(Sender: TObject);

var

fstr:TFormatSettings;

begin

DM.J.SQL.Clear;

fSTR.DateSeparator:='/';

fstr.ShortDateFormat:='mm/dd/yyyy';

DM.J.SQL.Add('SELECT * FROM Jurnal WHERE ((Jurnal.data>=#'+datetostr(DateTimePicker1.date,fstr)+'#) And(Jurnal.data<=#'+datetostr(DateTimePicker2.date,fstr)+'#)');

DM.J.SQL.Add('and (id_izd=id_i))');

((jurnal.data>=#'+Edit1.Text+'#)and(jurnal.data<=#'+Edit2.Text+'#))');

DM.J.Open;

PageControl1.ActivePage:=TabSheet1;

end;

procedure TForm1.RadioGroup1Click(Sender: TObject);

var fstr:TFormatSettings;

begin

if RadioGroup2.ItemIndex=0 then begin

DM.J.SQL.Clear;

DM.J.SQL.Add('Select * From Jurnal inner join Familii on Jurnal.id_fam = Familii.id_f Where Familii.Familiya = "'+LabeledEdit1.Text+'"');

if RadioGroup1.ItemIndex=0 then

DM.J.SQL.Add('and (id_izd=:id_i)and(pdm=true)')

else

if RadioGroup1.ItemIndex=1 then

DM.J.SQL.Add('and (id_izd=:id_i)and(pdm=false)')

else

DM.J.SQL.Add('and (id_izd=:id_i)');

if RadioGroup3.ItemIndex=0 then begin

fSTR.DateSeparator:='/';

fstr.ShortDateFormat:='mm/dd/yyyy';

DM.J.SQL.Add('and (Jurnal.data>=#'+datetostr(DateTimePicker1.date,fstr)+'#) And(Jurnal.data<=#'+datetostr(DateTimePicker2.date,fstr)+'#)');

end;

DM.J.Open;

end

else begin

if RadioGroup1.ItemIndex=0 then begin

DM.J.SQL.Clear;

DM.J.SQL.Add('select * from jurnal where (id_izd=:id_i)and(pdm=true)');

if RadioGroup2.ItemIndex=0 then

DM.J.SQL.Add('and (id_izd=:id_i)and(pdm=true)');

if RadioGroup3.ItemIndex=0 then begin

fSTR.DateSeparator:='/';

fstr.ShortDateFormat:='mm/dd/yyyy';

DM.J.SQL.Add('and (Jurnal.data>=#'+datetostr(DateTimePicker1.date,fstr)+'#) And(Jurnal.data<=#'+datetostr(DateTimePicker2.date,fstr)+'#)');

end;

DM.J.Open;

end else

if RadioGroup1.ItemIndex=1 then begin

DM.J.SQL.Clear;

DM.J.SQL.Add('select * from jurnal where (id_izd=:id_i)and(pdm=false)');

if RadioGroup3.ItemIndex=0 then begin

fSTR.DateSeparator:='/';

fstr.ShortDateFormat:='mm/dd/yyyy';

DM.J.SQL.Add('and (Jurnal.data>=#'+datetostr(DateTimePicker1.date,fstr)+'#) And(Jurnal.data<=#'+datetostr(DateTimePicker2.date,fstr)+'#)');

end;

DM.J.Open;

end else

begin

DM.J.SQL.Clear;

DM.J.SQL.Add('select * from jurnal where id_izd=:id_i');

if RadioGroup3.ItemIndex=0 then begin

fSTR.DateSeparator:='/';

fstr.ShortDateFormat:='mm/dd/yyyy';

DM.J.SQL.Add('and (Jurnal.data>=#'+datetostr(DateTimePicker1.date,fstr)+'#) And(Jurnal.data<=#'+datetostr(DateTimePicker2.date,fstr)+'#)');

end;

DM.J.Open;

end;

end;

end;

procedure TForm1.PageControl1Change(Sender: TObject);

begin

if PageControl1.activepage=tabsheet1 then

showmessage('1111');

end;

procedure TForm1.cxGrid1DBTableView1DblClick(Sender: TObject);

begin

if M1.Checked then begin

cxGrid1DBTableView1N_izv.Options.Editing:=true;

cxGrid1DBTableView1data.Options.Editing:=true;

cxGrid1DBTableView1PDM.Options.Editing:=true;

cxGrid1DBTableView1Pril.Options.Editing:=true;

cxGrid1DBTableView1FAM.Options.Editing:=true;

cxGrid1DBTableView1Primechanie.Options.Editing:=true;

end;

end;

procedure TForm1.cxGrid1DBTableView1Editing(Sender: TcxCustomGridTableView;

AItem: TcxCustomGridTableItem; var AAllow: Boolean);

begin

cxGrid1DBTableView1N_izv.Options.Editing:=false;

cxGrid1DBTableView1data.Options.Editing:=false;

cxGrid1DBTableView1PDM.Options.Editing:=false;

cxGrid1DBTableView1Pril.Options.Editing:=false;

cxGrid1DBTableView1FAM.Options.Editing:=false;

cxGrid1DBTableView1Primechanie.Options.Editing:=false;

end;

procedure TForm1.Button4Click(Sender: TObject);

begin

DM.J.Cancel;

end;

end.

unit Unit2;