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

📄 unit_frm_plan_info.pas

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

interface

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

type
  Ptickprice            =^Ttickprice;
  Ttickprice            =record
    seattypeid  :integer;
    seattypename:string;
    ticketid    :integer;
    ticketname  :string;
    price       :single;
  end;
  Tfrm_plan_info = class(Tfrmtemplate2)
    Label1: TLabel;
    Panel4: TPanel;
    CyberSizePanel2: TCyberSizePanel;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Label7: TLabel;
    DTPplandate: TCyberDateTimePicker;
    Label3: TLabel;
    Edtfieldnum: TCyberEdit;
    Label4: TLabel;
    dtpStarttime: TCyberDateTimePicker;
    dtpendtime: TCyberDateTimePicker;
    Label5: TLabel;
    Label6: TLabel;
    Edtfilm: TCyberButtonEdit;
    ListView1: TListView;
    BitBtn1: TBitBtn;
    BtnSave: TBitBtn;
    Label8: TLabel;
    Combocinema: TComboBox;
    Label9: TLabel;
    Combohall: TComboBox;
    Label2: TLabel;
    EdtNo: TCyberEdit;
    CyberXPMenu1: TCyberXPMenu;
    procedure EdtfilmButtonClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CombocinemaChange(Sender: TObject);
    procedure CombohallChange(Sender: TObject);
    procedure BtnSaveClick(Sender: TObject);
    procedure BtnSaveEnter(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure ListView1DblClick(Sender: TObject);
  private
    cinemaid,hallid:integer;
    pricetemplateid:integer;
    editmode:Boolean;
    filmid:integer;
    filmname:string;
    procedure initcombo(comb:TComboBox;sqlstr:string);
    procedure initlistview;
    function  PriceExist(_seattypeid,_ticketid:integer;_price:single):Boolean;
    Procedure Copyprice;
    procedure LoadPlan;
    function  Myinsert:Boolean;
    function  Myupdate:Boolean;
    function  SavePrice:Boolean;
    function  CopySeat:Boolean;
    { Private declarations }
  public
    SerialNo:String;
    id :integer;
    constructor MyCreate(AOwner: TComponent; _Editmode: Boolean);
    { Public declarations }
  end;

var
  frm_plan_info: Tfrm_plan_info;

implementation

uses unit_public,Unit_ADODM, Unit_frmfilm, Unit_frmfilm_sel,unit_frmpricetemplate;

{$R *.dfm}

{ Tfrm_plan_info }

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

procedure Tfrm_plan_info.EdtfilmButtonClick(Sender: TObject);
begin
  inherited;
  frmfilm_sel:=Tfrmfilm_sel.Create(Application);
  try
    if frmfilm_sel.ShowModal=mrok then
    begin
      filmid:=frmfilm_sel.filmid ;
      edtfilm.Text :=frmfilm_sel.filmname ;
    end;
  finally
    frmfilm_sel.Free ;
  end;
end;

procedure Tfrm_plan_info.initcombo(comb:TComboBox;sqlstr:string);
var
  i,reccount,_id:integer;
  _code,_name:string;
begin
  comb.Items.Clear ;
  if publicinfo.Execsql(sqlstr,false) then
  begin
    reccount:=Adodm.ADOQRY.RecordCount;
    if reccount>0 then
    begin
      Adodm.ADOQRY.First ;
      for i:=1 to reccount do
      begin
        _id         := Adodm.ADOQRY.fieldByName('id').AsInteger;
        _name       := Adodm.ADOQRY.fieldByName('name').AsString;
        _code       := Adodm.ADOQRY.fieldByName('code').AsString;
        comb.Items.AddObject(_code+'-'+_name,Tobject(_id));
        Adodm.ADOQRY.Next ;
      end;
      comb.ItemIndex := 0;
    end;
  end;
end;

procedure Tfrm_plan_info.FormShow(Sender: TObject);
var
  sqlstr:string;
  i:integer;
begin
  inherited;
  initlistview;
  sqlstr:='select * from tblcinemainfo';
  initcombo(combocinema,sqlstr);
  if not  editmode then
  begin
    i:=Combocinema.ItemIndex ;
    if i<0 then exit;
    cinemaid:=integer(Combocinema.Items.Objects[i]);
    publicinfo.refreshhallcomb(Combohall,cinemaid);
    i:=combohall.ItemIndex ;
    if i<0 then exit;
    hallid:=integer(combohall.Items.Objects[i]);
    DTPplandate.Date :=date;
    dtpstarttime.Time :=now;
    dtpendtime.Time :=now+90;
  end
  else
  begin
    loadplan;
    publicinfo.Combboxindexof(Combocinema,cinemaid);
    publicinfo.refreshhallcomb(Combohall,cinemaid);
    publicinfo.Combboxindexof(combohall,hallid);
  end;
end;

procedure Tfrm_plan_info.CombocinemaChange(Sender: TObject);
var
  i:integer;
  sqlstr:string;
begin
  inherited;
  i:=Combocinema.ItemIndex ;
  if i<0 then exit;
  cinemaid:=integer(Combocinema.Items.Objects[i]);
  sqlstr:='select * from tblhallinfo where cinemaid='+inttostr(cinemaid);
  initcombo(combohall,sqlstr);
  i:=combohall.ItemIndex ;
  if i<0 then exit;
  hallid:=integer(combohall.Items.Objects[i]);
end;

procedure Tfrm_plan_info.CombohallChange(Sender: TObject);
var
  i:integer;
begin
  inherited;
  i:=combohall.ItemIndex ;
  if i<0 then exit;
  hallid:=integer(combohall.Items.Objects[i]);
end;

procedure Tfrm_plan_info.BtnSaveClick(Sender: TObject);
var
  _maxid:integer;
begin
  inherited;
  if not dtpplandate.Checked then
  begin
    publicinfo.showmsg('请设置放映日期!');
    dtpplandate.SetFocus ;
    exit;
  end;
  if combocinema.Text='' then
  begin
    publicinfo.showmsg('请选择放映地点!');
    combocinema.SetFocus ;
    exit;
  end;
  if combohall.Text='' then
  begin
    publicinfo.showmsg('请选择放映影厅!');
    combohall.SetFocus ;
    exit;
  end;
  if edtfieldnum.Text ='' then
  begin
    publicinfo.showmsg('请设置放映场次!');
    edtfieldnum.SetFocus;
    exit;
  end;
  edtno.Text :=formatdatetime('yymmdd',dtpplandate.Date)+copy(combocinema.Text,1,2)+copy(combohall.Text,1,2)+edtfieldnum.Text;
  SerialNo   :=edtno.Text;
  if editmode then
  begin
    if myupdate then publicinfo.showmsg('放映计划修改成功 ') ;
  end
  else
  begin
    if myinsert then publicinfo.showmsg('放映计划添加成功 ') ;
  end;
end;

procedure Tfrm_plan_info.BtnSaveEnter(Sender: TObject);
begin
  inherited;
  edtno.Text :=formatdatetime('yyyymmdd',dtpplandate.Date)+copy(combocinema.Text,1,2)+copy(combohall.Text,1,2)+edtfieldnum.Text;
end;

procedure Tfrm_plan_info.BitBtn1Click(Sender: TObject);
begin
  inherited;
  frmpricetemplate:=Tfrmpricetemplate.MyCreate(Application,true);
  try
    frmpricetemplate.ShowModal ;
    pricetemplateid:=frmpricetemplate.templateid ;
    Copyprice;
  finally
    frmpricetemplate.Free ;
  end;
end;

procedure Tfrm_plan_info.Copyprice;
var
  i                     :integer;
  _seattypeid,_ticketid :integer;
  _price                :single;
  sqlstr                :string;
begin
  sqlstr:='select * from tblDefaultprice where templateid='+inttostr(pricetemplateid);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    with adodm.ADOQRY do
    begin
      if recordcount<=0 then exit;
      first ;
      for i:=1 to recordcount do
      begin
        _seattypeid:=fieldbyname('seattype').AsInteger ;
        _ticketid  :=fieldbyname('tickettype').AsInteger ;
        _price     :=fieldbyname('price').AsFloat ;
        PriceExist(_seattypeid,_ticketid,_price);
        next;
      end;
    end;
  end;
end;

procedure Tfrm_plan_info.initlistview;
var
  i,j:integer;
  sqlstr,_seattype,_ticket:string;
  _seattypeid,_ticketid:integer;
  qry:TAdoquery;
  item0:TListItem;
  prt:Ptickprice;
begin
  qry:=TAdoquery.Create(Application);
  listview1.Items.Clear ;
  try
    qry.Connection :=adodm.ADOCN ;
    sqlstr:='select * from tblseattype';
    if publicinfo.Execsql(sqlstr,false) then
    begin
      if adodm.ADOQRY.RecordCount<=0  then exit;
      with  adodm.ADOQRY do
      begin
        first;
        for i:=1 to recordcount do
        begin
          _seattype:=fieldbyname('name').AsString ;
          _seattypeid:=fieldbyname('id').AsInteger ;
          qry.Close ;
          qry.SQL.Clear ;
          qry.SQL.Add('select * from tbldict where kind=1');
          qry.Open ;
          if qry.RecordCount>0 then
          begin
            qry.First ;
            for j:=1 to qry.RecordCount do
            begin
             _ticketid          :=qry.fieldbyname('id').AsInteger;
             _ticket            :=qry.fieldbyname('name').AsString;
             new(prt);
             prt^.seattypeid    :=_seattypeid;
             prt^.seattypename  :=_seattype;
             prt^.ticketid      :=_ticketid;
             prt^.ticketname    :=_ticket;
             prt^.price         :=10.00;
             item0:=listview1.Items.Add ;
             item0.Caption :=prt^.seattypename;
             item0.SubItems.Add(prt^.ticketname);
             item0.SubItems.Add(format('%.2f',[prt^.price]));
             item0.Data :=prt;
             qry.Next ;
            end;
          end;
          next;
        end;
      end;
    end;
  finally
    qry.free;
  end;
end;

function Tfrm_plan_info.PriceExist(_seattypeid, _ticketid: integer;
  _price: single): Boolean;
var
  i:integer;
  item0:TListItem;
begin
  result:=true;
  for i:=0 to listview1.Items.Count-1 do
  begin
    item0:=listview1.Items[i];
    if (ptickprice(item0.Data ).seattypeid =_seattypeid)
       and (ptickprice(item0.Data ).ticketid =_ticketid) then
    begin
      ptickprice(item0.Data).price :=_price;
      item0.SubItems[1]:=format('%.2f',[_price]);
      item0.Checked :=true;
      Break;
    end;
  end;
end;

function Tfrm_plan_info.Myinsert: Boolean;
var
  sqlstr:string;
begin
  with Adodm.ADOProc do
  begin
      Close;
      ProcedureName := 'My_Create_plan';
      Parameters.Refresh;
      Parameters.Items[1].Value :=cinemaid;
      Parameters.Items[2].Value :=hallid;
      Parameters.Items[3].Value :=datetostr(dtpplandate.Date) ;
      Parameters.Items[4].Value :=strtoint(edtfieldnum.Text);
      Parameters.Items[5].Value :=dtpstarttime.DateTime;
      Parameters.Items[6].Value :=dtpendtime.DateTime;
      Parameters.Items[7].Value :=filmid;
      Parameters.Items[8].Value :=-1;
      Parameters.Items[9].Value :=-1;
      ExecProc;
      id:=Parameters.ParamByName('@plid').Value;
      if Parameters.ParamByName('@retcode').Value =1 then SavePrice;
  end;
end;

function Tfrm_plan_info.SavePrice: Boolean;
var
  i:integer;
  item0:TListItem;
  sqlstr:string;
begin
  result:=true;
  Sqlstr:='delete from tblplanticketprice where plid='+inttostr(id);
  publicinfo.Execsql(sqlstr,true);
  for i:=0 to listview1.Items.Count-1 do
  begin
     item0:=listview1.Items[i]  ;
     if not item0.Checked  then continue;
     sqlstr:='insert into tblplanticketprice(plid,seattype,tickettype,price) values('+
             inttostr(id)+','+inttostr(Ptickprice(item0.Data).seattypeid)+','+
             inttostr(Ptickprice(item0.Data).ticketid)+','+
             format('%.2f',[Ptickprice(item0.Data).price])+')';
     if not publicinfo.Execsql(sqlstr,true) then result:=false;
  end;
end;

function Tfrm_plan_info.Myupdate: Boolean;
begin
  with Adodm.ADOProc do
  begin
      Close;
      ProcedureName := 'My_Update_plan';
      Parameters.Refresh;
      Parameters.Items[1].Value :=id;
      Parameters.Items[2].Value :=cinemaid;
      Parameters.Items[3].Value :=hallid;
      Parameters.Items[4].Value :=datetostr(dtpplandate.Date) ;
      Parameters.Items[5].Value :=strtoint(edtfieldnum.Text);
      Parameters.Items[6].Value :=dtpstarttime.DateTime;
      Parameters.Items[7].Value :=dtpendtime.DateTime;
      Parameters.Items[8].Value :=filmid;
      Parameters.Items[9].Value :=-1;
      ExecProc;
      if Parameters.ParamByName('@retcode').Value =1 then SavePrice;
  end;
end;

procedure Tfrm_plan_info.LoadPlan;
var
  i                     :integer;
  _seattypeid,_ticketid :integer;
  _price                :single;
  sqlstr                :string;
begin
  EdtNo.Text :=SerialNo;
  sqlstr:='select * from tblfeatureplan_view where id='+inttostr(id);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    with adodm.ADOQRY do
    begin
      if recordcount<=0 then exit;
      first;
      dtpplandate.Date :=fieldbyname('plandate').AsDateTime;
      cinemaid:=fieldbyname('cinemaid').AsInteger ;
      hallid:=fieldbyname('hallid').AsInteger ;
      edtfieldnum.Text :=fieldbyname('fieldnum').AsString ;
      dtpstarttime.DateTime :=fieldbyname('starttime').AsDateTime ;
      dtpendtime.DateTime :=fieldbyname('endtime').AsDateTime ;
      edtfilm.Text :=fieldbyname('filmname').AsString ;
      filmid:=fieldbyname('filmid').AsInteger ;                                                 
    end;
  end;
  sqlstr:='select * from tblplanticketprice where plid='+inttostr(id);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    with adodm.ADOQRY do
    begin
      if recordcount<=0 then exit;
      first ;
      for i:=1 to recordcount do
      begin
        _seattypeid:=fieldbyname('seattype').AsInteger ;
        _ticketid  :=fieldbyname('tickettype').AsInteger ;
        _price     :=fieldbyname('price').AsFloat ;
        PriceExist(_seattypeid,_ticketid,_price);
        next;
      end;
    end;
  end;
end;

procedure Tfrm_plan_info.ListView1DblClick(Sender: TObject);
var
  selitem:TListItem;
  _price :single;
begin
  selitem:=Listview1.Selected ;
  if selitem=nil then exit;
  _price:=strtofloat(inputbox('输入票价','请输入票价,只能输入数值','10'));
  Ptickprice(selitem.Data).price :=_price;
  selitem.SubItems[1]:=format('%.2f',[_price]);
end;

function Tfrm_plan_info.CopySeat: Boolean;
var
  I:integer;
  sqlstr:string;
begin
  result:=true;
  sqlstr:='select * from tblhallseat where hallid='+inttostr(hallid);
  if publicinfo.Execsql(sqlstr,false) then
  begin
    with adodm.ADOQRY  do
    begin
      if recordcount<=0 then
      begin
         publicinfo.showmsg('请设置影厅座位信息');
         result:=false;
         exit;
      end;
      first;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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