unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, ComCtrls, StdCtrls, Buttons, ExtCtrls, DBCtrls,
  Mask, OleCtnrs, Menus, jpeg, RpDefine, RpCon, RpConDS, RpRave, ShellApi,
  XPMan;

type
  TForm2 = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet3: TTabSheet;
    DBGrid2: TDBGrid;
    DBGrid1: TDBGrid;
    GroupBox1: TGroupBox;
    RadioGroup1: TRadioGroup;
    LabeledEdit1: TLabeledEdit;
    BitBtn1: TBitBtn;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    BitBtn3: TBitBtn;
    DBNavigator1: TDBNavigator;
    DBGrid3: TDBGrid;
    DBGrid4: TDBGrid;
    Label1: TLabel;
    BitBtn2: TBitBtn;
    GroupBox3: TGroupBox;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    Label2: TLabel;
    Label3: TLabel;
    RadioGroup2: TRadioGroup;
    RadioButton6: TRadioButton;
    RadioButton7: TRadioButton;
    RadioButton8: TRadioButton;
    RadioButton9: TRadioButton;
    CheckBox1: TCheckBox;
    Button6: TButton;
    GroupBox4: TGroupBox;
    LabeledEdit10: TLabeledEdit;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBEdit4: TDBEdit;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    DBEdit5: TDBEdit;
    DBEdit6: TDBEdit;
    DBEdit7: TDBEdit;
    DBEdit8: TDBEdit;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    BitBtn6: TBitBtn;
    BitBtn7: TBitBtn;
    BitBtn8: TBitBtn;
    BitBtn9: TBitBtn;
    DBNavigator2: TDBNavigator;
    TabSheet2: TTabSheet;
    DBGrid6: TDBGrid;
    DBNavigator3: TDBNavigator;
    MonthCalendar1: TMonthCalendar;
    DBGrid5: TDBGrid;
    BitBtn10: TBitBtn;
    BitBtn11: TBitBtn;
    DBGrid7: TDBGrid;
    DBGrid8: TDBGrid;
    BitBtn13: TBitBtn;
    MainMenu1: TMainMenu;
    N2: TMenuItem;
    N4: TMenuItem;
    N8: TMenuItem;
    N10: TMenuItem;
    N11: TMenuItem;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    RvDataSetConnection1: TRvDataSetConnection;
    RvDataSetConnection2: TRvDataSetConnection;
    RvDataSetConnection3: TRvDataSetConnection;
    RvDataSetConnection4: TRvDataSetConnection;
    Edit1: TEdit;
    Label14: TLabel;
    BitBtn14: TBitBtn;
    RvProject1: TRvProject;
    BitBtn16: TBitBtn;
    BitBtn17: TBitBtn;
    N3: TMenuItem;
    N12: TMenuItem;
    N1: TMenuItem;
    N9: TMenuItem;
    N13: TMenuItem;
    N21: TMenuItem;
    N31: TMenuItem;
    N41: TMenuItem;
    N51: TMenuItem;
    N61: TMenuItem;
    N71: TMenuItem;
    PopupMenu1: TPopupMenu;
    N14: TMenuItem;
    N16: TMenuItem;
    N17: TMenuItem;
    N18: TMenuItem;
    BitBtn12: TBitBtn;
    BitBtn15: TBitBtn;
    XPManifest1: TXPManifest;
    DBGrid9: TDBGrid;
    RvDataSetConnection5: TRvDataSetConnection;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure RadioButton6Click(Sender: TObject);
    procedure RadioButton7Click(Sender: TObject);
    procedure RadioButton8Click(Sender: TObject);
    procedure RadioButton9Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure BitBtn8Click(Sender: TObject);
    procedure BitBtn9Click(Sender: TObject);
    procedure BitBtn10Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn11Click(Sender: TObject);
    procedure BitBtn12Click(Sender: TObject);
    procedure BitBtn13Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure N10Click(Sender: TObject);
    procedure N11Click(Sender: TObject);
    procedure BitBtn14Click(Sender: TObject);
    procedure BitBtn15Click(Sender: TObject);
    procedure BitBtn16Click(Sender: TObject);
    procedure BitBtn17Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure N13Click(Sender: TObject);
    procedure N21Click(Sender: TObject);
    procedure N31Click(Sender: TObject);
    procedure N41Click(Sender: TObject);
    procedure N51Click(Sender: TObject);
    procedure N61Click(Sender: TObject);
    procedure N71Click(Sender: TObject);
    procedure N14Click(Sender: TObject);
    procedure N15Click(Sender: TObject);
    procedure N16Click(Sender: TObject);
    procedure N17Click(Sender: TObject);
    procedure N18Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


var
  Form2: TForm2;




implementation

uses Unit3, Unit1, Unit4, Unit5, Unit6, Unit7, Unit8, Unit9, Unit10;

{$R *.dfm}

procedure TForm2.BitBtn1Click(Sender: TObject);
begin
datamodule3.ADOQuery1.Close;
if form2.RadioButton1.checked then
datamodule3.adoquery1.sql[2]:='where Name='''+labelededit1.Text+'''';

if form2.RadioButton2.checked then
datamodule3.adoquery1.sql[2]:='where Lmane='''+labelededit1.Text+'''';

if form2.RadioButton3.checked then
datamodule3.adoquery1.sql[2]:='where Phone='''+labelededit1.Text+''' or Phone2='''+labelededit1.Text+'''' ;

datamodule3.ADOQuery1.Open;
end;

procedure TForm2.BitBtn2Click(Sender: TObject);
begin
datamodule3.ADOQuery1.Close;
datamodule3.adoquery1.sql[2]:=' ';
datamodule3.ADOQuery1.Open;
end;

procedure TForm2.BitBtn3Click(Sender: TObject);
begin
form1.Close;
end;

procedure TForm2.RadioButton6Click(Sender: TObject);
begin
 datamodule3.adoquery2.Close;
if CheckBox1.Checked then
datamodule3.adoquery2.sql[3]:='ORDER BY idCust DESC' else
datamodule3.adoquery2.sql[3]:= 'ORDER BY idCust ASC';
datamodule3.adoquery2.Open;
end;

procedure TForm2.RadioButton7Click(Sender: TObject);
begin
  datamodule3.adoquery2.Close;
if CheckBox1.Checked then
datamodule3.adoquery2.sql[3]:='ORDER BY firm DESC' else
datamodule3.adoquery2.sql[3]:= 'ORDER BY Firm ASC';
datamodule3.adoquery2.Open;
end;

procedure TForm2.RadioButton8Click(Sender: TObject);
begin
 datamodule3.adoquery2.Close;
if CheckBox1.Checked then
datamodule3.adoquery2.sql[3]:='ORDER BY cena DESC' else
datamodule3.adoquery2.sql[3]:= 'ORDER BY cena ASC';
datamodule3.adoquery2.Open;
end;

procedure TForm2.RadioButton9Click(Sender: TObject);
begin
 datamodule3.adoquery2.Close;
if CheckBox1.Checked then
datamodule3.adoquery2.sql[3]:='ORDER BY Date DESC' else
datamodule3.adoquery2.sql[3]:= 'ORDER BY Date ASC';
datamodule3.adoquery2.Open;
end;

procedure TForm2.Button6Click(Sender: TObject);
begin
form1.Close;
end;

procedure TForm2.BitBtn5Click(Sender: TObject);
begin
datamodule3.ADOQuery1.Close;
datamodule3.ADOTable5.Close;
datamodule3.ADOTable1.Close;
datamodule3.ADOTable1.Masterfields:='';
datamodule3.ADOTable5.MasterFields:='';
datamodule3.adoquery1.sql[2]:=' ';
datamodule3.ADOQuery1.Open;
datamodule3.ADOTable1.Open;
datamodule3.ADOTable5.Open;
end;

procedure TForm2.BitBtn6Click(Sender: TObject);
begin

datamodule3.ADOTable1.Masterfields:='Номер';
datamodule3.ADOTable1.MasterSource:=datamodule3.DataSource1;
datamodule3.ADOTable5.MasterFields:='Номер';
datamodule3.ADOTable5.MasterSource:=datamodule3.datasource1;
end;

procedure TForm2.BitBtn7Click(Sender: TObject);
begin
if labelededit10.Text='379' then
begin

groupbox4.Visible:=true;
bitbtn8.Visible:=true;
bitbtn9.Visible:=true;
bitbtn11.Visible:=true;
labelededit10.Visible:=false;
bitbtn7.Visible:=false;


end   else
showmessage('Не правильный пароль! Повторите попытку!') ;
end;

procedure TForm2.BitBtn8Click(Sender: TObject);
begin
form4.GroupBox1.Visible:=false;
 form4.GroupBox2.Visible:=true;
form4.showmodal;
end;

procedure TForm2.BitBtn9Click(Sender: TObject);
begin
 form4.GroupBox1.Visible:=true;
 form4.GroupBox2.Visible:=false;
 form4.showmodal;
 
end;

procedure TForm2.BitBtn10Click(Sender: TObject);
begin




  datamodule3.adoquery5.Close;
  datamodule3.DataSource5.DataSet:=datamodule3.ADOQuery5;
  datamodule3.adoquery5.sql.add('insert INTO [orderAll](idcust,Firm,number,description,kol,cena)');
  datamodule3.adoquery5.sql.add( 'SELECT idcust,Firm,number,description,kol,cena' )    ;
  datamodule3.adoquery5.sql.add( 'from [orderNow] ' )   ;
  datamodule3.ADOQuery5.ExecSQL;


datamodule3.adoquery5.Close;
datamodule3.adoquery5.sql[0]:= 'delete from [orderNow] '  ;
datamodule3.adoquery5.sql[1]:= '' ;
datamodule3.adoquery5.sql[2]:= '' ;
datamodule3.adoquery5.ExecSQL;

datamodule3.adoquery5.SQL.Clear;


   datamodule3.adotable2.Close;
  datamodule3.DataSource5.DataSet:=datamodule3.ADOtable2;
  datamodule3.ADOtable2.open;

datamodule3.ADOQuery7.Close;
datamodule3.ADOQuery7.open;
datamodule3.ADOQuery2.Close;
datamodule3.ADOQuery2.open;
end;

procedure TForm2.BitBtn4Click(Sender: TObject);
begin
form2.DBNavigator1.BtnClick(nbrefresh);
datamodule3.ADOQuery1.Close;
datamodule3.ADOQuery1.open;
datamodule3.ADOTable5.Close;
datamodule3.ADOTable5.open;
datamodule3.ADOTable3.Close;
datamodule3.ADOTable3.open;
end;

procedure TForm2.BitBtn11Click(Sender: TObject);
begin

form5.showmodal;
form5.Height:=211;
form5.DBGrid1.Visible:=false;
form5.DBGrid2.Visible:=false;
form5.DBNavigator1.Visible:=false;
form5.DBNavigator2.Visible:=false;
form5.DBText1.Visible:=false;
form5.Label1.Visible:=false;
form5.BitBtn3.Visible:=false;
form5.GroupBox1.Visible:=true;
form5.BitBtn4.Visible:=false;
end;

procedure TForm2.BitBtn12Click(Sender: TObject);
begin
form2.DBNavigator3.BtnClick(nbpost);
datamodule3.ADOQuery7.Close;
datamodule3.ADOQuery7.open;
end;

procedure TForm2.BitBtn13Click(Sender: TObject);
begin
form6.showmodal;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form1.Close;
end;

procedure TForm2.N10Click(Sender: TObject);
begin
form7.Label5.Visible:=false;
form7.Label6.Visible:=false;
form7.Label7.Visible:=false;
form7.Label1.Visible:=true;
form7.Label2.Visible:=true;
form7.Label3.Visible:=true;
form7.Label4.Visible:=true;
form7.Caption:='Справка';
form7.showmodal;


end;

procedure TForm2.N11Click(Sender: TObject);
begin
form7.Caption:='Автор';
form7.Label5.Visible:=true;
form7.Label6.Visible:=true;
form7.Label7.Visible:=true;
form7.Label1.Visible:=false;
form7.Label2.Visible:=false;
form7.Label3.Visible:=false;
form7.Label4.Visible:=false;
form7.showmodal;

end;

procedure TForm2.BitBtn14Click(Sender: TObject);
begin
DataModule3.ADOTable2.Close;
DataModule3.ADOTable2.open;
if MessageDlg('Желаете проверить данные экспортируемые в наряд-заказ!?',mtConfirmation, [mbYes,mbNo],0)= mrYes  then
begin
form10.showmodal;
end else
begin
datamodule3.ADOQuery7.Close;
datamodule3.ADOQuery7.open;
RvProject1.Open;
RvProject1.SetParam('opl', form2.Edit1.Text);
RvProject1.Close;
RvProject1.Execute;
end;
end;




procedure TForm2.BitBtn15Click(Sender: TObject);
begin
if MessageDlg('Желаете удалить все записи таблицы текущих заказов?',mtConfirmation, [mbYes,mbNo],0)= mrYes  then
begin
datamodule3.ADOQuery9.execsql;
datamodule3.ADOTable2.Close;
datamodule3.ADOTable2.Open;
datamodule3.ADOQuery7.Close;
datamodule3.ADOQuery7.open;
end 


end;

procedure TForm2.BitBtn16Click(Sender: TObject);
begin
datamodule3.adoquery2.close;
datamodule3.adoquery2.sql[2]:=' ';
datamodule3.adoquery2.open;
datamodule3.adoquery2.Close;
DataModule3.ADOquery2.Parameters.AddParameter.Name:='D1';
DataModule3.ADOquery2.Parameters.AddParameter.Name:='D2';
DataModule3.ADOquery2.Parameters.ParamByName('D1').Value:=datetostr(form2.datetimepicker1.date);
DataModule3.ADOquery2.Parameters.ParamByName('D2').Value:=datetostr(form2.datetimepicker2.date);
datamodule3.adoquery2.sql[2]:='where [Date] between :D1 and :D2';
datamodule3.adoquery2.open;

datamodule3.adoquery6.close;
datamodule3.adoquery6.sql[2]:=' ';
datamodule3.adoquery6.open;
datamodule3.adoquery6.close;
DataModule3.ADOquery6.Parameters.AddParameter.Name:='D1';
DataModule3.ADOquery6.Parameters.AddParameter.Name:='D2';
DataModule3.ADOquery6.Parameters.ParamByName('D1').Value:=datetostr(form2.datetimepicker1.date);
DataModule3.ADOquery6.Parameters.ParamByName('D2').Value:=datetostr(form2.datetimepicker2.date);
datamodule3.adoquery6.sql[2]:='where [Date] between :D1 and :D2';
datamodule3.adoquery6.open;

end;

procedure TForm2.BitBtn17Click(Sender: TObject);
begin
datamodule3.adoquery2.Close;
datamodule3.adoquery2.sql[2]:=' ';
datamodule3.adoquery2.Open;

datamodule3.adoquery6.Close;
datamodule3.adoquery6.sql[2]:=' ';
datamodule3.adoquery6.Open;
end;

procedure TForm2.N8Click(Sender: TObject);
begin
form8.ShowModal;
end;

procedure TForm2.CheckBox1Click(Sender: TObject);
begin
form2.RadioButton6.Checked:=false;
form2.RadioButton7.Checked:=false;
form2.RadioButton8.Checked:=false;
form2.RadioButton9.Checked:=false;
end;

procedure TForm2.N3Click(Sender: TObject);
begin
form9.Show;
end;

procedure TForm2.N9Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\snake\Project1.exe', nil, nil, SW_SHOW);

end;

procedure TForm2.N1Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\go_quads\DODGE1\delph\xwxwc.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N13Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports1.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N21Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports2.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N31Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports3.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N41Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports4.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N51Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports5.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N61Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports6.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N71Click(Sender: TObject);
begin
shellexecute(Handle, 'open', 'C:\InterCarDB\Intercar\GAMES\yetisports\yetisports7.exe', nil, nil, SW_SHOWNORMAL);

end;

procedure TForm2.N14Click(Sender: TObject);
begin
form8.ShowModal;
end;

procedure TForm2.N15Click(Sender: TObject);
begin
form1.show;
end;

procedure TForm2.N16Click(Sender: TObject);
begin
form9.show;
end;

procedure TForm2.N17Click(Sender: TObject);
begin
form6.showmodal;
end;

procedure TForm2.N18Click(Sender: TObject);
begin
form1.Close;
end;

end.


