unit Unit2;

interface

uses
  Windows, Messages, SysUtils,Strutils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, StdCtrls, AdvEdit, AdvEdBtn, DBPlannerDatePicker, DBCtrls,
  Mask, AdvMemo, DBAdvMemo, Grids, DBGrids, ExtCtrls, Spin, AdvSpin,
  Buttons, AdvPanel, RzTabs, RzButton, FormSize, RzPanel, RzPopups;

type
  TForm2 = class(TForm)
    OpenDialog1: TOpenDialog;
    OpenDialog2: TOpenDialog;
    Panel1: TPanel;
    DBEdit4: TDBEdit;
    DBEdit5: TDBEdit;
    AdvPanel6: TAdvPanel;
    RzPageControl1: TRzPageControl;
    TabSheet1: TRzTabSheet;
    TabSheet2: TRzTabSheet;
    TabSheet3: TRzTabSheet;
    TabSheet4: TRzTabSheet;
    DBEdit1: TDBEdit;
    AdvSpinEdit1: TAdvSpinEdit;
    DBPlannerDatePicker2: TDBPlannerDatePicker;
    DBComboBox2: TDBComboBox;
    DBEdit3: TDBEdit;
    SpeedButton3: TRzToolButton;
    ComboBox1: TComboBox;
    DBEdit2: TDBEdit;
    SpeedButton2: TRzToolButton;
    Label1: TLabel;
    DBAdvMemo1: TDBAdvMemo;
    RzToolButton1: TRzToolButton;
    FormSize1: TFormSize;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    DBPlannerDatePicker1: TDBPlannerDatePicker;
    Label12: TLabel;
    Label13: TLabel;
    DBComboBox1: TDBComboBox;
    DBEdit6: TDBEdit;
    RzToolButton2: TRzToolButton;
    Label9: TLabel;
    DBEdit7: TDBEdit;
    RzToolButton3: TRzToolButton;
    RzTimePicker1: TRzTimePicker;
    RzTimePicker2: TRzTimePicker;
    procedure RzPageControl1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure RzToolButton1Click(Sender: TObject);
    procedure AdvPanel6MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure RzPageControl1Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure AdvSpinEdit1Change(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure DBComboBox2Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure DBComboBox1Change(Sender: TObject);
    procedure RzToolButton2Click(Sender: TObject);
    procedure RzToolButton3Click(Sender: TObject);
    procedure RzTimePicker1SetTime(Sender: TObject);
    procedure RzTimePicker2SetTime(Sender: TObject);
    procedure TabSheet1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
     private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1, Unit4, Unit3;

{$R *.dfm}

procedure TForm2.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.ItemIndex=0 then DBEdit5.text:='0';
if ComboBox1.ItemIndex=1 then DBEdit5.text:='1';
if ComboBox1.ItemIndex=2 then DBEdit5.text:='2';
if ComboBox1.ItemIndex=3 then DBEdit5.text:='3';
if ComboBox1.ItemIndex=4 then DBEdit5.text:='4';
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form4.Show;
form3.ADOTable1.Active:=true;

end;

procedure TForm2.AdvSpinEdit1Change(Sender: TObject);
begin
if length(AdvSpinEdit1.Text)=4 then
AdvSpinEdit1.Text:='0'+AdvSpinEdit1.Text;
dbedit4.Text:=AdvSpinEdit1.Text;
end;

procedure TForm2.SpeedButton2Click(Sender: TObject);
begin
opendialog2.Execute;
DBEdit2.Text:=OpenDialog2.FileName;
end;

procedure TForm2.SpeedButton3Click(Sender: TObject);
begin
opendialog1.Execute;
if DBComboBox2.Text='Kill Program' then
DBEdit3.Text:=extractfilename(opendialog1.FileName)
else
DBEdit3.Text:=opendialog1.FileName;
end;

procedure TForm2.DBComboBox2Change(Sender: TObject);
begin
if dbComboBox2.ItemIndex=0 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=true;

end;

begin
if dbComboBox2.ItemIndex=1 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=false;

end;

begin
if dbComboBox2.ItemIndex=2 then
begin
dbedit3.Visible:=false;
SpeedButton3.Visible:=false;

end;

begin
if dbComboBox2.ItemIndex=3 then
begin
dbedit3.Visible:=false;
SpeedButton3.Visible:=false;

end;

begin
if dbComboBox2.ItemIndex=4 then
begin
dbedit3.Visible:=false;
SpeedButton3.Visible:=false;

end;

begin
if dbComboBox2.ItemIndex=5 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=true;
end;

begin
if dbComboBox2.ItemIndex=6 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=false;
end;
end;
end;
end;
end;
end;
end;
end;

procedure TForm2.FormShow(Sender: TObject);
begin
if dbedit4.text='' then else
begin
AdvSpinEdit1.text:=dbedit4.Text;
RzTimePicker1.time:=strtotime(dbedit4.Text);
RzTimePicker2.time:=strtotime(dbedit4.Text);
end;
dbedit3.Visible:=false;
SpeedButton3.Visible:=false;
DBComboBox1.Text:='Only Alarm';
end;

procedure TForm2.RzPageControl1Change(Sender: TObject);
begin
if dbedit1.text='' then  else
if DBPlannerDatePicker2.Text='' then else
if DBComboBox2.text='' then else
if dbedit4.Text='' then
 else
  begin
    if RzPageControl1.ActivePageIndex=3 then
    begin
      form1.ADOTable1.Edit;
      form1.ADOTable1.Post;
form1.ADOTable1.Active:=false;
form3.ADOTable1.Active:=false;
form1.ADOTable1.Active:=true;
form3.ADOTable1.Active:=true;
      form2.close;
    end;
  end;
end;

procedure TForm2.AdvPanel6MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
releasecapture;
perform(wm_syscommand,$f012,0);
end;

procedure TForm2.RzToolButton1Click(Sender: TObject);
begin
form2.Close;
end;

procedure TForm2.RzPageControl1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
releasecapture;
perform(wm_syscommand,$f012,0);
end;

procedure TForm2.DBComboBox1Change(Sender: TObject);
begin
if dbComboBox1.ItemIndex=0 then
begin
dbedit6.Visible:=true;
RzToolButton2.Visible:=true;
end;

begin
if dbComboBox1.ItemIndex=1 then
begin
dbedit6.Visible:=true;
RzToolButton2.Visible:=false;
end;

begin
if dbComboBox1.ItemIndex=2 then
begin
dbedit6.Visible:=false;
SpeedButton2.Visible:=false;
end;

begin
if dbComboBox1.ItemIndex=3 then
begin
dbedit6.Visible:=false;
SpeedButton2.Visible:=false;
end;

begin
if dbComboBox1.ItemIndex=4 then
begin
dbedit6.Visible:=false;
SpeedButton2.Visible:=false;
begin
if dbComboBox2.ItemIndex=5 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=true;
end;

begin
if dbComboBox2.ItemIndex=6 then
begin
dbedit3.Visible:=true;
SpeedButton3.Visible:=false;
end;
end;
end;
end;
end;
end;
end;
end;
end;

procedure TForm2.RzToolButton2Click(Sender: TObject);
begin
opendialog1.Execute;
if DBComboBox1.Text='Kill Program' then
DBEdit6.Text:=extractfilename(opendialog1.FileName)
else
DBEdit6.Text:=opendialog1.FileName;
end;

procedure TForm2.RzToolButton3Click(Sender: TObject);
begin
dbedit7.text:='Quick - '+datetostr(Date)+','+form3.edit3.text;

if DBPlannerDatePicker1.Text='' then
  DBPlannerDatePicker1.Text:=datetostr(date);

dbedit4.Text := AnsiLeftStr(timetostr(rztimepicker2.time) , 5);

form1.ADOTable1.Edit;
form1.ADOTable1.Post;
form1.ADOTable1.Active:=false;
form3.ADOTable1.Active:=false;
form1.ADOTable1.Active:=true;
form3.ADOTable1.Active:=true;
form2.close;  
end;

procedure TForm2.RzTimePicker1SetTime(Sender: TObject);
begin
dbedit4.Text := AnsiLeftStr(timetostr(rztimepicker1.time) , 5);
AdvSpinEdit1.Text:=dbedit4.Text;
end;

procedure TForm2.RzTimePicker2SetTime(Sender: TObject);
begin
dbedit4.Text := AnsiLeftStr(timetostr(rztimepicker2.time) , 5);
end;

procedure TForm2.TabSheet1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
releasecapture;
perform(wm_syscommand,$f012,0);
end;

end.
