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

📄 unit_frmhallinfo.pas

📁 影院售票系统完整源码
💻 PAS
字号:
unit Unit_frmhallinfo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls, Mask, CyberEdit;

type
  Tfrmhallinfo = class(TForm)
    GroupBox1: TGroupBox;
    Label4: TLabel;
    Label12: TLabel;
    Label1: TLabel;
    EdtName: TCyberEdit;
    EdtCode: TCyberEdit;
    Panel2: TPanel;
    BtnSave: TBitBtn;
    BtnExit: TBitBtn;
    EdtSeatcount: TCyberEdit;
    Label2: TLabel;
    Memoremarks: TCyberMemo;
    procedure BtnSaveClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BtnExitClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    _editmode   :Boolean;
    _grade      :Integer;
    _code       :string;
    procedure Gethallinfobyid(_id:integer);
    { Private declarations }
  public
    id,cinemaid:Integer;
    constructor MyCreate(AOwner: TComponent; Editmode: Boolean);
    { Public declarations }
  end;

var
  frmhallinfo: Tfrmhallinfo;

implementation

uses Unit_ADODM,unit_public;

{$R *.dfm}

{ Tfrmhallinfo }

procedure Tfrmhallinfo.Gethallinfobyid(_id: integer);
var
  sqlstr:string;
begin
  sqlstr        :='select * from tblhallinfo where id='+inttostr(_id);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    if adodm.ADOQRY.RecordCount<0 then exit;
    adodm.ADOQRY.First ;
    edtcode.Text        :=adodm.ADOQRY.fieldbyname('code').AsString ;
    edtname.Text        :=adodm.ADOQRY.fieldbyname('name').AsString ;
    edtseatcount.Text   :=adodm.ADOQRY.fieldbyname('personcount').AsString ;
    memoremarks.Text    :=adodm.ADOQRY.fieldbyname('remarks').AsString ;
    cinemaid            :=adodm.ADOQRY.fieldbyname('cinemaid').AsInteger ;
  end;
end;

constructor Tfrmhallinfo.MyCreate(AOwner: TComponent; Editmode: Boolean);
begin
  inherited Create(AOwner);
  _editmode:=Editmode;
end;

procedure Tfrmhallinfo.BtnSaveClick(Sender: TObject);
var
  _name,_personcount,_remarks   :string;
  sqlstr                        :string;
  curid                         :integer;
begin
  _code         :=edtcode.Text ;
  _name         :=edtname.Text ;
  _personcount  :=EdtSeatcount.Text ;
  _remarks      :=memoremarks.Text;
  if _personcount='' then _personcount:='0';
  if _editmode then
  begin
    sqlstr:='update tblhallinfo set name='+#39+_name+#39+','+
            'code='+#39+_code+#39+','+
            'personcount='+_personcount+','+
            'remarks='+#39+_remarks+#39+
            'where id='+inttostr(id);
    if publicinfo.Execsql(sqlstr,true) then
    begin
      publicinfo.showmsg('影厅信息修改成功 !');
      modalresult:=mrok;
    end; 
  end
  else
  begin
    sqlstr:='insert into tblhallinfo (code,name,personcount,cinemaid,remarks) values('+
            #39+_code+#39+','+#39+_name+#39+','+
            _personcount+','+inttostr(cinemaid)+','+
            #39+_remarks+#39+')';
    if publicinfo.Execsql(sqlstr,true) then
    begin
      publicinfo.showmsg('影厅信息添加成功 !');
      publicinfo.Clear(self);
      _code:=publicinfo.formatstr(strtoint(_code)+1,2);
      edtcode.Text :=_code;
      edtname.SetFocus ;
    end;
  end;
end;

procedure Tfrmhallinfo.FormShow(Sender: TObject);
var
  sqlstr:string;
begin
  if _editmode then
  begin
    caption:='修改影厅信息';
    Gethallinfobyid(id);
  end
  else
  begin
    caption:='添加影厅信息';
    _code:='01';
    sqlstr:='select max(code) code from tblhallinfo where cinemaid='+inttostr(cinemaid);
    if publicinfo.Execsql(sqlstr,false) then
    begin
       if adodm.ADOQRY.RecordCount>0 then
         _code:=adodm.ADOQRY.fieldbyname('code').AsString ;
       if _code='' then _code:='01';  
    end;
    edtcode.Text :=_code;
  end;
end;

procedure Tfrmhallinfo.BtnExitClick(Sender: TObject);
begin
  close;
end;

procedure Tfrmhallinfo.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if key=27 then BtnExitClick(nil);
end;

end.

⌨️ 快捷键说明

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