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

📄 cw_zd.pas

📁 结于初学者来说这对数据库是一个很好的例子
💻 PAS
字号:
unit cw_zd;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, DBTables, Grids, DBGrids, StdCtrls;

type
  TForm24 = class(TForm)
    Label1: TLabel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    AccountNo: TEdit;
    Button1: TButton;
    GroupBox2: TGroupBox;
    Label3: TLabel;
    RoomName: TComboBox;
    Button2: TButton;
    GroupBox3: TGroupBox;
    DB_zd: TDBGrid;
    Button4: TButton;
    Button5: TButton;
    GroupBox4: TGroupBox;
    Label4: TLabel;
    Button3: TButton;
    krxm: TEdit;
    T_RoomList: TTable;
    Q_zdcx: TQuery;
    DS_zdcx: TDataSource;
    Q_zdxxcx: TQuery;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure DB_zdDblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form24: TForm24;

implementation

uses cw_zdxx;

{$R *.dfm}

procedure TForm24.FormShow(Sender: TObject);
begin
  T_RoomList.Open;
  while not T_RoomList.Eof do
        begin
          RoomName.Items.Add(T_RoomList.FieldByName('RoomName').AsString);
          T_RoomList.Next;
        end;

end;

procedure TForm24.Button1Click(Sender: TObject);
begin
 if (length(AccountNo.Text)=0) then
  begin
   MessageDlg('输入不能为空,请重新输入!',mtError,[mbok],0);
   end
  else
   begin
  q_zdcx.Active:=False;
  Q_zdcx.SQL.Clear;
  Q_zdcx.SQL.Add('select * from H_RoomIn where cstr(NowAccountNo)='''+AccountNo.Text+'''');
  Q_zdcx.Active:=True;
  end;

end;

procedure TForm24.Button2Click(Sender: TObject);
begin
 if (length(RoomName.Text)=0) then
  begin
   MessageDlg('输入不能为空,请重新输入!',mtError,[mbok],0);
   end
  else
   begin
  q_zdcx.Active:=False;
  Q_zdcx.SQL.Clear;
  Q_zdcx.SQL.Add('select * from H_RoomIn where RoomName='''+RoomName.Text+'''');
  Q_zdcx.Active:=True;
  end;

end;

procedure TForm24.Button3Click(Sender: TObject);
begin
 if (length(krxm.Text)=0) then
  begin
   MessageDlg('输入不能为空,请重新输入!',mtError,[mbok],0);
   end
  else
   begin
  q_zdcx.Active:=False;
  Q_zdcx.SQL.Clear;
  Q_zdcx.SQL.Add('select * from H_RoomIn where Name='''+krxm.Text+'''');
  Q_zdcx.Active:=True;
  end;

end;

procedure TForm24.Button4Click(Sender: TObject);
begin
  q_zdcx.Active:=False;
  Q_zdcx.SQL.Clear;
  Q_zdcx.SQL.Add('select * from H_RoomIn order by NowAccountNo');
  Q_zdcx.Active:=True;

end;

procedure TForm24.Button5Click(Sender: TObject);
begin
 close;
end;

procedure TForm24.DB_zdDblClick(Sender: TObject);
  var AccountNo:string;
begin
  Q_zdcx.Open;
     with db_zd.DataSource.DataSet do
     begin
     GotoBookmark(pointer(db_zd.SelectedRows[0]));
     AccountNo:=fields[4].AsString;
//读取H_RoonIn信息
     Form25.l1.Caption:=fields[4].AsString;
     Form25.l2.Caption:=fields[1].AsString;
     Form25.l3.Caption:=fields[3].AsString;
     Form25.l4.Caption:=fields[5].AsString;
     Form25.l5.Caption:=fields[6].AsString;
     Form25.l6.Caption:=fields[7].AsString;
     Form25.l7.Caption:=fields[8].AsString;
     Form25.l8.Caption:=fields[9].AsString;
     Form25.l9.Caption:=fields[10].AsString;
     Form25.l10.Caption:=fields[11].AsString;
     Form25.l11.Caption:=fields[14].AsString;
     Form25.l12.Caption:=fields[16].AsString;
     Form25.l13.Caption:=fields[12].AsString;
     Form25.l14.Caption:=fields[13].AsString;
     //结束
//读取H_DinList信息
     Form25.Q_DinList.SQL.Clear;
     Form25.Q_DinList.SQL.Add('select * from H_DinList where cstr(AccountNo)='''+AccountNo+'''');
     Form25.Q_DinList.Open;
//结束
//读取H_Account信息
     Q_zdxxcx.SQL.Clear;
     Q_zdxxcx.SQL.Add('select * from H_Account where cstr(AccountNo)='''+AccountNo+'''');
     Q_zdxxcx.Open;
     Form25.l15.Caption:=Q_zdxxcx.FieldByName('type1').AsString;
     Form25.l16.Caption:=Q_zdxxcx.FieldByName('type2').AsString;
     Form25.l17.Caption:=Q_zdxxcx.FieldByName('type3').AsString;
     Form25.l18.Caption:=Q_zdxxcx.FieldByName('type4').AsString;
     Form25.l19.Caption:=Q_zdxxcx.FieldByName('type5').AsString;
     Form25.l20.Caption:=Q_zdxxcx.FieldByName('type6').AsString;
     Form25.l21.Caption:=Q_zdxxcx.FieldByName('zlfy').AsString;
     Form25.l22.Caption:=Q_zdxxcx.FieldByName('zlfy_room').AsString;
     Form25.l23.Caption:=Q_zdxxcx.FieldByName('ysje').AsString;
     Form25.l24.Caption:=Q_zdxxcx.FieldByName('zkje').AsString;
     Form25.l25.Caption:=Q_zdxxcx.FieldByName('mlje').AsString;
     Form25.l26.Caption:=Q_zdxxcx.FieldByName('sfje').AsString;
     Form25.l27.Caption:=Q_zdxxcx.FieldByName('rmbje').AsString;
     Form25.l28.Caption:=Q_zdxxcx.FieldByName('zpje').AsString;
     Form25.l29.Caption:=Q_zdxxcx.FieldByName('xykje').AsString;
     Form25.l30.Caption:=Q_zdxxcx.FieldByName('kdje').AsString;
     Form25.l31.Caption:=Q_zdxxcx.FieldByName('kdr').AsString;
     Form25.l32.Caption:=Q_zdxxcx.FieldByName('dzje').AsString;
     Form25.l33.Caption:=Q_zdxxcx.FieldByName('dzr').AsString;
     Form25.l35.Caption:=Q_zdxxcx.fieldByName('sfzz').asstring;
     Form25.l36.Caption:=Q_zdxxcx.fieldByName('zzfh').asstring;
     Form25.l37.Caption:=Q_zdxxcx.fieldByName('zzje').asstring;
     Q_zdxxcx.Close;
//结束
     form25.showmodal;
     end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -