unit U_Membros;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, Mask, DBCtrls, ExtCtrls, DB, ExtDlgs,
  IBCustomDataSet, IBTable;

type
  TfrmMembros = class(TForm)
    DBNavigator1: TDBNavigator;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBEdit3: TDBEdit;
    DBGrid1: TDBGrid;
    DBEdit4: TDBEdit;
    Label4: TLabel;
    DBEdit5: TDBEdit;
    Label5: TLabel;
    DBEdit6: TDBEdit;
    Label6: TLabel;
    DBEdit7: TDBEdit;
    Label7: TLabel;
    DBEdit8: TDBEdit;
    Label8: TLabel;
    DBEdit9: TDBEdit;
    Label9: TLabel;
    DBEdit10: TDBEdit;
    Label10: TLabel;
    DBEdit12: TDBEdit;
    Label12: TLabel;
    DBEdit13: TDBEdit;
    Label13: TLabel;
    DBEdit14: TDBEdit;
    Label14: TLabel;
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Timer1: TTimer;
    Button1: TButton;
    DBEdit15: TDBEdit;
    foto: TImage;
    Label15: TLabel;
    abreFoto: TOpenPictureDialog;
    Button2: TButton;
    DBLookupComboBox2: TDBLookupComboBox;
    DBLookupComboBox3: TDBLookupComboBox;
    DBLookupComboBox4: TDBLookupComboBox;
    DBEdit11: TDBEdit;
    Label11: TLabel;
    rg: TRadioGroup;
    TBL_AUX_gRUPO: TIBTable;
    TBL_AUX_gRUPOMEM_CODIGO: TIntegerField;
    procedure Edit1Change(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
    procedure FormActivate(Sender: TObject);
    procedure rgClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMembros: TfrmMembros;

implementation

uses UDM_dados, U_con_Membros;


{$R *.dfm}

procedure TfrmMembros.Edit1Change(Sender: TObject);
begin
dm_dados.tlb_Membros.Locate('mem_nome' , Edit1.Text, [loPartialKey, loCaseInsensitive]);
end;

procedure TfrmMembros.Timer1Timer(Sender: TObject);
begin
{    DBNavigator1.BtnClick(nbNext);}
end;

procedure TfrmMembros.Button1Click(Sender: TObject);
begin
frmCons_Membros.Show;
end;

procedure TfrmMembros.Button2Click(Sender: TObject);
begin
     if abreFoto.Execute then
     begin
     foto.Picture.LoadFromFile(abreFoto.FileName);
     dm_dados.tlb_Membros.Edit;
     dm_dados.tlb_MembrosMEM_FOTO.Value:=abreFoto.FileName ;
     end;
end;

procedure TfrmMembros.DBNavigator1Click(Sender: TObject;
  Button: TNavigateBtn);
var ultcod:Integer;
begin
      if dm_dados.dsMembros.State in [dsInsert] then
      begin
         TBL_AUX_gRUPO.Open ;
         TBL_AUX_gRUPO.Last ;
         ultcod:=TBL_AUX_gRUPOMEM_CODIGO.Value + 1;
         dm_dados.tlb_MembrosMEM_CODIGO.Value :=ultcod ;
         TBL_AUX_gRUPO.close ;
      end;



     foto.Picture.LoadFromFile(dm_dados.tlb_MembrosMEM_FOTO.Value);
     if (dm_dados.tlb_MembrosMEM_FOTO.Value = '') then
     foto.Picture.LoadFromFile ('C:\Quadrangular\Imagem\Vazio.bmp');
end;

procedure TfrmMembros.FormActivate(Sender: TObject);
begin
     foto.Picture.LoadFromFile(dm_dados.tlb_MembrosMEM_FOTO.Value);
     if (dm_dados.tlb_MembrosMEM_FOTO.Value = '') then
     foto.Picture.LoadFromFile ('C:\Quadrangular\Imagem\Vazio.bmp');

end;

procedure TfrmMembros.rgClick(Sender: TObject);
begin
  case rg.ItemIndex of
  0:dm_dados.tlb_Membros.IndexName :='IND_COD_MEM';
  1:dm_dados.tlb_Membros.IndexName :='IND_NOME_MEM';
  end;
end;

end.
