unit U_Grupos;

interface

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

type
  Tfrm_grupo = class(TForm)
    DBNavigator1: TDBNavigator;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    DBGrid1: TDBGrid;
    Label1: TLabel;
    Label2: TLabel;
    rg: TRadioGroup;
    TBL_AUX_gRUPO: TIBTable;
    TBL_AUX_gRUPOGRU_CODIGO: TIntegerField;
    procedure rgClick(Sender: TObject);
    procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frm_grupo: Tfrm_grupo;

implementation

uses UDM_dados;

{$R *.dfm}

procedure Tfrm_grupo.rgClick(Sender: TObject);
begin
     case rg.ItemIndex of
     0: dm_dados.tbl_grup.IndexName:= 'IND_COD_GRUPO';
     1: dm_dados.tbl_grup.IndexName:= 'IND_NOME_GRUPO';
     end;

end;

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

end;

end.
