?? query2.~pas
字號:
unit Query2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls, DB, ADODB;
type
TQueryForm2 = class(TForm)
Panel1: TPanel;
Label20: TLabel;
ComboBox1: TComboBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Panel3: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
ListView1: TListView;
TabSheet2: TTabSheet;
Panel4: TPanel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
ListView2: TListView;
TabSheet3: TTabSheet;
Panel5: TPanel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Code3: TEdit;
Year3: TEdit;
ListView3: TListView;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
BitBtn3: TBitBtn;
procedure FormShow(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
tit1 : array [0..19] of string;
tit2 : array [0..18] of string;
tit3 : array [0..4] of string;
colname: array [2..13] of string;
procedure InitListViews();
function GetColIndex(str : String): integer;
procedure GetSum();
function GetRowIndex(str: string; num : integer) :integer; //在第n個Listview中找caption is str 的index //return -1 when failed
procedure SumBlock(stat : integer ; endp: integer; n:integer; aim :integer);
//procedure FillinRowOne();
end;
var
QueryForm2: TQueryForm2;
implementation
uses BusTradeDataModuleUnit, PrintProc, PrintInfoUnit;
{$R *.dfm}
procedure TQueryForm2.GetSum();
var
rowindex,colindex : integer;
begin
for rowindex := 1 to 19 do
begin
for colindex := 2 to 13 do
begin
listview1.Items.Item[rowindex].SubItems[1]:= IntToStr(StrToInt(listview1.Items.Item[rowindex].SubItems[1])+StrToInt(listview1.Items.Item[rowindex].SubItems[colindex]));
end;
end;
for rowindex := 0 to 18 do
begin
for colindex := 2 to 13 do
begin
listview2.Items.Item[rowindex].SubItems[1]:= IntToStr(StrToInt(listview2.Items.Item[rowindex].SubItems[1])+StrToInt(listview2.Items.Item[rowindex].SubItems[colindex]));
end;
end;
for rowindex := 0 to 4 do
begin
for colindex := 2 to 13 do
begin
listview3.Items.Item[rowindex].SubItems[1]:= FloatToStr(StrToFloat(listview3.Items.Item[rowindex].SubItems[1])+StrToFloat(listview3.Items.Item[rowindex].SubItems[colindex]));
end;
end;
end;
procedure TQueryForm2.SumBlock(stat : integer ; endp: integer; n: integer; aim : integer);
var
rowindex : integer;
begin
case n of
1 : begin
rowindex := stat;
while (rowindex<=endp) do
begin
listview1.Items.Item[aim].SubItems[1]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[1])+ StrToInt(listview1.Items.Item[rowindex].SubItems[1]));
listview1.Items.Item[aim].SubItems[2]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[2])+ StrToInt(listview1.Items.Item[rowindex].SubItems[2]));
listview1.Items.Item[aim].SubItems[3]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[3])+ StrToInt(listview1.Items.Item[rowindex].SubItems[3]));
listview1.Items.Item[aim].SubItems[4]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[4])+ StrToInt(listview1.Items.Item[rowindex].SubItems[4]));
listview1.Items.Item[aim].SubItems[5]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[5])+ StrToInt(listview1.Items.Item[rowindex].SubItems[5]));
listview1.Items.Item[aim].SubItems[6]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[6])+ StrToInt(listview1.Items.Item[rowindex].SubItems[6]));
listview1.Items.Item[aim].SubItems[7]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[7])+ StrToInt(listview1.Items.Item[rowindex].SubItems[7]));
listview1.Items.Item[aim].SubItems[8]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[8])+ StrToInt(listview1.Items.Item[rowindex].SubItems[8]));
listview1.Items.Item[aim].SubItems[9]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[9])+ StrToInt(listview1.Items.Item[rowindex].SubItems[9]));
listview1.Items.Item[aim].SubItems[10]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[10])+ StrToInt(listview1.Items.Item[rowindex].SubItems[10]));
listview1.Items.Item[aim].SubItems[11]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[11])+ StrToInt(listview1.Items.Item[rowindex].SubItems[11]));
listview1.Items.Item[aim].SubItems[12]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[12])+ StrToInt(listview1.Items.Item[rowindex].SubItems[12]));
listview1.Items.Item[aim].SubItems[13]:= IntToStr(StrToInt(listview1.Items.Item[aim].SubItems[13])+ StrToInt(listview1.Items.Item[rowindex].SubItems[13]));
end;
end;
2 : begin
rowindex := stat;
while (rowindex<=endp) do
begin
listview2.Items.Item[aim].SubItems[1]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[1])+ StrToInt(listview2.Items.Item[rowindex].SubItems[1]));
listview2.Items.Item[aim].SubItems[2]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[2])+ StrToInt(listview2.Items.Item[rowindex].SubItems[2]));
listview2.Items.Item[aim].SubItems[3]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[3])+ StrToInt(listview2.Items.Item[rowindex].SubItems[3]));
listview2.Items.Item[aim].SubItems[4]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[4])+ StrToInt(listview2.Items.Item[rowindex].SubItems[4]));
listview2.Items.Item[aim].SubItems[5]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[5])+ StrToInt(listview2.Items.Item[rowindex].SubItems[5]));
listview2.Items.Item[aim].SubItems[6]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[6])+ StrToInt(listview2.Items.Item[rowindex].SubItems[6]));
listview2.Items.Item[aim].SubItems[7]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[7])+ StrToInt(listview2.Items.Item[rowindex].SubItems[7]));
listview2.Items.Item[aim].SubItems[8]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[8])+ StrToInt(listview2.Items.Item[rowindex].SubItems[8]));
listview2.Items.Item[aim].SubItems[9]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[9])+ StrToInt(listview2.Items.Item[rowindex].SubItems[9]));
listview2.Items.Item[aim].SubItems[10]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[10])+ StrToInt(listview2.Items.Item[rowindex].SubItems[10]));
listview2.Items.Item[aim].SubItems[11]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[11])+ StrToInt(listview2.Items.Item[rowindex].SubItems[11]));
listview2.Items.Item[aim].SubItems[12]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[12])+ StrToInt(listview2.Items.Item[rowindex].SubItems[12]));
listview2.Items.Item[aim].SubItems[13]:= IntToStr(StrToInt(listview2.Items.Item[aim].SubItems[13])+ StrToInt(listview2.Items.Item[rowindex].SubItems[13]));
rowindex := rowindex+1;
end;
end;
3 : begin
rowindex := stat;
while (rowindex<=endp) do
begin
listview3.Items.Item[aim].SubItems[1]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[1])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[1]));
listview3.Items.Item[aim].SubItems[2]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[2])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[2]));
listview3.Items.Item[aim].SubItems[3]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[3])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[3]));
listview3.Items.Item[aim].SubItems[4]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[4])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[4]));
listview3.Items.Item[aim].SubItems[5]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[5])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[5]));
listview3.Items.Item[aim].SubItems[6]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[6])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[6]));
listview3.Items.Item[aim].SubItems[7]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[7])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[7]));
listview3.Items.Item[aim].SubItems[8]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[8])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[8]));
listview3.Items.Item[aim].SubItems[9]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[9])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[9]));
listview3.Items.Item[aim].SubItems[10]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[10])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[10]));
listview3.Items.Item[aim].SubItems[11]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[11])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[11]));
listview3.Items.Item[aim].SubItems[12]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[12])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[12]));
listview3.Items.Item[aim].SubItems[13]:= FloatToStr(StrToFloat(listview3.Items.Item[aim].SubItems[13])+ StrToFloat(listview3.Items.Item[rowindex].SubItems[13]));
rowindex := rowindex+1;
end;
end;
end;
end;
function TQueryForm2.GetRowIndex(str : string; num : integer): integer;
var
find : boolean;
ind : integer;
begin
find := false; ind := 0;
case num of
1 : while ((not find) and (ind < 20)) do
begin
if (str = tit1[ind])
then
find := true
else
ind := ind+1;
end;
2 : while ((not find) and (ind < 21)) do
begin
if (str = tit2[ind])
then
find := true
else
ind := ind+1;
end;
3 : while ((not find) and (ind < 11)) do
begin
if (str = tit3[ind])
then
find := true
else
ind := ind+1;
end;
end;
if (find) then GetRowIndex := ind
else GetRowIndex := -1;
end;
function TQueryForm2.GetColIndex(str : string):integer;
var
ind : integer;
find : boolean;
begin
find := false; ind := 2;
while ((not find) and (ind <14)) do
begin
if (colname[ind] = str) then find := true
else
ind := ind+1;
if (find) then GetColIndex := ind
else GetColIndex := -1;
end;
end;
procedure TQueryForm2.InitListViews();
var
rowindex,i : integer;
begin
for rowindex := 0 to 19 do
begin
listview1.Items.Item[rowindex].SubItems[1] := '0';
listview1.Items.Item[rowindex].SubItems[2] := '0';
listview1.Items.Item[rowindex].SubItems[3] := '0';
listview1.Items.Item[rowindex].SubItems[4] := '0';
listview1.Items.Item[rowindex].SubItems[5] := '0';
for i := 6 to 13 do
begin
listview1.Items.Item[rowindex].SubItems.Add('0');
end;
end;
for rowindex := 0 to 18 do
begin
listview2.Items.Item[rowindex].SubItems[1] := '0';
listview2.Items.Item[rowindex].SubItems[2] := '0';
listview2.Items.Item[rowindex].SubItems[3] := '0';
listview2.Items.Item[rowindex].SubItems[4] := '0';
listview2.Items.Item[rowindex].SubItems[5] := '0';
for i := 6 to 13 do
begin
listview2.Items.Item[rowindex].SubItems.Add('0');
end;
end;
for rowindex := 0 to 4 do
begin
listview3.Items.Item[rowindex].SubItems[1] := '0';
listview3.Items.Item[rowindex].SubItems[2] := '0';
listview3.Items.Item[rowindex].SubItems[3] := '0';
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -