unit UnitDadoEmpresa;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Mask, DBCtrls, Db, DBTables, ExtDlgs, ExtCtrls, Spin,
  ActnList, Grids, DBGrids, ComCtrls;

type
  TFDadoEmpresa = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    SpinEdit1: TSpinEdit;
    SpinEdit2: TSpinEdit;
    Memo1: TMemo;
    Image1: TDBImage;
    Memo2: TMemo;
    Memo3: TMemo;
    Memo4: TMemo;
    open1: TOpenPictureDialog;
    Bevel2: TBevel;
    ActionList1: TActionList;
    gravar: TAction;
    Bevel1: TBevel;
    tbsenha: TTable;
    dssenha: TDataSource;
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Memo3KeyPress(Sender: TObject; var Key: Char);
    procedure gravarExecute(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure tbsenhaNewRecord(DataSet: TDataSet);
    procedure FormActivate(Sender: TObject);
    procedure PageControl1Change(Sender: TObject);
  private
    { Private declarations }
  public
  ST:string;

    { Public declarations }
  end;

var
  FDadoEmpresa: TFDadoEmpresa;

implementation

uses UnitMenu;

{$R *.DFM}

procedure TFDadoEmpresa.SpeedButton1Click(Sender: TObject);
begin
        open1.Execute;
        image1.Picture.LoadFromFile(open1.FileName);

end;

procedure TFDadoEmpresa.FormShow(Sender: TObject);
begin

  if fileexists (extractfilepath(paramstr(0)) + '\imagem\logo.bmp') then
  image1.Picture.loadfromfile(extractfilepath(paramstr(0)) + '\imagem\logo.bmp');

  if fileexists (extractfilepath(paramstr(0)) + '\imagem\dado.txt') then
   memo1.lines.loadfromfile (extractfilepath(paramstr(0)) + '\imagem\dado.txt');

  if fileexists (extractfilepath(paramstr(0)) + '\imagem\icm.txt') then
   memo2.lines.loadfromfile  (extractfilepath(paramstr(0)) + '\imagem\icm.txt');

  if fileexists (extractfilepath(paramstr(0)) + '\imagem\ipi.txt') then
   memo3.lines.loadfromfile  (extractfilepath(paramstr(0)) + '\imagem\ipi.txt');

  if fileexists (extractfilepath(paramstr(0)) + '\imagem\lembrete.txt') then
   memo4.lines.loadfromfile  (extractfilepath(paramstr(0)) + '\imagem\lembrete.txt');

  spinedit1.Text := memo2.Text;
  spinedit2.Text := memo3.Text;

end;

procedure TFDadoEmpresa.Memo3KeyPress(Sender: TObject; var Key: Char);
begin
        if not (key in ['0'..'9']) then abort;
end;

procedure TFDadoEmpresa.gravarExecute(Sender: TObject);
begin
  image1.Picture.SaveToFile (extractfilepath(paramstr(0)) + '\imagem\logo.bmp');
  memo1.Lines.SaveToFile(extractfilepath(paramstr(0)) + '\imagem\dado.txt');
  memo2.Lines.SaveToFile(extractfilepath(paramstr(0)) + '\imagem\icm.txt');
  memo3.Lines.SaveToFile(extractfilepath(paramstr(0)) + '\imagem\ipi.txt');
  memo4.Lines.SaveToFile(extractfilepath(paramstr(0)) + '\imagem\lembrete.txt');
  fmenu.label1.caption := memo4.text;
end;

procedure TFDadoEmpresa.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
        gravarexecute(self);
         if tbsenha.State in [dsedit] then
          tbsenha.Post; 
           tbsenha.Close;
end;

procedure TFDadoEmpresa.tbsenhaNewRecord(DataSet: TDataSet);
begin
        tbsenha['permissao'] := 'T';
end;

procedure TFDadoEmpresa.FormActivate(Sender: TObject);
begin
        pagecontrol1.ActivePageIndex:= 0 ;
end;

procedure TFDadoEmpresa.PageControl1Change(Sender: TObject);
//var
//st:string;
begin
{        if pagecontrol1.ActivePageIndex = 1 then
         if inputquery ('Acesso','Para acessar este recurso, digite a senha que está no CD:', st) then

          if uppercase(st) = 'XANIN' then
           tbsenha.Open

          else begin

         showmessage('Senha incorreta, consulte o gerente !!!');
         pagecontrol1.ActivePageIndex := 0;
         end;
}

end;

end.
