Meu programa da pau Socorro......

19/05/2003

0

Por favor se alguem puder me ajudar nesse caso.

O sistema faz o seguinte ele pega todas datas daquele determinado periodo, joga para outra tabela, e depois na tabela onde ele jogou os dados ele soma por tipo de Categoria.
Mas o que esta acontecendo é que ele nao soma e trava e tem vez que ele apaga até da tabela principal

Se tiverem outra dica para alterar essa Unit por favor eu lhe agradeço.


unit UnitConsPeriodo;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, StdCtrls, Buttons, Mask, ExtCtrls;

type
TFormConsPeriodo = class(TForm)
Edit1: TEdit;
BtProcessar: TBitBtn;
BtSair: TBitBtn;
DataSource1: TDataSource;
TabelaBalanco: TTable;
DataSource2: TDataSource;
TabelaTempo: TTable;
Label2: TLabel;
Label3: TLabel;
GroupBox1: TGroupBox;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
Label4: TLabel;
Label5: TLabel;
Bevel1: TBevel;
Label8: TLabel;
TabelaBalancoCodigo: TAutoIncField;
TabelaBalancoData: TDateField;
TabelaBalancoValor: TCurrencyField;
TabelaBalancoTitulo: TStringField;
TabelaBalancoStatus: TStringField;
TabelaTempoCodigo: TAutoIncField;
TabelaTempoData: TDateField;
TabelaTempoValor: TCurrencyField;
TabelaTempoTitulo: TStringField;
TabelaTempoStatus: TStringField;
procedure BtProcessarClick(Sender: TObject);
procedure BtSairClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormConsPeriodo: TFormConsPeriodo;

implementation



{$R *.DFM}

procedure TFormConsPeriodo.BtProcessarClick(Sender: TObject);
var
Tot_Passa,Carro,PC,PE,PI:integer;
Assoc, Loca, Prop, Eventos, Rendas_Div, Alie_Im, Outra_Rec: currency;
Salario,Comissoes,Supri,Servicos,Manutencao,Mat_esportivo,Mat_Qui: currency;
Outra_Des,Mat_Const,Rendi_Div,Mat_cons, Mat_exp, Tari_banc, Pint_prop, Empr_Equi, Gas_eventos, Emprest, Outra_desp :currency;
CONVDATA: TDATETIME;
CONVDATA2: TDATETIME;
begin
begin
if maskedit1.text = ´ / / ´ then
begin
beep;
showmessage(´A Data de inicio está em branco´);
maskedit1.setfocus;
end
else
begin
if maskedit2.text = ´ / / ´ then
begin
beep;
showmessage(´A Data do Final está em branco´);
maskedit2.setfocus;
end
else
begin
if TabelaTempo.Active = TRUE then
begin
TabelaBalanco.FIRST;
TabelaTempo.close;
TabelaTempo.emptytable;
TabelaTempo.open;
CONVDATA:= STRTODATE(MASKEDIT1.TEXT);
CONVDATA2:= STRTODATE(MASKEDIT2.TEXT);
while not TabelaBalanco.eof do
begin
if (TabelaBalancoDATA.ASFLOAT >= CONVDATA) and (TabelaBalancodata.ASFLOAT <= convdata2)then
begin
TabelaTempo.edit;
TabelaTempo.append;
TabelaTempoData.asfloat:=TabelaBalancoData.asfloat;
TabelaTempoTitulo.value:=TabelaBalancoTitulo.value;
TabelaTempoValor.ascurrency:=TabelaBalancoValor.ascurrency;
//TabelaTempoStatus.value:=TabelaBalancoStatus.value;
TabelaTempo.post
end;
TabelaBalanco.next;
END;
if TabelaTempo.isempty then
begin
beep;
showmessage(´Sem Lançamento nesse período´);
maskedit1.setfocus;
end
else
begin
TabelaTempo.First;
Assoc:=0;
Loca:=0;
Prop:=0;
Eventos:=0;
Rendas_Div:=0;
Alie_Im:=0;
Outra_Rec:=0;
While Not TabelaTempo.eof do
begin
// RECEITAS
if TabelaTempoTitulo.Value = ´ASSOCIADOS / VISITANTES´ THEN
Assoc:= TabelaTempoValor.ascurrency + Assoc
else
if TabelaTempoTitulo.value = ´LOCAÇÃO S/ IMOVEL´ THEN
Loca:= TabelaTempoValor.ascurrency + Loca
else
if TabelaTempoTitulo.Value = ´PROPAGANDAS ESPAÇOS EXTERNO DO MURO´ THEN
Prop:= TabelaTempoValor.ascurrency + Prop
else
if TabelaTempoTitulo.Value = ´EVENTOS´ THEN
Eventos:= TabelaTempoValor.ascurrency + Eventos
else
if TabelaTempoTitulo.Value = ´RENDAS DIVERSAS´ THEN
Rendas_Div:= TabelaTempoValor.ascurrency + Rendas_Div
else
if TabelaTempoTitulo.Value = ´RENDIMENTOS DIVIDENDOS´ THEN
Rendi_Div:= TabelaTempoValor.ascurrency + Rendi_Div
else
if TabelaTempoTitulo.Value = ´ALIENAÇÃO IMOVEL´ THEN
Alie_Im:= TabelaTempoValor.ascurrency + Alie_Im
else
if TabelaTempoTitulo.Value = ´OUTRAS RECEITAS´ THEN
Outra_Rec:= TabelaTempoValor.ascurrency + Outra_Rec
// DESPESAS
else
if TabelaTempoTitulo.Value = ´SALARIO / ENCARGOS´ THEN
Salario:= TabelaTempoValor.ascurrency + Salario
else
if TabelaTempoTitulo.Value = ´COMISSOES S/ COBRANÇA´ THEN
Comissoes:= TabelaTempoValor.ascurrency + Comissoes
else
if TabelaTempoTitulo.Value = ´SUPRIMENTOS / FORNECIMENTOS EM GERAIS´ THEN
Supri:= TabelaTempoValor.ascurrency + Supri
else
if TabelaTempoTitulo.Value = ´SERVIÇOS ENERGIA TELECON IMPOSTOS TARIFAS ETC´ THEN
Servicos:= TabelaTempoValor.ascurrency + Servicos
else
if TabelaTempoTitulo.Value = ´MANUTENÇÃO / CONSERVAÇÃO´ THEN
Manutencao:= TabelaTempoValor.ascurrency + Manutencao
else
if TabelaTempoTitulo.Value = ´MATERIAL ESPORTIVO´ THEN
Mat_esportivo:= TabelaTempoValor.ascurrency + Mat_esportivo
else
if TabelaTempoTitulo.Value = ´MATERIAL QUIMICO´ THEN
Mat_Qui:= TabelaTempoValor.ascurrency + Mat_Qui
else
if TabelaTempoTitulo.Value = ´MATERIAL DE CONSTRUÇÃO / REFORMA´ THEN
Mat_Const:= TabelaTempoValor.ascurrency + Mat_Const
else
if TabelaTempoTitulo.Value = ´MATERIAL DE EXPEDIENTE´ THEN
Mat_Exp:= TabelaTempoValor.ascurrency + Mat_Exp
else
if TabelaTempoTitulo.Value = ´TARIFAS BANCARIAS´ THEN
Tari_Banc:= TabelaTempoValor.ascurrency + Tari_Banc
else
if TabelaTempoTitulo.Value = ´PINTURAS PROPAGANDAS DE MURO´ THEN
Pint_Prop:= TabelaTempoValor.ascurrency + Pint_Prop
else
if TabelaTempoTitulo.Value = ´EMPREENDIMENTOS / EQUIPAMANTOS´ THEN
Empr_Equi:= TabelaTempoValor.ascurrency + Empr_Equi
else
if TabelaTempoTitulo.Value = ´GASTOS EM EVENTOS´ THEN
Gas_Eventos:= TabelaTempoValor.ascurrency + Gas_Eventos
else
if TabelaTempoTitulo.Value = ´EMPRESTIMO A CURTO PRAZO´ THEN
Emprest:= TabelaTempoValor.ascurrency + Emprest
else
if TabelaTempoTitulo.Value = ´OUTRAS DESPESAS´ THEN
Outra_Des:= TabelaTempoValor.ascurrency + Outra_Des
else
TabelaTempo.Next;
end;
//ArrLivre:=(Caixa+diferenca);
//formConsPeriodoGride.label1.caption:=´Carro: ´+ edit1.text;
//formConsPeriodoGride.label2.caption:=´Periodo: ´ + maskedit1.Text + ´ A ´+ MASKEDIT2.TEXT;
//formConsPeriodoGride.label3.caption:=´Total de Passageiros Transportados =´ + currtostr(tot_passa);
//formConsPeriodoGride.label5.caption:=´Coletivo: ´ + currtostr(PC);
//formConsPeriodoGride.label6.caption:=´Escolar: ´ + currtostr(PE);
//formConsPeriodoGride.label7.caption:=´Idoso: ´ + currtostr(PI);
//formConsPeriodoGride.label8.caption:=´Total de Caixa, DH + Passes: ´+ FormatFloat(´R$ #,,,,0.00´, caixaGeral);
//formConsPeriodoGride.label9.caption:=´Total de Caixa em DH: ´+ FormatFloat(´R$ ,,,,0.00´, caixa);
//formConsPeriodoGride.label10.caption:=´Total de Perdas ou Ganho: ´+ FormatFloat(´R$ ,,,,0.00´, diferenca);
//formConsPeriodoGride.label11.caption:=´Total final recebido: ´+ FormatFloat(´R$ ,,,,0.00´, ArrLivre);
//formconsperiodogride.showmodal;
//close;
end;
end;
end;
end;
end;
end;


Marcelototini

Marcelototini

Responder

Posts

20/05/2003

M@rcelo

Amigo:
1- Tire a linha Tempo.edit; e deixe somente a do append;
2- seu programa ta travando pq vc so ta dando o next se nenhuma condicao for feita, ai o arquivo nao passa pro proximo registro.

MUDE:
if TabelaTempoTitulo.Value = ´OUTRAS DESPESAS´ THEN
Outra_Des:= TabelaTempoValor.ascurrency + Outra_Des
else
TabelaTempo.Next;
end;

PARA

if TabelaTempoTitulo.Value = ´OUTRAS DESPESAS´ THEN
Outra_Des:= TabelaTempoValor.ascurrency + Outra_Des; //
// OBSERVEO PONTO E VIRGULA NA LINHA DE CIMA;
TabelaTempo.Next;
end;



AI VAI PRO PROXIMO REGISTRO. ok


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar