|
mobidik (статус: Посетитель), 16 мая 2011, 11:36 [#3]:
dbs.Close;
query.close;
query.SQL.Text:= 'SELECT sum(doc_summ) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between :d1
and :d2 and card_number='''+Edit1.Text+''' )';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=DateTimePicker1.Date;
query.Parameters.ParamByName('d2').Value:=DateTimePicker2.Date;
query.Open;
StringGrid1.Cells[1,1]:=CurrToStr(query.Fields[0].AsCurrency);
StringGrid1.Cells[1,0]:=Format('Ïåðèîä àêöèè %s -
%s',[DateToStr(DateTimePicker1.Date),DateToStr(DateTimePicker2.Date)]);
query.Close;
query.SQL.Text:= 'SELECT sum(doc_summ) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between :d1
and :d2 and card_number='''+Edit1.Text+''') ';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(IncMonth(DateTimePicker1.Date,-1),-1);
query.Parameters.ParamByName('d2').Value:=IncYear(IncMonth(DateTimePicker2.Date,-1),-1);
query.Open;
//StringGrid1.Cells[1,1]:=query.Fields[0].AsString;
StringGrid1.Cells[2,1]:=CurrToStr(query.Fields[0].AsCurrency);
StringGrid1.Cells[2,0]:=Format('Ïðåäûäóùèé
ïåðèîä %s -
%s',[DateToStr(IncYear(IncMonth(DateTimePicker1.Date,-1),-1)),DateToStr(IncYear(IncMonth(DateTimePicker2.Date,-1),-1))]);
query.Close;
query.SQL.Text:= 'SELECT sum(doc_summ) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between :d1
and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(DateTimePicker1.Date,-1);
query.Parameters.ParamByName('d2').Value:=IncYear(DateTimePicker2.Date,-1);
query.Open;
StringGrid1.Cells[4,1]:=CurrToStr(query.Fields[0].AsCurrency);
StringGrid1.Cells[4,0]:=Format('Àíàëîãè÷íûé
ïåðèîä ïðîøëîãî ãîäà %s -
%s',[DateToStr(IncYear(DateTimePicker1.Date,-1)),DateToStr(IncYear(DateTimePicker2.Date,-1))]);
s:= StrToCurr(StringGrid1.Cells[1,1]);
a:= StrToCurr(StringGrid1.Cells[2,1]);
if StrToInt(StringGrid1.Cells[1,1])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[2,1])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[3,1]:= CurrToStr(b)+'%';
s:= StrToCurr(StringGrid1.Cells[1,1]);
a:= StrToCurr(StringGrid1.Cells[4,1]);
if StrToInt(StringGrid1.Cells[1,1])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[4,1])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[5,1]:= CurrToStr(b)+'%';
//Íà÷àëî íîâîé ñòðîêè
×èñëî ïîêóïîê
query.Close;
query.SQL.Text:= 'SELECT distinct count(doc_number) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date
between :d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=DateTimePicker1.Date;
query.Parameters.ParamByName('d2').Value:=DateTimePicker2.Date;
query.Open;
StringGrid1.Cells[1,2]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT distinct count(doc_number) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date
between :d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(IncMonth(DateTimePicker1.Date,-1),-1);
query.Parameters.ParamByName('d2').Value:=IncYear(IncMonth(DateTimePicker2.Date,-1),-1);
query.Open;
StringGrid1.Cells[2,2]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT distinct count(doc_number) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date
between :d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(DateTimePicker1.Date,-1);
query.Parameters.ParamByName('d2').Value:=IncYear(DateTimePicker2.Date,-1);
query.Open;
StringGrid1.Cells[4,2]:=query.Fields[0].AsString;
s:= StrToCurr(StringGrid1.Cells[1,2]);
a:= StrToCurr(StringGrid1.Cells[2,2]);
if StrToInt(StringGrid1.Cells[1,2])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[2,2])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[3,2]:= CurrToStr(b)+'%';
s:= StrToCurr(StringGrid1.Cells[1,2]);
a:= StrToCurr(StringGrid1.Cells[4,2]);
if StrToInt(StringGrid1.Cells[1,2])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[4,2])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[5,2]:= CurrToStr(b)+'%';
//Íà÷àëî íîâîé ñòðîêè
Âûäàíî êàðò
query.Close;
query.SQL.Text:= 'SELECT distinct count(active) FROM card WHERE (date_activated between :d1 and :d2 and
card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=DateTimePicker1.Date;
query.Parameters.ParamByName('d2').Value:=DateTimePicker2.Date;
query.Open;
StringGrid1.Cells[1,3]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT distinct count(active) FROM card WHERE (date_activated between :d1 and :d2 and
card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(IncMonth(DateTimePicker1.Date,-1),-1);
query.Parameters.ParamByName('d2').Value:=IncYear(IncMonth(DateTimePicker2.Date,-1),-1);
query.Open;
StringGrid1.Cells[2,3]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT distinct count(active) FROM card WHERE (date_activated between :d1 and :d2 and
card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(DateTimePicker1.Date,-1);
query.Parameters.ParamByName('d2').Value:=IncYear(DateTimePicker2.Date,-1);
query.Open;
StringGrid1.Cells[4,3]:=query.Fields[0].AsString;
s:= StrToCurr(StringGrid1.Cells[1,3]);
a:= StrToCurr(StringGrid1.Cells[2,3]);
if StrToInt(StringGrid1.Cells[1,3])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[2,3])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[3,3]:= CurrToStr(b)+'%';
s:= StrToCurr(StringGrid1.Cells[1,3]);
a:= StrToCurr(StringGrid1.Cells[4,3]);
if StrToInt(StringGrid1.Cells[1,3])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
if StrToInt(StringGrid1.Cells[4,3])= 0 then
begin
b:= 0;
end
else
begin
b:= s/a-1;
end;
StringGrid1.Cells[5,3]:= CurrToStr(b)+'%';
//Íà÷àëî íîâîé ñòðîêè
Ñðåäíèé ÷åê, ðóá
query.Close;
query.SQL.Text:= 'SELECT sum(doc_summ/2) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between
:d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=DateTimePicker1.Date;
query.Parameters.ParamByName('d2').Value:=DateTimePicker2.Date;
query.Open;
StringGrid1.Cells[1,4]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT sum(doc_summ/2) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between
:d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(IncMonth(DateTimePicker1.Date,-1),-1);
query.Parameters.ParamByName('d2').Value:=IncYear(IncMonth(DateTimePicker2.Date,-1),-1);
query.Open;
StringGrid1.Cells[2,4]:=query.Fields[0].AsString;
query.Close;
query.SQL.Text:= 'SELECT sum(doc_summ/2) FROM doc inner join card on doc.card_id=card.card_id WHERE (doc_date between
:d1 and :d2 and card_number='''+Edit1.Text+''')';
query.Parameters.ParseSQL(query.SQL.Text, true);
query.Parameters.ParamByName('d1').Value:=IncYear(DateTimePicker1.Date,-1);
query.Parameters.ParamByName('d2').Value:=IncYear(DateTimePicker2.Date,-1);
query.Open;
StringGrid1.Cells[4,4]:=query.Fields[0].AsString;
//s:= StrToCurr(StringGrid1.Cells[1,4]);
//a:= StrToCurr(StringGrid1.Cells[2,4]);
//if StrToInt(StringGrid1.Cells[1,4])= 0 then
//begin
//b:= 0;
//end
//else
//begin
//b:= s/a-1;
//end;
//if StrToInt(StringGrid1.Cells[2,4])= 0 then
//begin
//b:= 0;
//end
///else
//begin
//b:= s/a-1;
//end;
//StringGrid1.Cells[3,4]:= CurrToStr(b)+'%';
//s:= StrToCurr(StringGrid1.Cells[1,4]);
//a:= StrToCurr(StringGrid1.Cells[4,4]);
//if StrToInt(StringGrid1.Cells[1,4])= 0 then
//begin
//b:= 0;
//end
//else
//begin
//b:= s/a-1;
//end;
//if StrToInt(StringGrid1.Cells[4,4])= 0 then
//begin
//b:= 0;
//end
//else
//begin
//b:= s/a-1;
//end;
//StringGrid1.Cells[5,4]:= CurrToStr(b)+'%';
|