⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mc_xztjkm.pas

📁 1、系统环境要求:所有程序均在Windows98/XP操作系统下测试运行。 2、建议用户在系统上安装DELPHI7.0企业版。 3、如果数据库为SQL Server数据库
💻 PAS
📖 第 1 页 / 共 2 页
字号:
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 + -