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

📄 unit_frmfilminfo.pas

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

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Unit_frmtemplate2, StdCtrls, Buttons, ExtCtrls, CyberCmboBx,
  Mask, CyberEdit, ComCtrls, CyberRichEdit, CyberXPMenu, Menus;

type
  Tfrmfilminfo = class(Tfrmtemplate2)
    Label1: TLabel;
    BtnSave: TBitBtn;
    Label2: TLabel;
    Edtcode: TCyberEdit;
    Label3: TLabel;
    Edtname: TCyberEdit;
    Label4: TLabel;
    EdtAdr: TCyberEdit;
    Label5: TLabel;
    Combfilmtype: TCyberComboBox;
    Label6: TLabel;
    Edtfactory: TCyberEdit;
    Label7: TLabel;
    Edtissuer: TCyberEdit;
    Label8: TLabel;
    Edtdirector: TCyberEdit;
    Label9: TLabel;
    edtactor: TCyberEdit;
    Label10: TLabel;
    Label11: TLabel;
    Dtpstartdate: TCyberDateTimePicker;
    Label12: TLabel;
    DtpEnddate: TCyberDateTimePicker;
    CyberXPMenu1: TCyberXPMenu;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    memo: TCyberRichEdit;
    OpenDialog1: TOpenDialog;
    procedure BtnExitClick(Sender: TObject);
    procedure BtnSaveClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CombfilmtypeChange(Sender: TObject);
    procedure N1Click(Sender: TObject);
  private
    editmode:Boolean;
    filmtype:integer;
    procedure Getfilminfobyid(id:integer);
    { Private declarations }
  public
    id:integer;
    _code,_name,_adr,_factory,_issuer,_director,_actor,
    _startdate,_enddate,_introduction,_filmtypename:string;
    constructor MyCreate(AOwner: TComponent; _Editmode: Boolean);
    { Public declarations }
  end;

var
  frmfilminfo: Tfrmfilminfo;

implementation
uses unit_public,unit_adodm;
{$R *.dfm}

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

procedure Tfrmfilminfo.Getfilminfobyid(id: integer);
var
  sqlstr:string;
begin
  sqlstr:='select * from tblfilm_view where id='+inttostr(id);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    if adodm.ADOQRY.RecordCount<0 then exit;
    with adodm.ADOQRY do
    begin
      first;
      edtcode.Text :=fieldbyname('code').AsString ;
      edtname.Text :=fieldbyname('name').AsString ;
      edtadr.Text :=fieldbyname('address').AsString ;
      edtfactory.Text :=fieldbyname('manufacturer').AsString ;
      Edtissuer.Text :=fieldbyname('issuer').AsString ;
      edtdirector.Text :=fieldbyname('director').AsString ;
      edtactor.Text :=fieldbyname('player').AsString ;
      memo.Text :=fieldbyname('introduction').Value  ;
      filmtype:=fieldbyname('filmtype').AsInteger ;
      _filmtypename:=fieldbyname('filmtypename').AsString  ;
      publicinfo.Combboxindexof(TCombobox(combfilmtype),filmtype);
    end;
  end;
end;

constructor Tfrmfilminfo.MyCreate(AOwner: TComponent; _Editmode: Boolean);
begin
  inherited Create(AOwner);
  editmode:=_editmode;
end;

procedure Tfrmfilminfo.BtnSaveClick(Sender: TObject);
var
  sqlstr:string;
  _quickcode:string;
  savestream:TStringStream;
begin
  inherited;
  savestream:=TStringStream.Create('');
  try
    _code:=edtcode.Text ;
    _name:=edtname.Text ;
    _adr:=edtadr.Text ;
    _factory:=edtfactory.Text ;
    _issuer:=edtissuer.Text ;
    _director:=edtdirector.Text ;
    _actor:=edtactor.Text ;
    _startdate:=datetostr(dtpstartdate.Date);
    _enddate:=datetostr(dtpenddate.Date) ;
    //Memo.Lines.SaveToStream(savestream);
    _introduction:=memo.Text ;
    _quickcode:=publicinfo.QueryPy(_name);
    if editmode then
    begin
      sqlstr:='update tblfilm set code=:code,name=:name,quickcode=:quickcode,filmtype=:filmtype,address=:address,manufacturer=:factory,'+
              'issuer=:issuer,director=:director,player=:player,startdate=:startdate,'+
              'enddate=:enddate,introduction=:introduction where id=:id';
      with adodm.ADOQRY do
      begin
         close;
         sql.Clear ;
         sql.Add(sqlstr);
         Parameters.ParamByName('code').Value :=_code;
         Parameters.ParamByName('name').Value :=_name;
         Parameters.ParamByName('quickcode').Value :=_quickcode;
         Parameters.ParamByName('filmtype').Value :=filmtype;
         Parameters.ParamByName('address').Value :=_adr;
         Parameters.ParamByName('factory').Value :=_factory;
         Parameters.ParamByName('issuer').Value :=_issuer;
         Parameters.ParamByName('director').Value :=_director;
         Parameters.ParamByName('player').Value :=_actor;
         Parameters.ParamByName('startdate').Value :=_startdate;
         Parameters.ParamByName('enddate').Value :=_enddate;
         Parameters.ParamByName('introduction').Value :=_introduction;
         Parameters.ParamByName('id').Value  :=id;
         if execsql>0 then   modalresult:=mrok;
      end;
    end
    else
    begin
      sqlstr:='insert into tblfilm (code,name,quickcode,filmtype,address,manufacturer,issuer,director,player,'+
              'startdate,enddate,introduction) '+
              'values(:code,:name,:quickcode,:filmtype,:address,:factory,:issuer,:director,:player,'+
              ':startdate,:enddate,:introduction )';
      with adodm.ADOQRY do
      begin
         close;
         sql.Clear ;
         sql.Add(sqlstr);
         Parameters.ParamByName('code').Value :=_code;
         Parameters.ParamByName('name').Value :=_name;
         Parameters.ParamByName('quickcode').Value :=_quickcode;
         Parameters.ParamByName('filmtype').Value :=filmtype;
         Parameters.ParamByName('address').Value :=_adr;
         Parameters.ParamByName('factory').Value :=_factory;
         Parameters.ParamByName('issuer').Value :=_issuer;
         Parameters.ParamByName('director').Value :=_director;
         Parameters.ParamByName('player').Value :=_actor;
         Parameters.ParamByName('startdate').Value :=_startdate;
         Parameters.ParamByName('enddate').Value :=_enddate;
         Parameters.ParamByName('introduction').Value :=_introduction;
         if execsql>0 then
         begin
           publicinfo.clear(self);
           edtcode.SetFocus ;
         end;
      end;
    end;
  finally
    savestream.Free ;
  end;
end;

procedure Tfrmfilminfo.FormShow(Sender: TObject);
begin
  inherited;
  publicinfo.DatasetToCombbox(TComboBox(combfilmtype),4);
  if editmode then getfilminfobyid(id);
end;

procedure Tfrmfilminfo.CombfilmtypeChange(Sender: TObject);
var
  i:integer;
begin
  inherited;
  i:=combfilmtype.ItemIndex ;
  if i<0 then exit;
  filmtype:=integer(combfilmtype.Items.Objects[i]);
  _filmtypename:=combfilmtype.Text ;
end;

procedure Tfrmfilminfo.N1Click(Sender: TObject);
var
  filename:string;
begin
   OpenDialog1.InitialDir :=Paramstr(0);
   OpenDialog1.Filter := 'Word Files(*.rtf)|*.rtf|Text files (*.txt)|*.TXT|All Files(*.*)|*.*';
   try
     if OpenDialog1.Execute then filename:=OpenDialog1.FileName ;
     if filename='' then
     begin
       application.MessageBox('请选择一个文件!',pchar(application.Title),mb_ok);
       exit;
     end;
     Memo.Lines.LoadFromFile(filename);
   except
     on e:exception do showmessage('无法打开文件'+filename);
   end;
end;

end.

⌨️ 快捷键说明

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