?? mc_xztjkm.pas
字號:
unit MC_XZTJKM;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, Buttons, ExtCtrls, Db, DBTables;
type
TXZTJKM = class(TForm)
StringGrid1: TStringGrid;
GroupBox1: TGroupBox;
ComboBox1: TComboBox;
StringGrid2: TStringGrid;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Bevel1: TBevel;
BitBtn5: TBitBtn;
BitBtn3: TBitBtn;
Query1: TQuery;
Query2: TQuery;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
XZTJKM: TXZTJKM;
implementation
uses MC_XZHZDY, MC_FYHZDY;
{$R *.DFM}
procedure TXZTJKM.FormClose(Sender: TObject; var Action: TCloseAction);
begin
XZTJKM.Release;
XZTJKM:=Nil;
end;
procedure TXZTJKM.FormShow(Sender: TObject);
begin
StringGrid1.Cells[1,0]:='費用科目';
StringGrid1.Cells[2,0]:='直系表';
ComboBox1.ItemIndex:=0;
StringGrid2.Cells[1,0]:='科目名稱';
StringGrid2.RowCount:=2;
StringGrid2.Cells[1,1]:='水費';
end;
procedure TXZTJKM.BitBtn5Click(Sender: TObject);
begin
Close;
end;
procedure TXZTJKM.ComboBox1Change(Sender: TObject);
var a,b: Integer;
begin
if ComboBox1.Text='水費' then
begin
StringGrid2.RowCount:=2;
StringGrid2.Cells[1,1]:='水費';
end;
if ComboBox1.Text='電費' then
begin
StringGrid2.RowCount:=2;
StringGrid2.Cells[1,1]:='電費';
end;
if ComboBox1.Text='煤氣費' then
begin
StringGrid2.RowCount:=2;
StringGrid2.Cells[1,1]:='煤氣費';
end;
if ComboBox1.Text='采暖費' then
begin
StringGrid2.RowCount:=2;
StringGrid2.Cells[1,1]:='采暖費';
end;
//---------------------------------------------
if comboBox1.Text='費用科目' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From 費用科目');
Query1.Open;
StringGrid2.rowCount:=Query1.RecordCount+1;
a:=0;
While not Query1.Eof do
begin
a:=a+1;
StringGrid2.Cells[1,a]:=Query1.FieldByName('科目名').AsString;
Query1.Next;
end;
end;
//---------------------------------------------
if comboBox1.Text='其它科目' then
begin
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select * From 其它科目');
Query1.Open;
StringGrid2.rowCount:=Query1.RecordCount+1;
a:=0;
While not Query1.Eof do
begin
a:=a+1;
StringGrid2.Cells[1,a]:=Query1.FieldByName('科目名').AsString;
Query1.Next;
end;
end;
end;
procedure TXZTJKM.BitBtn1Click(Sender: TObject);
var a : Integer;
begin
if Length(StringGrid1.Cells[1,1])=0 then
begin
StringGrid1.Cells[1,1]:=StringGrid2.Cells[1,StringGrid2.Row];
StringGrid1.Cells[2,1]:=ComboBox1.Items[ComboBox1.ItemIndex];
end
else
begin
For a:=1 to StringGrid1.RowCount-1 do
begin
if StringGrid1.Cells[1,a]=StringGrid2.Cells[1,StringGrid2.Row] then Exit;
end;
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Cells[1,StringGrid1.RowCount-1]:=StringGrid2.Cells[1,StringGrid2.Row];
StringGrid1.Cells[2,StringGrid1.RowCount-1]:=ComboBox1.Items[ComboBox1.ItemIndex];
end;
end;
procedure TXZTJKM.BitBtn2Click(Sender: TObject);
var a,x,y:integer;
begin
x:=StringGrid1.Row;
y:=StringGrid1.Col;
if StringGrid1.RowCount<>2 then
begin
For a:=x to StringGrid1.RowCount-2 do
begin
StringGrid1.Cells[1,a]:=StringGrid1.Cells[1,a+1];
StringGrid1.Cells[2,a]:=StringGrid1.Cells[2,a+1];
end;
StringGrid1.RowCount:=StringGrid1.RowCount-1;
end
else
begin
StringGrid1.Cells[1,1]:='';
StringGrid1.Cells[2,1]:='';
end;
end;
procedure TXZTJKM.BitBtn3Click(Sender: TObject);
var a,b,c:integer;
begin
if Length(StringGrid1.Cells[1,1])<>0 then
if MessageDLG('您確認開始匯總費用數據嗎?可能需要很長時間請耐心等待!!!'
,mtCustom,[mbYes,mbNO],0)=mrYes then
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Select 房間編號,房主姓名 From 房屋信息表');
Query2.SQL.Add('Where 房間編號=:A');
Query2.ParamByName('A').AsString:=XZHZDY.StringGrid1.Cells[1,1];
For a:=2 to XZHZDY.StringGrid1.RowCount-1 do
begin
Query2.SQL.Add('or 房間編號='''+XZHZDY.StringGrid1.Cells[1,a]+'''');
end;
Query2.SQL.Add('ORDER By 房間編號 ASC');
Query2.Open;
//ShowMessage(IntToStr(Query2.Recordcount));
FYHZDY.StringGrid1.RowCount:=Query2.RecordCount+1;
For a:=1 to FYHZDY.StringGrid1.RowCount do
begin
FYHZDY.StringGrid1.Cells[1,a]:=Query2.FieldByName('房主姓名').AsString;
FYHZDY.StringGrid1.Cells[2,a]:=Query2.FieldbyName('房間編號').AsString;
Query2.Next;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -