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

📄 sea_zd.~pas

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

interface

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

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

var
  Form29: TForm29;

implementation

uses Ses_zdxx;

{$R *.dfm}

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

procedure TForm29.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 TForm29.FormCreate(Sender: TObject);
begin
//  InTime.Text:=DateTimeToStr(date);
  T_RoomList.Open;
  while not T_RoomList.Eof do
        begin
          RoomName.Items.Add(T_RoomList.FieldByName('RoomName').AsString);
          T_RoomList.Next;
        end;
end;

procedure TForm29.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 TForm29.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 TForm29.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 TForm29.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信息
     Form30.l1.Caption:=fields[4].AsString;
     Form30.l2.Caption:=fields[1].AsString;
     Form30.l3.Caption:=fields[3].AsString;
     Form30.l4.Caption:=fields[5].AsString;
     Form30.l5.Caption:=fields[6].AsString;
     Form30.l6.Caption:=fields[7].AsString;
     Form30.l7.Caption:=fields[8].AsString;
     Form30.l8.Caption:=fields[9].AsString;
     Form30.l9.Caption:=fields[10].AsString;
     Form30.l10.Caption:=fields[11].AsString;
     Form30.l11.Caption:=fields[14].AsString;
     Form30.l12.Caption:=fields[16].AsString;
     Form30.l13.Caption:=fields[12].AsString;
     Form30.l14.Caption:=fields[13].AsString;
     //结束
//读取H_DinList信息
     Form30.Q_DinList.SQL.Clear;
     Form30.Q_DinList.SQL.Add('select * from H_DinList where cstr(AccountNo)='''+AccountNo+'''');
     Form30.Q_DinList.Open;
//结束
//读取H_Account信息
     Q_zdxxcx.SQL.Clear;
     Q_zdxxcx.SQL.Add('select * from H_Account where cstr(AccountNo)='''+AccountNo+'''');
     Q_zdxxcx.Open;
     Form30.l15.Caption:=Q_zdxxcx.FieldByName('type1').AsString;
     Form30.l16.Caption:=Q_zdxxcx.FieldByName('type2').AsString;
     Form30.l17.Caption:=Q_zdxxcx.FieldByName('type3').AsString;
     Form30.l18.Caption:=Q_zdxxcx.FieldByName('type4').AsString;
     Form30.l19.Caption:=Q_zdxxcx.FieldByName('type5').AsString;
     Form30.l20.Caption:=Q_zdxxcx.FieldByName('type6').AsString;
     Form30.l21.Caption:=Q_zdxxcx.FieldByName('zlfy').AsString;
     Form30.l22.Caption:=Q_zdxxcx.FieldByName('zlfy_room').AsString;
     Form30.l23.Caption:=Q_zdxxcx.FieldByName('ysje').AsString;
     Form30.l24.Caption:=Q_zdxxcx.FieldByName('zkje').AsString;
     Form30.l25.Caption:=Q_zdxxcx.FieldByName('mlje').AsString;
     Form30.l26.Caption:=Q_zdxxcx.FieldByName('sfje').AsString;
     Form30.l27.Caption:=Q_zdxxcx.FieldByName('rmbje').AsString;
     Form30.l28.Caption:=Q_zdxxcx.FieldByName('zpje').AsString;
     Form30.l29.Caption:=Q_zdxxcx.FieldByName('xykje').AsString;
     Form30.l30.Caption:=Q_zdxxcx.FieldByName('kdje').AsString;
     Form30.l31.Caption:=Q_zdxxcx.FieldByName('kdr').AsString;
     Form30.l32.Caption:=Q_zdxxcx.FieldByName('dzje').AsString;
     Form30.l33.Caption:=Q_zdxxcx.FieldByName('dzr').AsString;
     Form30.l35.Caption:=Q_zdxxcx.fieldByName('sfzz').asstring;
     Form30.l36.Caption:=Q_zdxxcx.fieldByName('zzfh').asstring;
     Form30.l37.Caption:=Q_zdxxcx.fieldByName('zzje').asstring;
     Q_zdxxcx.Close;
//结束
     form30.Show;
     end;
end;

end.

⌨️ 快捷键说明

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