unit ubalcao;

interface

uses
  Windows, variants, Messages, clipbrd, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, Grids, DBGrids, ComCtrls, Db, DBTables, StdCtrls, DBCtrls, Mask,
  Buttons, ToolWin, ActnList, Menus;

type

THackDBGrid = class(TDBGrid);

  Tfbalcao = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    ScrollBox1: TScrollBox;
    Panel1: TPanel;
    ScrollBox2: TScrollBox;
    Panel21: TPanel;
    Panel11: TPanel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label6: TLabel;
    Label3: TLabel;
    EditQtd: TDBEdit;
    EditSubtotal: TDBEdit;
    EditPreco: TDBEdit;
    GroupBox2: TGroupBox;
    Label10: TLabel;
    Label11: TLabel;
    Label5: TLabel;
    EditTotal: TDBEdit;
    EditRecebido: TDBEdit;
    EditTroco: TDBEdit;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Label4: TLabel;
    DBText1: TDBText;
    DBEdit1: TDBEdit;
    GroupBox4: TGroupBox;
    SpeedButton1: TSpeedButton;
    Panel14: TPanel;
    DBGrid3: TDBGrid;
    Panel9: TPanel;
    Panel3: TPanel;
    dsitem: TDataSource;
    ActionList1: TActionList;
    Totalizar: TAction;
    preencher: TAction;
    Excluir: TAction;
    campos: TAction;
    novo: TAction;
    foco: TAction;
    estoque: TAction;
    formatar: TAction;
    fimageitem: TAction;
    conta: TAction;
    novoitem: TAction;
    Timer1: TTimer;
    Panel5: TPanel;
    Timer2: TTimer;
    StatusBar1: TStatusBar;
    DBText2: TDBText;
    DBGrid1: TDBGrid;
    Panel24: TPanel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    SpeedButton4: TSpeedButton;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    SpeedButton5: TSpeedButton;
    Panel23: TPanel;
    DBGrid2: TDBGrid;
    Label12: TLabel;
    Panel22: TPanel;
    imprimir: TAction;
    confirmar: TAction;
    btngravar: TSpeedButton;
    SpeedButton3: TSpeedButton;
    ajuda: TAction;
    deleteitem: TAction;
    ComboBox1: TComboBox;
    Label13: TLabel;
    Edit1: TEdit;
    Image1: TImage;
    Label14: TLabel;
    ComboBox2: TComboBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btngravarClick(Sender: TObject);
    procedure TotalizarExecute(Sender: TObject);
    procedure preencherExecute(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure DBRadioGroup1Exit(Sender: TObject);
    procedure ExcluirExecute(Sender: TObject);
    procedure camposExecute(Sender: TObject);
    procedure focoExecute(Sender: TObject);
    procedure novoExecute(Sender: TObject);
    procedure estoqueExecute(Sender: TObject);
    procedure formatarExecute(Sender: TObject);
    procedure EditRecebidoExit(Sender: TObject);
    procedure EditPrecoExit(Sender: TObject);
    procedure contaExecute(Sender: TObject);
    procedure DBEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure novoitemExecute(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure MaskEdit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure PageControl1Change(Sender: TObject);
    procedure MaskEdit2Change(Sender: TObject);
    procedure MaskEdit1Change(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure DBEdit1Exit(Sender: TObject);
    procedure EditQtdExit(Sender: TObject);
    procedure imprimirExecute(Sender: TObject);
    procedure confirmarExecute(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure ajudaExecute(Sender: TObject);
    procedure deleteitemExecute(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ComboBox2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
   procedure AppHint(Sender : TObject);
    { Private declarations }
  public
  BOK : boolean;
  St, tipo, CAIXA : String;
  it:integer;
    { Public declarations }
  end;

var
  fbalcao: Tfbalcao;

implementation

uses UnitDadoEmpresa, Extens, UnitMenu, ulistaproduto, UnitRelatorio, UNota, udm;




procedure tfbalcao.AppHint(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := Application.Hint;
end;

{$R *.DFM}

procedure Tfbalcao.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
	        Application.OnHint := nil;
end;

procedure Tfbalcao.btngravarClick(Sender: TObject);
begin
        confirmarexecute(self);
end;

procedure Tfbalcao.TotalizarExecute(Sender: TObject);
var
tot1, tot2, tot3, tot4 : real;
bookmark : tbookmarkstr;
begin


     fdm.tbbalcao.edit;
     fdm.tbbalcao['total'] := (fdm.tbbalcao.fieldbyname ('vrunit') as tfloatfield).Value * (fdm.tbbalcao.fieldbyname ('qtd') as tfloatfield).Value;

     bookmark := fdm.tbbalcao.Bookmark;

     try

      fdm.tbbalcao.DisableControls;
      tot1 := 0;
      tot2 := 0;
      tot3 := 0;
      tot4 := 0;

    try
    fdm.tbbalcao.First;

    while not fdm.tbbalcao.Eof do begin

    if fdm.tbbalcao['total'] <> null then
    tot1 := tot1 + (fdm.tbbalcao.fieldbyname ('total') as tfloatfield).Value;

    if fdm.tbbalcao['icm'] <> null then
    tot2 := tot2 + (fdm.tbbalcao.fieldbyname ('icm') as tfloatfield).Value;

    if fdm.tbbalcao['comissao'] <> null then
    tot3 := tot3 + (fdm.tbbalcao.fieldbyname ('comissao') as tfloatfield).Value;

    if fdm.tbbalcao['ipi'] <> null then
    tot4 := tot4 + (fdm.tbbalcao.fieldbyname ('ipi') as tfloatfield).Value;

    fdm.tbbalcao.next;
    end;
    finally

    fdm.tbbalcao.EnableControls;
    end;
    finally
    fdm.tbbalcao.Bookmark := bookmark;
    end;

    fdm.tbpedido.edit;

    fdm.tbpedido['total'] := tot1;
    fdm.tbpedido['vricm'] := tot1 / 100 * tot2;
    fdm.tbpedido['vrcomissao'] := tot1 / 100 * tot3;
    fdm.tbpedido['vripi'] := tot1 / 100 * tot4;
    fdm.tbpedido['vendedor'] := combobox1.Text;

    if editrecebido.text <>'' then
    fdm.tbpedido['troco'] := (fdm.tbpedido.fieldbyname ('recebido') as tfloatfield).Value - (fdm.tbpedido.fieldbyname ('total') as tfloatfield).Value;



end;

procedure Tfbalcao.preencherExecute(Sender: TObject);
var
prod, prod1 : string;

begin
      fdm.tbproduto.open;
       if fdm.tbproduto.Locate('codigo',fdm.tbbalcao['codigo'],[]) then begin

        if fdm.tbproduto['produto'] <> null then prod := fdm.tbproduto['produto'];
         if fdm.tbproduto['descricao'] <> null then prod := prod + ' ' + fdm.tbproduto['descricao'];

        fdm.tbbalcao.edit;
         fdm.tbbalcao['nome'] := prod;
          fdm.tbbalcao['vrunit'] := fdm.tbproduto['vrvenda'];
            fdm.tbbalcao['un'] := fdm.tbproduto['un'];
             fdm.tbbalcao['codigobarra'] := fdm.tbproduto['codigobarra'];
              fdm.tbbalcao['QTD'] := '1';

             if fdm.tbbalcao['nome']<> null then
              prod1 := fdm.tbbalcao['nome'];

              if fdm.tbproduto['vrvenda'] <> null then
               prod1 := prod1 + ' - R$ ' +  format('%n',[(fdm.tbbalcao.fieldbyname ('vrunit') as tfloatfield).Value]);


              panel21.caption := prod1 ;
               timer1.Enabled := false;
                timer2.Enabled := false;

           end else
         showmessage('Produto não foi cadastrado, ou campo código em branco, verificar!!!');

            fdm.tbproduto.close;
             panel22.Caption :='';

end;

procedure Tfbalcao.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if key=#13 then begin
  Key := #0;
       Perform(WM_nextdlgctl,0,0)
 end else if Key = #27 then
   Perform(WM_nextdlgctl,1,0);
end;

procedure Tfbalcao.DBRadioGroup1Exit(Sender: TObject);
begin

      fdm.tbbalcao.DisableControls;

    fdm.tbbalcao.First;

    while not fdm.tbbalcao.Eof do begin
    fdm.tbbalcao.edit;
    fdm.tbbalcao['operacao'] := fdm.tbpedido['operacao'];
    fdm.tbbalcao.post;
    fdm.tbbalcao.next;
    end;

    fdm.tbbalcao.EnableControls;


end;

procedure Tfbalcao.ExcluirExecute(Sender: TObject);
 var
 doc:string;

begin

        doc := fdm.tbpedido['pedido'];

        fdm.tbreceber.Filter:='docparcela = ''' + doc +'''';
         fdm.tbreceber.Filtered := true;

       fdm.tbreceber.Last;

       while fdm.tbreceber['docparcela'] <> null do begin
        fdm.tbreceber.delete;
         fdm.tbreceber.next;
           end;

        fdm.tbreceber.Filtered := false;
end;

procedure Tfbalcao.camposExecute(Sender: TObject);
begin
        fdm.tbreceber.insert;
        fdm.tbreceber['venc1'] := combobox2.Text;
        fdm.tbreceber['dataemissao'] := fdm.tbpedido['data'];
        fdm.tbreceber['docparcela'] := fdm.tbpedido['pedido'];
        fdm.tbreceber['fantasia'] :='BALCÃO';
        fdm.tbreceber['numeropedido'] := fdm.tbpedido['pedido'];
        fdm.tbreceber['valortitulo'] := fdm.tbpedido['total'];
        fdm.tbreceber['valordocumento'] := fdm.tbpedido['total'];
        fdm.tbreceber['VrDesconto'] := fdm.tbpedido['total'];
        fdm.tbreceber['extenso']:=Extens.Extenso(fdm.tbpedido['total']);
        fdm.tbreceber['vendedor'] := fdm.tbpedido['vendedor'];
        fdm.tbreceber['vrcomissao'] := fdm.tbpedido['vrcomissao'];
        fdm.tbreceber['tipoconta'] := combobox2.Text;
        fdm.tbreceber.post;

end;

procedure Tfbalcao.focoExecute(Sender: TObject);
begin
        it := it + 1;

        if it = 3 then it:=1;

        case it of

        1: dbedit1.setfocus;
        2: dbgrid3.setfocus;
        end;

end;

procedure Tfbalcao.novoExecute(Sender: TObject);
begin

        btnGravar.Enabled:=true;
       fdm.tbpedido.Refresh;

        with fdm.query1 do begin
         close;
          sql.clear;
           sql.add('select max(pedido) as codigo from tbpedido');
            open;
         end;

        fdm.tbpedido.insert;
        if fdm.query1['codigo'] <> null then
         fdm.tbpedido['pedido'] := fdm.query1['codigo'] + 1
        else
        fdm.tbpedido['pedido']:='1';
        fdm.tbpedido['operacao']:='P';
        fdm.tbpedido['data']:=DateTostr(now);
        fdm.tbpedido['fantasia']:='BALCAO';

        st := '';

          fdm.query1.close;

end;

procedure Tfbalcao.estoqueExecute(Sender: TObject);
var
tot, tot1: real;

begin

        with fdm.Query1 do begin
         close;
          sql.clear;
           sql.add ('select codigo, nome, sum(qtd)as entrada from tbentradaitem');
            sql.add (' where codigo = "'+ dbedit1.text + '" group by codigo, nome');
            open;
        end;

        with fdm.Query2 do begin
         close;
          sql.clear;
           sql.add ('select codigo, nome, sum(qtd) as saida from tbpedidoitem');
            sql.add (' where operacao="P" and codigo = "'+ dbedit1.text + '" group by codigo, nome');
            open;
        end;

        fdm.tbproduto.Open;


        if fdm.tbproduto.Locate('codigo',fdm.query1['codigo'],[]) then
        tot1:= fdm.tbproduto.FieldByName('minimo').asfloat
        else
        tot1 := 0;

        FDM.tbproduto.close;


        tot := (fdm.query1.fields[2].asfloat - fdm.query2.fields[2].asfloat);

        if fdm.query1['nome'] <> null then
            showmessage('ESTOQUE = ' + floattostr(tot) + ' ' + fdm.query1['nome']+#13+
            'ESTOQUE MÍNIMO = '+ floattostr(tot1))
        else
        showmessage('Estoque Vazio!!!');

             fdm.query1.Close;
              fdm.query2.Close;
end;

procedure Tfbalcao.formatarExecute(Sender: TObject);
begin

 (fdm.tbpedido.fieldbyname ('data') as tdatetimefield).editmask := '99/99/9999';
 (fdm.tbpedido.fieldbyname ('pedido') as tfloatfield).displayformat := '000000';
 (fdm.tbpedido.fieldbyname ('total') as tfloatfield).displayformat := '###,##0.00';
 (fdm.tbpedido.fieldbyname ('recebido') as tfloatfield).displayformat := '###,##0.00';
 (fdm.tbpedido.fieldbyname ('troco') as tfloatfield).displayformat := '###,##0.00';

 (fdm.tbbalcao.fieldbyname ('codigo') as tfloatfield).displayformat := '000000';
 (fdm.tbbalcao.fieldbyname ('vrunit') as tfloatfield).displayformat := '###,##0.00';
 (fdm.tbbalcao.fieldbyname ('total') as tfloatfield).displayformat := '###,##0.00';
 (fdm.tbbalcao.fieldbyname ('qtd') as tfloatfield).displayformat := '00';

end;

procedure Tfbalcao.EditRecebidoExit(Sender: TObject);
begin
        fdm.tbpedido.Edit;
            if editrecebido.text <>'' then
         fdm.tbpedido['troco'] := (fdm.tbpedido.fieldbyname ('recebido') as tfloatfield).Value - (fdm.tbpedido.fieldbyname ('total') as tfloatfield).Value;
end;

procedure Tfbalcao.EditPrecoExit(Sender: TObject);
begin
        totalizarexecute(self);
end;

procedure Tfbalcao.contaExecute(Sender: TObject);
begin
    if fdm.tbpedido['total']= null then begin
    showmessage('Não há valor para esta venda, verificar!!!');
    abort;
    end;


     fdm.tbreceber.open;

     if fdm.tbreceber.Locate ('docparcela',fdm.tbpedido['pedido'],[]) then
      excluirexecute(self);
       camposexecute(self);

      fdm.tbreceber.close;

end;

procedure Tfbalcao.DBEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

        if key = vk_F12 then begin
         timer1.Enabled := false;
          Application.CreateForm (Tflistaproduto, flistaproduto);
           flistaproduto.st :='balcao';
            flistaproduto.table1.open;
             flistaproduto.showmodal;
              end;

       if key = vk_F5 then
        estoqueexecute(self);

end;

procedure Tfbalcao.novoitemExecute(Sender: TObject);
begin

        fdm.tbbalcao.Insert;
       dbedit1.SetFocus;
      panel21.caption := '';
     timer1.Enabled := false; 

end;

procedure Tfbalcao.SpeedButton1Click(Sender: TObject);
begin
        novoitemexecute(self);
end;

procedure Tfbalcao.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin

        fdm.tbfatura.close;
        fdm.tbproduto.Close;

        fdm.tbpedido.Last;

         if dbedit1.Text <> '' then begin
         fdm.tbpedido.edit;
          fdm.tbpedido.post;
           fdm.tbbalcao.edit;
            fdm.tbbalcao.post;


              if edittotal.Text <> '0,00' then begin
              contaexecute(self);
              end else
              Showmessage('Não há total para esta venda, verificar.');

       end else

          fdm.tbpedido.delete;

end;

procedure Tfbalcao.FormActivate(Sender: TObject);
begin
        THackDBGrid(DBGrid3).FixedCols := 5;

        with fdm.Query1 do begin
         close;
          sql.clear;
           sql.add ('select apel from tbvendedor order by apel');
            open;
             end;

        combobox1.Items.Clear;

        fdm.Query1.First;

        while not fdm.Query1.Eof do begin

         if fdm.Query1['apel'] <> null then
         combobox1.Items.Add(fdm.Query1['apel']);

         fdm.Query1.Next;

        end;

        fdm.Query1.Close;

        if pagecontrol1.ActivePageIndex = 0 then
         combobox1.setfocus;


end;

procedure Tfbalcao.FormCreate(Sender: TObject);
begin
       Application.OnHint := AppHint;
       Timer1Timer(self);
       Timer2Timer(self);
end;

procedure Tfbalcao.Timer2Timer(Sender: TObject);
   var
   pt,prod:string;
begin

    fdm.tbproduto.open;

    fdm.tbproduto.next;

     if fdm.tbproduto.Eof then
      fdm.tbproduto.first;


      if fdm.tbproduto['imagem'] <> null then begin
       pt := fdm.tbproduto['imagem'] ;
        if fileexists (pt) then
        image1.Picture.LoadFromFile (pt);
         end else
          image1.Picture.LoadFromFile(extractfilepath(paramstr(0)) + '\imagem\imagem.wmf');


        if fdm.tbproduto['produto'] <> null then prod := fdm.tbproduto['produto'];
         if fdm.tbproduto['descricao'] <> null then prod := prod + ' ' + fdm.tbproduto['descricao'];
          if fdm.tbproduto['vrvenda'] <> null then prod := prod + ' - R$ ' +  format('%n',[(fdm.tbproduto.fieldbyname ('vrvenda') as tfloatfield).Value]);

          panel22.Caption := prod;

end;

procedure Tfbalcao.MaskEdit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

        if key = 13 then begin
        fdm.tbpedido.Filtered := false;
        if (maskedit1.text <>'  /  /    ') and (maskedit2.text <>'  /  /    ') then
        fdm.tbpedido.filter := 'data >=''' + maskedit1.text + ''' and data<=''' +  maskedit2.text + '''';
        fdm.tbpedido.filtered := true;
        end;
end;

procedure Tfbalcao.PageControl1Change(Sender: TObject);
begin

        fdm.tbpedido.Filtered := false;

        if PageControl1.ActivePageIndex = 0 then begin

              if edittotal.Text <> '0,00' then begin
              contaexecute(self);
              end else
              Showmessage('Não há total para esta venda, verificar.');


        fdm.tbpedido.Last;

        if fdm.tbbalcao['codigo']= null then begin
        Panel21.caption := ' - BALCÃO - CAIXA LIVRE ';
        timer1.Enabled := true;
        timer2.Enabled := true;
        end;

        end else begin

        maskedit1.SetFocus;
        timer1.Enabled := false;
        timer2.Enabled := false;
        fdm.tbpedido.Filtered := false;
        THackDBGrid(DBGrid2).FixedCols := 8;

        end;



end;

procedure Tfbalcao.MaskEdit2Change(Sender: TObject);
begin
       if maskedit2.Text = '  /  /    ' then
        maskedit2.Clear;
end;

procedure Tfbalcao.MaskEdit1Change(Sender: TObject);
begin
       if maskedit1.Text = '  /  /    ' then
        maskedit1.Clear;
end;

procedure Tfbalcao.DBGrid1DblClick(Sender: TObject);
Var
 vendaini, vendafin:String;
begin


     if InputQuery ('filtrar...', 'Entre com o número inicial da venda',vendaini ) then

      if InputQuery ('filtrar...', 'Entre com o número final da venda',vendafin ) then begin
       fdm.tbpedido.filter := 'pedido >= ''' + vendaini + ''' and pedido<= ''' + vendafin +'''' ;
        fdm.tbpedido.filtered := true;
         end;


end;

procedure Tfbalcao.SpeedButton4Click(Sender: TObject);
begin
        maskedit1.Clear;
        maskedit2.Clear;
        fdm.tbpedido.filtered := false;
end;

procedure Tfbalcao.SpeedButton5Click(Sender: TObject);
var
tot : real;
bookmark : tbookmarkstr;
begin

      bookmark :=  fdm.tbpedido.Bookmark;
      fdm.tbpedido.DisableControls;
      tot := 0;

    try
    fdm.tbpedido.First;

    while not fdm.tbpedido.Eof do begin

    tot := tot + (fdm.tbpedido.fieldbyname ('total') as tfloatfield).Value;
    fdm.tbpedido.next;
    end;
    finally

    fdm.tbpedido.EnableControls;

    end;

    fdm.tbpedido.Bookmark := bookmark;

    st := format('%n', [tot]);

    application.MessageBox(pchar('Total : R$ ' + st), 'Soma das vendas do período determinado',mb_ok + MB_ICONWARNING)



end;

procedure Tfbalcao.Timer1Timer(Sender: TObject);
var
texto:string;

begin

  Texto := panel21.Caption ;
  panel21.Caption := Copy(Texto,2,Length(Texto))+Texto[1];


end;

procedure Tfbalcao.DBEdit1Exit(Sender: TObject);
begin
         preencherexecute(self);
          totalizarexecute(self);

end;

procedure Tfbalcao.EditQtdExit(Sender: TObject);
begin
          totalizarexecute(self);
end;

procedure Tfbalcao.imprimirExecute(Sender: TObject);
var
bookmark : tbookmarkstr;

begin

///////////////////////////
      bookmark := fdm.tbpedido.Bookmark;

      fdm.tbpedido.Filter := 'pedido = ''' + floattostr(fdm.tbpedido['pedido']) + '''';
       fdm.tbpedido.Filtered := true;

        Application.CreateForm(Tfrpedido, frpedido);

  fmenu.logotipoExecute(self);
  if fileexists (extractfilepath(paramstr(0)) + '\imagem\dado.txt') then
   FrPedido.memo4.lines.loadfromfile(extractfilepath(paramstr(0)) + '\imagem\dado.txt');


          frpedido.quickvenda.Print;
           frpedido.Release;
            fdm.tbpedido.Filtered := false;

          fdm.tbpedido.Bookmark := bookmark;


end;

procedure Tfbalcao.confirmarExecute(Sender: TObject);
begin
      if edittotal.Text <> '0,00' then begin
        fdm.tbpedido.edit;
         fdm.tbpedido.post;
          fdm.tbbalcao.edit;
           fdm.tbbalcao.Post;


          if Application.MessageBox('Imprimir comprovante de venda? ',
          'Impressão', 4 + MB_ICONQUESTION)= idYes then
            imprimirexecute(self);

           contaexecute(self);
            novoexecute (self);
             Panel21.caption := ' - BALCÃO - CAIXA LIVRE ';
              timer1.Enabled := true;
               timer2.Enabled := true;
                dbedit1.SetFocus;

      end else

      Showmessage('Não há total para esta venda, verificar.');

end;

procedure Tfbalcao.SpeedButton3Click(Sender: TObject);
begin
        imprimirexecute(self);
end;

procedure Tfbalcao.ajudaExecute(Sender: TObject);
var
  Comp: Trichedit; // * variável Comp da classe TMemo
  texto : string;
begin
  Comp := Trichedit.Create (Self);  // * cria o componente Memo
  Comp.Parent := Self;    // * exibe o componente criado

  if fileexists (extractfilepath(paramstr(0)) + '\ajuda\ajudabalcao.txt') then
   comp.lines.loadfromfile (extractfilepath(paramstr(0)) + '\ajuda\ajudabalcao.txt');

  texto := comp.Text;
  comp.Destroy;

  Showmessage (texto);


end;

procedure Tfbalcao.deleteitemExecute(Sender: TObject);
begin

        if application.MessageBox('Apagar o ítem selecionado?','Excluir',4 + MB_ICONWARNING ) = mryes then begin
         fdm.tbbalcao.Delete;
          totalizarexecute(self);
           end;
end;

procedure Tfbalcao.ComboBox1Change(Sender: TObject);
begin
        fdm.tbvendedor.Open;

        if fdm.tbvendedor.Locate('apel', ComboBox1.Text, []) then
         edit1.Text := floattostr(fdm.tbvendedor['comissao']);

          fdm.tbvendedor.Close;


       fdm.tbbalcao.DisableControls;

       fdm.tbbalcao.First;

       while not fdm.tbbalcao.Eof do begin

        fdm.tbbalcao.edit;

        fdm.tbbalcao['comissao'] := strtofloat(edit1.Text) ;
        fdm.tbbalcao['vendedor'] := combobox1.Text;

      fdm.tbbalcao.Next;
      end;

      fdm.tbbalcao.EnableControls;

      totalizarexecute(self);




end;

procedure Tfbalcao.ComboBox2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
        if key = 13 then pagecontrol1.SetFocus;
end;

end.



